当前位置: 首页>>代码示例>>Java>>正文


Java InitialLdapContext.newInstance方法代码示例

本文整理汇总了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();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:TestInitialLdapContext.java

示例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());
    }

}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:LdapContextServerMockedTest.java

示例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();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:TestInitialLdapContext.java

示例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();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:TestInitialLdapContext.java

示例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();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:TestInitialLdapContext.java


注:本文中的javax.naming.ldap.InitialLdapContext.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。