Operation op = msg.createOperation(connection, rawDN);
Operation generatedOperation = newMsg.createOperation(connection, rawDN);
assertEquals(op.getClass(), AddOperationBasis.class);
assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
AddOperationBasis addOpBasis = (AddOperationBasis) op;
AddOperationBasis genAddOpBasis = (AddOperationBasis) generatedOperation;
assertEquals(addOpBasis.getRawEntryDN(), genAddOpBasis.getRawEntryDN());
assertEquals( addOpBasis.getAttachment(SYNCHROCONTEXT),
genAddOpBasis.getAttachment(SYNCHROCONTEXT));
assertEquals(addOpBasis.getObjectClasses(), genAddOpBasis.getObjectClasses());
assertEquals(addOpBasis.getOperationalAttributes(), genAddOpBasis.getOperationalAttributes());
assertEquals(addOpBasis.getUserAttributes(), genAddOpBasis.getUserAttributes());
// Check default value for only VLAST fields
assertEquals(newMsg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE);
assertEquals(newMsg.getSafeDataLevel(), (byte)1);
assertEquals(newMsg.getEclIncludes().size(), 0);
// Set again only VLAST fields
newMsg.setAssuredMode(assuredMode);
newMsg.setSafeDataLevel(safeDataLevel);
if (entryAttrList != null)
{
newMsg.setEclIncludes(entryAttrList);
}
// Serialize in VLAST msg
AddMsg vlastMsg = (AddMsg)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.getParentUid(), vlastMsg.getParentUid());
assertEquals(msg.isAssured(), vlastMsg.isAssured());
assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel());
// 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 eattr : entryAttrList)
{
assertTrue(eattr.getName().equalsIgnoreCase(genAttrList.get(i).toAttribute().getName()));
assertTrue(eattr.toString().equalsIgnoreCase(genAttrList.get(i).toAttribute().toString()),
"Comparing: " + eattr.toString() + " and " + genAttrList.get(i).toAttribute().toString());
i++;
}
}
// Create an add operation from each message to compare attributes (kept encoded in messages)
op = msg.createOperation(connection, rawDN);
generatedOperation = vlastMsg.createOperation(connection, rawDN);
assertEquals(op.getClass(), AddOperationBasis.class);
assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
addOpBasis = (AddOperationBasis) op;
genAddOpBasis = (AddOperationBasis) generatedOperation;
assertEquals(addOpBasis.getRawEntryDN(), genAddOpBasis.getRawEntryDN());
assertEquals( addOpBasis.getAttachment(SYNCHROCONTEXT),
genAddOpBasis.getAttachment(SYNCHROCONTEXT));
assertEquals(addOpBasis.getObjectClasses(), genAddOpBasis.getObjectClasses());
assertEquals(addOpBasis.getOperationalAttributes(), genAddOpBasis.getOperationalAttributes());
assertEquals(addOpBasis.getUserAttributes(), genAddOpBasis.getUserAttributes());
}