directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r893743 - in /directory/sandbox/kayyagari/integ-test-framework: pom.xml src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Date Thu, 24 Dec 2009 12:48:53 GMT
Author: kayyagari
Date: Thu Dec 24 12:48:52 2009
New Revision: 893743

URL: http://svn.apache.org/viewvc?rev=893743&view=rev
Log:
o applied various fixes and improvements
o added dependency on core-builder

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

Modified: directory/sandbox/kayyagari/integ-test-framework/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/pom.xml?rev=893743&r1=893742&r2=893743&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/pom.xml (original)
+++ directory/sandbox/kayyagari/integ-test-framework/pom.xml Thu Dec 24 12:48:52 2009
@@ -56,5 +56,10 @@
       <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/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=893743&r1=893742&r2=893743&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
Thu Dec 24 12:48:52 2009
@@ -21,6 +21,7 @@
 
 import java.lang.reflect.Field;
 import java.util.List;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.naming.NamingException;
@@ -48,25 +49,23 @@
 {
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( FrameworkRunner.class );
-    
+
     private static final String DIRECTORYSERVICE_FIELD_NAME = "service";
-    
+
     /** The suite this class depend on, if any */
     private FrameworkSuite suite;
-    
+
     /** The DSBuilder for this class, if any */
     private DSBuilder classDSBuilder;
-    
+
     /** The DirectoryService for this class, if any */
     private DirectoryService classService;
-    
-    /** The LDIFs entries for this class */
-    private ApplyLdifs classLdifs;
 
     private boolean started = false;
 
     private static AtomicInteger testCount = new AtomicInteger();
-    
+
+
     /**
      * Creates a new instance of FrameworkRunner.
      *
@@ -78,7 +77,7 @@
         super( clazz );
     }
 
-    
+
     private DirectoryService getDirectoryServer( DSBuilder factory ) throws Exception
     {
         DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) factory.factory().newInstance();
@@ -86,6 +85,7 @@
         return dsf.getDirectoryService();
     }
 
+
     /**
      * {@inheritDoc}
      */
@@ -94,7 +94,7 @@
     {
         // Get the class DSBuilder, if any
         classDSBuilder = getDescription().getAnnotation( DSBuilder.class );
-        
+
         try
         {
             /*
@@ -148,8 +148,37 @@
             
             field.set( getTestClass().getJavaClass(), dirService );
             */
-            
+
             super.run( notifier );
+            
+            // cleanup classService if it is not the same as suite service or
+            // it is not null (this second case happens in the absence of a suite)
+            if( suite != null ) 
+            {
+                if( ( classService != null ) && ( classService != suite.getSuiteService()
) )
+                {
+                    classService.shutdown();
+                    FileUtils.deleteDirectory( classService.getWorkingDirectory() );
+                }
+                else if( testCount.get() == suite.testCount() )
+                {
+                    suite.getSuiteService().shutdown();
+                    FileUtils.deleteDirectory( suite.getSuiteService().getWorkingDirectory()
);
+                    testCount.set( 0 );
+                }
+            }
+            else if( classService != null )
+            {
+                classService.shutdown();
+                FileUtils.deleteDirectory( classService.getWorkingDirectory() );
+            }
+            
+            
+            if( suite == null )
+            {
+                testCount.set( 0 );
+            }
+            
             /*
             // clean the DS ONLY if it is class level DS
             if( dirService != suiteDirectoryService )
@@ -183,6 +212,7 @@
         {
             LOG.error( "Failed to run the class {}", getTestClass().getName() );
             LOG.error( "", e );
+            e.printStackTrace();
         }
     }
 
@@ -194,7 +224,7 @@
     protected void runChild( FrameworkMethod method, RunNotifier notifier )
     {
         testCount.incrementAndGet();
-        
+
         // Don't run the test if the @Ignored annotation is used
         if ( method.getAnnotation( Ignore.class ) != null )
         {
@@ -204,7 +234,12 @@
         }
 
         // Get the applyLdifs for each level ( the class
-        ApplyLdifs suiteLdifs = suite.getSuiteLdifs();
+        ApplyLdifs suiteLdifs = null;
+        if ( suite != null )
+        {
+            suiteLdifs = suite.getSuiteLdifs();
+        }
+        
         ApplyLdifs classLdifs = getDescription().getAnnotation( ApplyLdifs.class );
         ApplyLdifs methodLdifs = method.getAnnotation( ApplyLdifs.class );
 
@@ -217,22 +252,19 @@
 
             // First check if this method has a dedicated DSBuilder
             DSBuilder methodDSBuilder = method.getAnnotation( DSBuilder.class );
-            
+
             if ( methodDSBuilder != null )
             {
                 // yes : instantiate the factory for this method then
                 service = getDirectoryServer( methodDSBuilder );
                 methodDS = service;
 
-                // get the current revision, we need it to revert the modifications
-                revision = service.getChangeLog().getCurrentRevision();
-                
                 // Apply all the LDIFs
                 applyLdifs( suiteLdifs, service );
                 applyLdifs( classLdifs, service );
                 applyLdifs( methodLdifs, service );
             }
-            else if ( classDSBuilder != null ) 
+            else if ( classDSBuilder != null )
             {
                 // Use the class DS. We now have to see if it's started
                 if ( classService != null )
@@ -242,7 +274,7 @@
                     // get the current revision, we need it to revert the modifications
                     revision = service.getChangeLog().getCurrentRevision();
 
-                    // Only apply the method LDIF, the class LDIFs have
+                    // Only apply the method LDIF, the class and suite(if present) LDIFs
have
                     // already been applied
                     applyLdifs( methodLdifs, service );
                 }
@@ -252,16 +284,17 @@
                     classService = getDirectoryServer( classDSBuilder );
                     service = classService;
 
-                    // get the current revision, we need it to revert the modifications
-                    revision = service.getChangeLog().getCurrentRevision();
-
                     // Apply all the LDIFs
                     applyLdifs( suiteLdifs, service );
                     applyLdifs( classLdifs, service );
+
+                    // get the current revision, we need it to revert the modifications
+                    revision = service.getChangeLog().getCurrentRevision();
+                 
                     applyLdifs( methodLdifs, service );
                 }
             }
-            else if ( suite.getSuiteDSBuilder() != null )
+            else if ( ( suite != null ) && ( suite.getSuiteDSBuilder() != null )
)
             {
                 // Use the suite DS. We now have to see if it's started
                 if ( suite.getSuiteService() != null )
@@ -277,35 +310,74 @@
                     {
                         applyLdifs( classLdifs, service );
                     }
-                    
+
                     // And also apply the method's LDIFs
                     applyLdifs( methodLdifs, service );
                 }
-                else
+                else if ( suite.getSuiteDSBuilder() != null ) 
                 {
-                    service = getDirectoryServer( suite.getSuiteDSBuilder() ) ;
+                    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( suiteLdifs, service );
+
                     // get the current revision, we need it to revert the modifications
                     revision = service.getChangeLog().getCurrentRevision();
 
-                    // Apply all the LDIFs
-                    applyLdifs( suiteLdifs, service );
+                    // Apply all the other LDIFs
                     applyLdifs( classLdifs, service );
                     applyLdifs( methodLdifs, service );
                 }
             }
-            else
+            else if( suite != null )
             {
                 // Use the default DS
-                suite.setSuiteService( getDirectoryServer( suite.getSuiteDSBuilder() ) );
+                DirectoryServiceFactory dsf = FrameworkDirectoryServiceFactory.DEFAULT;
+                dsf.init( "suite-" + 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( suiteLdifs, service );
 
                 // get the current revision, we need it to revert the modifications
                 revision = service.getChangeLog().getCurrentRevision();
 
-                // Apply all the LDIFs
-                applyLdifs( suiteLdifs, service );
+                // Apply all the other LDIFs
+                applyLdifs( classLdifs, service );
+                applyLdifs( methodLdifs, 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 = FrameworkDirectoryServiceFactory.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( classLdifs, service );
+
+                // get the current revision, we need it to revert the modifications
+                revision = service.getChangeLog().getCurrentRevision();
+
+                applyLdifs( methodLdifs, service );
+            }
+            else if ( classService != null )
+            {
+                service = classService;
+                // get the current revision, we need it to revert the modifications
+                revision = service.getChangeLog().getCurrentRevision();
+
                 applyLdifs( methodLdifs, service );
             }
 
@@ -317,12 +389,12 @@
             super.runChild( method, notifier );
 
             // Cleanup the methodDS if it has been created
-            if( methodDS != null )
+            if ( methodDS != null )
             {
                 methodDS.shutdown();
                 FileUtils.deleteDirectory( methodDS.getWorkingDirectory() );
             }
-            else
+            else if( revision < service.getChangeLog().getCurrentRevision() )
             {
                 // We use a class or suite DS, just revert the current test's modifications
                 service.revert( revision );
@@ -332,8 +404,9 @@
         {
             LOG.error( "Failed to run the method {}", method );
             LOG.error( "", e );
+            e.printStackTrace();
         }
-        
+
         started = true;
     }
 



Mime
View raw message