Emmanuel,

Good news.

I coded a self contained test and ran it.  It passes.  I'm pasting below.

I'll try running the other test now too, and see if I still
get the exception from that one.  I'll go ahead an close this
until I see whether there is anything else fishy going on.

Cheers,
- Ole

Test:
====================================================

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

SNIP

Reply via email to