long searchRequests = ldapStatistics.getSearchRequests();
long searchEntries = ldapStatistics.getSearchResultEntries();
long searchReferences = ldapStatistics.getSearchResultReferences();
long searchesDone = ldapStatistics.getSearchResultsDone();
LDAPMessage message;
message = new LDAPMessage(2, searchRequest1, controls);
w1.writeMessage(message);
this.sleep(500);
message = new LDAPMessage(2, searchRequest2, controls);
w2.writeMessage(message);
this.sleep(500);
message = new LDAPMessage(2, searchRequest3, controls);
w3.writeMessage(message);
this.sleep(500);
SearchResultEntryProtocolOp searchResultEntry = null;
SearchResultDoneProtocolOp searchResultDone = null;
if (changesOnly == false)
{
debugInfo(tn, "Search1 Persistent filter="+searchRequest1.getFilter().toString()
+ " expected to return change " + cn1);
searchEntries = 0;
message = null;
try
{
while ((searchEntries<1) && (message = r1.readMessage()) != null)
{
debugInfo(tn, "Search1 Result=" +
message.getProtocolOpType() + " " + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
if (searchEntries==1)
{
checkValue(searchResultEntry.toSearchResultEntry(),"replicationcsn",cn1.toString());
checkValue(searchResultEntry.toSearchResultEntry(),"changenumber",
(compatMode?"10":"0"));
}
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
searchesDone++;
break;
}
}
}
catch(Exception e)
{
fail("Search1 failed with e=" + stackTraceToSingleLineString(e));
}
debugInfo(tn, "Search1 done with success. searchEntries="
+ searchEntries + " #searchesDone="+ searchesDone);
searchEntries = 0;
message = null;
try
{
debugInfo(tn, "Search 2 Persistent filter="+searchRequest2.getFilter().toString()
+ " expected to return change " + cn2 + " & " + cn3);
while ((searchEntries<2) && (message = r2.readMessage()) != null)
{
debugInfo(tn, "Search 2 Result=" +
message.getProtocolOpType() + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
checkValue(searchResultEntry.toSearchResultEntry(),"changenumber",
(compatMode?"10":"0"));
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
searchesDone++;
break;
}
}
}
catch(Exception e)
{
fail("Search2 failed with e=" + stackTraceToSingleLineString(e));
}
debugInfo(tn, "Search2 done with success. searchEntries="
+ searchEntries + " #searchesDone="+ searchesDone);
searchEntries = 0;
message = null;
try
{
debugInfo(tn, "Search3 Persistent filter="+searchRequest3.getFilter().toString()
+ " expected to return change top + " + cn1 + " & " + cn2 + " & " + cn3);
while ((searchEntries<4) && (message = r3.readMessage()) != null)
{
debugInfo(tn, "Search3 Result=" +
message.getProtocolOpType() + " " + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
searchesDone++;
break;
}
}
}
catch(Exception e)
{
fail("Search3 failed with e=" + stackTraceToSingleLineString(e));
}
debugInfo(tn, "Search3 done with success. searchEntries="
+ searchEntries + " #searchesDone="+ searchesDone);
}
// Produces additional change
ChangeNumber cn11 = new ChangeNumber(TimeThread.getTime(), 11, 1201);
String expectedDn11 = "uid=" + tn + "11," + TEST_ROOT_DN_STRING;
DeleteMsg delMsg11 = new DeleteMsg(expectedDn11, cn11,
"44444444-4444-4444-4444-444444444444");
debugInfo(tn, " publishing " + delMsg11);
server01.publish(delMsg11);
this.sleep(500);
debugInfo(tn, delMsg11.getChangeNumber() + " published additionally ");
// Produces additional change
ChangeNumber cn12 = new ChangeNumber(TimeThread.getTime(), 12, 1202);
String expectedDn12 = "uid=" + tn + "12," + TEST_ROOT_DN_STRING2;
DeleteMsg delMsg12 = new DeleteMsg(expectedDn12, cn12,
"55555555-5555-5555-5555-555555555555");
debugInfo(tn, " publishing " + delMsg12 );
server02.publish(delMsg12);
this.sleep(500);
debugInfo(tn, delMsg12.getChangeNumber() + " published additionally ");
// Produces additional change
ChangeNumber cn13 = new ChangeNumber(TimeThread.getTime(), 13, 1202);
String expectedDn13 = "uid=" + tn + "13," + TEST_ROOT_DN_STRING2;
DeleteMsg delMsg13 = new DeleteMsg(expectedDn13, cn13,
"66666666-6666-6666-6666-666666666666");
debugInfo(tn, " publishing " + delMsg13);
server02.publish(delMsg13);
this.sleep(500);
debugInfo(tn, delMsg13.getChangeNumber() + " published additionally ");
// wait 11
searchEntries = 0;
searchResultEntry = null;
searchResultDone = null;
message = null;
while ((searchEntries<1) && (message = r1.readMessage()) != null)
{
debugInfo(tn, "Search 11 Result=" +
message.getProtocolOpType() + " " + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
// assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
searchesDone++;
break;
}
}
sleep(1000);
debugInfo(tn, "Search 1 successfully receives additional changes");
// wait 12 & 13
searchEntries = 0;
searchResultEntry = null;
searchResultDone = null;
message = null;
while ((searchEntries<2) && (message = r2.readMessage()) != null)
{
debugInfo(tn, "psearch search 12 Result=" +
message.getProtocolOpType() + " " + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
// assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
searchesDone++;
break;
}
}
sleep(1000);
debugInfo(tn, "Search 2 successfully receives additional changes");
// wait 11 & 12 & 13
searchEntries = 0;
searchResultEntry = null;
searchResultDone = null;
message = null;
while ((searchEntries<3) && (message = r3.readMessage()) != null)
{
debugInfo(tn, "psearch search 13 Result=" +
message.getProtocolOpType() + " " + message);
switch (message.getProtocolOpType())
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
searchEntries++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
searchResultDone = message.getSearchResultDoneProtocolOp();
assertEquals(
searchResultDone.getResultCode(), ResultCode.SUCCESS,
searchResultDone.getErrorMessage().toString());
// assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
searchesDone++;