directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r893256 - in /directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ: DirectoryServiceFactory.java FrameworkDirectoryServiceFactory.java FrameworkRunner.java
Date Tue, 22 Dec 2009 18:15:50 GMT
Author: kayyagari
Date: Tue Dec 22 18:15:49 2009
New Revision: 893256

URL: http://svn.apache.org/viewvc?rev=893256&view=rev
Log:
moved the init method to the Factory classes

Modified:
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java?rev=893256&r1=893255&r2=893256&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
Tue Dec 22 18:15:49 2009
@@ -84,6 +84,11 @@
 
         public void init() throws Exception
         {
+            if ( service.isStarted() )
+            {
+                return;
+            }
+
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
 
             // Init the LdifPartition
@@ -96,7 +101,11 @@
             // Extract the schema on disk (a brand new one) and load the registries
             File schemaRepository = new File( workingDirectory, "schema" );
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
+            
+            long t0 = System.currentTimeMillis();
             extractor.extractOrCopy();
+            long t1 = System.currentTimeMillis();
+            System.out.println( "Delta = " + ( t1 - t0 ) );
 
             schemaPartition.setWrappedPartition( ldifPartition );
 
@@ -107,7 +116,11 @@
             // 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
+            long t2 = System.currentTimeMillis();
             boolean loaded = schemaManager.loadAllEnabled();
+            long t3 = System.currentTimeMillis();
+            System.out.println( "Delta load = " + ( t3 - t2 ) );
+            
             schemaPartition.setSchemaManager( schemaManager );
 
             List<Throwable> errors = schemaManager.getErrors();
@@ -137,6 +150,8 @@
             ( ( JdbmPartition ) systemPartition ).setIndexedAttributes( indexedAttrs );
 
             service.setSystemPartition( systemPartition );
+
+            service.startup();
         }
     };
 

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java?rev=893256&r1=893255&r2=893256&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
Tue Dec 22 18:15:49 2009
@@ -48,9 +48,14 @@
         return service;
     }
 
-
+    
     public void init() throws Exception
     {
+        if ( service.isStarted() )
+        {
+            return;
+        }
+
         SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
 
         // Init the LdifPartition
@@ -63,7 +68,11 @@
         // Extract the schema on disk (a brand new one) and load the registries
         File schemaRepository = new File( workingDirectory, "schema" );
         SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
+        
+        long t0 = System.currentTimeMillis();
         extractor.extractOrCopy();
+        long t1 = System.currentTimeMillis();
+        System.out.println( "Delta = " + ( t1 - t0 ) );
 
         schemaPartition.setWrappedPartition( ldifPartition );
 
@@ -71,7 +80,15 @@
         SchemaManager schemaManager = new DefaultSchemaManager( loader );
         service.setSchemaManager( schemaManager );
 
-        schemaManager.loadAllEnabled();
+        // 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
+        long t2 = System.currentTimeMillis();
+        boolean loaded = schemaManager.loadAllEnabled();
+        long t3 = System.currentTimeMillis();
+        System.out.println( "Delta load = " + ( t3 - t2 ) );
+        
+        schemaPartition.setSchemaManager( schemaManager );
 
         List<Throwable> errors = schemaManager.getErrors();
 
@@ -80,8 +97,6 @@
             throw new Exception( "Schema load failed : " + ExceptionUtils.printErrors( errors
) );
         }
 
-        schemaPartition.setSchemaManager( schemaManager );
-
         service.getChangeLog().setEnabled( true );
 
         // change the working directory to something that is unique
@@ -102,6 +117,8 @@
         ( ( JdbmPartition ) systemPartition ).setIndexedAttributes( indexedAttrs );
 
         service.setSystemPartition( systemPartition );
-        service.setAccessControlEnabled( false );
+
+        service.startup();
     }
+
 }

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=893256&r1=893255&r2=893256&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Tue Dec 22 18:15:49 2009
@@ -87,11 +87,10 @@
             Object val = null;
             if ( fac != null )
             {
-                val = fac.value().newInstance();
-                val = ( ( DirectoryServiceFactory ) val ).newInstance();
+                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) fac.value().newInstance();
+                val = dsf.newInstance();
+                dsf.init();
                 
-                init( ( DirectoryService ) val );
-
                 if ( getSuite() != null )
                 {
                     applyLdifs( getSuite().getDescription(), ( DirectoryService ) val );
@@ -100,10 +99,9 @@
             }
             else if( getSuite() == null ) // for a class without a @Factory and running standalone
without a suite
             {
-                val = DirectoryServiceFactory.DEFAULT;
-                val = ( ( DirectoryServiceFactory ) val ).newInstance();
-                
-                init( ( DirectoryService ) val );
+                DirectoryServiceFactory dsf = DirectoryServiceFactory.DEFAULT;
+                val = dsf.newInstance();
+                dsf.init();
             }
             else if( suiteDirectoryService == null ) // set the parent suit's factory value
             {
@@ -119,11 +117,11 @@
                     val = suitFactory.value().newInstance();
                 }
 
-                val = ( ( DirectoryServiceFactory ) val ).newInstance();
-                suiteDirectoryService = ( DirectoryService ) val;
+                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) val;
+                suiteDirectoryService = dsf.newInstance();
+                val = suiteDirectoryService;
                 
-                init( suiteDirectoryService );
-
+                dsf.init();
                 applyLdifs( getSuite().getDescription(), suiteDirectoryService );
             }
             else
@@ -168,79 +166,6 @@
     }
 
 
-    public void init( DirectoryService service ) throws Exception
-    {
-        if ( service.isStarted() )
-        {
-            return;
-        }
-
-        SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-
-        // Init the LdifPartition
-        LdifPartition ldifPartition = new LdifPartition();
-
-        String workingDirectory = service.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 SchemaLdifExtractor( new File( workingDirectory
) );
-        
-        long t0 = System.currentTimeMillis();
-        extractor.extractOrCopy();
-        long t1 = System.currentTimeMillis();
-        System.out.println( "Delta = " + ( t1 - t0 ) );
-
-        schemaPartition.setWrappedPartition( ldifPartition );
-
-        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
-        SchemaManager schemaManager = new DefaultSchemaManager( loader );
-        service.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
-        long t2 = System.currentTimeMillis();
-        boolean loaded = schemaManager.loadAllEnabled();
-        long t3 = System.currentTimeMillis();
-        System.out.println( "Delta load = " + ( t3 - t2 ) );
-        
-        schemaPartition.setSchemaManager( schemaManager );
-
-        List<Throwable> errors = schemaManager.getErrors();
-
-        if ( errors.size() != 0 )
-        {
-            throw new Exception( "Schema load failed : " + ExceptionUtils.printErrors( errors
) );
-        }
-
-        service.getChangeLog().setEnabled( true );
-
-        // 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( schemaManager );
-        ( ( JdbmPartition ) systemPartition ).setPartitionDir( new File( workingDirectory,
"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 );
-
-        service.setSystemPartition( systemPartition );
-
-        service.startup();
-    }
-
-
     @Override
     protected void runChild( FrameworkMethod method, RunNotifier notifier )
     {
@@ -264,10 +189,12 @@
             Object childDirServiceObj = null;
             if ( fac != null )
             {
-                childDirServiceObj = ( ( DirectoryServiceFactory ) fac.value().newInstance()
).newInstance();
+                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) fac.value().newInstance();
+                childDirServiceObj = dsf.newInstance();
 
                 DirectoryService service = ( DirectoryService ) childDirServiceObj;
-                init( service );
+                
+                dsf.init();
                 // TODO only applying is present, revert should be added
                 applyLdifs( description, service );
                 field.set( getTestClass().getJavaClass(), childDirServiceObj );



Mime
View raw message