directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r889339 - /directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Date Thu, 10 Dec 2009 17:13:47 GMT
Author: elecharny
Date: Thu Dec 10 17:13:46 2009
New Revision: 889339

URL: http://svn.apache.org/viewvc?rev=889339&view=rev
Log:
Slightly improved the tests for Comparator

Modified:
    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/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=889339&r1=889338&r2=889339&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
Thu Dec 10 17:13:46 2009
@@ -28,7 +28,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -47,7 +46,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;
 
 
@@ -63,7 +61,7 @@
     private static String workingDirectory;
 
     // The schema repository
-    private static File   schemaRepository;
+    private static File schemaRepository;
 
 
     @BeforeClass
@@ -595,20 +593,14 @@
         assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
 
-        try
-        {
-            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+        LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
 
-            assertNotNull( added );
-        }
-        catch ( NamingException ne )
-        {
-            fail();
-        }
+        assertNotNull( added );
+        assertEquals( lc.getClass().getName(), added.getFqcn() );
     }
 
 
-    //@Test
+    @Test
     public void testAddAlreadyExistingComparator() throws Exception
     {
         SchemaManager schemaManager = loadSystem();
@@ -616,27 +608,21 @@
         int goidSize = schemaManager.getOidRegistry().size();
 
         String oid = "0.0.0";
-        LdapComparator<?> lc = new BooleanComparator( oid );
+        LdapComparator<?> bc = new BooleanComparator( oid );
 
-        assertTrue( schemaManager.add( lc ) );
+        assertTrue( schemaManager.add( bc ) );
 
-        try
-        {
-            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+        LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
 
-            assertNotNull( added );
-        }
-        catch ( NamingException ne )
-        {
-            fail();
-        }
+        assertNotNull( added );
+        assertEquals( bc.getClass().getName(), added.getFqcn() );
 
         List<Throwable> errors = schemaManager.getErrors();
         assertEquals( 0, errors.size() );
         assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
 
-        lc = new CsnComparator( oid );
+        LdapComparator<?> lc = new CsnComparator( oid );
 
         assertFalse( schemaManager.add( lc ) );
 
@@ -646,24 +632,15 @@
         assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
         assertEquals( goidSize, schemaManager.getOidRegistry().size() );
 
-        try
-        {
-            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+        added = schemaManager.lookupComparatorRegistry( oid );
 
-            assertNotNull( added );
-        }
-        catch ( NamingException ne )
-        {
-            fail();
-        }
+        assertNotNull( added );
+        assertEquals( bc.getClass().getName(), added.getFqcn() );
     }
 
 
     /**
      * Test that we can't add two comparators with the same class code.
-     * 
-     * This is a questionable test, as there is no real reason why it could
-     * be a problem.
      */
     @Test
     public void testAddComparatorWithWrongFQCN() throws Exception
@@ -674,6 +651,7 @@
 
         String oid = "0.0.0";
         LdapComparator<?> lc = new BooleanComparator( oid );
+
         // using java.sql.ResultSet cause it is very unlikely to get loaded
         // in ADS, as the FQCN is not the one expected
         lc.setFqcn( "java.sql.ResultSet" );
@@ -689,7 +667,7 @@
 
         try
         {
-            LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+            schemaManager.lookupComparatorRegistry( oid );
             fail();
         }
         catch ( Exception e )
@@ -699,47 +677,6 @@
         }
     }
 
-
-    @Ignore
-    // Definitively not an issue.
-    @Test
-    public void testAddNewComparatorWithDuplicateName() throws Exception
-    {
-        SchemaManager schemaManager = loadSystem();
-        int ctrSize = schemaManager.getComparatorRegistry().size();
-        int goidSize = schemaManager.getOidRegistry().size();
-
-        List<String> names = new ArrayList<String>();
-        names.add( "name" );
-        names.add( "name" );
-
-        String oid = "0.0.0";
-        LdapComparator<?> lc = new BooleanComparator( oid );
-        lc.setNames( names );
-
-        // FIXME this should fail cause the same name was set twice
-        assertTrue( schemaManager.add( lc ) );
-
-        List<Throwable> errors = schemaManager.getErrors();
-        errors = schemaManager.getErrors();
-        assertEquals( 1, errors.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