throws Exception
{
TestCaseUtils.initializeTestBackend(true);
Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort());
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
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<RawAttribute> attrs = new ArrayList<RawAttribute>();
ArrayList<ByteString> values = new ArrayList<ByteString>();
values.add(ByteString.valueOf("top"));
values.add(ByteString.valueOf("organizationalUnit"));
attrs.add(new LDAPAttribute("objectClass", values));
values = new ArrayList<ByteString>();
values.add(ByteString.valueOf("People"));
attrs.add(new LDAPAttribute("ou", values));
AddRequestProtocolOp addRequest =
new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"),
attrs);
message = new LDAPMessage(2, addRequest,
DisconnectClientPlugin.createDisconnectControlList("PreParse"));
w.writeMessage(message);
message = r.readMessage();
if (message != null)
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
assertEquals(message.getProtocolOpType(), OP_TYPE_EXTENDED_RESPONSE);