directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896599 [8/30] - in /directory/apacheds/trunk: ./ avl-partition/ avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/ avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/or...
Date Wed, 06 Jan 2010 18:27:19 GMT
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java Wed Jan  6 18:26:43 2010
@@ -20,24 +20,13 @@
 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 static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-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.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.AttributeType;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -47,6 +36,18 @@
 import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.integ.FrameworkRunner;
+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.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 
 /**
  * A test case which tests the addition of various schema elements
@@ -55,8 +56,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-@RunWith ( CiRunner.class )
-public class MetaAttributeTypeHandlerIT
+@RunWith ( FrameworkRunner.class )
+public class MetaAttributeTypeHandlerIT extends AbstractMetaSchemaObjectHandler
 {
     private static final String DESCRIPTION0 = "A test attributeType";
     private static final String DESCRIPTION1 = "An alternate description";
@@ -65,361 +66,381 @@
     private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.2.100001";
     private static final String DEPENDEE_OID = "1.3.6.1.4.1.18060.0.4.0.2.100002";
 
-
-    public static DirectoryService service;
-
-    
-    /**
-     * Gets relative DN to ou=schema.
-     *
-     * @param schemaName the name of the schema
-     * @return the dn of the a schema's attributeType entity container
-     * @throws Exception on failure
-     */
-    private LdapDN getAttributeTypeContainer( String schemaName ) throws Exception
-    {
-        return new LdapDN( "ou=attributeTypes,cn=" + schemaName );
-    }
-
-
-    private static AttributeTypeRegistry getAttributeTypeRegistry()
-    {
-        return service.getRegistries().getAttributeTypeRegistry();
-    }
-    
-    
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
-
-    
+    // Test Add operation
+    // ----------------------------------------------------------------------
     @Test
-    public void testAddAttributeType() throws Exception
+    public void testAddAttributeTypeToEnabledSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        attrs.put( MetaSchemaConstants.M_EQUALITY_AT, "caseIgnoreMatch" );
-        attrs.put( MetaSchemaConstants.M_SINGLE_VALUE_AT, "FALSE" );
-        attrs.put( MetaSchemaConstants.M_USAGE_AT, "directoryOperation" );
-        
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaAttributeType",
+            "m-oid:" + OID,
+            "m-syntax:" + SchemaConstants.INTEGER_SYNTAX,
+            "m-description:" + DESCRIPTION0,
+            "m-equality: caseIgnoreMatch",
+            "m-singleValue: FALSE",
+            "m-usage: directoryOperation" );
+        
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+        
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+
+        // Addition
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
-        assertTrue( service.getRegistries().getAttributeTypeRegistry().hasAttributeType( OID ) );
-        assertEquals( getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+        // Post-checks
+        assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        assertEquals( service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
     @Test
-    public void testDeleteAttributeType() throws Exception
+    public void testAddAttributeTypeToUnLoadedSchema() throws Exception
     {
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddAttributeType();
-        
-        getSchemaContext( service ).destroySubcontext( dn );
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaAttributeType",
+            "m-oid:" + OID,
+            "m-syntax:" + SchemaConstants.INTEGER_SYNTAX,
+            "m-description:" + DESCRIPTION0,
+            "m-equality: caseIgnoreMatch",
+            "m-singleValue: FALSE",
+            "m-usage: directoryOperation" );
 
-        assertFalse( "attributeType should be removed from the registry after being deleted", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        LdapDN dn = getAttributeTypeContainer( "notloaded" );
+        dn.add( "m-oid=" + OID );
         
         try
         {
-            getAttributeTypeRegistry().lookup( OID );
-            fail( "attributeType lookup should fail after deleting it" );
+            getSchemaContext( service ).createSubcontext( dn, attrs );
+            fail( "Should not be there" );
         }
-        catch( NamingException e )
+        catch( NameNotFoundException nnfe )
         {
+            // Expected result.
         }
+        
+        assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        
+        // The added entry must not be present on disk
+        assertFalse( isOnDisk( dn ) );
     }
+    
+    
+    @Test
+    public void testAddAttributeTypeToDisabledSchema() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaAttributeType",
+            "m-oid:" + OID,
+            "m-syntax:" + SchemaConstants.INTEGER_SYNTAX,
+            "m-description:" + DESCRIPTION0,
+            "m-equality: caseIgnoreMatch",
+            "m-singleValue: FALSE",
+            "m-usage: directoryOperation" );
 
+        LdapDN dn = getAttributeTypeContainer( "nis" );
+        dn.add( "m-oid=" + OID );
+        
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        
+        // The GlobalOidRegistries must not contain the AT
+        assertFalse( service.getSchemaManager().getGlobalOidRegistry().contains( OID ) );
+        
+        // The added entry must be present on disk
+        assertTrue( isOnDisk( dn ) );
+    }
 
+    
+    // ----------------------------------------------------------------------
+    // Test Delete operation
+    // ----------------------------------------------------------------------
     @Test
-    public void testRenameAttributeType() throws Exception
+    public void testDeleteAttributeTypeFromEnabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( service );
+        testAddAttributeTypeToEnabledSchema();
+
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddAttributeType();
-        
-        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
-        schemaRoot.rename( dn, newdn );
+        dn.add( "m-oid=" + OID );
 
-        assertFalse( "old attributeType OID should be removed from the registry after being renamed", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        // Check in Registries
+        assertTrue( "attributeType should be removed from the registry after being deleted", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+
+        // Check on disk that the added SchemaObject exist
+        assertTrue( isOnDisk( dn ) );
         
-        try
-        {
-            getAttributeTypeRegistry().lookup( OID );
-            fail( "attributeType lookup should fail after renaming the attributeType" );
-        }
-        catch( NamingException e )
-        {
-        }
+        getSchemaContext( service ).destroySubcontext( dn );
 
-        assertTrue( getAttributeTypeRegistry().hasAttributeType( NEW_OID ) );
+        // Check in Registries
+        assertFalse( "attributeType should be removed from the registry after being deleted", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        
+        // Check on disk that the deleted SchemaObject does not exist anymore
+        assertFalse( isOnDisk( dn ) );
     }
-
-
+    
+    
+    /**
+     * Try to delete an AT from a disabled schema. The AT is first
+     * added, then deleted. The AT should be present on disk but not
+     * in the registries before the deletion, and removed from disk
+     * after the deletion.
+     */
     @Test
-    public void testMoveAttributeType() throws Exception
+    public void testDeleteAttributeTypeFromDisabledSchema() throws Exception
     {
-        testAddAttributeType();
-        
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddAttributeTypeToDisabledSchema();
 
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        LdapDN dn = getAttributeTypeContainer( "nis" );
+        dn.add( "m-oid=" + OID );
+
+        // Check in Registries
+        assertFalse( "attributeType should be removed from the registry after being deleted", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+
+        // Check on disk that the added SchemaObject exists
+        assertTrue( isOnDisk( dn ) );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        // Remove the AT
+        getSchemaContext( service ).destroySubcontext( dn );
 
-        assertTrue( "attributeType OID should still be present",
-                getAttributeTypeRegistry().hasAttributeType( OID ) );
+        // Check in Registries
+        assertFalse( "attributeType should be removed from the registry after being deleted", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        assertFalse( service.getSchemaManager().getGlobalOidRegistry().contains( OID ) );
         
-        assertEquals( "attributeType schema should be set to apache not apachemeta", 
-            getAttributeTypeRegistry().getSchemaName( OID ), "apache" );
+        // Check on disk that the deleted SchemaObject does not exist anymore
+        assertFalse( isOnDisk( dn ) );
     }
 
-
+    
     @Test
-    public void testMoveAttributeTypeAndChangeRdn() throws Exception
+    public void testDeleteAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
-        
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddAttributeTypeToEnabledSchema();
 
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+        addDependeeAttributeType();
         
-        getSchemaContext( service ).rename( dn, newdn );
+        try
+        {
+            getSchemaContext( service ).destroySubcontext( dn );
+            fail( "should not be able to delete a attributeType in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
 
-        assertFalse( "old attributeType OID should NOT be present", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
-        
-        assertTrue( "new attributeType OID should be present", 
-            getAttributeTypeRegistry().hasAttributeType( NEW_OID ) );
-        
-        assertEquals( "attributeType with new oid should have schema set to apache NOT apachemeta", 
-            getAttributeTypeRegistry().getSchemaName( NEW_OID ), "apache" );
+        assertTrue( "attributeType should still be in the registry after delete failure", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
-
     
+    
+    // ----------------------------------------------------------------------
+    // Test Modify operation
+    // ----------------------------------------------------------------------
     @Test
+    @Ignore
     public void testModifyAttributeTypeWithModificationItems() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
-        AttributeType at = getAttributeTypeRegistry().lookup( OID );
+        AttributeType at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
         assertEquals( at.getDescription(), DESCRIPTION0 );
         assertEquals( at.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
 
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
         
         ModificationItem[] mods = new ModificationItem[2];
-        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        attr = new BasicAttribute( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
         assertTrue( "attributeType OID should still be present", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
         
         assertEquals( "attributeType schema should be set to apachemeta", 
-            getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
         
-        at = getAttributeTypeRegistry().lookup( OID );
+        at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
         assertEquals( at.getDescription(), DESCRIPTION1 );
         assertEquals( at.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
     }
 
     
     @Test
+    @Ignore
     public void testModifyAttributeTypeWithAttributes() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
-        AttributeType at = getAttributeTypeRegistry().lookup( OID );
+        AttributeType at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
         assertEquals( at.getDescription(), DESCRIPTION0 );
         assertEquals( at.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
 
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
         
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
-        mods.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        mods.put( "m-description", DESCRIPTION1 );
+        mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
         assertTrue( "attributeType OID should still be present", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
         
         assertEquals( "attributeType schema should be set to apachemeta", 
-            getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
 
-        at = getAttributeTypeRegistry().lookup( OID );
+        at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
         assertEquals( at.getDescription(), DESCRIPTION1 );
         assertEquals( at.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
     }
     
 
     // ----------------------------------------------------------------------
-    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // Test Rename operation
     // ----------------------------------------------------------------------
-
-    
-    private void addDependeeAttributeType() throws Exception
+    @Test
+    @Ignore
+    public void testRenameAttributeType() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, DEPENDEE_OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        attrs.put( MetaSchemaConstants.M_EQUALITY_AT, "caseIgnoreMatch" );
-        attrs.put( MetaSchemaConstants.M_SINGLE_VALUE_AT, "FALSE" );
-        attrs.put( MetaSchemaConstants.M_USAGE_AT, "directoryOperation" );
-        attrs.put( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT, OID );
-        
+        testAddAttributeTypeToEnabledSchema();
+
+        LdapContext schemaRoot = getSchemaContext( service );
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + DEPENDEE_OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        dn.add( "m-oid=" + OID );
         
-        assertTrue( getAttributeTypeRegistry().hasAttributeType( DEPENDEE_OID ) );
-        assertEquals( getAttributeTypeRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
-    }
-
+        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
+        newdn.add( "m-oid=" + NEW_OID );
+        schemaRoot.rename( dn, newdn );
 
-    @Test
-    public void testDeleteAttributeTypeWhenInUse() throws Exception
-    {
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddAttributeType();
-        addDependeeAttributeType();
+        assertFalse( "old attributeType OID should be removed from the registry after being renamed", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
         
         try
         {
-            getSchemaContext( service ).destroySubcontext( dn );
-            fail( "should not be able to delete a attributeType in use" );
+            service.getSchemaManager().getAttributeTypeRegistry().lookup( OID );
+            fail( "attributeType lookup should fail after renaming the attributeType" );
         }
-        catch( LdapOperationNotSupportedException e ) 
+        catch( NamingException e )
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "attributeType should still be in the registry after delete failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID ) );
     }
-    
-    
+
+
     @Test
-    public void testMoveAttributeTypeWhenInUse() throws Exception
+    @Ignore
+    public void testRenameAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
+
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
         addDependeeAttributeType();
         
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
+        newdn.add( "m-oid=" + NEW_OID );
         
         try
         {
             getSchemaContext( service ).rename( dn, newdn );
-            fail( "should not be able to move a attributeType in use" );
+            fail( "should not be able to rename a attributeType in use" );
         }
         catch( LdapOperationNotSupportedException e ) 
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "attributeType should still be in the registry after move failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        assertTrue( "attributeType should still be in the registry after rename failure", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Move operation
+    // ----------------------------------------------------------------------
     @Test
-    public void testMoveAttributeTypeAndChangeRdnWhenInUse() throws Exception
+    @Ignore
+    public void testMoveAttributeType() throws Exception
     {
-        testAddAttributeType();
-        addDependeeAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
 
         LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        newdn.add( "m-oid=" + OID );
         
-        try
-        {
-            getSchemaContext( service ).rename( dn, newdn );
-            fail( "should not be able to move a attributeType in use" );
-        }
-        catch( LdapOperationNotSupportedException e ) 
-        {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
-        }
+        getSchemaContext( service ).rename( dn, newdn );
 
-        assertTrue( "attributeType should still be in the registry after move failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        assertTrue( "attributeType OID should still be present",
+                service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        
+        assertEquals( "attributeType schema should be set to apache not apachemeta", 
+            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apache" );
     }
 
-    
+
     @Test
-    public void testRenameAttributeTypeWhenInUse() throws Exception
+    @Ignore
+    public void testMoveAttributeTypeAndChangeRdn() throws Exception
     {
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddAttributeType();
-        addDependeeAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
-        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+
+        LdapDN newdn = getAttributeTypeContainer( "apache" );
+        newdn.add( "m-oid=" + NEW_OID );
         
-        try
-        {
-            getSchemaContext( service ).rename( dn, newdn );
-            fail( "should not be able to rename a attributeType in use" );
-        }
-        catch( LdapOperationNotSupportedException e ) 
-        {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
-        }
+        getSchemaContext( service ).rename( dn, newdn );
 
-        assertTrue( "attributeType should still be in the registry after rename failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        assertFalse( "old attributeType OID should NOT be present", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        
+        assertTrue( "new attributeType OID should be present", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID ) );
+        
+        assertEquals( "attributeType with new oid should have schema set to apache NOT apachemeta", 
+            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( NEW_OID ), "apache" );
     }
 
 
-    // ----------------------------------------------------------------------
-    // Let's try some freaky stuff
-    // ----------------------------------------------------------------------
-
-
     @Test
+    @Ignore
     public void testMoveAttributeTypeToTop() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
 
         LdapDN top = new LdapDN();
-        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        top.add( "m-oid=" + OID );
         
         try
         {
@@ -432,20 +453,21 @@
         }
 
         assertTrue( "attributeType should still be in the registry after move failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveAttributeTypeToComparatorContainer() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid=" + OID );
         
         try
         {
@@ -458,74 +480,139 @@
         }
 
         assertTrue( "attributeType should still be in the registry after move failure", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
     
     
     @Test
-    public void testAddAttributeTypeToDisabledSchema() throws Exception
+    @Ignore
+    public void testMoveAttributeTypeToDisabledSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
-        attrs.put( MetaSchemaConstants.M_EQUALITY_AT, "caseIgnoreMatch" );
-        attrs.put( MetaSchemaConstants.M_SINGLE_VALUE_AT, "FALSE" );
-        attrs.put( MetaSchemaConstants.M_USAGE_AT, "directoryOperation" );
+        testAddAttributeTypeToEnabledSchema();
         
-        LdapDN dn = getAttributeTypeContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+
+        // nis is inactive by default
+        LdapDN newdn = getAttributeTypeContainer( "nis" );
+        newdn.add( "m-oid=" + OID );
         
-        assertFalse( "adding new attributeType to disabled schema should not register it into the registries", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "attributeType OID should no longer be present", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
 
 
     @Test
-    public void testMoveAttributeTypeToDisabledSchema() throws Exception
+    @Ignore
+    public void testMoveAttributeTypeWhenInUse() throws Exception
     {
-        testAddAttributeType();
+        testAddAttributeTypeToEnabledSchema();
+        addDependeeAttributeType();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
 
-        // nis is inactive by default
-        LdapDN newdn = getAttributeTypeContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        LdapDN newdn = getAttributeTypeContainer( "apache" );
+        newdn.add( "m-oid=" + OID );
         
-        getSchemaContext( service ).rename( dn, newdn );
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a attributeType in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
 
-        assertFalse( "attributeType OID should no longer be present", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+        assertTrue( "attributeType should still be in the registry after move failure", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+    }
+
+
+    @Test
+    @Ignore
+    public void testMoveAttributeTypeAndChangeRdnWhenInUse() throws Exception
+    {
+        testAddAttributeTypeToEnabledSchema();
+        addDependeeAttributeType();
+        
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+
+        LdapDN newdn = getAttributeTypeContainer( "apache" );
+        newdn.add( "m-oid=" + NEW_OID );
+        
+        try
+        {
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to move a attributeType in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "attributeType should still be in the registry after move failure", 
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+    }
+
+    
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // ----------------------------------------------------------------------
+    private void addDependeeAttributeType() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaAttributeType",
+            "m-oid", DEPENDEE_OID,
+            "m-syntax", SchemaConstants.INTEGER_SYNTAX,
+            "m-description", DESCRIPTION0,
+            "m-equality: caseIgnoreMatch",
+            "m-singleValue: FALSE",
+            "m-usage: directoryOperation",
+            "m-supAttributeType", OID );
+        
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + DEPENDEE_OID );
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+        
+        assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( DEPENDEE_OID ) );
+        assertEquals( service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Let's try some freaky stuff
+    // ----------------------------------------------------------------------
+    /*
     @Test
+    @Ignore
     public void testMoveMatchingRuleToEnabledSchema() throws Exception
     {
         testAddAttributeTypeToDisabledSchema();
         
         // nis is inactive by default
         LdapDN dn = getAttributeTypeContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid=" + OID );
 
         assertFalse( "attributeType OID should NOT be present when added to disabled nis schema", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
 
         LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        newdn.add( "m-oid=" + OID );
         
         getSchemaContext( service ).rename( dn, newdn );
 
         assertTrue( "attributeType OID should be present when moved to enabled schema", 
-            getAttributeTypeRegistry().hasAttributeType( OID ) );
+            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
         
         assertEquals( "attributeType should be in apachemeta schema after move", 
-            getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
+            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
     }
+    */
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java Wed Jan  6 18:26:43 2010
@@ -20,30 +20,16 @@
 package org.apache.directory.server.core.schema;
 
 
-import jdbm.helper.IntegerComparator;
-import jdbm.helper.StringComparator;
-import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
-import org.apache.directory.server.schema.registries.ComparatorRegistry;
-import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
-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.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.Syntax;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -52,9 +38,21 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.Comparator;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+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.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.BooleanComparator;
+import org.apache.directory.shared.ldap.schema.comparators.StringComparator;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 
 /**
@@ -64,369 +62,533 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-@RunWith ( CiRunner.class )
-public class MetaComparatorHandlerIT
+@RunWith(FrameworkRunner.class)
+public class MetaComparatorHandlerIT extends AbstractMetaSchemaObjectHandler
 {
     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 SchemaManager schemaManager;
 
-    public static DirectoryService service;
-
-    
-    /**
-     * Gets relative DN to ou=schema.
-     *
-     * @param schemaName the name of the schema
-     * @return the dn to the ou underwhich comparators are found for a schmea
-     * @throws Exception if there are dn construction issues
-     */
-    private LdapDN getComparatorContainer( String schemaName ) throws Exception
+    class DummyMR extends MatchingRule
     {
-        return new LdapDN( "ou=comparators,cn=" + schemaName );
+        public DummyMR()
+        {
+            super( OID );
+            addName( "dummy" );
+        }
+
+        private static final long serialVersionUID = 1L;
     }
 
 
-    private static ComparatorRegistry getComparatorRegistry()
+    @Before
+    public void setup()
     {
-        return service.getRegistries().getComparatorRegistry();
+        schemaManager = service.getSchemaManager();
     }
-    
 
-    private static MatchingRuleRegistry getMatchingRuleRegistry()
+
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+    // Test Add operation
+    // ----------------------------------------------------------------------
+    @Test
+    public void testAddComparatorToEnabledSchema() throws Exception
     {
-        return service.getRegistries().getMatchingRuleRegistry();
+        Attributes attrs = AttributeUtils.createAttributes( "objectClass: top", "objectClass: metaTop",
+            "objectClass: metaComparator", "m-fqcn: " + StringComparator.class.getName(), "m-oid: " + OID,
+            "m-description: A test comparator" );
+
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+
+        // Addition
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+
+        // Post-checks
+        assertTrue( schemaManager.getComparatorRegistry().contains( OID ) );
+        assertEquals( schemaManager.getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, StringComparator.class );
+        assertTrue( isOnDisk( dn ) );
     }
 
 
-    private static OidRegistry getOidRegistry()
+    @Test
+    public void testAddComparatorToDisabledSchema() throws Exception
     {
-        return service.getRegistries().getOidRegistry();
-    }
+        Attributes attrs = AttributeUtils.createAttributes( "objectClass: top", "objectClass: metaTop",
+            "objectClass: metaComparator", "m-fqcn: " + StringComparator.class.getName(), "m-oid: " + OID,
+            "m-description: A test comparator" );
 
+        // nis is by default inactive
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
 
-    // ----------------------------------------------------------------------
-    // Test all core methods with normal operational pathways
-    // ----------------------------------------------------------------------
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+
+        // Addition
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+
+        // Post-checks
+        assertFalse( "adding new comparator to disabled schema should not register it into the registries",
+            schemaManager.getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+    }
 
 
     @Test
-    public void testAddComparator() throws Exception
+    public void testAddComparatorToUnloadedSchema() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, StringComparator.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
-        
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertTrue( getComparatorRegistry().hasComparator( OID ) );
-        assertEquals( getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
-        Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, StringComparator.class );
+        Attributes attrs = AttributeUtils.createAttributes( "objectClass: top", "objectClass: metaTop",
+            "objectClass: metaComparator", "m-fqcn: " + StringComparator.class.getName(), "m-oid: " + OID,
+            "m-description: A test comparator" );
+
+        // nis is by default inactive
+        LdapDN dn = getComparatorContainer( "notloaded" );
+        dn.add( "m-oid" + "=" + OID );
+
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+
+        // Addition
+        try
+        {
+            getSchemaContext( service ).createSubcontext( dn, attrs );
+            fail( "Should not be there" );
+        }
+        catch ( NameNotFoundException nnfe )
+        {
+            // Expected result.
+        }
+
+        // Post-checks
+        assertFalse( "adding new comparator to disabled schema should not register it into the registries",
+            schemaManager.getComparatorRegistry().contains( OID ) );
+        assertFalse( isOnDisk( dn ) );
     }
-    
+
 
     @Test
-    public void testAddComparatorWithByteCode() throws Exception
+    public void testAddComparatorWithByteCodeToEnabledSchema() throws Exception
     {
         InputStream in = getClass().getResourceAsStream( "DummyComparator.bytecode" );
         ByteArrayOutputStream out = new ByteArrayOutputStream();
+
         while ( in.available() > 0 )
         {
             out.write( in.read() );
         }
-        
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, "DummyComparator" );
-        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
-        
+
+        Attributes attrs = AttributeUtils.createAttributes( "objectClass: top", "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: org.apache.directory.shared.ldap.schema.comparators.DummyComparator", "m-bytecode", out
+                .toByteArray(), "m-oid", OID, "m-description: A test comparator" );
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
+
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+
+        // Addition
         getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertTrue( getComparatorRegistry().hasComparator( OID ) );
-        assertEquals( getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
-        Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
-        assertEquals( clazz.getName(), "DummyComparator" );
+
+        // Post-checks
+        assertTrue( schemaManager.getComparatorRegistry().contains( OID ) );
+        assertEquals( schemaManager.getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( OID ).getClass();
+        assertEquals( clazz.getName(), "org.apache.directory.shared.ldap.schema.comparators.DummyComparator" );
+        assertTrue( isOnDisk( dn ) );
     }
-    
+
 
     @Test
-    public void testDeleteComparator() throws Exception
+    public void testAddComparatorWithByteCodeToDisabledSchema() throws Exception
     {
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
-        
-        getSchemaContext( service ).destroySubcontext( dn );
+        InputStream in = getClass().getResourceAsStream( "DummyComparator.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        assertFalse( "comparator should be removed from the registry after being deleted", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        try
-        {
-            getComparatorRegistry().lookup( OID );
-            fail( "comparator lookup should fail after deleting the comparator" );
-        }
-        catch( NamingException e )
+        while ( in.available() > 0 )
         {
+            out.write( in.read() );
         }
+
+        Attributes attrs = AttributeUtils.createAttributes( "objectClass: top", "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: org.apache.directory.shared.ldap.schema.comparators.DummyComparator", "m-bytecode", out
+                .toByteArray(), "m-oid", OID, "m-description: A test comparator" );
+
+        // nis is by default inactive
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+
+        // Addition
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+
+        // Post-checks
+        assertFalse( "adding new comparator to disabled schema should not register it into the registries",
+            schemaManager.getComparatorRegistry().contains( OID ) );
+
+        assertTrue( isOnDisk( dn ) );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Delete operation
+    // ----------------------------------------------------------------------
     @Test
-    public void testRenameComparator() throws Exception
+    public void testDeleteComparatorFromEnabledSchema() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
-        
-        LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
-        getSchemaContext( service ).rename( dn, newdn );
+        dn.add( "m-oid" + "=" + OID );
+
+        testAddComparatorToEnabledSchema();
+
+        // Pre-checks
+        assertTrue( schemaManager.getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
+
+        // Deletion
+        getSchemaContext( service ).destroySubcontext( dn );
+
+        // Post-checks
+        assertFalse( "comparator should be removed from the registry after being deleted", schemaManager
+            .getComparatorRegistry().contains( OID ) );
 
-        assertFalse( "old comparator OID should be removed from the registry after being renamed", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
         try
         {
-            getComparatorRegistry().lookup( OID );
+            schemaManager.getComparatorRegistry().lookup( OID );
             fail( "comparator lookup should fail after deleting the comparator" );
         }
-        catch( NamingException e )
+        catch ( NamingException e )
         {
         }
 
-        assertTrue( getComparatorRegistry().hasComparator( NEW_OID ) );
-        Class<?> clazz = getComparatorRegistry().lookup( NEW_OID ).getClass();
-        assertEquals( clazz, StringComparator.class );
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
-    public void testMoveComparator() throws Exception
+    public void testDeleteComparatorFromDisabledSchema() throws Exception
     {
-        testAddComparator();
-        
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        LdapDN dn = getComparatorContainer( "nis" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToDisabledSchema();
 
-        LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
-        getSchemaContext( service ).rename( dn, newdn );
+        // Pre-checks
+        assertFalse( "comparator should be removed from the registry after being deleted", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+        assertTrue( isOnDisk( dn ) );
 
-        assertTrue( "comparator OID should still be present", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        assertEquals( "comparator schema should be set to apache not apachemeta", 
-            getComparatorRegistry().getSchemaName( OID ), "apache" );
+        // Deletion
+        getSchemaContext( service ).destroySubcontext( dn );
 
-        Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, StringComparator.class );
+        // Post-checks
+        assertFalse( "comparator should be removed from the registry after being deleted", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+
+        try
+        {
+            schemaManager.getComparatorRegistry().lookup( OID );
+            fail( "comparator lookup should fail after deleting the comparator" );
+        }
+        catch ( NamingException e )
+        {
+        }
+
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
-    public void testMoveComparatorAndChangeRdn() throws Exception
+    public void testDeleteComparatorWhenInUse() throws Exception
     {
-        testAddComparator();
-        
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        LdapDN cDn = getComparatorContainer( "apachemeta" );
+        cDn.add( "m-oid" + "=" + OID );
 
-        LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
-        
-        getSchemaContext( service ).rename( dn, newdn );
+        // Create a new Comparator
+        testAddComparatorToEnabledSchema();
+        assertTrue( isOnDisk( cDn ) );
+        assertTrue( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+        
+        // Create a MR using this comparator
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaMatchingRule",
+            "m-oid", OID,
+            "m-syntax", SchemaConstants.INTEGER_SYNTAX,
+            "m-description: test" );
+
+        LdapDN mrDn = getMatchingRuleContainer( "apachemeta" );
+        mrDn.add( "m-oid" + "=" + OID );
+
+        // Pre-checks
+        assertFalse( isOnDisk( mrDn ) );
+        assertFalse( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
+
+        // MatchingRule Addition
+        getSchemaContext( service ).createSubcontext( mrDn, attrs );
+
+        // Post-checks
+        assertTrue( isOnDisk( mrDn ) );
+        assertTrue( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
 
-        assertFalse( "old comparator OID should NOT be present", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        assertTrue( "new comparator OID should be present", 
-            getComparatorRegistry().hasComparator( NEW_OID ) );
-        
-        assertEquals( "comparator with new oid should have schema set to apache NOT apachemeta", 
-            getComparatorRegistry().getSchemaName( NEW_OID ), "apache" );
+        try
+        {
+            getSchemaContext( service ).destroySubcontext( cDn );
+            fail( "should not be able to delete a comparator in use" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
 
-        Class<?> clazz = getComparatorRegistry().lookup( NEW_OID ).getClass();
-        assertEquals( clazz, StringComparator.class );
+        assertTrue( "comparator should still be in the registry after delete failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Modify operation
+    // ----------------------------------------------------------------------
     @Test
+    @Ignore
     public void testModifyComparatorWithModificationItems() throws Exception
     {
-        testAddComparator();
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
+        dn.add( "m-oid" + "=" + OID );
+
         ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_FQCN_AT, IntegerComparator.class.getName() );
+        Attribute attr = new BasicAttribute( "m-fqcn", BooleanComparator.class.getName() );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
         getSchemaContext( service ).modifyAttributes( dn, mods );
 
-        assertTrue( "comparator OID should still be present", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        assertEquals( "comparator schema should be set to apachemeta", 
-            getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
+
+        assertEquals( "comparator schema should be set to apachemeta", schemaManager.getComparatorRegistry()
+            .getSchemaName( OID ), "apachemeta" );
 
-        Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, IntegerComparator.class );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, BooleanComparator.class );
     }
 
 
     @Test
+    @Ignore
     public void testModifyComparatorWithAttributes() throws Exception
     {
-        testAddComparator();
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
+        dn.add( "m-oid" + "=" + OID );
+
         Attributes mods = new BasicAttributes( true );
-        mods.put( MetaSchemaConstants.M_FQCN_AT, IntegerComparator.class.getName() );
+        mods.put( "m-fqcn", BooleanComparator.class.getName() );
         getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
 
-        assertTrue( "comparator OID should still be present", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        assertEquals( "comparator schema should be set to apachemeta", 
-            getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
+        assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
+
+        assertEquals( "comparator schema should be set to apachemeta", schemaManager.getComparatorRegistry()
+            .getSchemaName( OID ), "apachemeta" );
 
-        Class<?> clazz = getComparatorRegistry().lookup( OID ).getClass();
-        assertEquals( clazz, IntegerComparator.class );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, BooleanComparator.class );
     }
-    
+
 
     // ----------------------------------------------------------------------
-    // Test move, rename, and delete when a MR exists and uses the Comparator
+    // Test Rename operation
     // ----------------------------------------------------------------------
-
-    
     @Test
-    public void testDeleteComparatorWhenInUse() throws Exception
+    @Ignore
+    public void testRenameComparator() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
-        getMatchingRuleRegistry().register( new DummyMR() );
-        
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
+
+        LdapDN newdn = getComparatorContainer( "apachemeta" );
+        newdn.add( "m-oid" + "=" + NEW_OID );
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old comparator OID should be removed from the registry after being renamed", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+
         try
         {
-            getSchemaContext( service ).destroySubcontext( dn );
-            fail( "should not be able to delete a comparator in use" );
+            schemaManager.getComparatorRegistry().lookup( OID );
+            fail( "comparator lookup should fail after deleting the comparator" );
         }
-        catch( LdapOperationNotSupportedException e ) 
+        catch ( NamingException e )
         {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after delete failure", 
-            getComparatorRegistry().hasComparator( OID ) );
-        getMatchingRuleRegistry().unregister( OID );
-        getOidRegistry().unregister( OID );
+        assertTrue( schemaManager.getComparatorRegistry().contains( NEW_OID ) );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, StringComparator.class );
     }
-    
-    
+
+
     @Test
-    public void testMoveComparatorWhenInUse() throws Exception
+    @Ignore
+    public void testRenameComparatorWhenInUse() throws Exception
     {
-        testAddComparator();
-        getMatchingRuleRegistry().register( new DummyMR() );
-        
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
+        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
+
+        LdapDN newdn = getComparatorContainer( "apachemeta" );
+        newdn.add( "m-oid" + "=" + NEW_OID );
 
-        LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
         try
         {
             getSchemaContext( service ).rename( dn, newdn );
-            fail( "should not be able to move a comparator in use" );
+            fail( "should not be able to rename a comparator in use" );
         }
-        catch( LdapOperationNotSupportedException e ) 
+        catch ( LdapOperationNotSupportedException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after move failure", 
-            getComparatorRegistry().hasComparator( OID ) );
-        getMatchingRuleRegistry().unregister( OID );
-        getOidRegistry().unregister( OID );
+        assertTrue( "comparator should still be in the registry after rename failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+        schemaManager.getMatchingRuleRegistry().unregister( OID );
+        service.getSchemaManager().getGlobalOidRegistry().unregister( OID );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Move operation
+    // ----------------------------------------------------------------------
     @Test
-    public void testMoveComparatorAndChangeRdnWhenInUse() throws Exception
+    @Ignore
+    public void testMoveComparator() throws Exception
     {
-        testAddComparator();
-        getMatchingRuleRegistry().register( new DummyMR() );
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = getComparatorContainer( "apache" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
-        
+        newdn.add( "m-oid" + "=" + OID );
+
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertTrue( "comparator OID should still be present", schemaManager.getComparatorRegistry().contains( OID ) );
+
+        assertEquals( "comparator schema should be set to apache not apachemeta", schemaManager.getComparatorRegistry()
+            .getSchemaName( OID ), "apache" );
+
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, StringComparator.class );
+    }
+
+
+    @Test
+    @Ignore
+    public void testMoveComparatorAndChangeRdn() throws Exception
+    {
+        testAddComparatorToEnabledSchema();
+
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+
+        LdapDN newdn = getComparatorContainer( "apache" );
+        newdn.add( "m-oid" + "=" + NEW_OID );
+
+        getSchemaContext( service ).rename( dn, newdn );
+
+        assertFalse( "old comparator OID should NOT be present", schemaManager.getComparatorRegistry().contains( OID ) );
+
+        assertTrue( "new comparator OID should be present", schemaManager.getComparatorRegistry().contains( NEW_OID ) );
+
+        assertEquals( "comparator with new oid should have schema set to apache NOT apachemeta", schemaManager
+            .getComparatorRegistry().getSchemaName( NEW_OID ), "apache" );
+
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, StringComparator.class );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a MR exists and uses the Comparator
+    // ----------------------------------------------------------------------
+    @Test
+    @Ignore
+    public void testMoveComparatorWhenInUse() throws Exception
+    {
+        testAddComparatorToEnabledSchema();
+        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
+
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+
+        LdapDN newdn = getComparatorContainer( "apache" );
+        newdn.add( "m-oid" + "=" + OID );
+
         try
         {
             getSchemaContext( service ).rename( dn, newdn );
             fail( "should not be able to move a comparator in use" );
         }
-        catch( LdapOperationNotSupportedException e ) 
+        catch ( LdapOperationNotSupportedException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after move failure", 
-            getComparatorRegistry().hasComparator( OID ) );
-        getMatchingRuleRegistry().unregister( OID );
-        getOidRegistry().unregister( OID );
+        assertTrue( "comparator should still be in the registry after move failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+        schemaManager.getMatchingRuleRegistry().unregister( OID );
+        service.getSchemaManager().getGlobalOidRegistry().unregister( OID );
     }
 
-    
+
     @Test
-    public void testRenameComparatorWhenInUse() throws Exception
+    @Ignore
+    public void testMoveComparatorAndChangeRdnWhenInUse() throws Exception
     {
+        testAddComparatorToEnabledSchema();
+        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        testAddComparator();
-        getMatchingRuleRegistry().register( new DummyMR() );
-        
-        LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
-        
+        dn.add( "m-oid" + "=" + OID );
+
+        LdapDN newdn = getComparatorContainer( "apache" );
+        newdn.add( "m-oid" + "=" + NEW_OID );
+
         try
         {
             getSchemaContext( service ).rename( dn, newdn );
-            fail( "should not be able to rename a comparator in use" );
+            fail( "should not be able to move a comparator in use" );
         }
-        catch( LdapOperationNotSupportedException e ) 
+        catch ( LdapOperationNotSupportedException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after rename failure", 
-            getComparatorRegistry().hasComparator( OID ) );
-        getMatchingRuleRegistry().unregister( OID );
-        getOidRegistry().unregister( OID );
+        assertTrue( "comparator should still be in the registry after move failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
+        schemaManager.getMatchingRuleRegistry().unregister( OID );
+        service.getSchemaManager().getGlobalOidRegistry().unregister( OID );
     }
 
 
@@ -434,181 +596,101 @@
     // Let's try some freaky stuff
     // ----------------------------------------------------------------------
 
-
     @Test
+    @Ignore
     public void testMoveComparatorToTop() throws Exception
     {
-        testAddComparator();
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN top = new LdapDN();
-        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
+        top.add( "m-oid" + "=" + OID );
+
         try
         {
             getSchemaContext( service ).rename( dn, top );
             fail( "should not be able to move a comparator up to ou=schema" );
         }
-        catch( LdapInvalidNameException e ) 
+        catch ( LdapInvalidNameException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
-        assertTrue( "comparator should still be in the registry after move failure", 
-            getComparatorRegistry().hasComparator( OID ) );
+        assertTrue( "comparator should still be in the registry after move failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveComparatorToNormalizers() throws Exception
     {
-        testAddComparator();
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         LdapDN newdn = new LdapDN( "ou=normalizers,cn=apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
+        newdn.add( "m-oid" + "=" + OID );
+
         try
         {
             getSchemaContext( service ).rename( dn, newdn );
             fail( "should not be able to move a comparator up to normalizers container" );
         }
-        catch( LdapInvalidNameException e ) 
+        catch ( LdapInvalidNameException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
-        assertTrue( "comparator should still be in the registry after move failure", 
-            getComparatorRegistry().hasComparator( OID ) );
-    }
-    
-    
-    @Test
-    public void testAddComparatorToDisabledSchema() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT, "top" );
-        oc.add( MetaSchemaConstants.META_TOP_OC );
-        oc.add( MetaSchemaConstants.META_COMPARATOR_OC );
-        attrs.put( oc );
-        attrs.put( MetaSchemaConstants.M_FQCN_AT, StringComparator.class.getName() );
-        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
-        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test comparator" );
-        
-        // nis is by default inactive
-        LdapDN dn = getComparatorContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        getSchemaContext( service ).createSubcontext( dn, attrs );
-        
-        assertFalse( "adding new comparator to disabled schema should not register it into the registries", 
-            getComparatorRegistry().hasComparator( OID ) );
+        assertTrue( "comparator should still be in the registry after move failure", schemaManager
+            .getComparatorRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveComparatorToDisabledSchema() throws Exception
     {
-        testAddComparator();
-        
+        testAddComparatorToEnabledSchema();
+
         LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         LdapDN newdn = getComparatorContainer( "nis" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
+        newdn.add( "m-oid" + "=" + OID );
+
         getSchemaContext( service ).rename( dn, newdn );
 
-        assertFalse( "comparator OID should no longer be present", 
-            getComparatorRegistry().hasComparator( OID ) );
+        assertFalse( "comparator OID should no longer be present", schemaManager.getComparatorRegistry().contains( OID ) );
     }
 
 
     @Test
+    @Ignore
     public void testMoveComparatorToEnabledSchema() throws Exception
     {
         testAddComparatorToDisabledSchema();
-        
+
         // nis is inactive by default
         LdapDN dn = getComparatorContainer( "nis" );
-        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        dn.add( "m-oid" + "=" + OID );
 
-        assertFalse( "comparator OID should NOT be present when added to disabled nis schema", 
-            getComparatorRegistry().hasComparator( OID ) );
+        assertFalse( "comparator OID should NOT be present when added to disabled nis schema", schemaManager
+            .getComparatorRegistry().contains( OID ) );
 
         LdapDN newdn = getComparatorContainer( "apachemeta" );
-        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
-        
-        getSchemaContext( service ).rename( dn, newdn );
+        newdn.add( "m-oid" + "=" + OID );
 
-        assertTrue( "comparator OID should be present when moved to enabled schema", 
-            getComparatorRegistry().hasComparator( OID ) );
-        
-        assertEquals( "comparator should be in apachemeta schema after move", 
-            getComparatorRegistry().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;
-        }
+        getSchemaContext( service ).rename( dn, newdn );
 
-        public String getSchema()
-        {
-            return null;
-        }
+        assertTrue( "comparator OID should be present when moved to enabled schema", schemaManager
+            .getComparatorRegistry().contains( OID ) );
 
-        public void setSchema( String schemaName )
-        {
-        }
-
-        public String[] getNamesRef()
-        {
-            return new String[] { "dummy" };
-        }
+        assertEquals( "comparator should be in apachemeta schema after move", schemaManager.getComparatorRegistry()
+            .getSchemaName( OID ), "apachemeta" );
     }
 }



Mime
View raw message