Package org.apache.harmony.jndi.provider.ldap.mock

Examples of org.apache.harmony.jndi.provider.ldap.mock.MockLdapServer


public class ReferralExceptionTest extends TestCase {
  private MockLdapServer server;

  public void setUp() {
    server = new MockLdapServer();
    server.start();
  }
View Full Code Here


public class ldapURLContextTest extends TestCase {
    private MockLdapServer server;

    @Override
    public void setUp() {
        server = new MockLdapServer();
        server.start();
    }
View Full Code Here

    private Hashtable<Object, Object> env = new Hashtable<Object, Object>();

    @Override
    public void setUp() {
        server = new MockLdapServer();
        server.start();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.harmony.jndi.provider.ldap.LdapContextFactory");
        env.put(Context.PROVIDER_URL, server.getURL());
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
View Full Code Here

        env.put(Context.REFERRAL, "follow");
        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        DirContext context = new InitialDirContext(env);

        MockLdapServer referralServer = new MockLdapServer();
        referralServer.start();

        EncodableLdapResult result = new EncodableLdapResult(
                LdapResult.REFERRAL, "", "", new String[] { referralServer
                        .getURL() });

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_SEARCH_RESULT_DONE, result, null) });

        referralServer.setResponseSeq(new LdapMessage[] {
                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
                        new BindResponse(), null),
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                        new EncodableLdapResult(), null) });

        context.getAttributes("cn=test");

        referralServer.stop();
    }
View Full Code Here

    private Hashtable<Object, Object> env = new Hashtable<Object, Object>();

    @Override
    public void setUp() throws Exception {
        server = new MockLdapServer();
        server.start();
        try {
            Class.forName("com.sun.jndi.ldap.LdapCtxFactory");
            env.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.sun.jndi.ldap.LdapCtxFactory");
View Full Code Here

                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("",
View Full Code Here

        env.put(Context.REFERRAL, "follow");
        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        DirContext context = new InitialDirContext(env);

        final MockLdapServer referralServer = new MockLdapServer();
        referralServer.start();

        ASN1Encodable ref = new ASN1Encodable() {

            public void encodeValues(Object[] values) {
                List<byte[]> list = new ArrayList<byte[]>();
                list.add(Utils.getBytes(referralServer.getURL()));
                values[0] = list;
            }

        };

        server.setResponseSeq(new LdapMessage[] {
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_REF, ref,
                        null),
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                        new EncodableLdapResult(), null) });

        referralServer.setResponseSeq(new LdapMessage[] {
                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
                        new BindResponse(), null),
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                        new EncodableLdapResult(), null) });
View Full Code Here

        env.put(Context.REFERRAL, "follow");
        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        DirContext context = new InitialDirContext(env);

        MockLdapServer referralServer = new MockLdapServer();
        referralServer.start();

        EncodableLdapResult result = new EncodableLdapResult(
                LdapResult.REFERRAL, "", "", new String[] { referralServer
                        .getURL() });

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_SEARCH_RESULT_DONE, result, null) });

        referralServer.setResponseSeq(new LdapMessage[] {
                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
                        new BindResponse(), null),
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                        new EncodableLdapResult(), null) });

        context.getAttributes("cn=test");

        referralServer.stop();
    }
View Full Code Here

        preValue = initialDirContext.addToEnvironment(
                Context.SECURITY_AUTHENTICATION, "simple");
        assertFalse("simple".equals(preValue));

        // initialDirContext is shared connection, will create new connection
        server = new MockLdapServer(server);
        server.start();
        server.setResponseSeq(new LdapMessage[] {
                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
                        new BindResponse(), null),
                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
View Full Code Here

                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
                new EncodableLdapResult(), null) });
        // another and context share the same connection now
        LdapContext another = (LdapContext) context.lookup("");

        MockLdapServer one = new MockLdapServer(server);
        one.start();

        one.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        // create new connection
        context.reconnect(null);

        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
View Full Code Here

TOP

Related Classes of org.apache.harmony.jndi.provider.ldap.mock.MockLdapServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.