use of com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest in project ldapsdk by pingidentity.
the class LDAPConnectionTestCase method testLastCommunicationTimeNonSynchronousMode.
/**
* Tests to ensure that the last communication time is properly updated for
* connections operating in non-synchronous mode.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLastCommunicationTimeNonSynchronousMode() throws Exception {
final InMemoryDirectoryServer ds = getTestDS(true, true);
final LDAPConnectionOptions opts = new LDAPConnectionOptions();
opts.setUseSynchronousMode(false);
final LDAPConnection conn = new LDAPConnection(opts);
assertEquals(conn.getConnectTime(), -1L);
assertEquals(conn.getLastCommunicationTime(), -1L);
conn.connect("localhost", ds.getListenPort());
final long connectTime = conn.getConnectTime();
assertTrue(connectTime > 0L);
long lastCommunicationTime = conn.getLastCommunicationTime();
assertTrue(lastCommunicationTime > 0L);
assertTrue(lastCommunicationTime >= connectTime);
// Get entry.
Thread.sleep(10L);
conn.getEntry("dc=example,dc=com");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Get root DSE.
Thread.sleep(10L);
conn.getRootDSE();
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Get schema.
Thread.sleep(10L);
conn.getSchema();
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Add.
Thread.sleep(10L);
conn.add("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Simple bind.
Thread.sleep(10L);
conn.bind("cn=Directory Manager", "password");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// SASL bind.
Thread.sleep(10L);
conn.bind(new PLAINBindRequest("dn:cn=Directory Manager", "password"));
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Compare.
Thread.sleep(10L);
conn.compare("dc=example,dc=com", "dc", "example");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Delete.
Thread.sleep(10L);
conn.delete("ou=test,dc=example,dc=com");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Extended.
Thread.sleep(10L);
conn.processExtendedOperation(new WhoAmIExtendedRequest());
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Modify.
Thread.sleep(10L);
conn.modify("dn: uid=test.user,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: foo");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Modify DN.
Thread.sleep(10L);
conn.modifyDN("uid=test.user,ou=People,dc=example,dc=com", "cn=Test User", false);
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Search.
Thread.sleep(10L);
conn.search("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Close.
conn.close();
assertEquals(conn.getConnectTime(), -1L);
assertEquals(conn.getLastCommunicationTime(), -1L);
}
use of com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest in project ldapsdk by pingidentity.
the class LDAPConnectionTestCase method testExtendedWhoAmI.
/**
* Tests the {@code processExtendedOperation} method variant that takes an
* extended request object, using the "Who Am I?" extended request object.
* <BR><BR>
* Access to a Directory Server instance is required for complete processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExtendedWhoAmI() throws Exception {
if (!isDirectoryInstanceAvailable()) {
return;
}
LDAPConnection conn = getAdminConnection();
try {
assertTrue(conn.isConnected());
assertNotNull(conn.getConnectedAddress());
assertTrue((conn.getConnectedPort() >= 1) && (conn.getConnectedPort() <= 65535));
assertNotNull(conn.toString());
WhoAmIExtendedRequest extendedRequest = new WhoAmIExtendedRequest();
ExtendedResult extendedResult = conn.processExtendedOperation(extendedRequest);
assertNotNull(extendedResult);
assertEquals(extendedResult.getResultCode(), ResultCode.SUCCESS);
assertNull(extendedResult.getOID());
assertNotNull(extendedResult.getValue());
assertTrue(extendedResult instanceof WhoAmIExtendedResult);
WhoAmIExtendedResult whoAmIResult = (WhoAmIExtendedResult) extendedResult;
assertNotNull(whoAmIResult);
assertNotNull(whoAmIResult.getAuthorizationID());
} finally {
conn.close();
assertFalse(conn.isConnected());
assertNull(conn.getConnectedAddress());
assertTrue(conn.getConnectedPort() < 0);
assertNotNull(conn.toString());
}
}
use of com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest in project ldapsdk by pingidentity.
the class LDAPConnectionTestCase method testLastCommunicationTimeSynchronousMode.
/**
* Tests to ensure that the last communication time is properly updated for
* connections operating in synchronous mode.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLastCommunicationTimeSynchronousMode() throws Exception {
final InMemoryDirectoryServer ds = getTestDS(true, true);
final LDAPConnectionOptions opts = new LDAPConnectionOptions();
opts.setUseSynchronousMode(true);
final LDAPConnection conn = new LDAPConnection(opts);
assertEquals(conn.getConnectTime(), -1L);
assertEquals(conn.getLastCommunicationTime(), -1L);
conn.connect("localhost", ds.getListenPort());
final long connectTime = conn.getConnectTime();
assertTrue(connectTime > 0L);
long lastCommunicationTime = conn.getLastCommunicationTime();
assertTrue(lastCommunicationTime > 0L);
assertTrue(lastCommunicationTime >= connectTime);
// Get entry.
Thread.sleep(10L);
conn.getEntry("dc=example,dc=com");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Get root DSE.
Thread.sleep(10L);
conn.getRootDSE();
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Get schema.
Thread.sleep(10L);
conn.getSchema();
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Add.
Thread.sleep(10L);
conn.add("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Simple bind.
Thread.sleep(10L);
conn.bind("cn=Directory Manager", "password");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// SASL bind.
Thread.sleep(10L);
conn.bind(new PLAINBindRequest("dn:cn=Directory Manager", "password"));
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Compare.
Thread.sleep(10L);
conn.compare("dc=example,dc=com", "dc", "example");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Delete.
Thread.sleep(10L);
conn.delete("ou=test,dc=example,dc=com");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Extended.
Thread.sleep(10L);
conn.processExtendedOperation(new WhoAmIExtendedRequest());
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Modify.
Thread.sleep(10L);
conn.modify("dn: uid=test.user,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: foo");
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Modify DN.
Thread.sleep(10L);
conn.modifyDN("uid=test.user,ou=People,dc=example,dc=com", "cn=Test User", false);
lastCommunicationTime = assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Search.
Thread.sleep(10L);
conn.search("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
assertLastCommunicationTimeUpdated(conn, lastCommunicationTime);
// Close.
conn.close();
assertEquals(conn.getConnectTime(), -1L);
assertEquals(conn.getLastCommunicationTime(), -1L);
}
use of com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest in project ldapsdk by pingidentity.
the class LDAPConnectionLoggerTestCase method testLogExtendedOperationsSynchronous.
/**
* Tests to ensure that extended operations are logged as expected when using
* synchronous mode.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLogExtendedOperationsSynchronous() throws Exception {
final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.addExtendedOperationHandler(new TestIntermediateResponseExtendedOperationHandler("1.2.3.4", "1.2.3.5", "1.2.3.6", 2, 3));
final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.startListening();
try {
final int port = ds.getListenPort();
final TestLDAPConnectionLogger logger = new TestLDAPConnectionLogger();
final LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setUseSynchronousMode(true);
options.setConnectionLogger(logger);
assertEquals(logger.getSuccessfulConnectCount(), 0);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 0);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 0);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
try (LDAPConnection connection = new LDAPConnection(options, "localhost", port)) {
// Verify that the connect was logged.
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 0);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 0);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Authenticate the connection.
assertResultCodeEquals(connection, new SimpleBindRequest("cn=Directory Manager", "password"), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Send a "Who Am I?" extended request on the connection.
assertResultCodeEquals(connection, new WhoAmIExtendedRequest(), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 1);
assertEquals(logger.getExtendedResultCount(), 1);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Send an extended request that will include intermediate responses.
assertResultCodeEquals(connection, new ExtendedRequest("1.2.3.4"), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 2);
assertEquals(logger.getExtendedResultCount(), 2);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 5);
// Send an extended request with an unrecognized request OID.
assertResultCodeEquals(connection, new ExtendedRequest("4.3.2.1"), ResultCode.UNWILLING_TO_PERFORM);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 3);
assertEquals(logger.getExtendedResultCount(), 3);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 5);
}
// Verify that the unbind and disconnect were logged.
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 1);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 3);
assertEquals(logger.getExtendedResultCount(), 3);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 1);
assertEquals(logger.getIntermediateResponseCount(), 5);
} finally {
ds.shutDown(true);
}
}
use of com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest in project ldapsdk by pingidentity.
the class LDAPConnectionLoggerTestCase method testLogExtendedOperationsNonSynchronous.
/**
* Tests to ensure that extended operations are logged as expected when not
* using synchronous mode.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLogExtendedOperationsNonSynchronous() throws Exception {
final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.addExtendedOperationHandler(new TestIntermediateResponseExtendedOperationHandler("1.2.3.4", "1.2.3.5", "1.2.3.6", 2, 3));
final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.startListening();
try {
final int port = ds.getListenPort();
final TestLDAPConnectionLogger logger = new TestLDAPConnectionLogger();
final LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setConnectionLogger(logger);
assertEquals(logger.getSuccessfulConnectCount(), 0);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 0);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 0);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
try (LDAPConnection connection = new LDAPConnection(options, "localhost", port)) {
// Verify that the connect was logged.
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 0);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 0);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Authenticate the connection.
assertResultCodeEquals(connection, new SimpleBindRequest("cn=Directory Manager", "password"), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 0);
assertEquals(logger.getExtendedResultCount(), 0);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Send a "Who Am I?" extended request on the connection.
assertResultCodeEquals(connection, new WhoAmIExtendedRequest(), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 1);
assertEquals(logger.getExtendedResultCount(), 1);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 0);
// Send an extended request that will include intermediate responses.
assertResultCodeEquals(connection, new ExtendedRequest("1.2.3.4"), ResultCode.SUCCESS);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 2);
assertEquals(logger.getExtendedResultCount(), 2);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 5);
// Send an extended request with an unrecognized request OID.
assertResultCodeEquals(connection, new ExtendedRequest("4.3.2.1"), ResultCode.UNWILLING_TO_PERFORM);
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 0);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 3);
assertEquals(logger.getExtendedResultCount(), 3);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 0);
assertEquals(logger.getIntermediateResponseCount(), 5);
}
// Verify that the unbind and disconnect were logged.
assertEquals(logger.getSuccessfulConnectCount(), 1);
assertEquals(logger.getFailedConnectCount(), 0);
assertEquals(logger.getDisconnectCount(), 1);
assertEquals(logger.getAbandonRequestCount(), 0);
assertEquals(logger.getAddRequestCount(), 0);
assertEquals(logger.getAddResultCount(), 0);
assertEquals(logger.getSimpleBindRequestCount(), 1);
assertEquals(logger.getSASLBindRequestCount(), 0);
assertEquals(logger.getBindResultCount(), 1);
assertEquals(logger.getCompareRequestCount(), 0);
assertEquals(logger.getCompareResultCount(), 0);
assertEquals(logger.getDeleteRequestCount(), 0);
assertEquals(logger.getDeleteResultCount(), 0);
assertEquals(logger.getExtendedRequestCount(), 3);
assertEquals(logger.getExtendedResultCount(), 3);
assertEquals(logger.getModifyRequestCount(), 0);
assertEquals(logger.getModifyResultCount(), 0);
assertEquals(logger.getModifyDNRequestCount(), 0);
assertEquals(logger.getModifyDNResultCount(), 0);
assertEquals(logger.getSearchRequestCount(), 0);
assertEquals(logger.getSearchResultEntryCount(), 0);
assertEquals(logger.getSearchResultReferenceCount(), 0);
assertEquals(logger.getSearchResultDoneCount(), 0);
assertEquals(logger.getUnbindRequestCount(), 1);
assertEquals(logger.getIntermediateResponseCount(), 5);
} finally {
ds.shutDown(true);
}
}
Aggregations