directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r893761 - in /directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ: FrameworkRunner.java FrameworkSuite.java
Date Thu, 24 Dec 2009 13:47:52 GMT
Author: elecharny
Date: Thu Dec 24 13:47:51 2009
New Revision: 893761

URL: http://svn.apache.org/viewvc?rev=893761&view=rev
Log:
Some more cleanup

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

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=893761&r1=893760&r2=893761&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 13:47:51 2009
@@ -42,6 +42,9 @@
 
 
 /**
+ * The class responsible for running all the tests. t read the annotations, 
+ * initialize the DirectoryService, call each test and do the cleanup at the end.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -50,6 +53,7 @@
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( FrameworkRunner.class );
 
+    /** The 'service' field in the run tests */
     private static final String DIRECTORYSERVICE_FIELD_NAME = "service";
 
     /** The suite this class depend on, if any */
@@ -61,16 +65,15 @@
     /** The DirectoryService for this class, if any */
     private DirectoryService classService;
 
-    private boolean started = false;
+    /** A flag set to true when the class has been started */
+    private boolean classStarted = false;
 
+    /** Is it usefull ? */
     private static AtomicInteger testCount = new AtomicInteger();
 
 
     /**
      * Creates a new instance of FrameworkRunner.
-     *
-     * @param clazz
-     * @throws InitializationError
      */
     public FrameworkRunner( Class<?> clazz ) throws InitializationError
     {
@@ -78,10 +81,14 @@
     }
 
 
+    /**
+     * Instantiate the DirectoryService we found in an annotation
+     */
     private DirectoryService getDirectoryServer( DSBuilder factory ) throws Exception
     {
         DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) factory.factory().newInstance();
         dsf.init( factory.name() );
+        
         return dsf.getDirectoryService();
     }
 
@@ -103,26 +110,26 @@
             // it is not null (this second case happens in the absence of a suite)
             if( suite != null ) 
             {
-                if( ( classService != null ) && ( classService != suite.getSuiteService()
) )
+                if ( ( classService != null ) && ( classService != suite.getSuiteService()
) )
                 {
                     classService.shutdown();
                     FileUtils.deleteDirectory( classService.getWorkingDirectory() );
                 }
-                else if( testCount.get() == suite.testCount() )
+                else if ( testCount.get() == suite.testCount() )
                 {
                     suite.getSuiteService().shutdown();
                     FileUtils.deleteDirectory( suite.getSuiteService().getWorkingDirectory()
);
                     testCount.set( 0 );
                 }
             }
-            else if( classService != null )
+            else if ( classService != null )
             {
                 classService.shutdown();
                 FileUtils.deleteDirectory( classService.getWorkingDirectory() );
             }
             
             
-            if( suite == null )
+            if ( suite == null )
             {
                 testCount.set( 0 );
             }
@@ -130,7 +137,7 @@
         catch ( Exception e )
         {
             LOG.error( "Failed to run the class {}", getTestClass().getName() );
-            LOG.error( "", e );
+            LOG.error( e.getMessage() );
             e.printStackTrace();
         }
     }
@@ -152,8 +159,9 @@
             return;
         }
 
-        // Get the applyLdifs for each level ( the class
+        // Get the applyLdifs for each level
         ApplyLdifs suiteLdifs = null;
+        
         if ( suite != null )
         {
             suiteLdifs = suite.getSuiteLdifs();
@@ -225,7 +233,7 @@
 
                     // Apply the method and class LDIFs, if the class
                     // LDIFs haven't been applied yet
-                    if ( !started )
+                    if ( !classStarted )
                     {
                         applyLdifs( classLdifs, service );
                     }
@@ -251,7 +259,7 @@
                     applyLdifs( methodLdifs, service );
                 }
             }
-            else if( suite != null && suite.getSuiteService() == null )
+            else if ( ( suite != null ) && ( suite.getSuiteService() == null ) )
             {
                 // Use the default DS
                 DirectoryServiceFactory dsf = FrameworkDirectoryServiceFactory.DEFAULT;
@@ -273,7 +281,7 @@
             }
             // 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
+            else if ( classService == null ) // finally just create a default DS for class
alone
             {
                 // Use the default DS
                 DirectoryServiceFactory dsf = FrameworkDirectoryServiceFactory.DEFAULT;
@@ -325,7 +333,7 @@
             e.printStackTrace();
         }
 
-        started = true;
+        classStarted = true;
     }
 
 
@@ -358,7 +366,6 @@
     }
 
 
-    // copied from IntegrationUtils
     /**
      * Inject an ldif String into the server. DN must be relative to the
      * root.

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java?rev=893761&r1=893760&r2=893761&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
Thu Dec 24 13:47:51 2009
@@ -28,6 +28,9 @@
 
 
 /**
+ * A class to read and store the Suite's annotations. It's called when we start
+ * running a Suite, and will call all the classes contained in the suite.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -44,10 +47,6 @@
 
     /**
      * Creates a new instance of FrameworkSuite.
-     *
-     * @param clazz
-     * @param builder
-     * @throws InitializationError
      */
     public FrameworkSuite( Class<?> clazz, RunnerBuilder builder ) throws InitializationError
     {
@@ -64,7 +63,10 @@
         suiteDSBuilder = getDescription().getAnnotation( DSBuilder.class );
         suiteLdifs = getDescription().getAnnotation( ApplyLdifs.class );
 
+        // Store the suite into the class we will run
         ( ( FrameworkRunner ) runner ).setSuite( this );
+        
+        // Now, call the class containing the tests
         super.runChild( runner, notifier );
     }
 



Mime
View raw message