// Run a basic connector test.
testConnector0( session );
// Send closeNotify to test TLS closure if it is TLS connection.
SSLFilter sslf = ( SSLFilter ) connector.getFilterChain().get( "SSL" );
if( sslf != null )
{
connector.getFilterChain().addFirst( "log", new LoggingFilter() );
sslf.stopSSL( session ).join();
System.out.println( "-------------------------------------------------------------------------------" );
// Test again after we finished TLS session.
testConnector0( session );
System.out.println( "-------------------------------------------------------------------------------" );
// Test if we can enter TLS mode again.
//// Send StartTLS request.
handler.readBuf.clear();
ByteBuffer buf = ByteBuffer.allocate( 1 );
buf.put( ( byte ) '.' );
buf.flip();
session.write( buf ).join();
//// Wait for StartTLS response.
waitForResponse( handler, 1 );
handler.readBuf.flip();
Assert.assertEquals( 1, handler.readBuf.remaining() );
Assert.assertEquals( ( byte ) '.', handler.readBuf.get() );
// Now start TLS connection
Assert.assertTrue( sslf.startSSL( session ) );
testConnector0( session );
connector.getFilterChain().remove( "log" );
}
session.close().join();