directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r891820 - /directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
Date Thu, 17 Dec 2009 18:21:38 GMT
Author: elecharny
Date: Thu Dec 17 18:21:37 2009
New Revision: 891820

URL: http://svn.apache.org/viewvc?rev=891820&view=rev
Log:
Added a test to check that we can remove a Syntax which was used by  a MR which has been removed

Modified:
    directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java?rev=891820&r1=891819&r2=891820&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
Thu Dec 17 18:21:37 2009
@@ -834,6 +834,53 @@
         assertEquals( sSize, schemaManager.getLdapSyntaxRegistry().size() );
         assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
     }
+    
+    
+    /**
+     * Check that a Syntax which has been used by a deleted MatchingRule
+     * can be removed
+     */
+    @Test
+    public void testDeleteExistingSyntaxUsedByRemovedMatchingRule() throws Exception
+    {
+        SchemaManager schemaManager = loadSchema( "system" );
+        int srSize = schemaManager.getLdapSyntaxRegistry().size();
+        int mrrSize = schemaManager.getMatchingRuleRegistry().size();
+        int goidSize = schemaManager.getGlobalOidRegistry().size();
+        
+        String MR_OID = "2.5.13.11";
+        String S_OID =  "1.3.6.1.4.1.1466.115.121.1.41";
+
+        // Check that the MR and S are present
+        assertTrue( isMatchingRulePresent( schemaManager, MR_OID ) );
+        assertTrue( isSyntaxPresent( schemaManager, S_OID ) );
+
+        // Now try to remove the S
+        LdapSyntax syntax = schemaManager.lookupLdapSyntaxRegistry( S_OID );
+        
+        // shouldn't be deleted cause there is a MR associated with it
+        assertFalse( schemaManager.delete( syntax ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertFalse( errors.isEmpty() );
+        assertTrue( errors.get( 0 ) instanceof LdapSchemaViolationException );
+
+        // Now delete the using MR : it should be OK
+        MatchingRule mr = new MatchingRule( MR_OID );
+        assertTrue( schemaManager.delete( mr ) );
+
+        assertEquals( mrrSize - 1, schemaManager.getMatchingRuleRegistry().size() );
+        assertEquals( goidSize - 1, schemaManager.getGlobalOidRegistry().size() );
+
+        assertFalse( isMatchingRulePresent( schemaManager, MR_OID ) );
+        
+        // and try to delete the normalizer again
+        assertTrue( schemaManager.delete( syntax ) );
+
+        assertFalse( isSyntaxPresent( schemaManager, S_OID ) );
+        assertEquals( srSize - 1, schemaManager.getLdapSyntaxRegistry().size() );
+        assertEquals( goidSize - 2, schemaManager.getGlobalOidRegistry().size() );
+    }
 
 
     /**



Mime
View raw message