本文整理汇总了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());
}
}