directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r893139 - 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 Tue, 22 Dec 2009 11:18:19 GMT
Author: kayyagari
Date: Tue Dec 22 11:18:16 2009
New Revision: 893139

URL: http://svn.apache.org/viewvc?rev=893139&view=rev
Log:
o fixed the way a suite level DirectoryService is instantiated and maintained for all classes
o added a test class to test the above fix

Added:
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
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/test/java/org/apache/directory/server/core/integ/TestSuite.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=893139&r1=893138&r2=893139&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 11:18:16 2009
@@ -62,6 +62,8 @@
     private static final String DIRECTORYSERVICE_FIELD_NAME = "service";
     private FrameworkSuite suite;
 
+    // WARN: static field, check when we move to concurrent execution
+    private static DirectoryService suiteDirectoryService;
 
     public FrameworkRunner( Class<?> clazz ) throws InitializationError
     {
@@ -82,8 +84,16 @@
             {
                 val = fac.value().newInstance();
                 val = ( ( DirectoryServiceFactory ) val ).newInstance();
+                
+                init( ( DirectoryService ) val );
+
+                if ( getSuite() != null )
+                {
+                    applyLdifs( getSuite().getDescription(), ( DirectoryService ) val );
+                }
+                
             }
-            else // set the parent suit's factory value
+            else if( suiteDirectoryService == null ) // set the parent suit's factory value
             {
                 // for a class without a @Factory and running standalone without a suite
                 if( getSuite() == null )
@@ -107,17 +117,23 @@
                 }
 
                 val = ( ( DirectoryServiceFactory ) val ).newInstance();
-            }
-
-            init( ( DirectoryService ) val );
+                
+                suiteDirectoryService = ( DirectoryService ) val;
+                
+                init( suiteDirectoryService );
 
-            if ( getSuite() != null )
+                if ( getSuite() != null )
+                {
+                    applyLdifs( getSuite().getDescription(), suiteDirectoryService );
+                }
+            }
+            else
             {
-                applyLdifs( getSuite().getDescription(), ( DirectoryService ) val );
+                val = suiteDirectoryService;
             }
 
             applyLdifs( getDescription(), ( DirectoryService ) val );
-
+            
             field.set( getTestClass().getJavaClass(), val );
 
             super.run( notifier );

Added: 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=893139&view=auto
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
(added)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassC.java
Tue Dec 22 11:18:16 2009
@@ -0,0 +1,33 @@
+package org.apache.directory.server.core.integ;
+
+
+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 )
+@ApplyLdifs(
+    {
+        "dn: cn=testClassC,ou=system\n" + 
+        "objectClass: person\n" + 
+        "cn: testClassC\n" + 
+        "sn: sn_testClassC\n"
+    })
+public class TestClassC
+{
+
+    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=testClassC,ou=system"
) ) );
+        // the below will not present if we apply the revert operation
+        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/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=893139&r1=893138&r2=893139&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
Tue Dec 22 11:18:16 2009
@@ -4,7 +4,7 @@
 import org.junit.runners.Suite;
 
 @RunWith( FrameworkSuite.class )
-@Suite.SuiteClasses({ TestClassA.class, TestClassB.class })
+@Suite.SuiteClasses({ TestClassA.class, TestClassB.class, TestClassC.class })
 @TestLevelFactory(FrameworkDirectoryServiceFactory.class)
 @ApplyLdifs(
     {



Mime
View raw message