directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r890425 - /directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
Date Mon, 14 Dec 2009 18:21:37 GMT
Author: kayyagari
Date: Mon Dec 14 18:21:35 2009
New Revision: 890425

URL: http://svn.apache.org/viewvc?rev=890425&view=rev
Log:
added test cases dealing with deletion of Comparators

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=890425&r1=890424&r2=890425&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
Mon Dec 14 18:21:35 2009
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -33,12 +34,15 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.BooleanComparator;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -247,10 +251,71 @@
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
 
+
     //=========================================================================
     // Comparator deletion tests
     //-------------------------------------------------------------------------
-    // TODO
+
+    @Ignore("lookup of newly added comparator is failing")
+    @Test
+    public void testDeleteExistingComaparator() throws Exception
+    {
+        SchemaManager schemaManager = loadSchema( "system" );
+        int ctrSize = schemaManager.getComparatorRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        LdapComparator<?> lc = new BooleanComparator( "0.1.1" );
+        assertTrue( schemaManager.add( lc ) );
+
+        assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+
+        // FIXME this lookup is failing ! but it shouldn't be
+        lc = schemaManager.lookupComparatorRegistry( "0.1.1" );
+        assertNotNull( lc );
+        assertTrue( schemaManager.delete( lc ) );
+
+        assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    @Test
+    public void testDeleteNonExistingComaparator() throws Exception
+    {
+        SchemaManager schemaManager = loadSchema( "system" );
+        int ctrSize = schemaManager.getComparatorRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        LdapComparator<?> lc = new BooleanComparator( "0.0" );
+        assertFalse( schemaManager.delete( lc ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertFalse( errors.isEmpty() );
+
+        assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    @Test
+    public void testDeleteExistingComaparatorUsedByMatchingRule() throws Exception
+    {
+        SchemaManager schemaManager = loadSchema( "system" );
+        int ctrSize = schemaManager.getComparatorRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        LdapComparator<?> lc = schemaManager.lookupComparatorRegistry( "2.5.13.0" );
+        // shouldn't be deleted cause there is a MR associated with it
+        assertFalse( schemaManager.delete( lc ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertFalse( errors.isEmpty() );
+
+        assertNotNull( schemaManager.lookupComparatorRegistry( "2.5.13.0" ) );
+        assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
 
     //=========================================================================
     // DITContentRule deletion tests



Mime
View raw message