directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r957254 - /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
Date Wed, 23 Jun 2010 15:47:33 GMT
Author: elecharny
Date: Wed Jun 23 15:47:33 2010
New Revision: 957254

URL: http://svn.apache.org/viewvc?rev=957254&view=rev
Log:
reapplied http://svn.apache.org/viewvc?rev=956039&view=rev

Modified:
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?rev=957254&r1=957253&r2=957254&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
Wed Jun 23 15:47:33 2010
@@ -23,22 +23,25 @@ package org.apache.directory.server.core
 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.util.Map;
+import java.util.Set;
 
+import org.apache.commons.lang.NotImplementedException;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
-import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
 import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -54,6 +57,7 @@ public class PartitionSchemaLoaderTest
 {
     private static SchemaManager schemaManager;
     private static DirectoryService directoryService;
+    private static JdbmPartition schemaPartition;
 
 
     @BeforeClass public static void setUp() throws Exception
@@ -92,126 +96,153 @@ public class PartitionSchemaLoaderTest
         {
             fail( "Schema load failed : " + LdapExceptionUtils.printErrors( schemaManager.getErrors()
) );
         }
-        
-        directoryService.setSchemaManager( schemaManager );
+
+        // --------------------------------------------------------------------
+        // TODO add code here to start up the LDIF schema partition
+        // --------------------------------------------------------------------
+
+        throw new NotImplementedException();
     }
     
     
-    @Test 
-    public void testGetSchemas() throws Exception
+    @Test public void testGetSchemas() throws Exception
     {
-        SchemaLoader loader = directoryService.getSchemaManager().getLoader();
+        PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, schemaManager
);
+        Map<String,Schema> schemas = loader.getSchemas();
         
-        Schema schema = loader.getSchema( "mozilla" );
+        Schema schema = schemas.get( "mozilla" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "mozilla" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "core" );
+        schema = schemas.get( "core" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "core" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "apachedns" );
+        schema = schemas.get( "apachedns" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "apachedns" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "autofs" );
+        schema = schemas.get( "autofs" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "autofs" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "apache" );
+        schema = schemas.get( "apache" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "apache" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
 
-        schema = loader.getSchema( "cosine" );
+        schema = schemas.get( "cosine" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "cosine" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "krb5kdc" );
+        schema = schemas.get( "krb5kdc" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "krb5kdc" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "samba" );
+        schema = schemas.get( "samba" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "samba" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "collective" );
+        schema = schemas.get( "collective" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "collective" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "java" );
+        schema = schemas.get( "java" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "java" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "dhcp" );
+        schema = schemas.get( "dhcp" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "dhcp" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "corba" );
+        schema = schemas.get( "corba" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "corba" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "nis" );
+        schema = schemas.get( "nis" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "nis" );
         //assertTrue( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "inetorgperson" );
+        schema = schemas.get( "inetorgperson" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "inetorgperson" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "system" );
+        schema = schemas.get( "system" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "system" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
         
-        schema = loader.getSchema( "apachemeta" );
+        schema = schemas.get( "apachemeta" );
         assertNotNull( schema );
         assertEquals( schema.getSchemaName(), "apachemeta" );
         assertFalse( schema.isDisabled() );
         assertEquals( schema.getOwner(), "uid=admin,ou=system" );
         schema = null;
     }
+    
+    
+    @Test public void testGetSchemaNames() throws Exception
+    {
+        PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, schemaManager
);
+        Set<String> schemaNames = loader.getSchemaNames();
+        assertTrue( schemaNames.contains( "mozilla" ) );
+        assertTrue( schemaNames.contains( "core" ) );
+        assertTrue( schemaNames.contains( "apachedns" ) );
+        assertTrue( schemaNames.contains( "autofs" ) );
+        assertTrue( schemaNames.contains( "apache" ) );
+        assertTrue( schemaNames.contains( "cosine" ) );
+        assertTrue( schemaNames.contains( "krb5kdc" ) );
+        assertTrue( schemaNames.contains( "samba" ) );
+        assertTrue( schemaNames.contains( "collective" ) );
+        assertTrue( schemaNames.contains( "java" ) );
+        assertTrue( schemaNames.contains( "dhcp" ) );
+        assertTrue( schemaNames.contains( "corba" ) );
+        assertTrue( schemaNames.contains( "nis" ) );
+        assertTrue( schemaNames.contains( "inetorgperson" ) );
+        assertTrue( schemaNames.contains( "system" ) );
+        assertTrue( schemaNames.contains( "apachemeta" ) );
+    }
 }



Mime
View raw message