directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r890571 - 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/SchemaManagerDelTest.java
Date Tue, 15 Dec 2009 00:01:57 GMT
Author: elecharny
Date: Tue Dec 15 00:01:56 2009
New Revision: 890571

URL: http://svn.apache.org/viewvc?rev=890571&view=rev
Log:
o Fixed on failing test (LoadableSchemaObject weren't orrectly handled)
o Added some checks 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/SchemaManagerDelTest.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=890571&r1=890570&r2=890571&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 15 00:01:56 2009
@@ -1420,13 +1420,13 @@
      */
     private SchemaObject getSchemaObject( SchemaObject schemaObject ) throws NamingException
     {
-        if ( registries.getGlobalOidRegistry().hasOid( schemaObject.getOid() ) )
+        if ( schemaObject instanceof LoadableSchemaObject )
         {
-            return registries.getGlobalOidRegistry().getSchemaObject( schemaObject.getOid()
);
+            return schemaObject;
         }
         else
         {
-            return schemaObject;
+            return registries.getGlobalOidRegistry().getSchemaObject( schemaObject.getOid()
);
         }
     }
 

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=890571&r1=890570&r2=890571&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
Tue Dec 15 00:01:56 2009
@@ -24,6 +24,7 @@
 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;
@@ -33,6 +34,7 @@
 import javax.naming.directory.NoSuchAttributeException;
 
 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.Normalizer;
@@ -46,7 +48,6 @@
 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;
 
 
@@ -261,7 +262,7 @@
     //-------------------------------------------------------------------------
 
     @Test
-    public void testDeleteExistingComaparator() throws Exception
+    public void testDeleteExistingComparator() throws Exception
     {
         SchemaManager schemaManager = loadSchema( "system" );
         int ctrSize = schemaManager.getComparatorRegistry().size();
@@ -276,6 +277,16 @@
         lc = schemaManager.lookupComparatorRegistry( "0.1.1" );
         assertNotNull( lc );
         assertTrue( schemaManager.delete( lc ) );
+        
+        try
+        {
+            schemaManager.lookupComparatorRegistry( "0.1.1" );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // expected
+        }
 
         assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
@@ -283,7 +294,7 @@
 
 
     @Test
-    public void testDeleteNonExistingComaparator() throws Exception
+    public void testDeleteNonExistingComparator() throws Exception
     {
         SchemaManager schemaManager = loadSchema( "system" );
         int ctrSize = schemaManager.getComparatorRegistry().size();
@@ -308,16 +319,19 @@
         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() );
+        assertTrue( errors.get( 0 ) instanceof LdapSchemaViolationException );
 
         assertNotNull( schemaManager.lookupComparatorRegistry( "2.5.13.0" ) );
         assertEquals( ctrSize, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
+    
 
     //=========================================================================
     // DITContentRule deletion tests
@@ -367,6 +381,16 @@
         assertNotNull( nr );
         assertTrue( schemaManager.delete( nr ) );
 
+        try
+        {
+            schemaManager.lookupNormalizerRegistry( "0.1.1" );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // expected
+        }
+
         assertEquals( nrSize, schemaManager.getNormalizerRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
@@ -404,6 +428,7 @@
 
         List<Throwable> errors = schemaManager.getErrors();
         assertFalse( errors.isEmpty() );
+        assertTrue( errors.get( 0 ) instanceof LdapSchemaViolationException );
 
         assertNotNull( schemaManager.lookupNormalizerRegistry( "2.5.13.0" ) );
         assertEquals( nrSize, schemaManager.getNormalizerRegistry().size() );
@@ -442,6 +467,16 @@
         assertNotNull( sc );
         assertTrue( schemaManager.delete( sc ) );
 
+        try
+        {
+            schemaManager.lookupSyntaxCheckerRegistry( "0.1.1" );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // expected
+        }
+
         assertEquals( scrSize, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
     }
@@ -466,7 +501,6 @@
     }
 
     
-    @Ignore ( "deleting a SC used by a S is successful where as it shouldn't be" )
     @Test
     public void testDeleteSyntaxCheckerUsedBySyntax() throws Exception
     {
@@ -481,6 +515,7 @@
 
         List<Throwable> errors = schemaManager.getErrors();
         assertFalse( errors.isEmpty() );
+        assertTrue( errors.get( 0 ) instanceof LdapSchemaViolationException );
 
         assertEquals( scrSize, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );



Mime
View raw message