directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r921060 - in /directory/apacheds/trunk/test-framework/src: main/java/org/apache/directory/server/core/integ/ test/java/org/apache/directory/server/core/integ/
Date Tue, 09 Mar 2010 19:15:51 GMT
Author: kayyagari
Date: Tue Mar  9 19:15:50 2010
New Revision: 921060

URL: http://svn.apache.org/viewvc?rev=921060&view=rev
Log:
o fixed a bug related to setting a method level DirectoryService in a class or suite level
LdapServer instance
o added a test case for the fix

Added:
    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
    directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuiteServer.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=921060&r1=921059&r2=921060&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
Tue Mar  9 19:15:50 2010
@@ -296,9 +296,19 @@ public class FrameworkRunner extends Blo
             // Check if this method has a dedicated DSBuilder
             DirectoryService methodDS = DSAnnotationProcessor.getDirectoryService( methodDescription
);
 
+            // give #1 priority to method level DS if present
+            if ( methodDS != null )
+            {
+                // Apply all the LDIFs
+                DSAnnotationProcessor.applyLdifs( suiteDescription, methodDS );
+                DSAnnotationProcessor.applyLdifs( classDescription, methodDS );
+                DSAnnotationProcessor.applyLdifs( methodDescription, methodDS );
+
+                directoryService = methodDS;
+            }
             // we don't support method level LdapServer so
             // we check for the presence of Class level LdapServer first 
-            if ( classLdapServer != null )
+            else if ( classLdapServer != null )
             {
                 directoryService = classLdapServer.getDirectoryService();
 
@@ -314,15 +324,6 @@ public class FrameworkRunner extends Blo
 
                 DSAnnotationProcessor.applyLdifs( methodDescription, directoryService );
             }
-            else if ( methodDS != null )
-            {
-                // Apply all the LDIFs
-                DSAnnotationProcessor.applyLdifs( suiteDescription, methodDS );
-                DSAnnotationProcessor.applyLdifs( classDescription, methodDS );
-                DSAnnotationProcessor.applyLdifs( methodDescription, methodDS );
-
-                directoryService = methodDS;
-            }
             else if ( classDS != null )
             {
                 directoryService = classDS;
@@ -353,15 +354,20 @@ public class FrameworkRunner extends Blo
 
             Field ldapServerField = getTestClass().getJavaClass().getField( LDAP_SERVER_FIELD_NAME
);
 
+            dirServiceField.set( getTestClass().getJavaClass(), directoryService );
+
             if ( classLdapServer != null )
             {
-                dirServiceField.set( getTestClass().getJavaClass(), classLdapServer.getDirectoryService()
);
+                // setting the directoryService is required to inject the correct level DS
instance in the class or suite level LdapServer
+                classLdapServer.setDirectoryService( directoryService );
+                
                 ldapServerField.set( getTestClass().getJavaClass(), classLdapServer );
             }
             else if ( classKdcServer != null )
             {
-                dirServiceField.set( getTestClass().getJavaClass(), 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 );
             }

Added: 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=921060&view=auto
==============================================================================
--- directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
(added)
+++ directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestMultiLevelDS.java
Tue Mar  9 19:15:50 2010
@@ -0,0 +1,64 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.core.integ;
+
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.junit.runner.RunWith;
+
+/**
+ * TODO TestMultiLevelDS.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@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 );
+        assertFalse( service.isAccessControlEnabled() );
+        assertEquals( "TestMultiLevelDS-class", service.getInstanceId() );
+    }
+    
+    
+    @Test
+    @CreateDS( enableAccessControl=true, name = "testMethodWithClassLevelDs-method" )
+    public void testMethodWithMethodLevelDs()
+    {
+        assertTrue( ldapServer.getDirectoryService() == service );
+        assertTrue( service.isAccessControlEnabled() );
+        assertEquals( "testMethodWithClassLevelDs-method", service.getInstanceId() );
+    }
+}

Modified: directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuiteServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuiteServer.java?rev=921060&r1=921059&r2=921060&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuiteServer.java
(original)
+++ directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestSuiteServer.java
Tue Mar  9 19:15:50 2010
@@ -29,7 +29,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
 @RunWith( FrameworkSuite.class )
-@Suite.SuiteClasses( { TestClassServer.class } )
+@Suite.SuiteClasses( { TestClassServer.class, TestMultiLevelDS.class } )
 @CreateDS( 
     name = "SuiteDS",
     partitions =



Mime
View raw message