Operation op = msg.createOperation(connection);
Operation generatedOperation = newMsg.createOperation(connection);
assertEquals(op.getClass(), ModifyDNOperationBasis.class);
assertEquals(generatedOperation.getClass(), ModifyDNOperationBasis.class);
ModifyDNOperationBasis modDnOpBasis = (ModifyDNOperationBasis) op;
ModifyDNOperationBasis genModDnOpBasis = (ModifyDNOperationBasis) generatedOperation;
assertEquals(modDnOpBasis.getRawEntryDN(), genModDnOpBasis.getRawEntryDN());
assertEquals( modDnOpBasis.getAttachment(SYNCHROCONTEXT),
genModDnOpBasis.getAttachment(SYNCHROCONTEXT));
// 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 VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
newMsg.setMods(mods);
// Set ECL entry attributes
if (entryAttrList != null)
{
newMsg.setEclIncludes(entryAttrList);
}
// Serialize in VLAST msg
ModifyDNMsg vlastMsg = (ModifyDNMsg)ReplicationMsg.generateMsg(
newMsg.getBytes(), ProtocolVersion.REPLICATION_PROTOCOL_V1);
// Check original version of message
assertEquals(vlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// 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());
// Get ECL entry attributes
ArrayList<RawAttribute> genAttrList = vlastMsg.getEclIncludes();
if (entryAttrList==null)
assertTrue(genAttrList.size()==0);
else
{
assertTrue(genAttrList.size()==entryAttrList.size());
int i=0;
for (Attribute attr : entryAttrList)
{
assertTrue(attr.getName().equalsIgnoreCase(genAttrList.get(i).toAttribute().getName()));
assertTrue(attr.toString().equalsIgnoreCase(genAttrList.get(i).toAttribute().toString()),
"Comparing: " + attr.toString() + " and " + genAttrList.get(i).toAttribute().toString());
i++;
}
}
// Create a modDn operation from each message to compare mods (kept encoded in messages)
op = msg.createOperation(connection);
generatedOperation = vlastMsg.createOperation(connection);
assertEquals(op.getClass(), ModifyDNOperationBasis.class);
assertEquals(generatedOperation.getClass(), ModifyDNOperationBasis.class);
modDnOpBasis = (ModifyDNOperationBasis) op;
genModDnOpBasis = (ModifyDNOperationBasis) generatedOperation;
assertEquals(modDnOpBasis.getRawEntryDN(), genModDnOpBasis.getRawEntryDN());
assertEquals( modDnOpBasis.getAttachment(SYNCHROCONTEXT),
genModDnOpBasis.getAttachment(SYNCHROCONTEXT));
assertEquals(modDnOpBasis.getModifications(), genModDnOpBasis.getModifications());
}