directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1150432 - /directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Date Sun, 24 Jul 2011 16:39:51 GMT
Author: seelmann
Date: Sun Jul 24 16:39:51 2011
New Revision: 1150432

URL: http://svn.apache.org/viewvc?rev=1150432&view=rev
Log:
Use the same mechanism to inject the KDC server into integration test as used for the LDAP
server

Modified:
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.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=1150432&r1=1150431&r2=1150432&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
Sun Jul 24 16:39:51 2011
@@ -24,6 +24,7 @@ import java.lang.reflect.Method;
 import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.annotations.CreateKdcServer;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.changelog.ChangeLog;
@@ -66,7 +67,7 @@ public class FrameworkRunner extends Blo
     private static final String SET_LDAP_SERVER_METHOD_NAME = "setLdapServer";
 
     /** The 'kdcServer' field in the run tests */
-    private static final String KDC_SERVER_FIELD_NAME = "kdcServer";
+    private static final String SET_KDC_SERVER_METHOD_NAME = "setKdcServer";
 
     /** 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";
@@ -237,7 +238,10 @@ public class FrameworkRunner extends Blo
 
             if ( classKdcServer == null )
             {
-                classKdcServer = ServerAnnotationProcessor.getKdcServer( getDescription(),
directoryService, 0 );
+                int minPort = getMinPort();
+
+                classKdcServer = ServerAnnotationProcessor.getKdcServer( getDescription(),
directoryService,
+                    minPort + 1 );
             }
             else if ( suite != null )
             {
@@ -332,7 +336,10 @@ public class FrameworkRunner extends Blo
     {
         /** The LdapServer for this method, if any */
         LdapServer methodLdapServer = null;
-        
+
+        /** The KdcServer for this method, if any */
+        KdcServer methodKdcServer = null;
+
         // Don't run the test if the @Ignored annotation is used
         if ( method.getAnnotation( Ignore.class ) != null )
         {
@@ -355,6 +362,7 @@ public class FrameworkRunner extends Blo
         // Before running any test, check to see if we must create a class DS
         // Get the LdapServerBuilder, if any
         CreateLdapServer methodLdapServerBuilder = methodDescription.getAnnotation( CreateLdapServer.class
);
+        CreateKdcServer methodKdcServerBuilder = methodDescription.getAnnotation( CreateKdcServer.class
);
 
         // Ok, ready to run the test
         try
@@ -422,6 +430,14 @@ public class FrameworkRunner extends Blo
                     minPort + 1 );
             }
 
+            if ( methodKdcServerBuilder != null )
+            {
+                int minPort = getMinPort();
+
+                methodKdcServer = ServerAnnotationProcessor.getKdcServer( methodDescription,
directoryService,
+                    minPort + 1 );
+            }
+
             // At this point, we know which service to use.
             // Inject it into the class
             Method setService = getTestClass().getJavaClass().getMethod( SET_SERVICE_METHOD_NAME,
DirectoryService.class );
@@ -431,36 +447,44 @@ public class FrameworkRunner extends Blo
             Field runInSuiteField = getTestClass().getJavaClass().getField( IS_RUN_IN_SUITE_FIELD_NAME
);
             runInSuiteField.set( getTestClass().getJavaClass(), suite != null );
 
-            Method setServer = getTestClass().getJavaClass().getMethod( SET_LDAP_SERVER_METHOD_NAME,
LdapServer.class );
-            //Field ldapServerField = getTestClass().getJavaClass().getField( LDAP_SERVER_FIELD_NAME
);
+            Method setLdapServer = getTestClass().getJavaClass().getMethod( SET_LDAP_SERVER_METHOD_NAME,
LdapServer.class );
+            Method setKdcServer = getTestClass().getJavaClass().getMethod( SET_KDC_SERVER_METHOD_NAME,
KdcServer.class );
 
             DirectoryService oldLdapServerDirService = null;
             DirectoryService oldKdcServerDirService = null;
-            
-            if ( methodLdapServer != null ) {
+
+            if ( methodLdapServer != null )
+            {
                 // setting the directoryService is required to inject the correct level DS
instance in the class or suite level LdapServer
                 methodLdapServer.setDirectoryService( directoryService );
-                
-                setServer.invoke( getTestClass().getJavaClass(), methodLdapServer );
+
+                setLdapServer.invoke( getTestClass().getJavaClass(), methodLdapServer );
             }    
             else 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 );
-                
-                setServer.invoke( getTestClass().getJavaClass(), classLdapServer );
+
+                setLdapServer.invoke( getTestClass().getJavaClass(), classLdapServer );
+            }
+
+            if ( methodKdcServer != null )
+            {
+                // setting the directoryService is required to inject the correct level DS
instance in the class or suite level KdcServer
+                methodKdcServer.setDirectoryService( directoryService );
+
+                setKdcServer.invoke( getTestClass().getJavaClass(), methodKdcServer );
             }
             else if ( classKdcServer != null )
             {
                 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
);
-                kdcServerField.set( getTestClass().getJavaClass(), classKdcServer );
+
+                setKdcServer.invoke( getTestClass().getJavaClass(), classKdcServer );
             }
 
             // Run the test



Mime
View raw message