// Send another BindRequest
BindRequest bindRequest = new BindRequest();
bindRequest.setName( "uid=admin,ou=system" );
bindRequest.setCredentials( "secret" );
BindFuture bindFuture = connection.bindAsync( bindRequest );
// Wait a bit to be sure the server is processing the bind request
Thread.sleep( 200 );
// It will take 1 seconds to bind, let's send another bind request : it should fail
BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
assertFalse( connection.isAuthenticated() );
assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
// Now get back the BindResponse
try
{
BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
assertNotNull( bindResponse );
assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
assertTrue( connection.isAuthenticated() );
}