directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r487869 - in /directory/branches/trunks/schema/apacheds/core/src: main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
Date Sat, 16 Dec 2006 19:39:29 GMT
Author: akarasulu
Date: Sat Dec 16 11:39:29 2006
New Revision: 487869

URL: http://svn.apache.org/viewvc?view=rev&rev=487869
Log:
added utility method and test case for that method to read schemas

Modified:
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=487869&r1=487868&r2=487869
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
Sat Dec 16 11:39:29 2006
@@ -22,6 +22,7 @@
 
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import javax.naming.NamingEnumeration;
@@ -62,14 +63,15 @@
     }
     
     
-    public Set<Schema> getSchemas() throws NamingException
+    public Map<String,Schema> getSchemas() throws NamingException
     {
-        Set<Schema> schemas = new HashSet<Schema>();
+        Map<String,Schema> schemas = new HashMap<String,Schema>();
         NamingEnumeration list = listSchemas();
         while( list.hasMore() )
         {
             SearchResult sr = ( SearchResult ) list.next();
-            schemas.add( factory.getSchema( sr.getAttributes() ) );
+            Schema schema = factory.getSchema( sr.getAttributes() ); 
+            schemas.put( schema.getSchemaName(), schema );
         }
         
         return schemas;

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?view=diff&rev=487869&r1=487868&r2=487869
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
Sat Dec 16 11:39:29 2006
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Map;
 import java.util.Set;
 
 import javax.naming.NamingException;
@@ -44,6 +45,7 @@
 import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
 import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
@@ -142,6 +144,125 @@
         pc.setContextEntry( entry );
         schemaPartition = new JdbmPartition();
         schemaPartition.init( configuration, pc );
+    }
+    
+    
+    public void testGetSchemas() throws NamingException
+    {
+        PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, registries
);
+        Map<String,Schema> schemas = loader.getSchemas();
+        
+        Schema schema = schemas.get( "mozilla" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "mozilla" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "core" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "core" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "apachedns" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "apachedns" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "autofs" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "autofs" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "apache" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "apache" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+
+        schema = schemas.get( "cosine" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "cosine" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "krb5kdc" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "krb5kdc" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "samba" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "samba" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "collective" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "collective" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "java" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "java" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "dhcp" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "dhcp" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "corba" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "corba" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "nis" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "nis" );
+        assertTrue( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "inetorgperson" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "inetorgperson" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "system" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "system" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
+        
+        schema = schemas.get( "apachemeta" );
+        assertNotNull( schema );
+        assertEquals( schema.getSchemaName(), "apachemeta" );
+        assertFalse( schema.isDisabled() );
+        assertEquals( schema.getOwner(), "uid=admin,ou=system" );
+        schema = null;
     }
     
     



Mime
View raw message