// - Delete
long time = TimeThread.getTime();
int ts = 1;
ChangeNumber cn = new ChangeNumber(time, ts++, brokerIds[0]);
DeleteMsg delMsg = new DeleteMsg("o=example" + itest + "," + TEST_ROOT_DN_STRING, cn, "uid");
broker1.publish(delMsg);
String user1entryUUID = "33333333-3333-3333-3333-333333333333";
String baseUUID = "22222222-2222-2222-2222-222222222222";
// - Add
String lentry = new String("dn: o=example," + TEST_ROOT_DN_STRING + "\n"
+ "objectClass: top\n" + "objectClass: domain\n"
+ "entryUUID: 11111111-1111-1111-1111-111111111111\n");
Entry entry = TestCaseUtils.entryFromLdifString(lentry);
cn = new ChangeNumber(time, ts++, brokerIds[0]);
AddMsg addMsg = new AddMsg(cn, "o=example," + TEST_ROOT_DN_STRING,
user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry
.getAttributes(), new ArrayList<Attribute>());
broker1.publish(addMsg);
// - Modify
Attribute attr1 = Attributes.create("description", "new value");
Modification mod1 = new Modification(ModificationType.REPLACE, attr1);
List<Modification> mods = new ArrayList<Modification>();
mods.add(mod1);
cn = new ChangeNumber(time, ts++, brokerIds[0]);
ModifyMsg modMsg = new ModifyMsg(cn, DN
.decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid");
broker1.publish(modMsg);
// - ModifyDN
cn = new ChangeNumber(time, ts++, brokerIds[0]);
ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, DN
.decode("o=example," + TEST_ROOT_DN_STRING), RDN.decode("o=example2"), true,
null);
op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(cn, "uniqueid",
"newparentId"));
LocalBackendModifyDNOperation localOp =
new LocalBackendModifyDNOperation(op);
ModifyDNMsg modDNMsg = new ModifyDNMsg(localOp);
broker1.publish(modDNMsg);
if (itest > 0)
{
socket.close();
SortedSet<String> servers = new TreeSet<String>();
servers.add("localhost:"+changelogPorts[0]);
ReplServerFakeConfiguration conf =
new ReplServerFakeConfiguration(changelogPorts[1], null, 0,
changelogIds[1], 0, 0, null);
changelogs[1] = new ReplicationServer(conf);
// Connect broker 2 to changelog2
broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
brokerIds[1], 100, changelogPorts[1], 2000, !emptyOldChanges);
assertTrue(broker2.isConnected());
}
// - Check msg receives by broker, through changeLog2
while (ts > 1)
{
ReplicationMsg msg2;
try
{
msg2 = broker2.receive();
if (msg2 == null)
break;
broker2.updateWindowAfterReplay();
}
catch (Exception e)
{
fail("Broker receive failed: " + e.getMessage() + "#Msg:" + ts + "#itest:" + itest);
break;
}
if (msg2 instanceof DeleteMsg)
{
DeleteMsg delMsg2 = (DeleteMsg) msg2;
if (delMsg2.toString().equals(delMsg.toString()))
ts--;
}
else if (msg2 instanceof AddMsg)
{
AddMsg addMsg2 = (AddMsg) msg2;