directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Zoerner (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DIRSERVER-935) Test hangs on non-existant schema entry lookup
Date Thu, 17 May 2007 17:16:16 GMT

     [ https://issues.apache.org/jira/browse/DIRSERVER-935?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Stefan Zoerner updated DIRSERVER-935:
-------------------------------------

    Description: 
Hey Guys,

I do a lookup like this inside a test:
        syntaxContext.lookup(xsdSyntaxStringRDN);
//      syntaxContext.lookup("monkeywrench");

If I leave the monkeywrench lookup commented
out, the test runs fine repeatedly.

If I comment in the monkeywrench the
test just hangs.  I was expecting
a NamingException.

I pasted a self contained test for this
below.

Cheers,
- Ole


  was:
Hey Guys,

I do a lookup like this inside a test:
        syntaxContext.lookup(xsdSyntaxStringRDN);
//      syntaxContext.lookup("monkeywrench");

If I leave the monkeywrench lookup commented
out, the test runs fine repeatedly.

If I comment in the monkeywrench the
test just hangs.  I was expecting
a NamingException.

I pasted a self contained test for this
below.

Cheers,
- Ole


package org.apache.tuscany.das.ldap.create.test;

import java.util.Hashtable;

import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import junit.framework.TestCase;

public class CreateSyntaxEntrySelfContainedTest extends TestCase
{
    private static final String XSD_CONTEXT_RDN     = "cn=xsd";
    private static final String XSD_SYNTAX_RDN      = "ou=syntaxes";
    private static final String OID    = "1.3.6.1.4.1.18060.0.4.0.0.100000.233.1233";

    private DirContext directoryContext = null;
    private DirContext xsdContext       = null;
    private DirContext syntaxContext    = null;
    private String xsdSyntaxStringRDN = "m-oid" + "=" + OID;


    public void setUp() throws NamingException
    {
        directoryContext    = connect();
        xsdContext          = createXSDSchemaContext();
        syntaxContext       = createSyntaxContext();
    }

    public void tearDown() throws NamingException
    {
        syntaxContext.destroySubcontext( xsdSyntaxStringRDN );
        syntaxContext.close();
        xsdContext.destroySubcontext( XSD_SYNTAX_RDN );
        xsdContext.close();
        directoryContext.destroySubcontext( XSD_CONTEXT_RDN );
        directoryContext.close();
    }

    public DirContext connect() throws NamingException
    {
                Hashtable<String,String> env = new Hashtable<String, String>();

                env.put(
                    DirContext.INITIAL_CONTEXT_FACTORY,
                    "com.sun.jndi.ldap.LdapCtxFactory" );
                env.put(
                    DirContext.PROVIDER_URL,
                    "ldap://localhost:10389/ou=schema");
                env.put(
                    DirContext.SECURITY_AUTHENTICATION,
                    "simple");
                env.put(
                    DirContext.SECURITY_PRINCIPAL,
                    "uid=admin,ou=system" );
                env.put(
                    DirContext.SECURITY_CREDENTIALS,
                   "secret" );
                return new InitialDirContext(env);
    }

    public DirContext createXSDSchemaContext() throws NamingException
    {
        Attributes xsdAttributes = new BasicAttributes();

        Attribute topAttribute = new BasicAttribute(
            "objectClass",
            "top");

        Attribute metaSchemaAttribute = new BasicAttribute(
            "objectClass",
            "metaSchema");

        Attribute xsdAttribute = new BasicAttribute(
            "cn",
            "xsd");

        Attribute mDependenciesAttribute = new BasicAttribute(
            "m-dependencies", "system");

        xsdAttributes.put( xsdAttribute );
        xsdAttributes.put( topAttribute );
        xsdAttributes.put( metaSchemaAttribute );
        xsdAttributes.put( mDependenciesAttribute );

        return directoryContext.createSubcontext(
            XSD_CONTEXT_RDN, xsdAttributes );
    }


    public DirContext createSyntaxContext() throws NamingException
    {
        Attribute syntaxesAttribute = new BasicAttribute(
            "ou", "syntaxes");

        Attribute organizationUnitAttribute = new BasicAttribute(
            "objectClass", "organizationalUnit");

        Attribute topAttribute = new BasicAttribute(
            "objectClass",
            "top");

        Attribute metaSchemaAttribute = new BasicAttribute(
            "objectClass",
            "metaSchema");

        Attributes syntaxAttributes = new BasicAttributes();
        syntaxAttributes.put( syntaxesAttribute );
        syntaxAttributes.put( topAttribute );
        syntaxAttributes.put( metaSchemaAttribute );
        syntaxAttributes.put( organizationUnitAttribute);

        return ( DirContext ) xsdContext.createSubcontext( XSD_SYNTAX_RDN, syntaxAttributes
);
    }

    public void testCreateSyntaxSchemaEntry() throws NamingException
    {
        Attribute objectClassAttribute = new BasicAttribute(
            "objectClass",
            "top" );

        objectClassAttribute.add( "metaTop" );
        objectClassAttribute.add( "metaSyntax" );

        Attribute oidAttribute = new BasicAttribute(
            "m-oid",
            OID);

        Attribute descriptionAttribute = new BasicAttribute(
            "m-description",
            "xsd:String");

        Attributes attributes = new BasicAttributes();

        attributes.put( objectClassAttribute );
        attributes.put( oidAttribute );
        attributes.put( descriptionAttribute );

        syntaxContext.createSubcontext( xsdSyntaxStringRDN, attributes );
        syntaxContext.lookup(xsdSyntaxStringRDN);
//      syntaxContext.lookup("monkeywrench");
    }
} 


Source code now attached thanks to Ole.

> Test hangs on non-existant schema entry lookup
> ----------------------------------------------
>
>                 Key: DIRSERVER-935
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-935
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: ldap
>    Affects Versions: 1.5.1
>            Reporter: Ole Ersoy
>            Priority: Minor
>             Fix For: pre-2.0
>
>         Attachments: CreateSyntaxEntrySelfContainedTest.java
>
>
> Hey Guys,
> I do a lookup like this inside a test:
>         syntaxContext.lookup(xsdSyntaxStringRDN);
> //      syntaxContext.lookup("monkeywrench");
> If I leave the monkeywrench lookup commented
> out, the test runs fine repeatedly.
> If I comment in the monkeywrench the
> test just hangs.  I was expecting
> a NamingException.
> I pasted a self contained test for this
> below.
> Cheers,
> - Ole

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message