<commit_before>var fs = require('fs');
var mqtt = require('mqtt');

var mqttServer = require('../src/server');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // trust self signed certificate

describe('server', function(){
  it('should start multiple servers and allow connection', function(done){
    mqttServer.startServers({
      ssl: {
        key: fs.readFileSync('./test/support/server.key'),
        cert: fs.readFileSync('./test/support/server.crt')
      },
      ports: {
        mqtt: 9001,
        mqtts: 9002,
        ws: 9003,
        wss: 9004
      }
    }, function(client){
      client.on('connect', function(){
        client.connack({
          returnCode: 0
        });
      });
    }, function(){
      var c1 = mqtt.connect('mqtt://0.0.0.0:9001');
      c1.on('connect', function(){
        var c2 = mqtt.connect('mqtts://0.0.0.0:9002', {
          rejectUnauthorized: false
        });
        c2.on('connect', function(){
          var c3 = mqtt.connect('ws://0.0.0.0:9003');
          c3.on('connect', function(){
            var c4 = mqtt.connect('wss://0.0.0.0:9004');
            c4.on('connect', function(){
              done();
            });
          });
        });
      });
    });
  });

  it('should start multiple servers and allow connection', function(done){
    mqttServer.startServers({
      ssl: {
        key: fs.readFileSync('./test/support/server.key'),
        cert: fs.readFileSync('./test/support/server.crt')
      },
      ports: {
        mqtt: 9005,
        mqtts: 9006,
        ws: 9007,
        wss: 9008
      },
      emitEvents: false
    }, function(client){
      client.on('connect', function(){
        assert(false);
      });
      client.on('data', function(){
        setImmediate(function(){
          client.connack({
            returnCode: 0
          });
        });
      })
    }, function(){
      var c1 = mqtt.connect('mqtt://0.0.0.0:9001');
      c1.on('connect', done)
    });<commit_msg>renamed test<commit_after>var fs = require('fs');
var mqtt = require('mqtt');

var mqttServer = require('../src/server');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // trust self signed certificate

describe('server', function(){
  it('should start multiple servers and allow connection', function(done){
    mqttServer.startServers({
      ssl: {
        key: fs.readFileSync('./test/support/server.key'),
        cert: fs.readFileSync('./test/support/server.crt')
      },
      ports: {
        mqtt: 9001,
        mqtts: 9002,
        ws: 9003,
        wss: 9004
      }
    }, function(client){
      client.on('connect', function(){
        client.connack({
          returnCode: 0
        });
      });
    }, function(){
      var c1 = mqtt.connect('mqtt://0.0.0.0:9001');
      c1.on('connect', function(){
        var c2 = mqtt.connect('mqtts://0.0.0.0:9002', {
          rejectUnauthorized: false
        });
        c2.on('connect', function(){
          var c3 = mqtt.connect('ws://0.0.0.0:9003');
          c3.on('connect', function(){
            var c4 = mqtt.connect('wss://0.0.0.0:9004');
            c4.on('connect', function(){
              done();
            });
          });
        });
      });
    });
  });

  it('should have an option to disable event emitting', function(done){
    mqttServer.startServers({
      ssl: {
        key: fs.readFileSync('./test/support/server.key'),
        cert: fs.readFileSync('./test/support/server.crt')
      },
      ports: {
        mqtt: 9005,
        mqtts: 9006,
        ws: 9007,
        wss: 9008
      },
      emitEvents: false
    }, function(client){
      client.on('connect', function(){
        assert(false);
      });
      client.on('data', function(){
        setImmediate(function(){
          client.connack({
            returnCode: 0
          });
        });
      })
    }, function(){
      var c1 = mqtt.connect('mqtt://0.0.0.0:9001');
      c1.on('connect', done)
    });
{'fraction_non_alphanumeric': 0.17638114546376077, 'fraction_numerical': 0.04308160162189559, 'mean_word_length': 1.8831263696128562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3657504', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1275, 'n_words': 224}