boolean subtree)
throws Exception
{
InternalClientConnection connection =
InternalClientConnection.getRootConnection();
DeleteOperationBasis opBasis =
new DeleteOperationBasis(connection, 1, 1,null, DN.decode(rawDN));
if (subtree)
{
opBasis.addRequestControl(new SubtreeDeleteControl(false));
}
LocalBackendDeleteOperation op = new LocalBackendDeleteOperation(opBasis);
ChangeNumber cn = new ChangeNumber(TimeThread.getTime(),123, 45);
op.setAttachment(SYNCHROCONTEXT, new DeleteContext(cn, "uniqueid"));
DeleteMsg msg = new DeleteMsg(op);
assertTrue((msg.isSubtreeDelete()==subtree));
// Set ECL entry attributes
if (entryAttrList != null)
{
msg.setEclIncludes(entryAttrList);
}
msg.setInitiatorsName("johnny h");
DeleteMsg generatedMsg = (DeleteMsg) ReplicationMsg.generateMsg(
msg.getBytes(), ProtocolVersion.getCurrentVersion());
assertEquals(msg.toString(), generatedMsg.toString());
assertEquals(msg.getInitiatorsName(), generatedMsg.getInitiatorsName());
assertEquals(msg.getChangeNumber(), generatedMsg.getChangeNumber());
assertEquals(generatedMsg.isSubtreeDelete(), subtree);
// Get ECL entry attributes
ArrayList<RawAttribute> genAttrList = generatedMsg.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++;
}
}
Operation generatedOperation = generatedMsg.createOperation(connection);
assertEquals(generatedOperation.getClass(), DeleteOperationBasis.class);
assertTrue(
(subtree?(generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)!=null):
(generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)==null)));
DeleteOperationBasis mod2 = (DeleteOperationBasis) generatedOperation;
assertEquals(op.getRawEntryDN(), mod2.getRawEntryDN());
// Create an update message from this op
DeleteMsg updateMsg = (DeleteMsg) LDAPUpdateMsg.generateMsg(op);
assertEquals(msg.getChangeNumber(), updateMsg.getChangeNumber());
assertEquals(msg.isSubtreeDelete(), updateMsg.isSubtreeDelete());