InitialDirContext initialDirContext = new InitialDirContext(env);
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
LdapContext context = (LdapContext) initialDirContext.lookup("");
assertNull(context.getConnectControls());
server = new MockLdapServer(server);
server.start();
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
context.reconnect(new Control[] { new SortControl("",
Control.NONCRITICAL) });
Control[] controls = context.getConnectControls();
assertNotNull(controls);
assertEquals(1, controls.length);
Control c = controls[0];
assertTrue(c instanceof SortControl);
assertEquals(Control.NONCRITICAL, c.isCritical());
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
context = (LdapContext) context.lookup("");
// connect controls are inherited
controls = context.getConnectControls();
assertNotNull(controls);