directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r881401 - in /directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema: MetaAttributeTypeHandlerIT.java MetaComparatorHandlerIT.java
Date Tue, 17 Nov 2009 17:38:54 GMT
Author: elecharny
Date: Tue Nov 17 17:38:53 2009
New Revision: 881401

URL: http://svn.apache.org/viewvc?rev=881401&view=rev
Log:
Fixed tests to work with the latest modifications on the Handlers

Modified:
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java?rev=881401&r1=881400&r2=881401&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java
Tue Nov 17 17:38:53 2009
@@ -263,83 +263,34 @@
         assertFalse( isOnDisk( dn ) );
     }
 
-
+    
     @Test
-    public void testRenameAttributeType() throws Exception
+    public void testDeleteAttributeTypeWhenInUse() throws Exception
     {
         testAddAttributeTypeToEnabledSchema();
 
-        LdapContext schemaRoot = getSchemaContext( service );
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
-        
-        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
-        newdn.add( "m-oid=" + NEW_OID );
-        schemaRoot.rename( dn, newdn );
-
-        assertFalse( "old attributeType OID should be removed from the registry after being
renamed", 
-            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        addDependeeAttributeType();
         
         try
         {
-            service.getSchemaManager().getAttributeTypeRegistry().lookup( OID );
-            fail( "attributeType lookup should fail after renaming the attributeType" );
+            getSchemaContext( service ).destroySubcontext( dn );
+            fail( "should not be able to delete a attributeType in use" );
         }
-        catch( NamingException e )
+        catch( LdapOperationNotSupportedException e ) 
         {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID
) );
-    }
-
-
-    @Test
-    @Ignore
-    public void testMoveAttributeType() throws Exception
-    {
-        testAddAttributeTypeToEnabledSchema();
-        
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( "m-oid=" + OID );
-
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( "m-oid=" + OID );
-        
-        getSchemaContext( service ).rename( dn, newdn );
-
-        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
-    @Ignore
-    public void testMoveAttributeTypeAndChangeRdn() throws Exception
-    {
-        testAddAttributeTypeToEnabledSchema();
-        
-        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
-        dn.add( "m-oid=" + OID );
-
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( "m-oid=" + NEW_OID );
-        
-        getSchemaContext( service ).rename( dn, newdn );
-
-        assertFalse( "old attributeType OID should NOT be present", 
+        assertTrue( "attributeType should still be in the registry after delete failure",

             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" );
     }
-
     
+    
+    // ----------------------------------------------------------------------
+    // Test Modify operation
+    // ----------------------------------------------------------------------
     @Test
     public void testModifyAttributeTypeWithModificationItems() throws Exception
     {
@@ -401,146 +352,114 @@
     
 
     // ----------------------------------------------------------------------
-    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // Test Rename operation
     // ----------------------------------------------------------------------
-
-    
-    private void addDependeeAttributeType() throws Exception
-    {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaAttributeType" );
-        attrs.put( oc );
-        attrs.put( "m-oid", DEPENDEE_OID );
-        attrs.put( "m-syntax", SchemaConstants.INTEGER_SYNTAX );
-        attrs.put( "m-description", DESCRIPTION0 );
-        attrs.put( "m-equality", "caseIgnoreMatch" );
-        attrs.put( "m-singleValue", "FALSE" );
-        attrs.put( "m-usage", "directoryOperation" );
-        attrs.put( "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" );
-    }
-
-
     @Test
-    public void testDeleteAttributeTypeWhenInUse() throws Exception
+    public void testRenameAttributeType() throws Exception
     {
         testAddAttributeTypeToEnabledSchema();
 
+        LdapContext schemaRoot = getSchemaContext( service );
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
-        addDependeeAttributeType();
+        
+        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
+        newdn.add( "m-oid=" + NEW_OID );
+        schemaRoot.rename( dn, newdn );
+
+        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",

-            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
+        assertTrue( service.getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID
) );
     }
-    
-    
+
+
     @Test
-    @Ignore
-    public void testMoveAttributeTypeWhenInUse() throws Exception
+    public void testRenameAttributeTypeWhenInUse() throws Exception
     {
         testAddAttributeTypeToEnabledSchema();
-        addDependeeAttributeType();
-        
+
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
-
-        LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( "m-oid=" + OID );
+        addDependeeAttributeType();
+        
+        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", 
+        assertTrue( "attributeType should still be in the registry after rename failure",

             service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Move operation
+    // ----------------------------------------------------------------------
     @Test
     @Ignore
-    public void testMoveAttributeTypeAndChangeRdnWhenInUse() throws Exception
+    public void testMoveAttributeType() throws Exception
     {
         testAddAttributeTypeToEnabledSchema();
-        addDependeeAttributeType();
         
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
 
         LdapDN newdn = getAttributeTypeContainer( "apache" );
-        newdn.add( "m-oid=" + 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", 
-            service.getSchemaManager().getAttributeTypeRegistry().contains( 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
     {
         testAddAttributeTypeToEnabledSchema();
-
+        
         LdapDN dn = getAttributeTypeContainer( "apachemeta" );
         dn.add( "m-oid=" + OID );
-        addDependeeAttributeType();
-        
-        LdapDN newdn = getAttributeTypeContainer( "apachemeta" );
+
+        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",

+        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
@@ -615,6 +534,91 @@
     }
 
 
+    @Test
+    @Ignore
+    public void testMoveAttributeTypeWhenInUse() throws Exception
+    {
+        testAddAttributeTypeToEnabledSchema();
+        addDependeeAttributeType();
+        
+        LdapDN dn = getAttributeTypeContainer( "apachemeta" );
+        dn.add( "m-oid=" + OID );
+
+        LdapDN newdn = getAttributeTypeContainer( "apache" );
+        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 );
+        }
+
+        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: directryOperation",
+            "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

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java?rev=881401&r1=881400&r2=881401&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaComparatorHandlerIT.java
Tue Nov 17 17:38:53 2009
@@ -75,6 +75,17 @@
     public static DirectoryService service;
     public static SchemaManager schemaManager;
     
+    class DummyMR extends MatchingRule
+    {
+        public DummyMR()
+        {
+            super( OID );
+            addName( "dummy" );
+        }
+
+        private static final long serialVersionUID = 1L;
+    }
+    
     
     @Before
     public void setup()
@@ -342,87 +353,40 @@
 
 
     @Test
-    public void testRenameComparator() throws Exception
+    public void testDeleteComparatorWhenInUse() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
         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 ) );
+        MatchingRule mr = new DummyMR();
+        schemaManager.register( mr );
+        
+        // Pre-checks
+        assertTrue( isOnDisk( dn ) );
+        assertTrue( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
+        assertTrue( service.getSchemaManager().getMatchingRuleRegistry().contains( mr.getOid()
) );
         
         try
         {
-            schemaManager.getComparatorRegistry().lookup( OID );
-            fail( "comparator lookup should fail after deleting the comparator" );
+            getSchemaContext( service ).destroySubcontext( dn );
+            fail( "should not be able to delete a comparator in use" );
         }
-        catch( NamingException e )
+        catch( LdapOperationNotSupportedException e ) 
         {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( schemaManager.getComparatorRegistry().contains( NEW_OID ) );
-        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( NEW_OID ).getClass();
-        assertEquals( clazz, StringComparator.class );
-    }
-
-
-    @Test
-    @Ignore
-    public void testMoveComparator() throws Exception
-    {
-        testAddComparatorToEnabledSchema();
-        
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( "m-oid" + "=" + OID );
-
-        LdapDN newdn = getComparatorContainer( "apache" );
-        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", 
+        assertTrue( "comparator should still be in the registry after delete failure", 
             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 );
+        schemaManager.unregister( mr );
     }
-
-
+    
+    
+    // ----------------------------------------------------------------------
+    // Test Modify operation
+    // ----------------------------------------------------------------------
     @Test
     public void testModifyComparatorWithModificationItems() throws Exception
     {
@@ -469,49 +433,74 @@
         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
+    public void testRenameComparator() throws Exception
     {
         LdapDN dn = getComparatorContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
-        
         testAddComparatorToEnabledSchema();
         
-        MatchingRule mr = new DummyMR();
-        schemaManager.register( mr );
+        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 ) );
         
-        // Pre-checks
-        assertTrue( isOnDisk( dn ) );
-        assertTrue( service.getSchemaManager().getComparatorRegistry().contains( OID ) );
-        assertTrue( service.getSchemaManager().getMatchingRuleRegistry().contains( mr.getOid()
) );
+        try
+        {
+            schemaManager.getComparatorRegistry().lookup( OID );
+            fail( "comparator lookup should fail after deleting the comparator" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertTrue( schemaManager.getComparatorRegistry().contains( NEW_OID ) );
+        Class<?> clazz = schemaManager.getComparatorRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, StringComparator.class );
+    }
+
+
+    @Test
+    public void testRenameComparatorWhenInUse() throws Exception
+    {
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        testAddComparatorToEnabledSchema();
+        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
+        
+        LdapDN newdn = getComparatorContainer( "apachemeta" );
+        newdn.add( "m-oid" + "=" + NEW_OID );
         
         try
         {
-            getSchemaContext( service ).destroySubcontext( dn );
-            fail( "should not be able to delete a comparator in use" );
+            getSchemaContext( service ).rename( dn, newdn );
+            fail( "should not be able to rename a comparator in use" );
         }
         catch( LdapOperationNotSupportedException e ) 
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after delete failure", 
+        assertTrue( "comparator should still be in the registry after rename failure", 
             schemaManager.getComparatorRegistry().contains( OID ) );
         schemaManager.getMatchingRuleRegistry().unregister( OID );
         service.getSchemaManager().getOidRegistry().unregister( OID );
     }
-    
-    
+
+
+    // ----------------------------------------------------------------------
+    // Test Move operation
+    // ----------------------------------------------------------------------
     @Test
     @Ignore
-    public void testMoveComparatorWhenInUse() throws Exception
+    public void testMoveComparator() throws Exception
     {
         testAddComparatorToEnabledSchema();
-        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -519,29 +508,24 @@
         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 ) 
-        {
-            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
-        }
+        getSchemaContext( service ).rename( dn, newdn );
 
-        assertTrue( "comparator should still be in the registry after move failure", 
+        assertTrue( "comparator OID should still be present", 
             schemaManager.getComparatorRegistry().contains( OID ) );
-        schemaManager.getMatchingRuleRegistry().unregister( OID );
-        service.getSchemaManager().getOidRegistry().unregister( 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 testMoveComparatorAndChangeRdnWhenInUse() throws Exception
+    public void testMoveComparatorAndChangeRdn() throws Exception
     {
         testAddComparatorToEnabledSchema();
-        schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
         
         LdapDN dn = getComparatorContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
@@ -549,6 +533,38 @@
         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 );
@@ -565,35 +581,37 @@
         service.getSchemaManager().getOidRegistry().unregister( OID );
     }
 
-    
+
     @Test
-    public void testRenameComparatorWhenInUse() throws Exception
+    @Ignore
+    public void testMoveComparatorAndChangeRdnWhenInUse() throws Exception
     {
-        LdapDN dn = getComparatorContainer( "apachemeta" );
-        dn.add( "m-oid" + "=" + OID );
         testAddComparatorToEnabledSchema();
         schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
         
-        LdapDN newdn = getComparatorContainer( "apachemeta" );
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        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 ) 
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "comparator should still be in the registry after rename failure", 
+        assertTrue( "comparator should still be in the registry after move failure", 
             schemaManager.getComparatorRegistry().contains( OID ) );
         schemaManager.getMatchingRuleRegistry().unregister( OID );
         service.getSchemaManager().getOidRegistry().unregister( OID );
     }
 
-
+    
     // ----------------------------------------------------------------------
     // Let's try some freaky stuff
     // ----------------------------------------------------------------------
@@ -697,16 +715,4 @@
         assertEquals( "comparator should be in apachemeta schema after move", 
             schemaManager.getComparatorRegistry().getSchemaName( OID ), "apachemeta" );
     }
-
-
-    class DummyMR extends MatchingRule
-    {
-        public DummyMR()
-        {
-            super( OID );
-            addName( "dummy" );
-        }
-
-        private static final long serialVersionUID = 1L;
-    }
 }



Mime
View raw message