本文整理匯總了Java中javax.naming.ldap.LdapContext.getRequestControls方法的典型用法代碼示例。如果您正苦於以下問題:Java LdapContext.getRequestControls方法的具體用法?Java LdapContext.getRequestControls怎麽用?Java LdapContext.getRequestControls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.ldap.LdapContext
的用法示例。
在下文中一共展示了LdapContext.getRequestControls方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testnewInstance
import javax.naming.ldap.LdapContext; //導入方法依賴的package包/類
public void testnewInstance() throws Exception {
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
InitialLdapContext initialDirContext = new InitialLdapContext(env, null);
Control[] reqCtls = initialDirContext.getRequestControls();
assertEquals(1, reqCtls.length);
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[0].getID());
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
LdapContext context = initialDirContext
.newInstance(new Control[] { new SortControl("",
Control.NONCRITICAL) });
assertNotSame(initialDirContext, context);
reqCtls = context.getRequestControls();
assertEquals(2, reqCtls.length);
Control control = reqCtls[0];
if (control instanceof SortControl) {
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[1].getID());
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
} else {
assertEquals("2.16.840.1.113730.3.4.2", control.getID());
assertEquals(Control.NONCRITICAL, control.isCritical());
assertTrue(reqCtls[1] instanceof SortControl);
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
}
}
示例2: testRequestControls
import javax.naming.ldap.LdapContext; //導入方法依賴的package包/類
public void testRequestControls() throws Exception {
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
InitialLdapContext initialContext = new InitialLdapContext(env, null);
Control[] reqCtls = initialContext.getRequestControls();
assertEquals(1, reqCtls.length);
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[0].getID());
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
initialContext.setRequestControls(new Control[] { new SortControl("",
Control.NONCRITICAL) });
reqCtls = initialContext.getRequestControls();
assertEquals(2, reqCtls.length);
Control control = reqCtls[0];
if (control instanceof SortControl) {
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[1].getID());
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
} else {
assertEquals("2.16.840.1.113730.3.4.2", control.getID());
assertEquals(Control.NONCRITICAL, control.isCritical());
assertTrue(reqCtls[1] instanceof SortControl);
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
}
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
LdapContext context = (LdapContext) initialContext.lookup("");
// request controls are not inherited
reqCtls = context.getRequestControls();
assertEquals(1, reqCtls.length);
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[0].getID());
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
context = context.newInstance(new Control[] { new SortControl("",
Control.NONCRITICAL) });
reqCtls = context.getRequestControls();
assertEquals(2, reqCtls.length);
control = reqCtls[0];
if (control instanceof SortControl) {
assertEquals(Control.NONCRITICAL, reqCtls[0].isCritical());
assertEquals("2.16.840.1.113730.3.4.2", reqCtls[1].getID());
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
} else {
assertEquals("2.16.840.1.113730.3.4.2", control.getID());
assertEquals(Control.NONCRITICAL, control.isCritical());
assertTrue(reqCtls[1] instanceof SortControl);
assertEquals(Control.NONCRITICAL, reqCtls[1].isCritical());
}
}