public void testBindThroughConnect() throws Exception {
   client1.oldConnect(svrAddr);
   int port = client1.getLocalAddress().getPort();
   assertTrue("port is zero, this is bad", port != 0);
   mockServer.expect("connected");
   // verifyTearDown();
 }
  private ByteBuffer verifyDataPassing(TCPChannel svrChan) throws Exception {
    ByteBuffer b = ByteBuffer.allocate(10);
    helper.putString(b, "de");
    helper.doneFillingBuffer(b);
    int expectedWrote = b.remaining();
    log.fine("***********************************************");
    int actualWrite = client1.oldWrite(b);
    assertEquals(expectedWrote, actualWrite);

    CalledMethod m = mockServer.expect(MockNIOServer.INCOMING_DATA);
    TCPChannel actualChannel = (TCPChannel) m.getAllParams()[0];
    Class c = Class.forName(getChannelImplName());
    assertEquals("should be correct type of channel", c, actualChannel.getClass());

    ByteBuffer actualBuf = (ByteBuffer) m.getAllParams()[1];
    String result = helper.readString(actualBuf, actualBuf.remaining());
    assertEquals("de", result);

    b.rewind();
    svrChan.oldWrite(b);

    m = mockHandler.expect(MockDataHandler.INCOMING_DATA);
    actualBuf = (ByteBuffer) m.getAllParams()[1];
    result = helper.readString(actualBuf, actualBuf.remaining());
    assertEquals("de", result);
    return b;
  }
  public void testConnectClose() throws Exception {
    // make sure we are testing the right one....
    //        Class c = Class.forName(getChannelImplName());
    //        assertEquals("should be instance of secure channel", c, client1.getClass());

    // no bind, just do connect to test port is not zero
    client1.oldConnect(svrAddr, (ConnectionCallback) mockConnect);
    mockConnect.expect("connected");

    mockServer.expect(MockNIOServer.CONNECTED);

    verifyTearDown();
  }
 private void verifyTearDown() throws IOException {
   log.info("local=" + client1.getLocalAddress() + " remote=" + client1.getRemoteAddress());
   log.info("CLIENT1 CLOSE");
   client1.oldClose();
   mockServer.expect(MockNIOServer.FAR_END_CLOSED);
 }