// 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 : " + msg);
ModifyMsg modMsg = (ModifyMsg) msg;
modMsg.createOperation(connection);
assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0,
"The received MODIFY replication message is not for the excepted DN : " + modMsg);
// Modify the entry DN
DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING) ;
ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection,
InternalClientConnection.nextOperationID(), InternalClientConnection
.nextMessageID(), null, personEntry.getDN(), RDN
.decode("uid=new person"), true, DN
.decode("ou=People," + TEST_ROOT_DN_STRING));
modDNOp.run();
assertTrue(DirectoryServer.entryExists(newDN),
"The MOD_DN operation didn't create the new person entry");
assertFalse(DirectoryServer.entryExists(personEntry.getDN()),
"The MOD_DN operation didn't delete the old person entry");
// See if the client has received the msg
msg = broker.receive();
assertTrue(msg instanceof ModifyDNMsg,
"The received replication message is not a MODIFY DN msg : " + msg);
ModifyDNMsg moddnMsg = (ModifyDNMsg) msg;
moddnMsg.createOperation(connection);
assertTrue(DN.decode(moddnMsg.getDn()).compareTo(personEntry.getDN()) == 0,
"The received MODIFY_DN message is not for the excepted DN : " + moddnMsg);
// Delete the entry
DeleteOperationBasis delOp = new DeleteOperationBasis(connection,
InternalClientConnection.nextOperationID(), InternalClientConnection
.nextMessageID(), null, DN
.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING));
delOp.run();
assertFalse(DirectoryServer.entryExists(newDN),
"Unable to delete the new person Entry");
// See if the client has received the msg
msg = broker.receive();
assertTrue(msg instanceof DeleteMsg,
"The received replication message is not a MODIFY DN msg : " + msg);
DeleteMsg delMsg = (DeleteMsg) msg;
delMsg.createOperation(connection);
assertTrue(DN.decode(delMsg.getDn()).compareTo(DN
.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING)) == 0,
"The received DELETE message is not for the excepted DN : " + delMsg);
/*
* Now check that when we send message to the ReplicationServer
* and that they are received and correctly replayed by the server.
*
* Start by testing the Add message reception
*/
AddMsg addMsg = new AddMsg(gen.newChangeNumber(),
personWithUUIDEntry.getDN().toString(),
user1entryUUID, baseUUID,
personWithUUIDEntry.getObjectClassAttribute(),
personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
if (assured)
addMsg.setAssured(true);
broker.publish(addMsg);
/*
* Check that the entry has been created in the local DS.
*/
Entry resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true);
assertNotNull(resultEntry,
"The send ADD replication message was not applied for "+personWithUUIDEntry.getDN().toString());
/*
* Test the reception of Modify Msg
*/
modMsg = new ModifyMsg(gen.newChangeNumber(), personWithUUIDEntry.getDN(),
mods, user1entryUUID);
if (assured)
modMsg.setAssured(true);
broker.publish(modMsg);
boolean found = checkEntryHasAttribute(personWithUUIDEntry.getDN(),
"telephonenumber", "01 02 45", 10000, true);
if (found == false)
fail("The modification has not been correctly replayed.");
// Test that replication is able to add attribute that do
// not exist in the schema.
List<Modification> invalidMods = generatemods("badattribute", "value");
modMsg = new ModifyMsg(gen.newChangeNumber(), personWithUUIDEntry.getDN(),
invalidMods, user1entryUUID);
if (assured)
modMsg.setAssured(true);
broker.publish(modMsg);
found = checkEntryHasAttribute(
personWithUUIDEntry.getDN(), "badattribute", "value", 10000, true);
if (found == false)