| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import org.opends.server.api.WorkQueue; |
| | | |
| | | /** |
| | | * This class defines some utility functions which can be used by test |
| | |
| | | } |
| | | |
| | | /** |
| | | * Bring the server to a quiescent state. This includes waiting for all |
| | | * operations to complete. This can be used in a @BeforeMethod setup method |
| | | * to make sure that the server has finished processing all operations |
| | | * from previous tests. |
| | | */ |
| | | public static void quiesceServer() |
| | | { |
| | | waitForOpsToComplete(); |
| | | } |
| | | |
| | | /** |
| | | * This can be made public if quiesceServer becomes too heavy-weight in |
| | | * some circumstance. |
| | | */ |
| | | private static void waitForOpsToComplete() |
| | | { |
| | | WorkQueue workQueue = DirectoryServer.getWorkQueue(); |
| | | final long NO_TIMEOUT = -1; |
| | | workQueue.waitUntilIdle(NO_TIMEOUT); |
| | | } |
| | | |
| | | /** |
| | | * Binds to the given socket port on the local host. |
| | | * @return the bounded Server socket. |
| | | * |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeMethod; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | assertTrue(InvocationCounterPlugin.getPreParseCount() > 0); |
| | | assertTrue(InvocationCounterPlugin.getPreOperationCount() > 0); |
| | | assertTrue(InvocationCounterPlugin.getPostOperationCount() > 0); |
| | | ensurePostReponseHasRun(); |
| | | assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0); |
| | | } |
| | | |
| | |
| | | assertTrue(InvocationCounterPlugin.getPreParseCount() > 0); |
| | | assertTrue(InvocationCounterPlugin.getPreOperationCount() > 0); |
| | | assertTrue(InvocationCounterPlugin.getPostOperationCount() > 0); |
| | | ensurePostReponseHasRun(); |
| | | assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0); |
| | | } |
| | | |
| | |
| | | assertEquals(DirectoryServer.getAuthenticatedUsers().get(userDN).size(), |
| | | 1); |
| | | |
| | | // We occasionally run into |
| | | // ProtocolMessages.MSGID_LDAP_CLIENT_DUPLICATE_MESSAGE_ID, so we wait |
| | | // for previous ops to complete. |
| | | TestCaseUtils.quiesceServer(); |
| | | bindRequest = new BindRequestProtocolOp( |
| | | new ASN1OctetString("cn=Directory Manager"), 3, |
| | | new ASN1OctetString("password")); |
| | |
| | | |
| | | message = LDAPMessage.decode(r.readElement().decodeAsSequence()); |
| | | bindResponse = message.getBindResponseProtocolOp(); |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | assertEquals(bindResponse.getResultCode(), 0, message.toString()); |
| | | |
| | | assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN)); |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 1); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 0); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 1); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 0); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 0); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeMethod; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | // The LDAPStatistics object associated with the LDAPS connection handler. |
| | | protected LDAPStatistics ldapsStatistics; |
| | | |
| | | @BeforeMethod |
| | | public void setUpQuiesceServer() |
| | | { |
| | | TestCaseUtils.quiesceServer(); |
| | | } |
| | | |
| | | /** |
| | | * Since the PostResponse plugins are called after the response is sent |
| | | * back to the client, a client (e.g. a test case) can get a response before |
| | | * the PostResponse plugins have been called. So that we can verify that the |
| | | * PostResponse plugins were called, the tests call this method to ensure |
| | | * that all operations in the server have been completed. |
| | | */ |
| | | protected void ensurePostReponseHasRun() |
| | | { |
| | | TestCaseUtils.quiesceServer(); |
| | | } |
| | | |
| | | /** |
| | | * Ensures that the Directory Server is running. |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 1); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 1); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 0); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 1); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | |
| | | assertEquals(InvocationCounterPlugin.getPreParseCount(), 1); |
| | | assertEquals(InvocationCounterPlugin.getPreOperationCount(), 0); |
| | | assertEquals(InvocationCounterPlugin.getPostOperationCount(), 0); |
| | | ensurePostReponseHasRun(); |
| | | assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |