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/ReplicationTestCase.java | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 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));
+ }
}
}
--
Gitblit v1.10.0