directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r894166 - in /directory/apacheds/branches/apacheds-schema: core-annotations/src/main/java/org/apache/directory/server/core/ core-annotations/src/main/java/org/apache/directory/server/core/annotations/ core-annotations/src/main/java/org/apac...
Date Mon, 28 Dec 2009 13:18:25 GMT
Author: elecharny
Date: Mon Dec 28 13:18:24 2009
New Revision: 894166

URL: http://svn.apache.org/viewvc?rev=894166&view=rev
Log:
Refactored the Annotations projects, merged the builder and @ projects together.

Added:
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
      - copied, changed from r894082, directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DirectoryServiceFactory.java
      - copied, changed from r894074, directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceBuilderTest.java
      - copied, changed from r894074, directory/apacheds/branches/apacheds-schema/core-builder/src/test/java/org/apache/directory/server/core/builder/DirectoryServiceBuilderTest.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/resources/
    directory/apacheds/branches/apacheds-schema/core-annotations/src/test/resources/log4j.properties
      - copied unchanged from r894074, directory/apacheds/branches/apacheds-schema/core-builder/src/test/resources/log4j.properties
    directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/DefaultLdapServerFactory.java
      - copied, changed from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/DefaultLdapServerFactory.java
    directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/LdapServerFactory.java
      - copied, changed from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerFactory.java
    directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java
      - copied, changed from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java
Removed:
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/DefaultLdapServerFactory.java
    directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerFactory.java
Modified:
    directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/DSBuilder.java
    directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
    directory/apacheds/branches/apacheds-schema/test-framework/pom.xml
    directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
    directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java

Modified: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/DSBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/DSBuilder.java?rev=894166&r1=894165&r2=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/DSBuilder.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/annotations/DSBuilder.java
Mon Dec 28 13:18:24 2009
@@ -23,7 +23,7 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.apache.directory.server.core.DefaultDirectoryServiceFactory;
+import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
 
 /**
  * An anntation for the DirectoryService builder

Copied: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
(from r894082, directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/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?p2=directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java&p1=directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceFactory.java&r1=894082&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
Mon Dec 28 13:18:24 2009
@@ -16,10 +16,33 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.directory.server.core;
+package org.apache.directory.server.core.factory;
 
 
-import org.apache.directory.server.core.builder.DirectoryServiceBuilder;
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+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.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.schema.SchemaPartition;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+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.SchemaLoader;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 
 /**
@@ -30,7 +53,7 @@
  */
 public class DefaultDirectoryServiceFactory implements DirectoryServiceFactory
 {
-    private DirectoryService service;
+    private DirectoryService directoryService;
 
     /**
      * The default factory returns stock instances of a directory
@@ -38,22 +61,138 @@
      */
     public static final DirectoryServiceFactory DEFAULT = new DefaultDirectoryServiceFactory();
 
+    
     public void init( String name ) throws Exception
     {
-        if ( ( service != null ) && (service.isStarted() ) )
+        if ( ( directoryService != null ) && ( directoryService.isStarted() ) )
         {
             return;
         }
 
-        DirectoryServiceBuilder builder = new DirectoryServiceBuilder();
-        builder.build( name );
+        directoryService = new DefaultDirectoryService();
+        build( name );
+    }
+    
+    
+    /**
+     * Build the working directory
+     */
+    private void buildWorkingDirectory( String name )
+    {
+        String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = DefaultDirectoryServiceFactory.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work-" + name;
+        }
+        
+        directoryService.setWorkingDirectory( new File( workingDirectory ) );
+    }
+    
+    
+    private void initSchema() throws Exception
+    {
+        SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
+
+        // Init the LdifPartition
+        LdifPartition ldifPartition = new LdifPartition();
+        String workingDirectory = directoryService.getWorkingDirectory().getPath();
+        ldifPartition.setWorkingDirectory( workingDirectory + "/schema" );
+
+        // Extract the schema on disk (a brand new one) and load the registries
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy();
+
+        schemaPartition.setWrappedPartition( ldifPartition );
+
+        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+        directoryService.setSchemaManager( schemaManager );
+
+        // We have to load the schema now, otherwise we won't be able
+        // to initialize the Partitions, as we won't be able to parse 
+        // and normalize their suffix DN
+        schemaManager.loadAllEnabled();
+        
+        schemaPartition.setSchemaManager( schemaManager );
+
+        List<Throwable> errors = schemaManager.getErrors();
+
+        if ( errors.size() != 0 )
+        {
+            throw new Exception( "Schema load failed : " + ExceptionUtils.printErrors( errors
) );
+        }
+    }
+    
+    
+    private void initChangeLog()
+    {
+        directoryService.getChangeLog().setEnabled( true );
+    }
+    
+    
+    private void initSystemPartition() throws Exception
+    {
+        // change the working directory to something that is unique
+        // on the system and somewhere either under target directory
+        // or somewhere in a temp area of the machine.
+
+        // Inject the System Partition
+        Partition systemPartition = new JdbmPartition();
+        systemPartition.setId( "system" );
+        ( ( JdbmPartition ) systemPartition ).setCacheSize( 500 );
+        systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
+        systemPartition.setSchemaManager( directoryService.getSchemaManager() );
+        ( ( JdbmPartition ) systemPartition ).setPartitionDir( 
+            new File( directoryService.getWorkingDirectory(), "system" ) );
+
+        // Add objectClass attribute for the system partition
+        Set<Index<?, ServerEntry>> indexedAttrs = new HashSet<Index<?,
ServerEntry>>();
+        indexedAttrs.add( new JdbmIndex<Object, ServerEntry>( SchemaConstants.OBJECT_CLASS_AT
) );
+        ( ( JdbmPartition ) systemPartition ).setIndexedAttributes( indexedAttrs );
+
+        directoryService.setSystemPartition( systemPartition );
+    }
+
+    
+    public void initJdbmPartition( String name, String suffix ) throws Exception
+    {
+        Partition partition = new JdbmPartition();
+        partition.setId( name );
+        partition.setSuffix( suffix );
+        partition.setSchemaManager( directoryService.getSchemaManager() );
+        ( ( JdbmPartition ) partition ).setPartitionDir( 
+            new File( directoryService.getWorkingDirectory(), name ) );
+        directoryService.addPartition( partition );
+
+    }
+
+    
+    public void build( String name ) throws Exception
+    {
+        directoryService.setInstanceId( name );
+        buildWorkingDirectory( name );
+        
+        // Erase the working directory to be sure that we don't have some
+        // remaining data from a previous run
+        String workingDirectoryPath = directoryService.getWorkingDirectory().getPath();
+        File workingDirectory = new File( workingDirectoryPath );
+        FileUtils.deleteDirectory( workingDirectory );
+        
+        // Init the sevice now
+        initSchema();
+        initChangeLog();
+        initSystemPartition();
         
-        service = builder.getDirectoryService();
+        directoryService.startup();
     }
 
     
     public DirectoryService getDirectoryService() throws Exception
     {
-        return service;
+        return directoryService;
     }
 }

Copied: directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DirectoryServiceFactory.java
(from r894074, directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DirectoryServiceFactory.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DirectoryServiceFactory.java?p2=directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DirectoryServiceFactory.java&p1=directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DirectoryServiceFactory.java&r1=894074&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/DirectoryServiceFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/DirectoryServiceFactory.java
Mon Dec 28 13:18:24 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.directory.server.core;
+package org.apache.directory.server.core.factory;
 
 import org.apache.directory.server.core.DirectoryService;
 

Copied: directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceBuilderTest.java
(from r894074, directory/apacheds/branches/apacheds-schema/core-builder/src/test/java/org/apache/directory/server/core/builder/DirectoryServiceBuilderTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceBuilderTest.java?p2=directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceBuilderTest.java&p1=directory/apacheds/branches/apacheds-schema/core-builder/src/test/java/org/apache/directory/server/core/builder/DirectoryServiceBuilderTest.java&r1=894074&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-builder/src/test/java/org/apache/directory/server/core/builder/DirectoryServiceBuilderTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceBuilderTest.java
Mon Dec 28 13:18:24 2009
@@ -18,7 +18,7 @@
  *
  */
 
-package org.apache.directory.server.core.builder;
+package org.apache.directory.server.core.factory;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.DirectoryService;
@@ -36,10 +36,10 @@
     @Test
     public void testCreateDS() throws Exception
     {
-        DirectoryServiceBuilder builder = new DirectoryServiceBuilder();
-        builder.build( "Test" );
+        DefaultDirectoryServiceFactory factory = new DefaultDirectoryServiceFactory();
+        factory.build( "Test" );
         
-        DirectoryService service = builder.getDirectoryService();
+        DirectoryService service = factory.getDirectoryService();
         
         service.shutdown();
         FileUtils.deleteDirectory( service.getWorkingDirectory() );

Copied: directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/DefaultLdapServerFactory.java
(from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/DefaultLdapServerFactory.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/DefaultLdapServerFactory.java?p2=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/DefaultLdapServerFactory.java&p1=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/DefaultLdapServerFactory.java&r1=894082&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/DefaultLdapServerFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/DefaultLdapServerFactory.java
Mon Dec 28 13:18:24 2009
@@ -17,21 +17,61 @@
  *  under the License.
  *
  */
-package org.apache.directory.server.annotations;
+package org.apache.directory.server;
 
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.schema.SchemaPartition;
 import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.server.protocol.shared.transport.Transport;
 
+/**
+ * 
+ * TODO DefaultLdapServerFactory.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class DefaultLdapServerFactory
 {
     private LdapServer ldapServer;
     
+    /* The DirectoryService instance */
+    private DirectoryService directoryService = null;
+    
+    private Partition wrappedPartition = null;
+    
+    /** The Schema partition */
+    private SchemaPartition schemaPartition = null;
+    
+    /** The LDAP transport */
+    private Transport ldapTransport;
+    
+    /** The LDAPS transport */
+    private Transport ldapsTransport;
+    
+    
+    public DefaultLdapServerFactory() throws Exception
+    {
+    }
+
     void init()
     {
-        
+        if ( ( ldapServer != null ) && ( ldapServer.isStarted() ) )
+        {
+            return;
+        }
     }
+
     
     LdapServer getLdapServer()
     {
         return ldapServer;
     }
+    
+    
+    public void setDirectoryService( DirectoryService directoryService )
+    {
+        this.directoryService = directoryService;
+    }
 }

Copied: directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/LdapServerFactory.java
(from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerFactory.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/LdapServerFactory.java?p2=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/LdapServerFactory.java&p1=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerFactory.java&r1=894082&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/LdapServerFactory.java
Mon Dec 28 13:18:24 2009
@@ -17,10 +17,17 @@
  *  under the License.
  *
  */
-package org.apache.directory.server.annotations;
+package org.apache.directory.server;
 
 import org.apache.directory.server.ldap.LdapServer;
 
+/**
+ * 
+ * TODO LdapServerFactory.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface LdapServerFactory
 {
     void init();

Copied: directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java
(from r894082, directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java?p2=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java&p1=directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java&r1=894082&r2=894166&rev=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-annotations/src/main/java/org/apache/directory/server/annotations/LdapServerBuilder.java
Mon Dec 28 13:18:24 2009
@@ -26,6 +26,8 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.directory.server.DefaultLdapServerFactory;
+
 
 /**
  * A annotation used to define a LdapServer configuration. Many elements can be configured
:

Modified: directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=894166&r1=894165&r2=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Mon Dec 28 13:18:24 2009
@@ -43,10 +43,10 @@
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DefaultDirectoryServiceFactory;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.annotations.DSBuilder;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.ldap.handlers.bind.MechanismHandler;

Modified: directory/apacheds/branches/apacheds-schema/test-framework/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/test-framework/pom.xml?rev=894166&r1=894165&r2=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/test-framework/pom.xml (original)
+++ directory/apacheds/branches/apacheds-schema/test-framework/pom.xml Mon Dec 28 13:18:24
2009
@@ -71,11 +71,5 @@
       <artifactId>apacheds-avl-partition</artifactId>
       <version>${pom.version}</version>
     </dependency>  
-
-    <dependency>
-      <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core-builder</artifactId>
-      <version>${pom.version}</version>
-    </dependency>  
   </dependencies>
 </project>

Modified: directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=894166&r1=894165&r2=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
(original)
+++ directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Mon Dec 28 13:18:24 2009
@@ -27,13 +27,15 @@
 import javax.naming.NamingException;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.DefaultLdapServerFactory;
+import org.apache.directory.server.annotations.LdapServerBuilder;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.DirectoryServiceFactory;
-import org.apache.directory.server.core.DefaultDirectoryServiceFactory;
 import org.apache.directory.server.core.annotations.ApplyLdifFiles;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.DSBuilder;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
+import org.apache.directory.server.core.factory.DirectoryServiceFactory;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.junit.Ignore;
@@ -69,6 +71,9 @@
 
     /** The DSBuilder for this class, if any */
     private DSBuilder classDSBuilder;
+    
+    /** The LdapServerBuilder for this class, if any */
+    private LdapServerBuilder classLdapServerBuilder;
 
     /** The DirectoryService for this class, if any */
     private DirectoryService classService;
@@ -109,6 +114,9 @@
     {
         // Get the class DSBuilder, if any
         classDSBuilder = getDescription().getAnnotation( DSBuilder.class );
+        
+        // Get the LdapServerBuilder, if any
+        classLdapServerBuilder = getDescription().getAnnotation( LdapServerBuilder.class
);
 
         try
         {
@@ -229,36 +237,60 @@
                     applyLdifs( methodDescription, service );
                 }
             }
-            else if ( ( suite != null ) && ( suite.getSuiteDSBuilder() != null )
)
+            else if ( suite != null )
             {
-                // Use the suite DS. We now have to see if it's started
-                if ( suite.getSuiteService() != null )
+                if ( suite.getSuiteDSBuilder() != null )
                 {
-                    service = suite.getSuiteService();
-
-                    // get the current revision, we need it to revert the modifications
-                    revision = service.getChangeLog().getCurrentRevision();
-
-                    // Apply the method and class LDIFs, if the class
-                    // LDIFs haven't been applied yet
-                    if ( !classStarted )
+                    // Use the suite DS. We now have to see if it's started
+                    if ( suite.getSuiteService() != null )
+                    {
+                        service = suite.getSuiteService();
+    
+                        // get the current revision, we need it to revert the modifications
+                        revision = service.getChangeLog().getCurrentRevision();
+    
+                        // Apply the method and class LDIFs, if the class
+                        // LDIFs haven't been applied yet
+                        if ( !classStarted )
+                        {
+                            applyLdifs( classDescription, service );
+                        }
+    
+                        // And also apply the method's LDIFs
+                        applyLdifs( methodDescription, service );
+                    }
+                    else
                     {
+                        // Create the suite DS
+                        service = getDirectoryServer( suite.getSuiteDSBuilder() );
+                        
+                        suite.setSuiteService( service );
+    
+                        // apply the suite LDIFs first, these will never be reverted
+                        // during the running time of a test suite
+                        applyLdifs( suiteDescription, service );
+    
+                        // get the current revision, we need it to revert the modifications
+                        revision = service.getChangeLog().getCurrentRevision();
+    
+                        // Apply all the other LDIFs
                         applyLdifs( classDescription, service );
+                        applyLdifs( methodDescription, service );
                     }
-
-                    // And also apply the method's LDIFs
-                    applyLdifs( methodDescription, service );
                 }
-                else if ( suite.getSuiteDSBuilder() != null ) 
+                else
                 {
-                    service = getDirectoryServer( suite.getSuiteDSBuilder() );
+                    // Use the default DS
+                    DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
+                    dsf.init( "default" + UUID.randomUUID().toString() );
+                    service = dsf.getDirectoryService();
                     
-                    suite.setSuiteService( service );
-
+                    // same as in above else-if condition 
                     // apply the suite LDIFs first, these will never be reverted
                     // during the running time of a test suite
                     applyLdifs( suiteDescription, service );
 
+                    suite.setSuiteService( service );
                     // get the current revision, we need it to revert the modifications
                     revision = service.getChangeLog().getCurrentRevision();
 
@@ -267,7 +299,7 @@
                     applyLdifs( methodDescription, service );
                 }
             }
-            else if ( ( suite != null ) && ( suite.getSuiteService() == null ) )
+            else 
             {
                 // Use the default DS
                 DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
@@ -287,33 +319,6 @@
                 applyLdifs( classDescription, service );
                 applyLdifs( methodDescription, service );
             }
-            // FIXME the below else if is kind of supication as
-            // the above else if ( classDSBuilder != null ) condition
-            else if ( classService == null ) // finally just create a default DS for class
alone
-            {
-                // Use the default DS
-                DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
-                dsf.init( "class-" + UUID.randomUUID().toString() );
-                classService = dsf.getDirectoryService();
-                service = classService;
-                
-                // apply only class LDIFs, no need to apply suite LDIFs casue if this block
is executing
-                // means there is no suite associated with the class
-                applyLdifs( classDescription, service );
-
-                // get the current revision, we need it to revert the modifications
-                revision = service.getChangeLog().getCurrentRevision();
-
-                applyLdifs( methodDescription, service );
-            }
-            else if ( classService != null )
-            {
-                service = classService;
-                // get the current revision, we need it to revert the modifications
-                revision = service.getChangeLog().getCurrentRevision();
-
-                applyLdifs( methodDescription, service );
-            }
 
             // At this point, we know which service to use.
             // Inject it into the class
@@ -324,6 +329,14 @@
             field = getTestClass().getJavaClass().getField( IS_RUN_IN_SUITE_FIELD_NAME );
             field.set( getTestClass().getJavaClass(), suite != null );
 
+            // Last not least, see if we have to start a server
+            if ( suite.getSuiteLdapServerBuilder() != null )
+            {
+                LdapServerBuilder ldapServerBuilder = suite.getSuiteLdapServerBuilder();
+                
+                DefaultLdapServerFactory ldapServerFactory = (DefaultLdapServerFactory)ldapServerBuilder.factory().newInstance();
+                ldapServerFactory.setDirectoryService( service );
+            }
 
             super.runChild( method, notifier );
 

Modified: directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java?rev=894166&r1=894165&r2=894166&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
(original)
+++ directory/apacheds/branches/apacheds-schema/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
Mon Dec 28 13:18:24 2009
@@ -19,9 +19,11 @@
 package org.apache.directory.server.core.integ;
 
 
+import org.apache.directory.server.annotations.LdapServerBuilder;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.DSBuilder;
+import org.apache.directory.server.ldap.LdapServer;
 import org.junit.runner.Runner;
 import org.junit.runner.notification.RunNotifier;
 import org.junit.runners.Suite;
@@ -41,9 +43,16 @@
     /** The DSBuilder for this suite, if any */
     private DSBuilder suiteDSBuilder;
     
+    /** The LdapServerBuilder for this class, if any */
+    private LdapServerBuilder suiteLdapServerBuilder;
+
     /** The DirectoryService for this suite, if any */
     private DirectoryService suiteService;
     
+    /** The LdapServer for this class, if any */
+    private LdapServer suiteLdapServer;
+
+    
     /** The LDIFs entries for this suite */
     private ApplyLdifs suiteLdifs;
 
@@ -64,6 +73,7 @@
     {
         suiteDSBuilder = getDescription().getAnnotation( DSBuilder.class );
         suiteLdifs = getDescription().getAnnotation( ApplyLdifs.class );
+        suiteLdapServerBuilder = getDescription().getAnnotation( LdapServerBuilder.class
);
 
         // Store the suite into the class we will run
         ( ( FrameworkRunner ) runner ).setSuite( this );
@@ -107,4 +117,22 @@
     {
         return suiteLdifs;
     }
+
+
+    /**
+     * @return the suiteLdapServerBuilder
+     */
+    public LdapServerBuilder getSuiteLdapServerBuilder()
+    {
+        return suiteLdapServerBuilder;
+    }
+
+
+    /**
+     * @return the suiteLdapServer
+     */
+    public LdapServer getSuiteLdapServer()
+    {
+        return suiteLdapServer;
+    }
 }



Mime
View raw message