本文整理匯總了Java中javax.naming.ldap.InitialLdapContext.newInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java InitialLdapContext.newInstance方法的具體用法?Java InitialLdapContext.newInstance怎麽用?Java InitialLdapContext.newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.ldap.InitialLdapContext
的用法示例。
在下文中一共展示了InitialLdapContext.newInstance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testNewInstance002
import javax.naming.ldap.InitialLdapContext; //導入方法依賴的package包/類
/**
* <p>
* Test method for
* 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
* </p>
* <p>
* Here we are testing if this method correctly creates a new
* InitialLdapContext instance. In this case we are using a non-null
* parameter.
* </p>
* <p>
* The expected result is a non-null InitialLdapContext.
* </p>
*/
public void testNewInstance002() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
Control[] cs = {
new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
InitialLdapContext x = new InitialLdapContext(env, null);
InitialLdapContext t = (InitialLdapContext) x.newInstance(cs);
assertNotNull(x);
assertNotSame(x, t);
x.close();
t.close();
}
示例2: testnewInstance
import javax.naming.ldap.InitialLdapContext; //導入方法依賴的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());
}
}
示例3: testNewInstance002
import javax.naming.ldap.InitialLdapContext; //導入方法依賴的package包/類
/**
* <p>
* Test method for
* 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
* </p>
* <p>
* Here we are testing if this method creates a new instance of this context
* initialized using request controls. In this case we are using as a
* parameters null controls.
* </p>
* <p>
* The expected result is a not null initial ladp context.
* </p>
*/
public void testNewInstance002() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
Control[] cs = {
new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
InitialLdapContext x = new InitialLdapContext(env, null);
InitialLdapContext t = (InitialLdapContext) x.newInstance(cs);
assertNotNull(x);
assertNotSame(x, t);
x.close();
t.close();
}
示例4: testNewInstance001
import javax.naming.ldap.InitialLdapContext; //導入方法依賴的package包/類
/**
* <p>
* Test method for
* 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
* </p>
* <p>
* Here we are testing if this method correctly creates a new
* InitialLdapContext instance. In this case we are using null as a
* parameter.
* </p>
* <p>
* The expected result is a non-null InitialLdapContext.
* </p>
*/
public void testNewInstance001() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
InitialLdapContext x = new InitialLdapContext(env, null);
InitialLdapContext t = (InitialLdapContext) x.newInstance(null);
assertNotNull(t);
assertNotSame(x, t);
x.close();
t.close();
}
示例5: testNewInstance001
import javax.naming.ldap.InitialLdapContext; //導入方法依賴的package包/類
/**
* <p>
* Test method for
* 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
* </p>
* <p>
* Here we are testing if this method creates a new instance of this context
* initialized using request controls. In this case we are using as a
* parameters null controls.
* </p>
* <p>
* The expected result is a not null initial ladp context.
* </p>
*/
public void testNewInstance001() throws Exception {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
InitialLdapContext x = new InitialLdapContext(env, null);
InitialLdapContext t = (InitialLdapContext) x.newInstance(null);
assertNotNull(t);
assertNotSame(x, t);
x.close();
t.close();
}