Operation opFromV1 = newv1Msg.createOperation(connection);
assertEquals(opFromOrigVlast.getClass(), ModifyOperationBasis.class);
assertEquals(opFromV1.getClass(), ModifyOperationBasis.class);
ModifyOperationBasis modOpBasisFromOrigVlast = (ModifyOperationBasis) opFromOrigVlast;
ModifyOperationBasis genModOpBasisFromV1 = (ModifyOperationBasis) opFromV1;
assertEquals(modOpBasisFromOrigVlast.getRawEntryDN(), genModOpBasisFromV1.getRawEntryDN());
assertEquals( modOpBasisFromOrigVlast.getAttachment(SYNCHROCONTEXT),
genModOpBasisFromV1.getAttachment(SYNCHROCONTEXT));
List<Modification> modsvlast = modOpBasisFromOrigVlast.getModifications();
List<Modification> modsv1 = genModOpBasisFromV1.getModifications();
assertEquals(modsvlast, modsv1);
// Check default value for only VLAST fields
assertEquals(newv1Msg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newv1Msg.getSafeDataLevel(), (byte)1);
// Set again only VLAST fields
newv1Msg.setAssuredMode(assuredMode);
newv1Msg.setSafeDataLevel(safeDataLevel);
if (entryAttrList != null)
{
newv1Msg.setEclIncludes(entryAttrList);
}
// Serialize in VLAST msg
ModifyMsg generatedVlastMsg = (ModifyMsg)ReplicationMsg.generateMsg(
newv1Msg.getBytes(), ProtocolVersion.REPLICATION_PROTOCOL_V1);
// Check original version of message
assertEquals(generatedVlastMsg.getVersion(), REPLICATION_PROTOCOL_VLAST);
// Check we retrieve original VLAST message (VLAST fields)
assertEquals(origVlastMsg.getUniqueId(), generatedVlastMsg.getUniqueId());
assertEquals(origVlastMsg.getDn(), generatedVlastMsg.getDn());
assertEquals(origVlastMsg.getChangeNumber(), generatedVlastMsg.getChangeNumber());
assertEquals(origVlastMsg.isAssured(), generatedVlastMsg.isAssured());
assertEquals(origVlastMsg.getAssuredMode(), generatedVlastMsg.getAssuredMode());
assertEquals(origVlastMsg.getSafeDataLevel(), generatedVlastMsg.getSafeDataLevel());
assertEquals(origVlastMsg.getSafeDataLevel(), generatedVlastMsg.getSafeDataLevel());
// Get ECL entry attributes
ArrayList<RawAttribute> genAttrList = generatedVlastMsg.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 modify operation from each message to compare mods (kept encoded in messages)
opFromOrigVlast = origVlastMsg.createOperation(connection);
Operation opFromGeneratedVlastMsg = generatedVlastMsg.createOperation(connection);
assertEquals(opFromOrigVlast.getClass(), ModifyOperationBasis.class);
assertEquals(opFromGeneratedVlastMsg.getClass(), ModifyOperationBasis.class);
modOpBasisFromOrigVlast = (ModifyOperationBasis) opFromOrigVlast;
ModifyOperationBasis modOpBasisFromGeneratedVlast = (ModifyOperationBasis) opFromGeneratedVlastMsg;
assertEquals(modOpBasisFromOrigVlast.getRawEntryDN(),
modOpBasisFromGeneratedVlast.getRawEntryDN());
assertEquals( modOpBasisFromOrigVlast.getAttachment(SYNCHROCONTEXT),
modOpBasisFromGeneratedVlast.getAttachment(SYNCHROCONTEXT));
assertEquals(modOpBasisFromOrigVlast.getModifications(),
modOpBasisFromGeneratedVlast.getModifications());
}