From e309a1a31f3493fd553b4633cc751d0bbca5a117 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 14 May 2007 14:25:40 +0000
Subject: [PATCH] Fix small problems in the unit tests where - port number was wrong - return values were not tested before they were used leading to occasional failure of tests.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java | 4 ++--
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java | 32 +++++++++++++++++++++++---------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 33b3c3e..dd19136 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -70,6 +70,7 @@
import org.opends.server.types.LockManager;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
+import org.opends.server.util.TimeThread;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
@@ -362,13 +363,23 @@
protected long getReplayedUpdatesCount(DN syncDN) throws Exception
{
String monitorFilter =
- "(&(cn=synchronization*)(base-dn=" + syncDN + "))";
+ "(&(cn=replication*)(base-dn=" + syncDN + "))";
InternalSearchOperation op;
- op = connection.processSearch(
- ByteStringFactory.create("cn=monitor"),
- SearchScope.SINGLE_LEVEL,
- LDAPFilter.decode(monitorFilter));
+ int count = 0;
+ do
+ {
+ if (count++>0)
+ TimeThread.sleep(100);
+ op = connection.processSearch(
+ ByteStringFactory.create("cn=monitor"),
+ SearchScope.SINGLE_LEVEL,
+ LDAPFilter.decode(monitorFilter));
+ }
+ while (op.getSearchEntries().isEmpty() && (count<100));
+ if (op.getSearchEntries().isEmpty())
+ throw new Exception("Could not read monitoring information");
+
SearchResultEntry entry = op.getSearchEntries().getFirst();
AttributeType attrType =
@@ -414,11 +425,14 @@
if (newEntry != null)
{
List<Attribute> tmpAttrList = newEntry.getAttribute(attrTypeStr);
- Attribute tmpAttr = tmpAttrList.get(0);
+ if ((tmpAttrList != null) && (!tmpAttrList.isEmpty()))
+ {
+ Attribute tmpAttr = tmpAttrList.get(0);
- AttributeType attrType =
- DirectoryServer.getAttributeType(attrTypeStr, true);
- found = tmpAttr.hasValue(new AttributeValue(attrType, valueString));
+ AttributeType attrType =
+ DirectoryServer.getAttributeType(attrTypeStr, true);
+ found = tmpAttr.hasValue(new AttributeValue(attrType, valueString));
+ }
}
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
index 774255e..003d141 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -829,7 +829,7 @@
cleanRealEntries();
ReplicationBroker broker =
- openReplicationSession(baseDn, (short) 27, 100, 8989, 1000, true);
+ openReplicationSession(baseDn, (short) 27, 100, replServerPort, 1000, true);
try {
ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 27, 0);
@@ -1100,7 +1100,7 @@
Thread.sleep(2000);
ReplicationBroker broker =
- openReplicationSession(baseDn, (short) 11, 100, 8989, 1000, true);
+ openReplicationSession(baseDn, (short) 11, 100, replServerPort, 1000, true);
try
{
ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 11, 0);
--
Gitblit v1.10.0