s.setSoTimeout(5000);
BindRequestProtocolOp bindRequest =
new BindRequestProtocolOp(ByteString.valueOf("cn=Directory Manager"),
3, ByteString.valueOf("password"));
LDAPMessage message = new LDAPMessage(1, bindRequest);
w.writeMessage(message);
message = r.readMessage();
BindResponseProtocolOp bindResponse =
message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
ArrayList<ByteString> values = new ArrayList<ByteString>();
values.add(ByteString.valueOf("foo"));
LDAPAttribute attr = new LDAPAttribute("description", values);
ArrayList<RawModification> mods = new ArrayList<RawModification>();
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(ByteString.valueOf(baseDN), mods);
message = new LDAPMessage(2, modifyRequest,
DisconnectClientPlugin.createDisconnectControlList(
"PostOperation"));
w.writeMessage(message);
// The operation should NOT be aborted at the post operation stage. While
// the plugin can disconnect the client, the modify should have already
// been committed to the backend and a SUCCESS COULD get back to the
// client.
responseLoop:
while (true)
{
message = r.readMessage();
if (message == null)
{
// The connection has been closed.
break responseLoop;
}
switch (message.getProtocolOpType())
{
case OP_TYPE_MODIFY_RESPONSE:
// This was expected. The disconnect didn't happen until after the
// response was sent.
break;