directory-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=893722&view=rev
Log:
Big refactoring of the unit tests

Added:
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DSBuilder.java
      - copied, changed from r893488, directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/TestLevelFactory.java
Removed:
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/TestLevelFactory.java
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
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuite.java

Added: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java?rev=893722&view=auto
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
(added)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
Thu Dec 24 09:34:13 2009
@@ -0,0 +1,9 @@
+
+package org.apache.directory.server.core.integ;
+
+import org.apache.directory.server.core.DirectoryService;
+
+public abstract class AbstractTestUnit
+{
+    public static DirectoryService service;
+}

Copied: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DSBuilder.java
(from r893488, directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/TestLevelFactory.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DSBuilder.java?p2=directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DSBuilder.java&p1=directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/TestLevelFactory.java&r1=893488&r2=893722&rev=893722&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/TestLevelFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DSBuilder.java
Thu Dec 24 09:34:13 2009
@@ -25,7 +25,11 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target( {ElementType.METHOD, ElementType.TYPE } )
-public @interface TestLevelFactory
+public @interface DSBuilder
 {
-    Class value();
+    /** The Factory to use to create a DirectoryService */
+    Class<?> factory();
+    
+    /** The DS name */
+    String name();
 }

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=893722&r1=893721&r2=893722&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
Thu Dec 24 09:34:13 2009
@@ -18,10 +18,11 @@
  */
 package org.apache.directory.server.core.integ;
 
-
 import org.apache.directory.server.core.DirectoryService;
 
 
+
+
 /**
  * A factory used to generate differently configured DirectoryService objects.
  * Since the DirectoryService itself is what is configured then a factory for
@@ -34,8 +35,8 @@
 public interface DirectoryServiceFactory
 {
 
-    void init() throws Exception;
+    void init( String name ) throws Exception;
 
 
-    DirectoryService newInstance() throws Exception;
+    DirectoryService getDirectoryService() throws Exception;
 }

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=893722&r1=893721&r2=893722&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
Thu Dec 24 09:34:13 2009
@@ -19,29 +19,8 @@
 package org.apache.directory.server.core.integ;
 
 
-import java.io.File;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-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.registries.SchemaLoader;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.directory.shared.schema.DefaultSchemaManager;
-import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.server.core.builder.DirectoryServiceBuilder;
 
 
 public class FrameworkDirectoryServiceFactory implements DirectoryServiceFactory
@@ -54,6 +33,7 @@
      */
     public static final DirectoryServiceFactory DEFAULT = new FrameworkDirectoryServiceFactory();
 
+    /*
     public DirectoryService newInstance() throws Exception
     {
         String workingDirectory = System.getProperty( "workingDirectory" );
@@ -64,28 +44,35 @@
             int targetPos = path.indexOf( "target" );
             workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work-" + UUID.randomUUID().toString();
         }
+        
+        System.out.println( "Starting DS " + workingDirectory );
 
         service = new DefaultDirectoryService();
         service.setWorkingDirectory( new File( workingDirectory ) );
 
         return service;
     }
+    */
 
     
-    public void init() throws Exception
+    public void init( String name ) throws Exception
     {
-        if ( service.isStarted() )
+        if ( ( service != null ) && (service.isStarted() ) )
         {
             return;
         }
 
+        DirectoryServiceBuilder builder = new DirectoryServiceBuilder();
+        builder.build( name );
+        
+        service = builder.getDirectoryService();
+        
+        /*
         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
@@ -136,6 +123,12 @@
         service.setSystemPartition( systemPartition );
 
         service.startup();
+        */
     }
 
+    
+    public DirectoryService getDirectoryService() throws Exception
+    {
+        return service;
+    }
 }

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=893722&r1=893721&r2=893722&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 09:34:13 2009
@@ -46,36 +46,63 @@
  */
 public class FrameworkRunner extends BlockJUnit4ClassRunner
 {
+    /** 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;
 
-    // WARN: static field, check when we move to concurrent execution
-    private static DirectoryService suiteDirectoryService;
+    private boolean started = false;
 
     private static AtomicInteger testCount = new AtomicInteger();
-
-    private static final Logger LOG = LoggerFactory.getLogger( FrameworkRunner.class );
     
+    /**
+     * Creates a new instance of FrameworkRunner.
+     *
+     * @param clazz
+     * @throws InitializationError
+     */
     public FrameworkRunner( Class<?> clazz ) throws InitializationError
     {
         super( clazz );
     }
 
+    
+    private DirectoryService getDirectoryServer( DSBuilder factory ) throws Exception
+    {
+        DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) factory.factory().newInstance();
+        dsf.init( factory.name() );
+        return dsf.getDirectoryService();
+    }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void run( final RunNotifier notifier )
     {
-        TestLevelFactory fac = getDescription().getAnnotation( TestLevelFactory.class );
+        // Get the class DSBuilder, if any
+        classDSBuilder = getDescription().getAnnotation( DSBuilder.class );
+        
         try
         {
-            Field field = getTestClass().getJavaClass().getDeclaredField( DIRECTORYSERVICE_FIELD_NAME
);
-
-            DirectoryService dirService = null;
+            /*
             if ( fac != null )
             {
-                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) fac.value().newInstance();
-                dirService = dsf.newInstance();
+                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) fac.factory().newInstance();
                 dsf.init();
+                dirService = dsf.getDirectoryService();
                 
                 if ( getSuite() != null )
                 {
@@ -86,12 +113,12 @@
             else if( getSuite() == null ) // for a class without a @Factory and running standalone
without a suite
             {
                 DirectoryServiceFactory dsf = FrameworkDirectoryServiceFactory.DEFAULT;
-                dirService = dsf.newInstance();
                 dsf.init();
+                dirService = dsf.getDirectoryService();
             }
             else if( suiteDirectoryService == null ) // set the parent suit's factory value
             {
-                TestLevelFactory suitFactory = getSuite().getDescription().getAnnotation(
TestLevelFactory.class );
+                DSBuilder suitFactory = getSuite().getDescription().getAnnotation( DSBuilder.class
);
                 
                 DirectoryServiceFactory dsf;
                 if ( suitFactory == null )
@@ -101,13 +128,13 @@
                 }
                 else
                 {
-                    dsf = ( DirectoryServiceFactory ) suitFactory.value().newInstance();
+                    dsf = ( DirectoryServiceFactory ) suitFactory.factory().newInstance();
                 }
 
-                suiteDirectoryService = dsf.newInstance();
+                dsf.init();
+                suiteDirectoryService = dsf.getDirectoryService();
                 dirService = suiteDirectoryService;
                 
-                dsf.init();
                 applyLdifs( getSuite().getDescription(), suiteDirectoryService );
             }
             else
@@ -120,9 +147,10 @@
             applyLdifs( getDescription(), dirService );
             
             field.set( getTestClass().getJavaClass(), dirService );
-
-            super.run( notifier );
+            */
             
+            super.run( notifier );
+            /*
             // clean the DS ONLY if it is class level DS
             if( dirService != suiteDirectoryService )
             {
@@ -149,6 +177,7 @@
                     suiteDirectoryService = null;
                 }
             }
+            */
         }
         catch ( Exception e )
         {
@@ -158,56 +187,145 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected void runChild( FrameworkMethod method, RunNotifier notifier )
     {
         testCount.incrementAndGet();
         
-        Description description = describeChild( method );
+        // Don't run the test if the @Ignored annotation is used
         if ( method.getAnnotation( Ignore.class ) != null )
         {
+            Description description = describeChild( method );
             notifier.fireTestIgnored( description );
             return;
         }
 
+        // Get the applyLdifs for each level ( the class
+        ApplyLdifs suiteLdifs = suite.getSuiteLdifs();
+        ApplyLdifs classLdifs = getDescription().getAnnotation( ApplyLdifs.class );
+        ApplyLdifs methodLdifs = method.getAnnotation( ApplyLdifs.class );
+
+        // Ok, ready to run the test
         try
         {
-            Field field = getTestClass().getJavaClass().getDeclaredField( DIRECTORYSERVICE_FIELD_NAME
);
+            DirectoryService service = null;
+            DirectoryService methodDS = null;
+            long revision = 0L;
 
-            DirectoryService classDirService = ( DirectoryService ) field.get( getTestClass().getJavaClass()
);
-
-            long revision = classDirService.getChangeLog().getCurrentRevision();
+            // First check if this method has a dedicated DSBuilder
+            DSBuilder methodDSBuilder = method.getAnnotation( DSBuilder.class );
             
-            TestLevelFactory fac = description.getAnnotation( TestLevelFactory.class );
+            if ( methodDSBuilder != null )
+            {
+                // yes : instantiate the factory for this method then
+                service = getDirectoryServer( methodDSBuilder );
+                methodDS = service;
 
-            DirectoryService methodDirService = null;
-            if ( fac != null )
+                // 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 ) 
             {
-                DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) fac.value().newInstance();
-                methodDirService = dsf.newInstance();
+                // Use the class DS. We now have to see if it's started
+                if ( classService != null )
+                {
+                    service = classService;
 
-                dsf.init();
-                applyLdifs( description, methodDirService );
-                field.set( getTestClass().getJavaClass(), methodDirService );
+                    // get the current revision, we need it to revert the modifications
+                    revision = service.getChangeLog().getCurrentRevision();
+
+                    // Only apply the method LDIF, the class LDIFs have
+                    // already been applied
+                    applyLdifs( methodLdifs, service );
+                }
+                else
+                {
+                    // let's instantiate this class DS
+                    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 );
+                    applyLdifs( methodLdifs, service );
+                }
             }
-            else
+            else if ( suite.getSuiteDSBuilder() != null )
             {
-                applyLdifs( description, classDirService );
+                // 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 ( !started )
+                    {
+                        applyLdifs( classLdifs, service );
+                    }
+                    
+                    // And also apply the method's LDIFs
+                    applyLdifs( methodLdifs, service );
+                }
+                else
+                {
+                    service = getDirectoryServer( suite.getSuiteDSBuilder() ) ;
+                    suite.setSuiteService( 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
+            {
+                // Use the default DS
+                suite.setSuiteService( getDirectoryServer( suite.getSuiteDSBuilder() ) );
+
+                // 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 );
+            }
+
+            // At this point, we know which service to use.
+            // Inject it into the class
+            Field field = getTestClass().getJavaClass().getField( DIRECTORYSERVICE_FIELD_NAME
);
+            field.set( getTestClass().getJavaClass(), service );
+
             super.runChild( method, notifier );
 
-            // reset the parent's value
-            field.set( getTestClass().getJavaClass(), classDirService );
-            
-            if( methodDirService != null )
+            // Cleanup the methodDS if it has been created
+            if( methodDS != null )
             {
-                methodDirService.shutdown();
-                FileUtils.deleteDirectory( methodDirService.getWorkingDirectory() );
+                methodDS.shutdown();
+                FileUtils.deleteDirectory( methodDS.getWorkingDirectory() );
             }
             else
             {
-                classDirService.revert( revision );
+                // We use a class or suite DS, just revert the current test's modifications
+                service.revert( revision );
             }
         }
         catch ( Exception e )
@@ -215,7 +333,8 @@
             LOG.error( "Failed to run the method {}", method );
             LOG.error( "", e );
         }
-
+        
+        started = true;
     }
 
 
@@ -231,13 +350,14 @@
     }
 
 
-    private void applyLdifs( Description description, DirectoryService service ) throws Exception
+    /**
+     * Apply the LDIF entries to the given service
+     */
+    private void applyLdifs( ApplyLdifs applyLdifs, DirectoryService service ) throws Exception
     {
-        ApplyLdifs annotation = description.getAnnotation( ApplyLdifs.class );
-
-        if ( ( annotation != null ) && ( annotation.value() != null ) )
+        if ( ( applyLdifs != null ) && ( applyLdifs.value() != null ) )
         {
-            String[] ldifs = annotation.value();
+            String[] ldifs = applyLdifs.value();
 
             for ( String s : ldifs )
             {

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=893722&r1=893721&r2=893722&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 09:34:13 2009
@@ -19,6 +19,7 @@
 package org.apache.directory.server.core.integ;
 
 
+import org.apache.directory.server.core.DirectoryService;
 import org.junit.runner.Runner;
 import org.junit.runner.notification.RunNotifier;
 import org.junit.runners.Suite;
@@ -32,18 +33,74 @@
  */
 public class FrameworkSuite extends Suite
 {
-
+    /** The DSBuilder for this suite, if any */
+    private DSBuilder suiteDSBuilder;
+    
+    /** The DirectoryService for this suite, if any */
+    private DirectoryService suiteService;
+    
+    /** The LDIFs entries for this suite */
+    private ApplyLdifs suiteLdifs;
+
+    /**
+     * Creates a new instance of FrameworkSuite.
+     *
+     * @param clazz
+     * @param builder
+     * @throws InitializationError
+     */
     public FrameworkSuite( Class<?> clazz, RunnerBuilder builder ) throws InitializationError
     {
         super( clazz, builder );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected void runChild( Runner runner, RunNotifier notifier )
     {
+        suiteDSBuilder = getDescription().getAnnotation( DSBuilder.class );
+        suiteLdifs = getDescription().getAnnotation( ApplyLdifs.class );
+
         ( ( FrameworkRunner ) runner ).setSuite( this );
         super.runChild( runner, notifier );
     }
 
+
+    /**
+     * @return the suiteDSBuilder
+     */
+    public DSBuilder getSuiteDSBuilder()
+    {
+        return suiteDSBuilder;
+    }
+
+
+    /**
+     * @return the suiteService
+     */
+    public DirectoryService getSuiteService()
+    {
+        return suiteService;
+    }
+    
+    
+    /**
+     * @param suiteService the suiteService to set
+     */
+    public void setSuiteService( DirectoryService suiteService )
+    {
+        this.suiteService = suiteService;
+    }
+    
+    
+    /**
+     * @return the suiteLdifs
+     */
+    public ApplyLdifs getSuiteLdifs()
+    {
+        return suiteLdifs;
+    }
 }

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java?rev=893722&r1=893721&r2=893722&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
Thu Dec 24 09:34:13 2009
@@ -22,14 +22,13 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 
 @RunWith(FrameworkRunner.class)
-@TestLevelFactory(FrameworkDirectoryServiceFactory.class)
+@DSBuilder( factory=FrameworkDirectoryServiceFactory.class, name="Class" )
 @ApplyLdifs(
     {
         "dn: cn=testClassA,ou=system\n" + 
@@ -37,14 +36,10 @@
         "cn: testClassA\n" + 
         "sn: sn_testClassA\n"
     })
-public class TestClassA
+public class TestClassA extends AbstractTestUnit
 {
-
-    public static DirectoryService service;
-
-
     @Test
-    @TestLevelFactory(FrameworkDirectoryServiceFactory.class)
+    @DSBuilder( factory=FrameworkDirectoryServiceFactory.class, name="test" )
     @ApplyLdifs(
         {
             "dn: cn=testMethodA,ou=system\n" + 
@@ -54,7 +49,8 @@
         })
     public void testWithFactoryAnnotation() throws Exception
     {
-        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testClassA,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassA,ou=system"
) ) );
         assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testMethodA,ou=system"
) ) );
     }
 
@@ -69,6 +65,7 @@
         })
     public void testWithoutFactoryAnnotation() throws Exception
     {
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
         assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassA,ou=system"
) ) );
         assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testMethodA,ou=system"
) ) );
         assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testMethodWithApplyLdif,ou=system"
) ) );

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java?rev=893722&r1=893721&r2=893722&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
Thu Dec 24 09:34:13 2009
@@ -19,10 +19,8 @@
 package org.apache.directory.server.core.integ;
 
 
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -35,17 +33,15 @@
         "cn: testClassB\n" + 
         "sn: sn_testClassB\n"
     })
-public class TestClassB
+public class TestClassB extends AbstractTestUnit
 {
 
-    public static DirectoryService service;
-    
     @Test
-    @TestLevelFactory( FrameworkDirectoryServiceFactory.class )
+    @DSBuilder( factory=FrameworkDirectoryServiceFactory.class, name="test" )
     public void testWithFactoryAnnotation() throws Exception
     {
-        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
-        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testClassB,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassB,ou=system"
) ) );
     }
     
     
@@ -56,6 +52,7 @@
         // commenting this to make maven report test success, uncomment in an IDE
         // while running the TestSuite
         // assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
         assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassB,ou=system"
) ) );
     }
 }

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java?rev=893722&r1=893721&r2=893722&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
Thu Dec 24 09:34:13 2009
@@ -22,7 +22,6 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -35,15 +34,12 @@
         "cn: testClassC\n" + 
         "sn: sn_testClassC\n"
     })
-public class TestClassC
+public class TestClassC extends AbstractTestUnit
 {
-
-    public static DirectoryService service;
-
     @Test
     public void testWithoutMethodOrClassLevelFactory() throws Exception
     {
-        //assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
         assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassC,ou=system"
) ) );
         
         // the below DN will be injected in TestClassB when ran as suite, but that DN

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuite.java?rev=893722&r1=893721&r2=893722&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuite.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuite.java
Thu Dec 24 09:34:13 2009
@@ -23,7 +23,7 @@
 
 @RunWith( FrameworkSuite.class )
 @Suite.SuiteClasses({ TestClassA.class, TestClassB.class, TestClassC.class })
-@TestLevelFactory(FrameworkDirectoryServiceFactory.class)
+@DSBuilder(factory = FrameworkDirectoryServiceFactory.class, name = "SuiteDS")
 @ApplyLdifs(
     {
         "dn: cn=testSuite,ou=system\n" + 



Mime
View raw message