You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/12/06 09:39:27 UTC

svn commit: r601657 [2/6] - in /directory/apacheds/branches/bigbang: core-integ/src/main/java/org/apache/directory/server/core/integ/ core-integ/src/test/java/org/apache/directory/server/core/jndi/ core-integ/src/test/java/org/apache/directory/server/c...

Added: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java?rev=601657&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java (added)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java Thu Dec  6 00:39:23 2007
@@ -0,0 +1,595 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema;
+
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.SetupMode;
+import org.apache.directory.server.core.integ.annotations.Mode;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
+import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
+import org.apache.directory.server.schema.registries.NormalizerRegistry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Comparator;
+
+
+/**
+ * A test case which tests the addition of various schema elements
+ * to the ldap server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+@RunWith ( CiRunner.class )
+@Mode ( SetupMode.PRISTINE )
+public class MetaNormalizerHandlerIT
+{
+    private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.100000";
+    private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.1.100001";
+
+
+    public static DirectoryService service;
+
+
+    /**
+     * Gets relative DN to ou=schema.
+     *
+     * @param schemaName the name of the schema
+     * @return  the name of the container with normalizer entries in it
+     * @throws NamingException on error
+     */
+    private LdapDN getNormalizerContainer( String schemaName ) throws NamingException
+    {
+        return new LdapDN( "ou=normalizers,cn=" + schemaName );
+    }
+    
+
+    private static NormalizerRegistry getNormalizerRegistry()
+    {
+        return service.getRegistries().getNormalizerRegistry();
+    }
+
+
+    private static MatchingRuleRegistry getMatchingRuleRegistry()
+    {
+        return service.getRegistries().getMatchingRuleRegistry();
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+
+
+    @Test
+    public void testAddNormalizer() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_NORMALIZER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, NoOpNormalizer.class.getName() );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( getNormalizerRegistry().hasNormalizer( OID ) );
+        assertEquals( getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
+        Class clazz = getNormalizerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, NoOpNormalizer.class );
+    }
+    
+    
+    @Test
+    public void testAddNormalizerWithByteCode() throws Exception
+    {
+        InputStream in = getClass().getResourceAsStream( "DummyNormalizer.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        while ( in.available() > 0 )
+        {
+            out.write( in.read() );
+        }
+        
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_NORMALIZER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, "DummyNormalizer" );
+        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( getNormalizerRegistry().hasNormalizer( OID ) );
+        assertEquals( getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
+        Class clazz = getNormalizerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz.getName(), "DummyNormalizer" );
+    }
+    
+    
+    @Test
+    public void testDeleteNormalizer() throws NamingException
+    {
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddNormalizer();
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "normalizer should be removed from the registry after being deleted", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            getNormalizerRegistry().lookup( OID );
+            fail( "normalizer lookup should fail after deleting the normalizer" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+
+    @Test
+    public void testRenameNormalizer() throws NamingException
+    {
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddNormalizer();
+        
+        LdapDN newdn = getNormalizerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old normalizer OID should be removed from the registry after being renamed", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            getNormalizerRegistry().lookup( OID );
+            fail( "normalizer lookup should fail after deleting the normalizer" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertTrue( getNormalizerRegistry().hasNormalizer( NEW_OID ) );
+        Class clazz = getNormalizerRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, NoOpNormalizer.class );
+    }
+
+
+    @Test
+    public void testMoveNormalizer() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getNormalizerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertTrue( "normalizer OID should still be present", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        
+        assertEquals( "normalizer schema should be set to apache not apachemeta", 
+            getNormalizerRegistry().getSchemaName( OID ), "apache" );
+
+        Class clazz = getNormalizerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, NoOpNormalizer.class );
+    }
+
+
+    @Test
+    public void testMoveNormalizerAndChangeRdn() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getNormalizerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old normalizer OID should NOT be present", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        
+        assertTrue( "new normalizer OID should be present", 
+            getNormalizerRegistry().hasNormalizer( NEW_OID ) );
+        
+        assertEquals( "normalizer with new oid should have schema set to apache NOT apachemeta", 
+            getNormalizerRegistry().getSchemaName( NEW_OID ), "apache" );
+
+        Class clazz = getNormalizerRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, NoOpNormalizer.class );
+    }
+
+    
+    @Test
+    public void testModifyNormalizerWithModificationItems() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( MetaSchemaConstants.M_FQCN_AT, DeepTrimNormalizer.class.getName() );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        getSchemaContext( service ).modifyAttributes( dn, mods );
+
+        assertTrue( "normalizer OID should still be present", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        
+        assertEquals( "normalizer schema should be set to apachemeta", 
+            getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
+
+        Class clazz = getNormalizerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, DeepTrimNormalizer.class );
+    }
+
+    
+    @Test
+    public void testModifyNormalizerWithAttributes() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        Attributes mods = new AttributesImpl();
+        mods.put( MetaSchemaConstants.M_FQCN_AT, DeepTrimNormalizer.class.getName() );
+        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+
+        assertTrue( "normalizer OID should still be present", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        
+        assertEquals( "normalizer schema should be set to apachemeta", 
+            getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
+
+        Class clazz = getNormalizerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, DeepTrimNormalizer.class );
+    }
+    
+
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // ----------------------------------------------------------------------
+
+    
+    @Test
+    public void testDeleteNormalizerWhenInUse() throws NamingException
+    {
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddNormalizer();
+        getMatchingRuleRegistry().register( new DummyMR() );
+        
+        try
+        {
+            getSchemaContext( service ).destroySubcontext( dn );
+            fail( "should not be able to delete a normalizer in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "normalizer should still be in the registry after delete failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        getMatchingRuleRegistry().unregister( OID );
+    }
+    
+    
+    @Test
+    public void testMoveNormalizerWhenInUse() throws NamingException
+    {
+        testAddNormalizer();
+        getMatchingRuleRegistry().register( new DummyMR() );
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getNormalizerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a normalizer in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "normalizer should still be in the registry after move failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        getMatchingRuleRegistry().unregister( OID );
+    }
+
+
+    @Test
+    public void testMoveNormalizerAndChangeRdnWhenInUse() throws NamingException
+    {
+        testAddNormalizer();
+        getMatchingRuleRegistry().register( new DummyMR() );
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getNormalizerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a normalizer in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "normalizer should still be in the registry after move failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        getMatchingRuleRegistry().unregister( OID );
+    }
+
+    
+    @Test
+    public void testRenameNormalizerWhenInUse() throws NamingException
+    {
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddNormalizer();
+        getMatchingRuleRegistry().register( new DummyMR() );
+        
+        LdapDN newdn = getNormalizerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to rename a normalizer in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "normalizer should still be in the registry after rename failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        getMatchingRuleRegistry().unregister( OID );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Let's try some freaky stuff
+    // ----------------------------------------------------------------------
+
+
+    @Test
+    public void testMoveNormalizerToTop() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN top = new LdapDN();
+        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, top );
+            fail( "should not be able to move a normalizer up to ou=schema" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "normalizer should still be in the registry after move failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+    }
+
+
+    @Test
+    public void testMoveNormalizerToComparatorContainer() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a normalizer into comparators container" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "normalizer should still be in the registry after move failure", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+    }
+    
+    
+    @Test
+    public void testAddNormalizerToDisabledSchema() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_NORMALIZER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, NoOpNormalizer.class.getName() );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test normalizer" );
+        
+        // nis is by default inactive
+        LdapDN dn = getNormalizerContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new normalizer to disabled schema should not register it into the registries", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+    }
+
+
+    @Test
+    public void testMoveNormalizerToDisabledSchema() throws NamingException
+    {
+        testAddNormalizer();
+        
+        LdapDN dn = getNormalizerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        // nis is inactive by default
+        LdapDN newdn = getNormalizerContainer( "nis" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "normalizer OID should no longer be present", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+    }
+
+
+    @Test
+    public void testMoveNormalizerToEnabledSchema() throws NamingException
+    {
+        testAddNormalizerToDisabledSchema();
+        
+        // nis is inactive by default
+        LdapDN dn = getNormalizerContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        assertFalse( "normalizer OID should NOT be present when added to disabled nis schema", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+
+        LdapDN newdn = getNormalizerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertTrue( "normalizer OID should be present when moved to enabled schema", 
+            getNormalizerRegistry().hasNormalizer( OID ) );
+        
+        assertEquals( "normalizer should be in apachemeta schema after move", 
+            getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+
+
+    class DummyMR implements MatchingRule
+    {
+        private static final long serialVersionUID = 1L;
+
+        public Comparator getComparator() throws NamingException
+        {
+            return null;
+        }
+
+        public Normalizer getNormalizer() throws NamingException
+        {
+            return null;
+        }
+
+        public Syntax getSyntax() throws NamingException
+        {
+            return null;
+        }
+
+        public String getDescription()
+        {
+            return null;
+        }
+
+        public String getName()
+        {
+            return "dummy";
+        }
+
+        public String[] getNames()
+        {
+            return new String[] { "dummy" };
+        }
+
+        public String getOid()
+        {
+            return OID;
+        }
+
+        public boolean isObsolete()
+        {
+            return false;
+        }
+
+        public String getSchema()
+        {
+            return null;
+        }
+
+        public void setSchema( String schemaName )
+        {
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java?rev=601657&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (added)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java Thu Dec  6 00:39:23 2007
@@ -0,0 +1,535 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema;
+
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.SetupMode;
+import org.apache.directory.server.core.integ.annotations.Mode;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
+import org.apache.directory.server.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.junit.runner.RunWith;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+
+
+/**
+ * A test case which tests the addition of various schema elements
+ * to the ldap server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+@RunWith ( CiRunner.class )
+@Mode ( SetupMode.PRISTINE )
+public class MetaObjectClassHandlerIT
+{
+    private static final String NAME = "testObjectClass";
+    private static final String NEW_NAME = "alternateName";
+    private static final String DEPENDEE_NAME = "dependeeName";
+
+    private static final String DESCRIPTION0 = "A test objectClass";
+    private static final String DESCRIPTION1 = "An alternate description";
+    
+    private static final String OID = "1.3.6.1.4.1.18060.0.4.0.3.100000";
+    private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.3.100001";
+    private static final String DEPENDEE_OID = "1.3.6.1.4.1.18060.0.4.0.3.100002";
+
+
+    public static DirectoryService service;
+
+    
+    /**
+     * Gets relative DN to ou=schema.
+     *
+     * @param schemaName the name of the schema
+     * @return the dn of the container which contains objectClasses
+     * @throws NamingException on error
+     */
+    private LdapDN getObjectClassContainer( String schemaName ) throws NamingException
+    {
+        return new LdapDN( "ou=objectClasses,cn=" + schemaName );
+    }
+
+
+    private static ObjectClassRegistry getObjectClassRegistry()
+    {
+        return service.getRegistries().getObjectClassRegistry();
+    }
+
+    
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+
+
+    @Test
+    public void testAddObjectClass() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_NAME_AT, NAME);
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        attrs.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, "AUXILIARY" );
+        attrs.put( MetaSchemaConstants.M_MUST_AT, "cn" );
+        attrs.put( MetaSchemaConstants.M_MAY_AT, "ou" );
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( getObjectClassRegistry().hasObjectClass( OID ) );
+        assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+    
+    
+    @Test
+    public void testDeleteAttributeType() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        assertFalse( "objectClass should be removed from the registry after being deleted", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            getObjectClassRegistry().lookup( OID );
+            fail( "objectClass lookup should fail after deleting it" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+
+    @Test
+    public void testRenameAttributeType() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        
+        LdapDN newdn = getObjectClassContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old objectClass OID should be removed from the registry after being renamed", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            getObjectClassRegistry().lookup( OID );
+            fail( "objectClass lookup should fail after renaming the objectClass" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertTrue( getObjectClassRegistry().hasObjectClass( NEW_OID ) );
+    }
+
+
+    @Test
+    public void testMoveAttributeType() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertTrue( "objectClass OID should still be present", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apache not apachemeta", 
+            getObjectClassRegistry().getSchemaName( OID ), "apache" );
+    }
+
+
+    @Test
+    public void testMoveObjectClassAndChangeRdn() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old objectClass OID should NOT be present", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertTrue( "new objectClass OID should be present", 
+            getObjectClassRegistry().hasObjectClass( NEW_OID ) );
+        
+        assertEquals( "objectClass with new oid should have schema set to apache NOT apachemeta", 
+            getObjectClassRegistry().getSchemaName( NEW_OID ), "apache" );
+    }
+
+    
+    @Test
+    public void testModifyAttributeTypeWithModificationItems() throws NamingException
+    {
+        testAddObjectClass();
+        
+        ObjectClass oc = getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION0 );
+        assertEquals( oc.getName(), NAME );
+
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        ModificationItemImpl[] mods = new ModificationItemImpl[2];
+        Attribute attr = new AttributeImpl( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        attr = new AttributeImpl( MetaSchemaConstants.M_NAME_AT, NEW_NAME );
+        mods[1] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        getSchemaContext( service ).modifyAttributes( dn, mods );
+
+        assertTrue( "objectClass OID should still be present", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apachemeta", 
+            getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+        
+        oc = getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION1 );
+        assertEquals( oc.getName(), NEW_NAME );
+    }
+
+    
+    @Test
+    public void testModifyAttributeTypeWithAttributes() throws NamingException
+    {
+        testAddObjectClass();
+        
+        ObjectClass oc = getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION0 );
+        assertEquals( oc.getName(), NAME );
+
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        Attributes mods = new AttributesImpl();
+        mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        mods.put( MetaSchemaConstants.M_NAME_AT, NEW_NAME );
+        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+
+        assertTrue( "objectClass OID should still be present", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apachemeta", 
+            getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+
+        oc = getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION1 );
+        assertEquals( oc.getName(), NEW_NAME );
+    }
+    
+
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a OC exists and uses the OC as sup
+    // ----------------------------------------------------------------------
+
+    
+    private void addDependeeObjectClass() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_OID_AT, DEPENDEE_OID );
+        attrs.put( MetaSchemaConstants.M_NAME_AT, DEPENDEE_NAME );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        attrs.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, "AUXILIARY" );
+        attrs.put( MetaSchemaConstants.M_MUST_AT, "cn" );
+        attrs.put( MetaSchemaConstants.M_MAY_AT, "ou" );
+        attrs.put( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT, OID );
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + DEPENDEE_OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( getObjectClassRegistry().hasObjectClass( DEPENDEE_OID ) );
+        assertEquals( getObjectClassRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
+    }
+
+    
+    @Test
+    public void testDeleteObjectClassWhenInUse() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        addDependeeObjectClass();
+        
+        try
+        {
+            getSchemaContext( service ).destroySubcontext( dn );
+            fail( "should not be able to delete a objectClass in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "objectClass should still be in the registry after delete failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+    
+    
+    @Test
+    public void testMoveObjectClassWhenInUse() throws NamingException
+    {
+        testAddObjectClass();
+        addDependeeObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a objectClass in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "objectClass should still be in the registry after move failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    @Test
+    public void testMoveObjectClassAndChangeRdnWhenInUse() throws NamingException
+    {
+        testAddObjectClass();
+        addDependeeObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move an objectClass in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "ObjectClass should still be in the registry after move failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+    
+    @Test
+    public void testRenameObjectClassWhenInUse() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        addDependeeObjectClass();
+        
+        LdapDN newdn = getObjectClassContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to rename an objectClass in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "objectClass should still be in the registry after rename failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Let's try some freaky stuff
+    // ----------------------------------------------------------------------
+
+
+    @Test
+    public void testMoveObjectClassToTop() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN top = new LdapDN();
+        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, top );
+            fail( "should not be able to move a objectClass up to ou=schema" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "objectClass should still be in the registry after move failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    @Test
+    public void testMoveObjectClassToComparatorContainer() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a objectClass into comparators container" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "objectClass should still be in the registry after move failure", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+    
+    
+    @Test
+    public void testAddObjectClassToDisabledSchema() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_NAME_AT, NAME);
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        attrs.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, "AUXILIARY" );
+        attrs.put( MetaSchemaConstants.M_MUST_AT, "cn" );
+        attrs.put( MetaSchemaConstants.M_MAY_AT, "ou" );
+        
+        LdapDN dn = getObjectClassContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new objectClass to disabled schema should not register it into the registries", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    @Test
+    public void testMoveObjectClassToDisabledSchema() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        // nis is inactive by default
+        LdapDN newdn = getObjectClassContainer( "nis" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "objectClass OID should no longer be present", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    @Test
+    public void testMoveObjectClassToEnabledSchema() throws NamingException
+    {
+        testAddObjectClassToDisabledSchema();
+        
+        // nis is inactive by default
+        LdapDN dn = getObjectClassContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        assertFalse( "objectClass OID should NOT be present when added to disabled nis schema", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+
+        LdapDN newdn = getObjectClassContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertTrue( "objectClass OID should be present when moved to enabled schema", 
+            getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass should be in apachemeta schema after move", 
+            getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+}

Propchange: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java?rev=601657&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java (added)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java Thu Dec  6 00:39:23 2007
@@ -0,0 +1,683 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema;
+
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.SetupMode;
+import org.apache.directory.server.core.integ.annotations.Mode;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+import java.util.Map;
+
+
+/**
+ * A test case which tests the correct operation of the schema 
+ * entity handler.  
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+@RunWith ( CiRunner.class )
+@Mode ( SetupMode.PRISTINE )
+public class MetaSchemaHandlerIT
+{
+    /** the schema to use for this test: one that is not loaded by default */
+    private static final String TEST_SCHEMA = "nis";
+    /** a test attribute in the test schema: uidNumber in nis schema */
+    private static final String TEST_ATTR_OID = "1.3.6.1.1.1.1.0";
+    /** the name of the dummy schema to test metaSchema adds/deletes with */
+    private static final String DUMMY_SCHEMA = "dummy";
+    
+
+    public static DirectoryService service;
+
+
+    private static AttributeTypeRegistry getAttributeTypeRegistry()
+    {
+        return service.getRegistries().getAttributeTypeRegistry();
+    }
+
+
+    private static Map<String, Schema> getLoadedSchemas()
+    {
+        return service.getRegistries().getLoadedSchemas();
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Schema Add Tests
+    // -----------------------------------------------------------------------
+
+    
+    /**
+     * Tests the addition of a new metaSchema object that is disabled 
+     * on addition and has no dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testAddDisabledSchemaNoDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
+        schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+        
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        assertNotNull( schemaRoot.lookup( "cn=" + DUMMY_SCHEMA ) );
+    }
+    
+    
+    /**
+     * Tests the addition of a new metaSchema object that is disabled 
+     * on addition and has dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testAddDisabledSchemaWithDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
+        dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+        dummySchema.get( MetaSchemaConstants.M_DEPENDENCIES_AT ).add( "core" );
+        schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+        
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        assertNotNull( schemaRoot.lookup( "cn=" + DUMMY_SCHEMA ) );
+    }
+    
+    
+    /**
+     * Tests the rejection of a new metaSchema object that is disabled 
+     * on addition and has missing dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectDisabledSchemaAddWithMissingDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
+        dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, "missing" );
+        dummySchema.get( MetaSchemaConstants.M_DEPENDENCIES_AT ).add( "core" );
+        
+        try
+        {
+            schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+        } 
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+        }
+        
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=" + DUMMY_SCHEMA );
+            fail( "schema should not be added to schema partition" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+    
+    
+    /**
+     * Tests the addition of a new metaSchema object that is enabled 
+     * on addition and has no dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testAddEnabledSchemaNoDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+        
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        assertNotNull( schemaRoot.lookup( "cn=" + DUMMY_SCHEMA ) );
+    }
+    
+    
+    /**
+     * Tests the rejection of a metaSchema object add that is enabled 
+     * on addition yet has disabled dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectEnabledSchemaAddWithDisabledDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+        
+        try
+        {
+            schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+            fail( "should not be able to add enabled schema with deps on disabled schemas" );
+        }
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+        }
+        
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=" + DUMMY_SCHEMA );
+            fail( "schema should not be added to schema partition" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+    
+    // -----------------------------------------------------------------------
+    // Schema Delete Tests
+    // -----------------------------------------------------------------------
+
+    
+    /**
+     * Makes sure we can delete schemas that have no dependents.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testDeleteSchemaNoDependents() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        // add the dummy schema enabled 
+        testAddEnabledSchemaNoDeps();
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        
+        // delete it now
+        schemaRoot.destroySubcontext( "cn=" + DUMMY_SCHEMA );
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+    }
+    
+    
+    /**
+     * Makes sure we can NOT delete schemas that have dependents.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectSchemaDeleteWithDependents() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        // add the dummy schema enabled
+        testAddEnabledSchemaNoDeps();
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        
+        // make the nis schema depend on the dummy schema
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        mods[0] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
+                new AttributeImpl( MetaSchemaConstants.M_DEPENDENCIES_AT, DUMMY_SCHEMA ) );
+        schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+        
+        // attempt to delete it now & it should fail
+        try
+        {
+            schemaRoot.destroySubcontext( "cn=" + DUMMY_SCHEMA );
+            fail( "should not be able to delete a schema with dependents" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+        }
+
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+    }
+    
+    
+    /**
+     * Tests the rejection of a new metaSchema object that is enabled 
+     * on addition and missing dependencies.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectEnabledSchemaAddWithMisingDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, "missing" );
+        
+        try
+        {
+            schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+            fail( "should not be able to add enabled schema with deps on missing schemas" );
+        }
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+        }
+        
+        assertNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=" + DUMMY_SCHEMA );
+            fail( "schema should not be added to schema partition" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+    
+    // -----------------------------------------------------------------------
+    // Enable/Disable Schema Tests
+    // -----------------------------------------------------------------------
+
+    
+    private void enableSchema( String schemaName ) throws NamingException
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        // now enable the test schema
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-disabled", "FALSE" );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        schemaRoot.modifyAttributes( "cn=" + schemaName, mods );
+    }
+    
+    
+    private void disableSchema( String schemaName ) throws NamingException
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        // now enable the test schema
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-disabled", "TRUE" );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        schemaRoot.modifyAttributes( "cn=" + schemaName, mods );
+    }
+    
+    
+    /**
+     * Checks to make sure updates enabling a metaSchema object in
+     * the schema partition triggers the loading of that schema into
+     * the global registries.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testEnableSchema() throws Exception
+    {
+        AttributeTypeRegistry atr = getAttributeTypeRegistry();
+        
+        // check that the nis schema is not loaded
+        assertNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        
+        // double check and make sure an attribute from that schema is 
+        // not in the AttributeTypeRegistry
+        assertFalse( atr.hasAttributeType( TEST_ATTR_OID ) );
+        
+        // now enable the test schema
+        enableSchema( "nis" );
+        
+        // now test that the schema is loaded 
+        assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        
+        // double check and make sure the test attribute from the 
+        // test schema is now loaded and present within the attr registry
+        assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
+    }
+
+
+    /**
+     * Checks to make sure an attempt to disable a metaSchema fails if 
+     * that schema has dependents which are enabled.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testDisableSchema() throws Exception
+    {
+        // let's enable the test schema
+        testEnableSchema();
+        
+        AttributeTypeRegistry atr = getAttributeTypeRegistry();
+        
+        // check that the nis schema is loaded
+        assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        
+        // double check and make sure an attribute from that schema is 
+        // in the AttributeTypeRegistry
+        assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
+        
+        // now disable the test schema 
+        disableSchema( "samba" );
+        disableSchema( "nis" );
+        
+        // now test that the schema is NOT loaded 
+        assertNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        
+        // double check and make sure the test attribute from the test  
+        // schema is now NOT loaded and present within the attr registry
+        assertFalse( atr.hasAttributeType( TEST_ATTR_OID ) );
+    }
+
+    
+    /**
+     * Checks to make sure updates disabling a metaSchema object in
+     * the schema partition triggers the unloading of that schema from
+     * the global registries.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testDisableSchemaWithEnabledDependents() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        // let's enable the test schema and add the dummy schema
+        // as enabled by default and dependends on the test schema
+        
+//      // enables the test schema and samba
+        testEnableSchema(); 
+        
+        // adds enabled dummy schema that depends on the test schema  
+        Attributes dummySchema = new AttributesImpl( "objectClass", "top" );
+        dummySchema.get( "objectClass" ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        dummySchema.put( "cn", DUMMY_SCHEMA );
+        dummySchema.put( MetaSchemaConstants.M_DEPENDENCIES_AT, TEST_SCHEMA );
+        schemaRoot.createSubcontext( "cn=" + DUMMY_SCHEMA, dummySchema );
+        
+        // check that the nis schema is loaded and the dummy schema is loaded
+        assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        
+        AttributeTypeRegistry atr = getAttributeTypeRegistry();
+        
+        // double check and make sure an attribute from that schema is 
+        // in the AttributeTypeRegistry
+        assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
+        
+        // now try to disable the test schema which should fail 
+        // since it's dependent, the dummy schema, is enabled
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-disabled", "TRUE" );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        
+        try
+        {
+            schemaRoot.modifyAttributes( "cn=nis", mods );
+            fail( "attempt to disable schema with enabled dependents should fail" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertTrue( e.getResultCode().equals( ResultCodeEnum.UNWILLING_TO_PERFORM ) );
+        }
+        
+        // now test that both schema are still loaded 
+        assertNotNull( getLoadedSchemas().get( TEST_SCHEMA ) );
+        assertNotNull( getLoadedSchemas().get( DUMMY_SCHEMA ) );
+        
+        // double check and make sure the test attribute from the test  
+        // schema is still loaded and present within the attr registry
+        assertTrue( atr.hasAttributeType( TEST_ATTR_OID ) );
+    }
+    
+    
+    // -----------------------------------------------------------------------
+    // Schema Rename Tests
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Makes sure we can change the name of a schema with entities in it.
+     * Will use the samba schema which comes out of the box and nothing 
+     * depends on.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testSchemaRenameDisabledSchema() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        schemaRoot.rename( "cn=samba", "cn=foo" );
+        assertNotNull( schemaRoot.lookup( "cn=foo" ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=samba" );
+            fail( "the samba schema should not be present after a rename to foo" );
+        }
+        catch( LdapNameNotFoundException e )
+        {
+        }
+    }
+
+
+    /**
+     * Makes sure we can NOT change the name of a schema that has dependents.
+     * Will use the nis schema which comes out of the box and has samba as
+     * it's dependent.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectSchemaRenameWithDeps() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        try
+        {
+            schemaRoot.rename( "cn=nis", "cn=foo" );
+            fail( "should not be able to rename nis which has samba as it's dependent" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+        
+        assertNotNull( schemaRoot.lookup( "cn=nis" ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=foo" );
+            fail( "the foo schema should not be present after rejecting the rename" );
+        }
+        catch( LdapNameNotFoundException e )
+        {
+        }
+    }
+
+
+    /**
+     * Makes sure we can change the name of a schema with entities in it.
+     * Will use the samba schema which comes out of the box and nothing 
+     * depends on.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testSchemaRenameEnabledSchema() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        enableSchema( "samba" );
+        assertTrue( getAttributeTypeRegistry().hasAttributeType( "sambaNTPassword" ) );
+        assertEquals( "samba", getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
+        
+        schemaRoot.rename( "cn=samba", "cn=foo" );
+        assertNotNull( schemaRoot.lookup( "cn=foo" ) );
+        assertTrue( getAttributeTypeRegistry().hasAttributeType( "sambaNTPassword" ) );
+        assertEquals( "foo", getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
+
+        //noinspection EmptyCatchBlock
+        try
+        {
+            schemaRoot.lookup( "cn=samba" );
+            fail( "the samba schema should not be present after a rename to foo" );
+        }
+        catch( LdapNameNotFoundException e )
+        {
+        }
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Dependency Modify Tests
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Checks to make sure the addition of an undefined schema to the dependencies 
+     * of an existing schema fail with an UNWILLING_TO_PERFORM result code.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectAddBogusDependency() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-dependencies", "bogus" );
+        mods[0] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE, attr );
+        
+        try
+        {
+            schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+            fail( "Should not be able to add bogus dependency to schema" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+    }
+
+
+    /**
+     * Checks to make sure the addition of an defined yet disabled schema to the 
+     * dependencies of an existing enabled schema fails with an UNWILLING_TO_PERFORM 
+     * result code.  You must enable the dependency to add it or disable the schema 
+     * depending on it to add it.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testRejectAddOfDisabledDependencyToEnabledSchema() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        enableSchema( TEST_SCHEMA );
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-dependencies", "mozilla" );
+        mods[0] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE, attr );
+        
+        try
+        {
+            schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+            fail( "Should not be able to add disabled dependency to schema" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+    }
+
+
+    /**
+     * Checks to make sure the addition of an defined yet disabled schema to the 
+     * dependencies of an existing disabled schema succeeds. 
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testAddOfDisabledDependencyToDisabledSchema() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-dependencies", "mozilla" );
+        mods[0] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE, attr );
+        schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+        Attributes attrs = schemaRoot.getAttributes( "cn=" + TEST_SCHEMA );
+        Attribute dependencies = attrs.get( "m-dependencies" );
+        assertTrue( dependencies.contains( "mozilla" ) );
+    }
+
+
+    /**
+     * Checks to make sure the addition of an defined yet enabled schema to the 
+     * dependencies of an existing disabled schema succeeds.
+     *
+     * @throws Exception on error
+     */
+    @Test
+    public void testAddOfEnabledDependencyToDisabledSchema() throws Exception
+    {
+        LdapContext schemaRoot = getSchemaContext( service );
+        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        Attribute attr = new AttributeImpl( "m-dependencies", "java" );
+        mods[0] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE, attr );
+        schemaRoot.modifyAttributes( "cn=" + TEST_SCHEMA, mods );
+        Attributes attrs = schemaRoot.getAttributes( "cn=" + TEST_SCHEMA );
+        Attribute dependencies = attrs.get( "m-dependencies" );
+        assertTrue( dependencies.contains( "java" ) );
+    }
+}

Propchange: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
------------------------------------------------------------------------------
    svn:eol-style = native