@BeforeClass
  public static void initialization() {
    boolean enableSslLbPort = false;
    boolean terminateTLSTraffic = true;
    // start lb
    balancer = new BalancerRunner();
    balancer.start(ConfigInit.getLbSpliterProperties(enableSslLbPort, terminateTLSTraffic));
    // start servers
    serverArray = new DefaultSmppServer[serverNumbers];
    serverHandlerArray = new DefaultSmppServerHandler[serverNumbers];
    for (int i = 0; i < serverNumbers; i++) {
      serverHandlerArray[i] = new DefaultSmppServerHandler();
      serverArray[i] =
          new DefaultSmppServer(
              ConfigInit.getSmppServerConfiguration(i, false),
              serverHandlerArray[i],
              executor,
              monitorExecutor);
      logger.info("Starting SMPP server...");
      try {
        serverArray[i].start();
      } catch (SmppChannelException e) {
        logger.info("SMPP server does not started");
        e.printStackTrace();
      }

      logger.info("SMPP server started");
    }
    try {
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @Before
  public void setUp() throws Exception {
    shootist = new Shootist();
    balancer = new BalancerRunner();
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "SipBalancerForwarder");
    properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "logs/sipbalancerforwarderdebug.txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "logs/sipbalancerforwarder.xml");
    properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", "2");
    properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "true");
    properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "false");
    properties.setProperty("algorithmClass", WorstCaseUdpTestAffinityAlgorithm.class.getName());
    properties.setProperty("host", "127.0.0.1");
    properties.setProperty("internalPort", "5065");
    properties.setProperty("externalPort", "5060");
    balancer.start(properties);

    for (int q = 0; q < servers.length; q++) {
      servers[q] =
          new AppServer(
              "node" + q, 4060 + q, "127.0.0.1", 2000, 5060, 5065, "0", ListeningPoint.UDP);
      servers[q].start();
    }
    Thread.sleep(5000);
  }
 @After
 public void tearDown() throws Exception {
   shootist.stop();
   for (int q = 0; q < servers.length; q++) {
     servers[q].stop();
   }
   balancer.stop();
 }
  // tests statistic of SMPP load balancer
  @Test
  public void testStatisticVariable() {
    int clientNumbers = 3;
    clientHandlerArray = new DefaultSmppClientHandler[clientNumbers];
    int smsNumber = 1;
    Locker locker = new Locker(clientNumbers);

    for (int i = 0; i < clientNumbers; i++) new Load(i, smsNumber, locker).start();

    try {
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    activeConnections = balancer.getNumberOfActiveSmppConnections();
    locker.waitForClients();
    assertEquals(348, balancer.getNumberOfSmppBytesToServer());
    assertEquals(198, balancer.getNumberOfSmppBytesToClient());
    assertEquals(clientNumbers * 3, balancer.getNumberOfSmppRequestsToServer());
    assertEquals(
        clientNumbers, balancer.getSmppRequestsProcessedById(SmppConstants.CMD_ID_SUBMIT_SM));
    assertEquals(
        clientNumbers, balancer.getSmppResponsesProcessedById(SmppConstants.CMD_ID_SUBMIT_SM_RESP));
    assertEquals(clientNumbers * 2, activeConnections);
  }
  @AfterClass
  public static void finalization() {

    for (int i = 0; i < serverNumbers; i++) {
      logger.info("Stopping SMPP server " + i + " ...");
      serverArray[i].destroy();
      logger.info("SMPP server " + i + "stopped");
    }
    executor.shutdownNow();
    monitorExecutor.shutdownNow();
    balancer.stop();
    logger.info("Done. Exiting");
  }