directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r888472 - in /directory/shared/branches/shared-schema/ldap-schema-loader/src: main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Date Tue, 08 Dec 2009 16:35:30 GMT
Author: elecharny
Date: Tue Dec  8 16:35:29 2009
New Revision: 888472

URL: http://svn.apache.org/viewvc?rev=888472&view=rev
Log:
o Injected Kiran's first test for comparator
o Fixed a NPE in the add method when we are adding some LoadableSchemaObjects
o Added some more check in the test

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

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java?rev=888472&r1=888471&r2=888472&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
Tue Dec  8 16:35:29 2009
@@ -38,6 +38,7 @@
 import org.apache.directory.shared.ldap.schema.EntityFactory;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.schema.LoadableSchemaObject;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
@@ -1377,8 +1378,17 @@
         // First, clear the errors
         errors.clear();
 
+        SchemaObject copy = null;
+
         // Clone the schemaObject
-        SchemaObject copy = schemaObject.copy();
+        if ( !( schemaObject instanceof LoadableSchemaObject ) )
+        {
+            copy = schemaObject.copy();
+        }
+        else
+        {
+            copy = schemaObject;
+        }
 
         if ( registries.isRelaxed() )
         {

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java?rev=888472&r1=888471&r2=888472&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Tue Dec  8 16:35:29 2009
@@ -22,7 +22,9 @@
 
 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 static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
@@ -34,8 +36,10 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 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.UsageEnum;
+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;
@@ -56,7 +60,7 @@
     private static String workingDirectory;
 
     // The schema repository
-    private static File schemaRepository;
+    private static File   schemaRepository;
 
 
     @BeforeClass
@@ -566,10 +570,38 @@
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
 
+
     //=========================================================================
     // Comparator addition tests
     //-------------------------------------------------------------------------
-    // TODO
+    @Test
+    public void testAddNewComparator() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int ctrSize = schemaManager.getComparatorRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        LdapComparator<?> lc = new BooleanComparator( "0.0.0" );
+
+        assertTrue( schemaManager.add( lc ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 0, errors.size() );
+
+        assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+
+        try
+        {
+            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( "0.0.0"
);
+
+            assertNotNull( added );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+    }
 
     //=========================================================================
     // DITContentRule addition tests



Mime
View raw message