Attribute attr = Attributes.create("attributetypes",
"( 2.5.44.77.33 NAME 'dummy' )");
List<Modification> mods = new ArrayList<Modification>();
Modification mod = new Modification(ModificationType.ADD, attr);
mods.add(mod);
ModifyOperationBasis modOp = new ModifyOperationBasis(connection,
InternalClientConnection.nextOperationID(), InternalClientConnection
.nextMessageID(), null, baseDn, mods);
modOp.setInternalOperation(true);
modOp.run();
ResultCode code = modOp.getResultCode();
assertTrue(code.equals(ResultCode.SUCCESS),
"The original operation failed: " + code.getResultCodeName());
// See if the client has received the msg
ReplicationMsg msg = broker.receive();
assertTrue(msg instanceof ModifyMsg,
"The received replication message is not a MODIFY msg");
ModifyMsg modMsg = (ModifyMsg) msg;
Operation receivedOp = modMsg.createOperation(connection);
assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0,
"The received message is not for cn=schema");
assertTrue(receivedOp instanceof ModifyOperation,
"The received replication message is not a MODIFY msg");
ModifyOperation receivedModifyOperation = (ModifyOperation) receivedOp;
List<RawModification> rcvdRawMods =
receivedModifyOperation.getRawModifications();
this.rcvdMods = new ArrayList<Modification>();
for (RawModification m : rcvdRawMods)
{
this.rcvdMods.add(m.toModification());
}
assertTrue(this.rcvdMods.contains(mod),
"The received mod does not contain the original change");
/*
* Now cleanup the schema for the next test
*/
mod = new Modification(ModificationType.DELETE, attr);
mods.clear();
mods.add(mod);
modOp = new ModifyOperationBasis(connection,
InternalClientConnection.nextOperationID(), InternalClientConnection
.nextMessageID(), null, baseDn, mods);
modOp.setInternalOperation(true);
modOp.run();
code = modOp.getResultCode();
assertTrue(code.equals(ResultCode.SUCCESS),
"The original operation failed" + code.getResultCodeName());
// See if the client has received the msg
msg = broker.receive();