directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph king <king.a....@gmail.com>
Subject Unsubscribe
Date Thu, 24 Dec 2009 14:44:07 GMT
On Dec 24, 2009 9:35 AM, <elecharny@apache.org> wrote:

Author: elecharny
Date: Thu Dec 24 14:35:16 2009
New Revision: 893767

URL: http://svn.apache.org/viewvc?rev=893767&view=rev
Log:
Added a flag to tell the test that it is run in a suite or not.

Modified:

 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/FrameworkRunner.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

Modified:
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=893767&r1=893766&r2=893767&view=diff
==============================================================================
---
directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
(original)
+++
directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/AbstractTestUnit.java
Thu Dec 24 14:35:16 2009
@@ -21,7 +21,18 @@

 import org.apache.directory.server.core.DirectoryService;

+
+/**
+ * An abstract class created to hold common elements.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
Project</a>
+ * @version $Rev$, $Date$
+ */
 public abstract class AbstractTestUnit
 {
+    /** The used DirectoryService instance */
    public static DirectoryService service;
+
+    /** A flag set if the test is run in a suite */
+    public static boolean isRunInSuite;
 }

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=893767&r1=893766&r2=893767&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 14:35:16 2009
@@ -54,7 +54,10 @@
    private static final Logger LOG = LoggerFactory.getLogger(
FrameworkRunner.class );

    /** The 'service' field in the run tests */
-    private static final String DIRECTORYSERVICE_FIELD_NAME = "service";
+    private static final String DIRECTORY_SERVICE_FIELD_NAME = "service";
+
+    /** The filed used to tell the test that it is run in a suite */
+    private static final String IS_RUN_IN_SUITE_FIELD_NAME =
"isRunInSuite";

    /** The suite this class depend on, if any */
    private FrameworkSuite suite;
@@ -263,7 +266,7 @@
            {
                // Use the default DS
                DirectoryServiceFactory dsf =
FrameworkDirectoryServiceFactory.DEFAULT;
-                dsf.init( "suite-" + UUID.randomUUID().toString() );
+                dsf.init( "default" + UUID.randomUUID().toString() );
                service = dsf.getDirectoryService();

                // same as in above else-if condition
@@ -309,8 +312,13 @@

            // At this point, we know which service to use.
            // Inject it into the class
-            Field field = getTestClass().getJavaClass().getField(
DIRECTORYSERVICE_FIELD_NAME );
+            Field field = getTestClass().getJavaClass().getField(
DIRECTORY_SERVICE_FIELD_NAME );
            field.set( getTestClass().getJavaClass(), service );
+
+            // if we run this class in a suite, tell it to the test
+            field = getTestClass().getJavaClass().getField(
IS_RUN_IN_SUITE_FIELD_NAME );
+            field.set( getTestClass().getJavaClass(), suite != null );
+

            super.runChild( method, notifier );


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=893767&r1=893766&r2=893767&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 14:35:16 2009
@@ -49,7 +49,11 @@
        })
    public void testWithFactoryAnnotation() throws Exception
    {
-        assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testSuite,ou=system" ) ) );
+        if ( isRunInSuite )
+        {
+            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" ) ) );
    }
@@ -65,7 +69,11 @@
        })
    public void testWithoutFactoryAnnotation() throws Exception
    {
-        assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testSuite,ou=system" ) ) );
+        if ( isRunInSuite )
+        {
+            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=893767&r1=893766&r2=893767&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 14:35:16 2009
@@ -40,7 +40,11 @@
    @DSBuilder( factory=FrameworkDirectoryServiceFactory.class, name="test"
)
    public void testWithFactoryAnnotation() throws Exception
    {
-        assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testSuite,ou=system" ) ) );
+        if ( isRunInSuite )
+        {
+            assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testSuite,ou=system" ) ) );
+        }
+
        assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testClassB,ou=system" ) ) );
    }

@@ -52,7 +56,11 @@
        // 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" ) ) );
+        if ( isRunInSuite )
+        {
+            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=893767&r1=893766&r2=893767&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 14:35:16 2009
@@ -39,7 +39,11 @@
    @Test
    public void testWithoutMethodOrClassLevelFactory() throws Exception
    {
-        assertTrue( service.getAdminSession().exists( new LdapDN(
"cn=testSuite,ou=system" ) ) );
+        if ( isRunInSuite )
+        {
+            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

Mime
View raw message