From f825d7fc46067dfe3e5c126dcd491ddcef73c806 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 06 Jun 2014 14:29:35 +0000
Subject: [PATCH] Fixed broken test.
---
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java | 45 ++++++++++++++++++++++++++++-----------------
1 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index 50aae5e..978d75c 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -33,11 +33,16 @@
import org.assertj.core.api.Assertions;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.MemoryBackend;
+import org.opends.server.controls.ExternalChangelogRequestControl;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.replication.common.CSNGenerator;
+import org.opends.server.replication.common.MultiDomainServerState;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.replication.plugin.MultimasterReplication;
@@ -554,14 +559,32 @@
*/
private void checkChangelogSize(int expectedCount) throws Exception
{
- throw new RuntimeException("Dead code. Should we remove this method and the test calling it?");
+ final MultiDomainServerState state = new MultiDomainServerState();
+ final Control control = new ExternalChangelogRequestControl(true, state);
+ final List<Control> controls = newList(control);
+
+ final int timeout = 500;
+ long start = System.currentTimeMillis();
+ InternalSearchOperation searchOperation;
+ do
+ {
+ Thread.sleep(10);
+ searchOperation = connection.processSearch(
+ "cn=changelog", SearchScope.SUBORDINATES,
+ DereferenceAliasesPolicy.NEVER, 0, 0, false,
+ "(objectclass=*)", null, controls, null);
+ }
+ while (System.currentTimeMillis() - start <= timeout
+ && searchOperation.getResultCode() != ResultCode.SUCCESS
+ && searchOperation.getSearchEntries().size() != expectedCount);
+ Assertions.assertThat(searchOperation.getSearchEntries()).hasSize(expectedCount);
}
/**
* SingleRS tests basic features of generationID
* with one single Replication Server.
*/
- @Test(enabled=false)
+ @Test
public void testSingleRS() throws Exception
{
String testCase = "testSingleRS";
@@ -901,7 +924,7 @@
* - genId setting propagation from one RS to the others
* - genId reset propagation from one RS to the others
*/
- @Test(enabled=false)
+ @Test(dependsOnMethods = { "testSingleRS" })
public void testMultiRS() throws Exception
{
String testCase = "testMultiRS";
@@ -1041,7 +1064,7 @@
* Test generationID saving when the root entry does not exist
* at the moment when the replication is enabled.
*/
- @Test(enabled=false, groups="slow")
+ @Test(dependsOnMethods = { "testMultiRS" }, groups = "slow")
public void testServerStop() throws Exception
{
String testCase = "testServerStop";
@@ -1082,7 +1105,7 @@
* Loop opening sessions to the Replication Server
* to check that it handle correctly disconnection and reconnection.
*/
- @Test(enabled=false, groups="slow")
+ @Test(dependsOnMethods = { "testServerStop" }, groups = "slow")
public void testLoop() throws Exception
{
String testCase = "testLoop";
@@ -1119,16 +1142,4 @@
}
}
- /**
- * This is used to make sure that the 3 tests are run in the
- * specified order since this is necessary.
- */
- @Test(enabled=true, groups="slow")
- public void generationIdTest() throws Exception
- {
- testSingleRS();
- testMultiRS();
- testServerStop();
- testLoop();
- }
}
--
Gitblit v1.10.0