directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r894518 - in /directory/apacheds/branches/apacheds-schema/core-annotations/src: main/java/org/apache/directory/server/core/factory/ test/java/org/apache/directory/server/core/factory/
Date Wed, 30 Dec 2009 00:02:29 GMT
Author: elecharny
Date: Wed Dec 30 00:02:28 2009
New Revision: 894518

URL: http://svn.apache.org/viewvc?rev=894518&view=rev
Log:
o Fixed the partition initialization (the workingDir and schemaManager weren't injected)
o Activated the test to demonstrate that the partition is created

Modified:
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=894518&r1=894517&r2=894518&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
Wed Dec 30 00:02:28 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.directory.server.core.factory;
 
+import java.io.File;
 import java.lang.reflect.Method;
 import java.util.List;
 
@@ -32,6 +33,7 @@
 import org.apache.directory.server.core.annotations.CreatePartition;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.xdbm.Index;
@@ -151,10 +153,13 @@
             for ( CreatePartition createPartition : dsBuilder.partitions() )
             {
                 // Create the partition
-                JdbmPartition partition = new JdbmPartition();
+                Partition partition = new JdbmPartition();
                 partition.setId( createPartition.name() );
                 partition.setSuffix( createPartition.suffix() );
-                partition.setCacheSize( createPartition.cacheSize() );
+                partition.setSchemaManager( service.getSchemaManager() );
+                ( ( JdbmPartition ) partition ).setCacheSize( createPartition.cacheSize()
);
+                ( ( JdbmPartition ) partition ).setPartitionDir( 
+                    new File( service.getWorkingDirectory(), createPartition.name() ) );
                 
                 // Process the indexes if any
                 CreateIndex[] indexes = createPartition.indexes();
@@ -164,9 +169,11 @@
                     Index<String, ServerEntry> index = new JdbmIndex<String, ServerEntry>(
createIndex.attribute() );
                     index.setCacheSize( createIndex.cacheSize() );
                     
-                    partition.addIndexedAttributes( index );
+                    ( ( JdbmPartition ) partition ).addIndexedAttributes( index );
                 }
                 
+                partition.setSchemaManager( service.getSchemaManager() );
+                
                 // Inject the partition into the DirectoryService
                 service.addPartition( partition );
                 

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=894518&r1=894517&r2=894518&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
Wed Dec 30 00:02:28 2009
@@ -181,7 +181,6 @@
         ( ( JdbmPartition ) partition ).setPartitionDir( 
             new File( directoryService.getWorkingDirectory(), name ) );
         directoryService.addPartition( partition );
-
     }
 
     

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java?rev=894518&r1=894517&r2=894518&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
Wed Dec 30 00:02:28 2009
@@ -23,12 +23,16 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.annotations.ContextEntry;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.annotations.CreateIndex;
 import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.partition.Partition;
 import org.junit.Test;
 
 
@@ -91,14 +95,35 @@
         } )
     public void testCreateMethodDSWithPartition() throws Exception
     {
-        /*
         DirectoryService service = DSAnnotationProcessor.getDirectoryService();
         
         assertTrue( service.isStarted() );
-        assertEquals( "methodDS", service.getInstanceId() );
+        assertEquals( "MethodDSWithPartition", service.getInstanceId() );
+        
+        Set<String> expectedNames = new HashSet<String>();
+        
+        expectedNames.add( "example" );
+        expectedNames.add( "schema" );
+        
+        assertEquals( 2, service.getPartitions().size() );
+        
+        for ( Partition partition : service.getPartitions() )
+        {
+            assertTrue( expectedNames.contains( partition.getId() ) );
+            
+            if ( "example".equalsIgnoreCase( partition.getId() ) )
+            {
+                assertTrue( partition.isInitialized() );
+                assertEquals( "dc=example,dc=com", partition.getSuffixDn().getUpName() );
+            }
+            else if ( "schema".equalsIgnoreCase( partition.getId() ) )
+            {
+                assertTrue( partition.isInitialized() );
+                assertEquals( "ou=schema", partition.getSuffixDn().getUpName() );
+            }
+        }
         
         service.shutdown();
         FileUtils.deleteDirectory( service.getWorkingDirectory() );
-        */
     }
 }



Mime
View raw message