| | |
| | | |
| | | @Test(description = "OPENDJ-1197") |
| | | public void testClientSideConnectTimeout() throws Exception { |
| | | // Use an non-local unreachable network address. |
| | | final ConnectionFactory factory = new LDAPConnectionFactory("10.20.30.40", 1389, |
| | | Options.defaultOptions().set(CONNECT_TIMEOUT, duration("1 ms"))); |
| | | try { |
| | | // Use a non-local unreachable network address. |
| | | try (ConnectionFactory factory = new LDAPConnectionFactory("10.20.30.40", 1389, |
| | | Options.defaultOptions().set(CONNECT_TIMEOUT, duration("1 ms")))) { |
| | | for (int i = 0; i < ITERATIONS; i++) { |
| | | final PromiseImpl<LdapException, NeverThrowsException> promise = PromiseImpl.create(); |
| | | final Promise<? extends Connection, LdapException> connectionPromise = factory.getConnectionAsync(); |
| | |
| | | assertThat(ce.getResult().getResultCode()).isEqualTo(ResultCode.CLIENT_SIDE_CONNECT_ERROR); |
| | | } |
| | | } |
| | | } finally { |
| | | factory.close(); |
| | | } |
| | | } |
| | | |
| | |
| | | registerBindEvent(); |
| | | registerCloseEvent(); |
| | | |
| | | final Connection connection = factory.getConnection(); |
| | | try { |
| | | try (Connection connection = factory.getConnection()) { |
| | | waitForConnect(); |
| | | final MockConnectionEventListener listener = new MockConnectionEventListener(); |
| | | connection.addConnectionEventListener(listener); |
| | |
| | | connection.close(); |
| | | waitForClose(); |
| | | verifyNoAbandonSent(); |
| | | } finally { |
| | | connection.close(); |
| | | } |
| | | } |
| | | |
| | |
| | | registerCloseEvent(); |
| | | |
| | | for (int i = 0; i < ITERATIONS; i++) { |
| | | final Connection connection = pool.getConnection(); |
| | | try { |
| | | try (Connection connection = pool.getConnection()) { |
| | | waitForConnect(); |
| | | final MockConnectionEventListener listener = new MockConnectionEventListener(); |
| | | connection.addConnectionEventListener(listener); |
| | |
| | | connection.close(); |
| | | waitForClose(); |
| | | verifyNoAbandonSent(); |
| | | } finally { |
| | | connection.close(); |
| | | } |
| | | } |
| | | } |
| | |
| | | registerAbandonEvent(); |
| | | |
| | | for (int i = 0; i < ITERATIONS; i++) { |
| | | final Connection connection = factory.getConnection(); |
| | | try { |
| | | try (Connection connection = factory.getConnection()) { |
| | | waitForConnect(); |
| | | final ConnectionEventListener listener = mock(ConnectionEventListener.class); |
| | | connection.addConnectionEventListener(listener); |
| | |
| | | * LDAPConnection for explanation). |
| | | */ |
| | | // waitForAbandon(); |
| | | } finally { |
| | | connection.close(); |
| | | } |
| | | } |
| | | } |
| | |
| | | resetState(); |
| | | |
| | | for (int i = 0; i < ITERATIONS; i++) { |
| | | final Connection connection = factory.getConnection(); |
| | | try { |
| | | try (Connection connection = factory.getConnection()) { |
| | | waitForConnect(); |
| | | final MockConnectionEventListener listener = new MockConnectionEventListener(); |
| | | connection.addConnectionEventListener(listener); |
| | |
| | | |
| | | // Wait for the error notification to reach the client. |
| | | listener.awaitError(TEST_TIMEOUT, TimeUnit.SECONDS); |
| | | } finally { |
| | | connection.close(); |
| | | } |
| | | } |
| | | } |