You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Ole Ersoy (JIRA)" <ji...@apache.org> on 2007/05/17 19:09:16 UTC

[jira] Updated: (DIRSERVER-935) Test hangs on non-existant schema entry lookup

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

Ole Ersoy updated DIRSERVER-935:
--------------------------------

    Attachment: CreateSyntaxEntrySelfContainedTest.java

> 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
> 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");
>     }
> } 

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