From 0a15c3e6aa9e1fa7fc20f730b3fcf6400fa86e85 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Fri, 19 Jun 2009 07:55:22 +0000
Subject: [PATCH] Increase replication protocol version to 3 + code cleaning
---
opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java | 9 +
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java | 232 ++++++++++++++++++++++++--------------
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java | 43 ++++--
opends/src/server/org/opends/server/replication/protocol/AddMsg.java | 2
opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java | 2
opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java | 2
opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java | 35 ++---
opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java | 2
8 files changed, 197 insertions(+), 130 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
index 688afd6..dd7ae4b 100644
--- a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
@@ -321,7 +321,7 @@
"\nuniqueId: " + uniqueId +
"\nassuredFlag: " + assuredFlag;
}
- if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V2)
+ if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V2)
{
return "AddMsg content: " +
"\nprotocolVersion: " + protocolVersion +
diff --git a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
index c6c9ab0..7927eee 100644
--- a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
@@ -131,7 +131,7 @@
"\nuniqueId: " + uniqueId +
"\nassuredFlag: " + assuredFlag;
}
- if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V2)
+ if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V2)
{
return "DeleteMsg content: " +
"\nprotocolVersion: " + protocolVersion +
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
index 70b162b..ea1e85e 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
@@ -324,7 +324,7 @@
"\nnewSuperior: " + newSuperior +
"\ndeleteOldRdn: " + deleteOldRdn;
}
- if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V2)
+ if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V2)
{
return "ModifyDNMsg content: " +
"\nprotocolVersion: " + protocolVersion +
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
index 9b6d81c..507461a 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
@@ -203,7 +203,7 @@
"\nuniqueId: " + uniqueId +
"\nassuredFlag: " + assuredFlag;
}
- if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V2)
+ if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V2)
{
return "ModifyMsg content: " +
"\nprotocolVersion: " + protocolVersion +
diff --git a/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java b/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
index 9e4b6e5..042f5a2 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.replication.protocol;
@@ -47,6 +47,11 @@
public static final short REPLICATION_PROTOCOL_V2 = 2;
/**
+ * The constant for the 3rd version of the replication protocol.
+ */
+ public static final short REPLICATION_PROTOCOL_V3 = 3;
+
+ /**
* The replication protocol version used by the instance of RS/DS in this VM.
*/
private static short currentVersion = -1;
@@ -81,7 +86,7 @@
*/
public static void resetCurrentVersion()
{
- currentVersion = REPLICATION_PROTOCOL_V2;
+ currentVersion = REPLICATION_PROTOCOL_V3;
}
/**
diff --git a/opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java b/opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java
index 2d7bf14..374593c 100644
--- a/opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java
+++ b/opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java
@@ -56,9 +56,9 @@
// Ready to be sent.
private byte[] realUpdateMsgNotAssuredBytesV1 = null;
- // V2 serialized form of the real message with assured flag set to false.
+ // VLatest serialized form of the real message with assured flag set to false.
// Ready to be sent.
- private byte[] realUpdateMsgNotAssuredBytesV2 = null;
+ private byte[] realUpdateMsgNotAssuredBytesVLatest = null;
/**
* Creates a new empty UpdateMsg.
@@ -131,12 +131,11 @@
realUpdateMsgNotAssuredBytesV1 = bytes;
/**
- * Prepare V2 serialized form of the message:
+ * Prepare VLATEST serialized form of the message:
* Get the encoding form of the real message then overwrite the assured
* flag to always be false.
*/
- origBytes = realUpdateMsg.getBytes(
- ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ origBytes = realUpdateMsg.getBytes(ProtocolVersion.getCurrentVersion());
// Clone the byte array to be able to modify it without problems
// (ModifyMsg messages for instance do not return a cloned version of
// their byte array)
@@ -179,8 +178,8 @@
// Force assured flag to false
bytes[pos] = (byte) 0;
- // Store computed V2 serialized form
- realUpdateMsgNotAssuredBytesV2 = bytes;
+ // Store computed VLATEST serialized form
+ realUpdateMsgNotAssuredBytesVLatest = bytes;
} else
{
@@ -192,12 +191,12 @@
}
/**
- * Prepare V2 serialized form of the message:
+ * Prepare VLATEST serialized form of the message:
* Get the encoding form of the real message then overwrite the assured
* flag to always be false.
*/
byte[] origBytes = realUpdateMsg.getBytes(
- ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ ProtocolVersion.getCurrentVersion());
// Clone the byte array to be able to modify it without problems
// (ModifyMsg messages for instance do not return a cloned version of
// their byte array)
@@ -241,8 +240,8 @@
// Force assured flag to false
bytes[pos] = (byte) 0;
- // Store computed V2 serialized form
- realUpdateMsgNotAssuredBytesV2 = bytes;
+ // Store computed VLatest serialized form
+ realUpdateMsgNotAssuredBytesVLatest = bytes;
}
}
@@ -320,16 +319,10 @@
public byte[] getBytes(short reqProtocolVersion)
throws UnsupportedEncodingException
{
- switch (reqProtocolVersion)
- {
- case ProtocolVersion.REPLICATION_PROTOCOL_V1:
- return realUpdateMsgNotAssuredBytesV1;
- case ProtocolVersion.REPLICATION_PROTOCOL_V2:
- return realUpdateMsgNotAssuredBytesV2;
- default:
- throw new UnsupportedEncodingException("Unsupported requested " +
- " protocol version: " + reqProtocolVersion);
- }
+ if (reqProtocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V1)
+ return realUpdateMsgNotAssuredBytesV1;
+ else
+ return realUpdateMsgNotAssuredBytesVLatest;
}
/**
diff --git a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index a711d46..0d7a971 100644
--- a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -819,14 +819,18 @@
{
DeleteMsg delMsg = (DeleteMsg)msg;
ArrayList<RawAttribute> rattributes = new ArrayList<RawAttribute>();
+ /* TODO:ECL Entry attributes for DEL op
+ ArrayList<RawAttribute> rattributes = delMsg.getEntryAttributes();
+ // Map the entry attributes of the DelMsg to an LDIF string
+ // for the 'deletedentryattributes' attribute of the CL entry
String delAttrs = delMsgToLDIFString(rattributes);
-
+ */
clEntry = createChangelogEntry(
eclmsg.getServiceId(),
eclmsg.getCookie().toString(),
DN.decode(delMsg.getDn()),
delMsg.getChangeNumber(),
- delAttrs,
+ null,
delMsg.getUniqueId(),
null,
null,
@@ -873,7 +877,9 @@
}
/**
- * Create an ECL entry.
+ * Create an ECL entry from a set of provided information. This is the part
+ * of entry creation common to all types of msgs (ADD, DEL, MOD, MODDN).
+ *
* @param serviceID The provided cookie value.
* @param cookie The provided cookie value.
* @param targetDN The provided targetDN.
@@ -1095,6 +1101,12 @@
return cle;
}
+ /**
+ * Dump a replication AddMsg to an LDIF string that will be the 'changes'
+ * attributes of the ECL entry.
+ * @param addMsg The provided replication add msg.
+ * @return The LDIF string.
+ */
private static String addMsgToLDIFString(AddMsg addMsg)
{
StringBuilder modTypeLine = new StringBuilder();
@@ -1164,13 +1176,13 @@
}
/**
- * q.
- * @param rattributes q.
- * @return
- */
+ * Dump a replication delMsg to an LDIF string that will be the 'changes'
+ * attributes of the ECL entry.
+ * @param addMsg The provided replication del msg.
+ * @return The LDIF string.
private static String delMsgToLDIFString(ArrayList<RawAttribute> rattributes)
{
- StringBuilder modTypeLine = new StringBuilder();
+ StringBuilder delTypeLine = new StringBuilder();
try
{
@@ -1208,22 +1220,22 @@
{
// ??
String stringValue = av.toString();
- modTypeLine.append(attrName);
+ delTypeLine.append(attrName);
if (needsBase64Encoding(stringValue))
{
- modTypeLine.append(":: ");
- modTypeLine.append(Base64.encode(av.getValue()));
+ delTypeLine.append(":: ");
+ delTypeLine.append(Base64.encode(av.getValue()));
}
else
{
- modTypeLine.append(": ");
- modTypeLine.append(stringValue);
+ delTypeLine.append(": ");
+ delTypeLine.append(stringValue);
}
- modTypeLine.append("\n");
+ delTypeLine.append("\n");
}
}
}
- return modTypeLine.toString();
+ return delTypeLine.toString();
}
catch(Exception e)
{
@@ -1231,6 +1243,7 @@
}
return null;
}
+ */
/**
* Dumps a list of modifications into an LDIF string.
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
index 9efdd80..1f2aad5 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2009 Sun Microsystems, Inc.
*/
package org.opends.server.replication.protocol;
@@ -62,6 +62,7 @@
*/
public class ProtocolCompatibilityTest extends ReplicationTestCase {
+ short REPLICATION_PROTOCOL_VLAST = ProtocolVersion.REPLICATION_PROTOCOL_V3;
/**
* Set up the environment for performing the tests in this Class.
*
@@ -109,18 +110,25 @@
/**
* Test that various combinations of ReplServerStartMsg encoding and decoding
- * using protocol V1 and V2 are working.
+ * using protocol VLAST and V2 are working.
*/
@Test(dataProvider="createReplServerStartData")
- public void replServerStartMsgTest(short serverId, String baseDN, int window,
+ public void replServerStartMsgTestVLASTV2(short serverId, String baseDN, int window,
String url, ServerState state, long genId, byte groupId, int degTh) throws Exception
{
- // Create V2 message
+ // TODO: replServerStartMsgTestV3V2 as soon as V3 will have any incompatibility with V2
+ }
+
+ @Test(dataProvider="createReplServerStartData")
+ public void replServerStartMsgTestVLASTV1(short serverId, String baseDN, int window,
+ String url, ServerState state, long genId, byte groupId, int degTh) throws Exception
+ {
+ // Create VLAST message
ReplServerStartMsg msg = new ReplServerStartMsg(serverId,
url, baseDN, window, state, ProtocolVersion.getCurrentVersion(), genId, true, groupId, degTh);
// Check version of message
- assertEquals(msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(msg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Serialize in V1
byte[] v1MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V1);
@@ -141,31 +149,31 @@
newMsg.getServerState().getMaxChangeNumber((short)1));
assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption());
- // Check default value for only V2 fields
+ // Check default value for only post V1 fields
assertEquals(newMsg.getGroupId(), (byte) -1);
assertEquals(newMsg.getDegradedStatusThreshold(), -1);
- // Set again only V2 fields
+ // Set again only post V1 fields
newMsg.setGroupId(groupId);
newMsg.setDegradedStatusThreshold(degTh);
- // Serialize in V2 msg
- ReplServerStartMsg v2Msg = new ReplServerStartMsg(newMsg.getBytes());
+ // Serialize in VLAST msg
+ ReplServerStartMsg vlastMsg = new ReplServerStartMsg(newMsg.getBytes());
// Check original version of message
- assertEquals(v2Msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
- // Check we retrieve original V2 message (V2 fields)
- assertEquals(msg.getGenerationId(), v2Msg.getGenerationId());
- assertEquals(msg.getServerId(), v2Msg.getServerId());
- assertEquals(msg.getServerURL(), v2Msg.getServerURL());
- assertEquals(msg.getBaseDn(), v2Msg.getBaseDn());
- assertEquals(msg.getWindowSize(), v2Msg.getWindowSize());
+ // Check we retrieve original V3 message (V3 fields)
+ assertEquals(msg.getGenerationId(), vlastMsg.getGenerationId());
+ assertEquals(msg.getServerId(), vlastMsg.getServerId());
+ assertEquals(msg.getServerURL(), vlastMsg.getServerURL());
+ assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn());
+ assertEquals(msg.getWindowSize(), vlastMsg.getWindowSize());
assertEquals(msg.getServerState().getMaxChangeNumber((short)1),
- v2Msg.getServerState().getMaxChangeNumber((short)1));
- assertEquals(msg.getSSLEncryption(), v2Msg.getSSLEncryption());
- assertEquals(msg.getGroupId(), v2Msg.getGroupId());
- assertEquals(msg.getDegradedStatusThreshold(), v2Msg.getDegradedStatusThreshold());
+ vlastMsg.getServerState().getMaxChangeNumber((short)1));
+ assertEquals(msg.getSSLEncryption(), vlastMsg.getSSLEncryption());
+ assertEquals(msg.getGroupId(), vlastMsg.getGroupId());
+ assertEquals(msg.getDegradedStatusThreshold(), vlastMsg.getDegradedStatusThreshold());
}
@DataProvider(name = "createAddData")
@@ -177,11 +185,19 @@
}
@Test(dataProvider = "createAddData")
- public void addMsgTest(String rawDN, boolean isAssured, AssuredMode assuredMode,
+ public void addMsgTestVLASTV2(String rawDN, boolean isAssured, AssuredMode assuredMode,
byte safeDataLevel)
throws Exception
{
- // Create V2 message
+ // TODO: addMsgTest as soon as V3 will have any incompatibility with V2
+ }
+
+ @Test(dataProvider = "createAddData")
+ public void addMsgTestVLASTV1(String rawDN, boolean isAssured, AssuredMode assuredMode,
+ byte safeDataLevel)
+ throws Exception
+ {
+ // Create VLAST message
Attribute objectClass = Attributes.create(DirectoryServer
.getObjectClassAttributeType(), "organization");
HashMap<ObjectClass, String> objectClassList = new HashMap<ObjectClass, String>();
@@ -214,7 +230,7 @@
msg.setSafeDataLevel(safeDataLevel);
// Check version of message
- assertEquals(msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(msg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Serialize in V1
byte[] v1MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V1);
@@ -248,32 +264,32 @@
assertEquals(addOpBasis.getOperationalAttributes(), genAddOpBasis.getOperationalAttributes());
assertEquals(addOpBasis.getUserAttributes(), genAddOpBasis.getUserAttributes());
- // Check default value for only V2 fields
+ // Check default value for only VLAST fields
assertEquals(newMsg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newMsg.getSafeDataLevel(), (byte)1);
- // Set again only V2 fields
+ // Set again only VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
- // Serialize in V2 msg
- AddMsg v2Msg = (AddMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
+ // Serialize in VLAST msg
+ AddMsg vlastMsg = (AddMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
// Check original version of message
- assertEquals(v2Msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
- // Check we retrieve original V2 message (V2 fields)
- assertEquals(msg.getUniqueId(), v2Msg.getUniqueId());
- assertEquals(msg.getDn(), v2Msg.getDn());
- assertEquals(msg.getChangeNumber(), v2Msg.getChangeNumber());
- assertEquals(msg.getParentUid(), v2Msg.getParentUid());
- assertEquals(msg.isAssured(), v2Msg.isAssured());
- assertEquals(msg.getAssuredMode(), v2Msg.getAssuredMode());
- assertEquals(msg.getSafeDataLevel(), v2Msg.getSafeDataLevel());
+ // Check we retrieve original VLAST message (VLAST fields)
+ assertEquals(msg.getUniqueId(), vlastMsg.getUniqueId());
+ assertEquals(msg.getDn(), vlastMsg.getDn());
+ assertEquals(msg.getChangeNumber(), vlastMsg.getChangeNumber());
+ assertEquals(msg.getParentUid(), vlastMsg.getParentUid());
+ assertEquals(msg.isAssured(), vlastMsg.isAssured());
+ assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
+ assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel());
// Create an add operation from each message to compare attributes (kept encoded in messages)
op = msg.createOperation(connection, rawDN);
- generatedOperation = v2Msg.createOperation(connection, rawDN);
+ generatedOperation = vlastMsg.createOperation(connection, rawDN);
assertEquals(op.getClass(), AddOperationBasis.class);
assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
@@ -301,10 +317,22 @@
/**
* Test that various combinations of DeleteMsg encoding and decoding
- * using protocol V1 and V2 are working.
+ * using protocol V2 and VLAST are working.
*/
@Test(dataProvider = "createDeleteData")
- public void deleteMsgTest(String rawDN, boolean isAssured, AssuredMode assuredMode,
+ public void deleteMsgTestVLASTV2(String rawDN, boolean isAssured, AssuredMode assuredMode,
+ byte safeDataLevel)
+ throws Exception
+ {
+ // TODO: deleteMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
+ }
+
+ /**
+ * Test that various combinations of DeleteMsg encoding and decoding
+ * using protocol V1 and VLAST are working.
+ */
+ @Test(dataProvider = "createDeleteData")
+ public void deleteMsgTestVLASTV1(String rawDN, boolean isAssured, AssuredMode assuredMode,
byte safeDataLevel)
throws Exception
{
@@ -317,7 +345,7 @@
msg.setSafeDataLevel(safeDataLevel);
// Check version of message
- assertEquals(msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(msg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Serialize in V1
byte[] v1MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V1);
@@ -334,27 +362,27 @@
assertEquals(newMsg.getChangeNumber(), msg.getChangeNumber());
assertEquals(newMsg.isAssured(), msg.isAssured());
- // Check default value for only V2 fields
+ // Check default value for only VLAST fields
assertEquals(newMsg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newMsg.getSafeDataLevel(), (byte)1);
- // Set again only V2 fields
+ // Set again only VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
- // Serialize in V2 msg
- DeleteMsg v2Msg = (DeleteMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
+ // Serialize in VLAST msg
+ DeleteMsg vlastMsg = (DeleteMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
// Check original version of message
- assertEquals(v2Msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Check we retrieve original V2 message (V2 fields)
- assertEquals(msg.getUniqueId(), v2Msg.getUniqueId());
- assertEquals(msg.getDn(), v2Msg.getDn());
- assertEquals(msg.getChangeNumber(), v2Msg.getChangeNumber());
- assertEquals(msg.isAssured(), v2Msg.isAssured());
- assertEquals(msg.getAssuredMode(), v2Msg.getAssuredMode());
- assertEquals(msg.getSafeDataLevel(), v2Msg.getSafeDataLevel());
+ assertEquals(msg.getUniqueId(), vlastMsg.getUniqueId());
+ assertEquals(msg.getDn(), vlastMsg.getDn());
+ assertEquals(msg.getChangeNumber(), vlastMsg.getChangeNumber());
+ assertEquals(msg.isAssured(), vlastMsg.isAssured());
+ assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
+ assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel());
}
/**
@@ -421,13 +449,27 @@
* using protocol V1 and V2 are working.
*/
@Test(dataProvider = "createModifyData")
- public void modifyMsgTest(ChangeNumber changeNumber,
+ public void modifyMsgTestVLASTV2(ChangeNumber changeNumber,
String rawdn, List<Modification> mods,
boolean isAssured, AssuredMode assuredMode,
byte safeDataLevel)
throws Exception
{
- // Create V2 message
+ // TODO: modifyMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
+ }
+
+ /**
+ * Test that various combinations of ModifyMsg encoding and decoding
+ * using protocol V1 and VLAST are working.
+ */
+ @Test(dataProvider = "createModifyData")
+ public void modifyMsgTestVLASTV1(ChangeNumber changeNumber,
+ String rawdn, List<Modification> mods,
+ boolean isAssured, AssuredMode assuredMode,
+ byte safeDataLevel)
+ throws Exception
+ {
+ // Create VLAST message
DN dn = DN.decode(rawdn);
ModifyMsg msg = new ModifyMsg(changeNumber, dn, mods, "fakeuniqueid");
@@ -436,7 +478,7 @@
msg.setSafeDataLevel(safeDataLevel);
// Check version of message
- assertEquals(msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(msg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Serialize in V1
byte[] v1MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V1);
@@ -467,31 +509,31 @@
genModOpBasis.getAttachment(SYNCHROCONTEXT));
assertEquals(modOpBasis.getModifications(), genModOpBasis.getModifications());
- // Check default value for only V2 fields
+ // Check default value for only VLAST fields
assertEquals(newMsg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newMsg.getSafeDataLevel(), (byte)1);
- // Set again only V2 fields
+ // Set again only VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
- // Serialize in V2 msg
- ModifyMsg v2Msg = (ModifyMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
+ // Serialize in VLAST msg
+ ModifyMsg vlastMsg = (ModifyMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
// Check original version of message
- assertEquals(v2Msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
- // Check we retrieve original V2 message (V2 fields)
- assertEquals(msg.getUniqueId(), v2Msg.getUniqueId());
- assertEquals(msg.getDn(), v2Msg.getDn());
- assertEquals(msg.getChangeNumber(), v2Msg.getChangeNumber());
- assertEquals(msg.isAssured(), v2Msg.isAssured());
- assertEquals(msg.getAssuredMode(), v2Msg.getAssuredMode());
- assertEquals(msg.getSafeDataLevel(), v2Msg.getSafeDataLevel());
+ // Check we retrieve original VLAST message (VLAST fields)
+ assertEquals(msg.getUniqueId(), vlastMsg.getUniqueId());
+ assertEquals(msg.getDn(), vlastMsg.getDn());
+ assertEquals(msg.getChangeNumber(), vlastMsg.getChangeNumber());
+ assertEquals(msg.isAssured(), vlastMsg.isAssured());
+ assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
+ assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel());
// Create a modify operation from each message to compare mods (kept encoded in messages)
op = msg.createOperation(connection);
- generatedOperation = v2Msg.createOperation(connection);
+ generatedOperation = vlastMsg.createOperation(connection);
assertEquals(op.getClass(), ModifyOperationBasis.class);
assertEquals(generatedOperation.getClass(), ModifyOperationBasis.class);
@@ -549,16 +591,30 @@
/**
* Test that various combinations of ModifyDnMsg encoding and decoding
- * using protocol V1 and V2 are working.
+ * using protocol VLAST and V2 are working.
*/
@Test(dataProvider = "createModifyDnData")
- public void modifyDnMsgTest(String rawDN, String newRdn, String uid, String newParentUid,
+ public void modifyDnMsgTestVLASTV2(String rawDN, String newRdn, String uid, String newParentUid,
boolean deleteOldRdn, String newSuperior,
List<Modification> mods, boolean isAssured,
AssuredMode assuredMode, byte safeDataLevel)
throws Exception
{
- // Create V2 message
+ // TODO: modifyMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
+ }
+
+ /**
+ * Test that various combinations of ModifyDnMsg encoding and decoding
+ * using protocol VLAST and V1 are working.
+ */
+ @Test(dataProvider = "createModifyDnData")
+ public void modifyDnMsgTestVLASTV1(String rawDN, String newRdn, String uid, String newParentUid,
+ boolean deleteOldRdn, String newSuperior,
+ List<Modification> mods, boolean isAssured,
+ AssuredMode assuredMode, byte safeDataLevel)
+ throws Exception
+ {
+ // Create VLAST message
ChangeNumber cn = new ChangeNumber(TimeThread.getTime(),
(short) 596, (short) 13);
ModifyDNMsg msg = new ModifyDNMsg(rawDN, cn, uid,
@@ -570,7 +626,7 @@
msg.setSafeDataLevel(safeDataLevel);
// Check version of message
- assertEquals(msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(msg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Serialize in V1
byte[] v1MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V1);
@@ -604,38 +660,38 @@
assertEquals( modDnOpBasis.getAttachment(SYNCHROCONTEXT),
genModDnOpBasis.getAttachment(SYNCHROCONTEXT));
- // Check default value for only V2 fields
+ // Check default value for only VLAST fields
assertEquals(newMsg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newMsg.getSafeDataLevel(), (byte)1);
assertEquals(modDnOpBasis.getModifications(), mods);
assertTrue(genModDnOpBasis.getModifications() == null);
- // Set again only V2 fields
+ // Set again only VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
newMsg.setMods(mods);
- // Serialize in V2 msg
- ModifyDNMsg v2Msg = (ModifyDNMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
+ // Serialize in VLAST msg
+ ModifyDNMsg vlastMsg = (ModifyDNMsg)ReplicationMsg.generateMsg(newMsg.getBytes());
// Check original version of message
- assertEquals(v2Msg.getVersion(), ProtocolVersion.REPLICATION_PROTOCOL_V2);
+ assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
- // Check we retrieve original V2 message (V2 fields)
- assertEquals(msg.getUniqueId(), v2Msg.getUniqueId());
- assertEquals(msg.getDn(), v2Msg.getDn());
- assertEquals(msg.getChangeNumber(), v2Msg.getChangeNumber());
- assertEquals(msg.isAssured(), v2Msg.isAssured());
- assertEquals(msg.getAssuredMode(), v2Msg.getAssuredMode());
- assertEquals(msg.getSafeDataLevel(), v2Msg.getSafeDataLevel());
- assertEquals(msg.getNewRDN(), v2Msg.getNewRDN());
- assertEquals(msg.getNewSuperior(), v2Msg.getNewSuperior());
- assertEquals(msg.getNewSuperiorId(), v2Msg.getNewSuperiorId());
- assertEquals(msg.deleteOldRdn(), v2Msg.deleteOldRdn());
+ // Check we retrieve original VLAST message (VLAST fields)
+ assertEquals(msg.getUniqueId(), vlastMsg.getUniqueId());
+ assertEquals(msg.getDn(), vlastMsg.getDn());
+ assertEquals(msg.getChangeNumber(), vlastMsg.getChangeNumber());
+ assertEquals(msg.isAssured(), vlastMsg.isAssured());
+ assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
+ assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel());
+ assertEquals(msg.getNewRDN(), vlastMsg.getNewRDN());
+ assertEquals(msg.getNewSuperior(), vlastMsg.getNewSuperior());
+ assertEquals(msg.getNewSuperiorId(), vlastMsg.getNewSuperiorId());
+ assertEquals(msg.deleteOldRdn(), vlastMsg.deleteOldRdn());
// Create a modDn operation from each message to compare mods (kept encoded in messages)
op = msg.createOperation(connection);
- generatedOperation = v2Msg.createOperation(connection);
+ generatedOperation = vlastMsg.createOperation(connection);
assertEquals(op.getClass(), ModifyDNOperationBasis.class);
assertEquals(generatedOperation.getClass(), ModifyDNOperationBasis.class);
--
Gitblit v1.10.0