@Override
  protected void tearDown() throws Exception {
    if (!clientEngine.isClosed()) closeWithExpects(clientEngine, clientList);
    if (!serverEngine.isClosed()) closeWithExpects(serverEngine, serverList);

    HandlerForTests.checkForWarnings();
    clientList.expect(MockObject.NONE);
    serverList.expect(MockObject.NONE);
  }
 protected void tearDown() throws Exception {
   log.info("CHAN MGR STOP");
   chanMgr.stop();
   chanMgr = null;
   log.info("MOCK SERVER STOP");
   mockServer.stop();
   log.info("check for warns");
   HandlerForTests.checkForWarnings();
   log.info("done");
 }
  @Override
  protected void setUp() throws Exception {
    HandlerForTests.setupLogging();

    serverList.setDefaultBehavior("packetEncrypted", new CloneByteBuffer());
    clientList.setDefaultBehavior("packetEncrypted", new CloneByteBuffer());
    SSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
    FactoryCreator creator = FactoryCreator.createFactory(null);

    SSLEngine wrappedSvr = sslEngineFactory.createEngineForServerSocket();
    serverEngine = creator.createSSLEngine("[serverAsynch] ", wrappedSvr, null);
    serverEngine.setListener((SSLListener) serverList);

    SSLEngine wrappedClient = sslEngineFactory.createEngineForSocket();
    clientEngine = creator.createSSLEngine("[clientEngine] ", wrappedClient, null);
    clientEngine.setListener((SSLListener) clientList);
  }
  protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    // here I keep using the same channel manager on purpose, just
    // so we get testing between tests that the channel manager shutdown
    // and started back up cleanly.....
    if (chanMgr == null) {
      chanMgr = getClientChanMgr();
    }
    if (mockServer == null) {
      ChannelService svcChanMgr = getServerChanMgr();
      mockServer = new MockNIOServer(svcChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = mockServer.start();
    log.fine("server port =" + svrAddr);

    loopBack = InetAddress.getByName("127.0.0.1");
    loopBackAnyPort = new InetSocketAddress(loopBack, 0);

    mockHandler = MockObjectFactory.createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
    client1 = chanMgr.createTCPChannel("ClientChannel", getClientFactoryHolder());
  }