directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r925246 - in /directory/apacheds/trunk/test-framework/src: main/java/org/apache/directory/server/core/integ/FrameworkRunner.java test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
Date Fri, 19 Mar 2010 14:49:33 GMT
Author: kayyagari
Date: Fri Mar 19 14:49:32 2010
New Revision: 925246

URL: http://svn.apache.org/viewvc?rev=925246&view=rev
Log:
o fixed an issue where the class level DS is not set in the suite level LdapServer
o fixed another issue related to restoring the LdapServer's actual DS instance after it gets
replaced with DS instance declared at a lower level test unit
  (e.x Class level DS for a Suite level LdapServer)
o reused the test case by making appropriate changes to test this behavior also

Modified:
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
    directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java

Modified: directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=925246&r1=925245&r2=925246&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
(original)
+++ directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Fri Mar 19 14:49:32 2010
@@ -206,7 +206,12 @@ public class FrameworkRunner extends Blo
             else if ( suite != null && suite.getLdapServer() != null )
             {
                 classLdapServer = suite.getLdapServer();
-                directoryService = classLdapServer.getDirectoryService();
+                
+                // set directoryService only if there is no class level DS
+                if( directoryService == null )
+                {
+                    directoryService = classLdapServer.getDirectoryService();
+                }
                 // no need to inject the LDIF data that would have been done above
                 // if ApplyLdifs is present
             }
@@ -306,29 +311,29 @@ public class FrameworkRunner extends Blo
 
                 directoryService = methodDS;
             }
-            // we don't support method level LdapServer so
-            // we check for the presence of Class level LdapServer first 
-            else if ( classLdapServer != null )
+            else if ( classDS != null )
             {
-                directoryService = classLdapServer.getDirectoryService();
+                directoryService = classDS;
 
+                // apply the method LDIFs, and tag for reversion
                 revision = getCurrentRevision( directoryService );
 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
-            else if ( classKdcServer != null )
+            // we don't support method level LdapServer so
+            // we check for the presence of Class level LdapServer first 
+            else if ( classLdapServer != null )
             {
-                directoryService = classKdcServer.getDirectoryService();
+                directoryService = classLdapServer.getDirectoryService();
 
                 revision = getCurrentRevision( directoryService );
 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
-            else if ( classDS != null )
+            else if ( classKdcServer != null )
             {
-                directoryService = classDS;
+                directoryService = classKdcServer.getDirectoryService();
 
-                // apply the method LDIFs, and tag for reversion
                 revision = getCurrentRevision( directoryService );
 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
@@ -356,8 +361,13 @@ public class FrameworkRunner extends Blo
 
             dirServiceField.set( getTestClass().getJavaClass(), directoryService );
 
+            DirectoryService oldLdapServerDirService = null;
+            DirectoryService oldKdcServerDirService = null;
+            
             if ( classLdapServer != null )
             {
+                oldLdapServerDirService = classLdapServer.getDirectoryService();
+                
                 // setting the directoryService is required to inject the correct level DS
instance in the class or suite level LdapServer
                 classLdapServer.setDirectoryService( directoryService );
                 
@@ -365,7 +375,9 @@ public class FrameworkRunner extends Blo
             }
             else if ( classKdcServer != null )
             {
-             // setting the directoryService is required to inject the correct level DS instance
in the class or suite level KdcServer
+                oldKdcServerDirService = classKdcServer.getDirectoryService();
+                
+                // setting the directoryService is required to inject the correct level DS
instance in the class or suite level KdcServer
                 classKdcServer.setDirectoryService( directoryService );
                 
                 Field kdcServerField = getTestClass().getJavaClass().getField( KDC_SERVER_FIELD_NAME
);
@@ -375,6 +387,16 @@ public class FrameworkRunner extends Blo
             // Run the test
             super.runChild( method, notifier );
 
+            if ( oldLdapServerDirService != null )
+            {
+                classLdapServer.setDirectoryService( oldLdapServerDirService );
+            }
+            
+            if ( oldKdcServerDirService != null )
+            {
+                classKdcServer.setDirectoryService( oldKdcServerDirService );
+            }
+            
             // Cleanup the methodDS if it has been created
             if ( methodDS != null )
             {

Modified: directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java?rev=925246&r1=925245&r2=925246&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
(original)
+++ directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
Fri Mar 19 14:49:32 2010
@@ -20,11 +20,12 @@
 
 package org.apache.directory.server.core.integ;
 
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.junit.Test;
-import static org.junit.Assert.*;
 import org.junit.runner.RunWith;
 
 /**
@@ -35,19 +36,17 @@ import org.junit.runner.RunWith;
  */
 @RunWith( FrameworkRunner.class )
 @CreateDS( name = "TestMultiLevelDS-class" )
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ), 
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
 public class TestMultiLevelDS extends AbstractLdapTestUnit
 {
     
     @Test
     public void testMethodWithClassLevelDs()
     {
-        assertTrue( ldapServer.getDirectoryService() == service );
+        // to make this test pass standalone
+        if( isRunInSuite )
+        {
+            assertTrue( ldapServer.getDirectoryService() == service );
+        }
         assertFalse( service.isAccessControlEnabled() );
         assertEquals( "TestMultiLevelDS-class", service.getInstanceId() );
     }
@@ -57,7 +56,11 @@ public class TestMultiLevelDS extends Ab
     @CreateDS( enableAccessControl=true, name = "testMethodWithClassLevelDs-method" )
     public void testMethodWithMethodLevelDs()
     {
-        assertTrue( ldapServer.getDirectoryService() == service );
+        // to make this test pass standalone
+        if( isRunInSuite )
+        {
+            assertTrue( ldapServer.getDirectoryService() == service );
+        }
         assertTrue( service.isAccessControlEnabled() );
         assertEquals( "testMethodWithClassLevelDs-method", service.getInstanceId() );
     }



Mime
View raw message