From 23f2dcda4aa7e579464f069cde98d032c9328626 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 03 Oct 2006 13:37:41 +0000
Subject: [PATCH] minor improvement in synchronization unit tests
---
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationMsgTest.java | 1
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ModifyConflictTest.java | 39 +++++++------------
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ServerStateTest.java | 46 +++++-----------------
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ChangeNumberTest.java | 4 +-
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java | 1
5 files changed, 28 insertions(+), 63 deletions(-)
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ChangeNumberTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ChangeNumberTest.java
index 8dc5b64..dafe316 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ChangeNumberTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ChangeNumberTest.java
@@ -244,13 +244,13 @@
// Generate a changeNumber separates by 10 milliseconds
// and check that they are differents
- Thread.currentThread().sleep(10);
+ Thread.sleep(10);
CN2 = cng.NewChangeNumber();
assertTrue(CN1.compareTo(CN2) != 0);
// Generate a changeNumber separates by 300 milliseconds
// and check that they are differents
- Thread.currentThread().sleep(300);
+ Thread.sleep(300);
CN2 = cng.NewChangeNumber();
assertTrue(CN1.compareTo(CN2) != 0);
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ModifyConflictTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ModifyConflictTest.java
index b10fcc5..192cc39 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ModifyConflictTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ModifyConflictTest.java
@@ -101,7 +101,7 @@
Map<AttributeType, List<Attribute>> operationalAttributes = entry
.getOperationalAttributes();
operationalAttributes.put(Historical.entryuuidAttrType, uuidList);
-
+
// Create the att values list of historicalAttr
String stringVal =
"ds-sync-hist:00000108b3a6cbb800000001:repl:00000108b3a6cbb800000002";
@@ -118,7 +118,7 @@
//Add the historical att in the entry
operationalAttributes.put(Historical.historicalAttrType,histList) ;
-
+
// load historical from the entry
Historical hist = Historical.load(entry);
@@ -161,7 +161,7 @@
// Get the historical uuid associated to the entry
// (the one that needs to be tested)
- String uuid = hist.getEntryUuid(entry);
+ String uuid = Historical.getEntryUuid(entry);
// Get the Entry uuid in String format
List<Attribute> uuidAttrs = entry
@@ -177,18 +177,8 @@
assertTrue(retrievedUuid.equals(uuid));
}
}
-
- try
- {
- Historical dup = hist.duplicate();
- // TODO Check values
- }
- catch (RuntimeException e)
- {
- assertTrue(false) ;
- }
-
-
+
+
// Test FakeOperation
try
{
@@ -203,11 +193,11 @@
{
UpdateMessage new_name = (UpdateMessage) generatedMsg;
assertEquals(new_name.getUniqueId(),uuid);
-
+
}
-
+
}
-
+
}
catch (RuntimeException e)
{
@@ -224,7 +214,7 @@
// Get the historical uuid associated to the entry
// (the one that needs to be tested)
- String uuid = hist.getEntryUuid(addOp);
+ String uuid = Historical.getEntryUuid(addOp);
// Get the op uuid in String format
List<Attribute> uuidAttrs = addOp.getOperationalAttributes().get(
@@ -284,7 +274,7 @@
.getOperationalAttributes();
operationalAttributes.put(Historical.entryuuidAttrType, uuidList);
-
+
// Create the att values list of historicalAttr
String stringVal =
"ds-sync-hist:00000108b3a6cbb800000001:del:00000108b3a6cbb800000002";
@@ -297,10 +287,11 @@
ArrayList<Attribute> histList = new ArrayList<Attribute>(1);
Attribute histAttr = new Attribute(Historical.historicalAttrType,
"ds-sync-hist", valuesHist);
+ histList.add(0, histAttr);
//Add the historical att in the entry
entry.putAttribute(Historical.historicalAttrType,histList) ;
-
+
// load historical from the entry
Historical hist = Historical.load(entry);
@@ -394,9 +385,9 @@
//Add the historycal att in the entry
entry.putAttribute(Historical.historicalAttrType,histList) ;
-
+
// load historical from the entry
-
+
Historical hist = Historical.load(entry);
/*
@@ -449,7 +440,7 @@
List<Modification> mods = new ArrayList<Modification>();
Modification mod = new Modification(modType, attr);
mods.add(mod);
-
+
ModifyOperation modOp = new ModifyOperation(connection, 1, 1, null,
entry.getDN(), mods);
ModifyContext ctx = new ModifyContext(t, "uniqueId");
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ServerStateTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ServerStateTest.java
index 3e303fa..513bf89 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ServerStateTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ServerStateTest.java
@@ -26,41 +26,14 @@
*/
package org.opends.server.synchronization;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Map;
-import java.util.zip.DataFormatException;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
import static org.testng.Assert.*;
-import org.opends.server.api.ClientConnection;
-import org.opends.server.core.AddOperation;
-import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyDNOperation;
-import org.opends.server.core.ModifyOperation;
-import org.opends.server.core.Operation;
-import org.opends.server.protocols.internal.InternalClientConnection;
-import org.opends.server.protocols.ldap.LDAPAttribute;
-import org.opends.server.synchronization.ModifyMsg;
-import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeValue;
-import org.opends.server.types.Control;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.DN;
-import org.opends.server.types.Modification;
-import org.opends.server.types.ModificationType;
-import org.opends.server.types.ObjectClass;
-import org.opends.server.types.RDN;
-import org.opends.server.util.TimeThread;
+import java.util.Set;
-import static org.opends.server.synchronization.OperationContext.*;
+import org.opends.server.types.DN;
+import org.opends.server.util.TimeThread;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the ServerState
@@ -96,7 +69,8 @@
// Check getServerStateDn()
DN returned_DN = serverState.getServerStateDn();
- // TODO Check the returned DN
+ // Check that the returned DN stays below dn
+ assertTrue(dn.isAncestorOf(returned_DN));
// Check update
assertFalse(serverState.update(null));
@@ -122,8 +96,10 @@
assertEquals(cn3.compareTo(serverState.getMaxChangeNumber(cn3.getServerId())),0);
// Check the toString
- String stringRep = serverState.toString() ;
- // TODO Check the value
+ String stringRep = serverState.toString();
+ assertFalse(stringRep.isEmpty());
+ assertTrue(stringRep.contains(cn2.toString()));
+ assertTrue(stringRep.contains(cn3.toString()));
// Check getBytes
byte[] b = serverState.getBytes();
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationMsgTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationMsgTest.java
index e3d33f1..5df7ff9 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationMsgTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationMsgTest.java
@@ -174,7 +174,6 @@
throws Exception
{
DN dn = DN.decode(rawdn);
- InternalClientConnection connection = new InternalClientConnection();
ModifyMsg msg = new ModifyMsg(changeNumber, dn, mods, "fakeuniqueid");;
// Check uuid
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
index 34e7dff..2b45b55 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
@@ -35,7 +35,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opends.server.synchronization.OperationContext.SYNCHROCONTEXT;
import static org.testng.Assert.*;
import org.opends.server.TestCaseUtils;
--
Gitblit v1.10.0