directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r888626 - 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 23:30:29 GMT
Author: elecharny
Date: Tue Dec  8 23:30:29 2009
New Revision: 888626

URL: http://svn.apache.org/viewvc?rev=888626&view=rev
Log:
o Fixed the checkOidExist() method to take care of LoadableSchemaObject
o Fixing the comparator add 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=888626&r1=888625&r2=888626&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 23:30:29 2009
@@ -1345,7 +1345,27 @@
      */
     private boolean checkOidExist( SchemaObject schemaObject )
     {
-        return registries.getGlobalOidRegistry().hasOid( schemaObject.getOid() );
+        if ( !( schemaObject instanceof LoadableSchemaObject ) )
+        {
+            return registries.getGlobalOidRegistry().hasOid( schemaObject.getOid() );
+        }
+
+        if ( schemaObject instanceof LdapComparator<?> )
+        {
+            return registries.getComparatorRegistry().contains( schemaObject.getOid() );
+        }
+
+        if ( schemaObject instanceof LdapSyntax )
+        {
+            return registries.getLdapSyntaxRegistry().contains( schemaObject.getOid() );
+        }
+
+        if ( schemaObject instanceof Normalizer )
+        {
+            return registries.getNormalizerRegistry().contains( schemaObject.getOid() );
+        }
+
+        return false;
     }
 
 

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=888626&r1=888625&r2=888626&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 23:30:29 2009
@@ -605,7 +605,7 @@
         }
     }
 
-    
+
     @Test
     public void testAddAlreadyExistingComparator() throws Exception
     {
@@ -618,22 +618,44 @@
 
         assertTrue( schemaManager.add( lc ) );
 
+        try
+        {
+            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+
+            assertNotNull( added );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+
         List<Throwable> errors = schemaManager.getErrors();
         assertEquals( 0, errors.size() );
+        assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
 
         lc = new CsnComparator( oid );
-        // FIXME the below add throws a NamingException instead of false
-        // expected behaviour is to return a boolean value consistently
+
         assertFalse( schemaManager.add( lc ) );
 
         errors = schemaManager.getErrors();
         assertEquals( 1, errors.size() );
-        
-        assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
+
+        assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+
+        try
+        {
+            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+
+            assertNotNull( added );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
     }
-    
-    
+
     //=========================================================================
     // DITContentRule addition tests
     //-------------------------------------------------------------------------



Mime
View raw message