{
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(3000);
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));
values = new ArrayList<ByteString>();
values.add(ByteString.valueOf("cn=Directory Manager"));
attrs.add(new LDAPAttribute("creatorsName", values));
values = new ArrayList<ByteString>();
values.add(ByteString.valueOf("20060101000000Z"));
attrs.add(new LDAPAttribute("createTimestamp", values));
long addRequests = ldapStatistics.getAddRequests();
long addResponses = ldapStatistics.getAddResponses();
AddRequestProtocolOp addRequest =
new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"),
attrs);
message = new LDAPMessage(2, addRequest);
w.writeMessage(message);
message = r.readMessage();
AddResponseProtocolOp addResponse =
message.getAddResponseProtocolOp();
assertFalse(addResponse.getResultCode() == 0);