You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/02/16 18:01:57 UTC

svn commit: r378298 - in /lenya/trunk/src: targets/ test/org/apache/lenya/ac/file/ test/org/apache/lenya/ac/impl/ test/org/apache/lenya/ac/ldap/ test/org/apache/lenya/cms/ test/org/apache/lenya/cms/workflow/

Author: andreas
Date: Thu Feb 16 09:01:42 2006
New Revision: 378298

URL: http://svn.apache.org/viewcvs?rev=378298&view=rev
Log:
Refactoring of test base classes. Adding Request object to context. Fixed access control tests.

Added:
    lenya/trunk/src/test/org/apache/lenya/ac/ldap/
    lenya/trunk/src/test/org/apache/lenya/ac/ldap/LDAPUserTest.java
      - copied, changed from r377757, lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java
    lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest
Removed:
    lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessController.xtest
    lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest
    lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java
    lenya/trunk/src/test/org/apache/lenya/cms/lenya.xtest
Modified:
    lenya/trunk/src/targets/test-build.xml
    lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/file/FileRoleTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java
    lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java
    lenya/trunk/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java

Modified: lenya/trunk/src/targets/test-build.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/targets/test-build.xml?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/targets/test-build.xml (original)
+++ lenya/trunk/src/targets/test-build.xml Thu Feb 16 09:01:42 2006
@@ -28,7 +28,7 @@
   <property name="debug" value="true"/>
   <property name="test.pub.id" value="test"/>
   <property name="test.pub.source.id" value="default"/>
-  <property name="junit.test.loglevel" value="1"/>
+  <property name="junit.test.loglevel" value="2"/>
   
   <!--
   DEBUG 0
@@ -50,7 +50,10 @@
   <!-- Runs all tests -->
   <target name="test"
       description="Runs all tests"
-      depends="tests.junit, tests.anteater, tests.webtest"/>
+      depends="tests.junit"/>
+  <!--
+  depends="tests.junit, tests.anteater, tests.webtest"/>
+  -->
   
   <!-- Prepares the test publication -->
   <target name="test.pub.prepare">
@@ -94,10 +97,9 @@
 
   <!-- Runs JUnit tests -->
   <target name="tests.junit"	depends="init, tests.prepare,
-        test.identity" />
+        test.accesscontrol" />
   
   <!--
-  			test.identity,
   			test.workflow,
   			test.anttask,
   			test.publisher,
@@ -107,8 +109,8 @@
   -->
 
   
-  <!-- Identity Test -->
-  <target name="test.identity" depends="test.pub.prepare">
+  <!-- Access Control Tests -->
+  <target name="test.accesscontrol" depends="test.pub.prepare">
     <junit printsummary="yes" showoutput="true" haltonerror="on" haltonfailure="on">
       <sysproperty key="junit.test.loglevel" value="${junit.test.loglevel}"/>
       <sysproperty key="contextRoot" value="${basedir}/build/lenya/webapp"/>
@@ -124,6 +126,19 @@
         <pathelement path="${src.test.dir}"/>
       </classpath>
       <test name="org.apache.lenya.ac.impl.IdentityTest"/>
+      <test name="org.apache.lenya.ac.impl.AccessControllerTest"/>
+      <test name="org.apache.lenya.ac.impl.AccreditableManagerTest"/>
+      <test name="org.apache.lenya.ac.impl.UserManagerTest"/>
+      <test name="org.apache.lenya.ac.impl.GroupManagerTest"/>
+      <test name="org.apache.lenya.ac.impl.RoleManagerTest"/>
+      <test name="org.apache.lenya.ac.impl.PolicyManagerTest"/>
+      <test name="org.apache.lenya.ac.impl.PolicyTest"/>
+      <!--
+      <test name="org.apache.lenya.ac.ldap.LDAPUserTest"/>
+      -->
+      <test name="org.apache.lenya.ac.file.FileUserTest"/>
+      <test name="org.apache.lenya.ac.file.FileGroupTest"/>
+      <test name="org.apache.lenya.ac.file.FileRoleTest"/>
     </junit>
   </target>
   
@@ -156,16 +171,6 @@
   <!-- Publisher Test -->
   <target name="test.publisher" depends="test.pub.prepare">
     <java fork="yes" classname="org.apache.lenya.cms.task.PublisherTest">
-      <jvmarg value="-enableassertions"/>
-      <arg value="${build.webapp}"/>
-      <arg value="${test.pub.id}"/>
-      <classpath refid="classpath.default"/>
-    </java>
-  </target>  
-
-  <!-- Access Control Test -->
-  <target name="test.accesscontrol" depends="test.pub.prepare">
-    <java fork="yes" classname="org.apache.lenya.ac.impl.AccessControllerTest">
       <jvmarg value="-enableassertions"/>
       <arg value="${build.webapp}"/>
       <arg value="${test.pub.id}"/>

Modified: lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java Thu Feb 16 09:01:42 2006
@@ -42,23 +42,6 @@
     public static final String GROUP_ID = "testGroup";
 
     /**
-     * Constructor for FileGroupTest.
-     * @param arg0 command line args
-     */
-    public FileGroupTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * The command line interface
-     *
-     * @param args The command line args
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(FileGroupTest.class);
-    }
-
-    /**
      * Runs the test
      *
      * @throws AccessControlException if an AC error occurs

Modified: lenya/trunk/src/test/org/apache/lenya/ac/file/FileRoleTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/file/FileRoleTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/file/FileRoleTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/file/FileRoleTest.java Thu Feb 16 09:01:42 2006
@@ -26,23 +26,7 @@
  * @version $Id$
  */
 public class FileRoleTest extends AccessControlTest {
-    /**
-     * Constructor for FileRoleTest.
-     * @param arg0 The test to execute.
-     */
-    public FileRoleTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * DOCUMENT ME!
-     * 
-     * @param args DOCUMENT ME!
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(FileRoleTest.class);
-    }
-
+    
     /**
      * DOCUMENT ME!
      * 

Modified: lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java Thu Feb 16 09:01:42 2006
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.Group;
 import org.apache.lenya.ac.User;
@@ -39,23 +40,6 @@
     private HashMap groups = new HashMap();
 
     /**
-     * Constructor for FileUserTest.
-     * @param arg0 command line args
-     */
-    public FileUserTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * The main method
-     * 
-     * @param args command line args
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(FileUserTest.class);
-    }
-
-    /**
      * (non-Javadoc)
      * @see junit.framework.TestCase#setUp()
      */
@@ -92,11 +76,14 @@
         String adminGroupName = "adminGroup";
 
         FileGroup editorGroup = new FileGroup(configDir, editorGroupName);
+        ContainerUtil.enableLogging(editorGroup, getLogger());
         FileGroup adminGroup = new FileGroup(configDir, adminGroupName);
+        ContainerUtil.enableLogging(adminGroup, getLogger());
         this.groups.put(editorGroupName, editorGroup);
         this.groups.put(adminGroupName, adminGroup);
 
         FileUser user = new FileUser(configDir, userName, fullName, email, password);
+        ContainerUtil.enableLogging(user, getLogger());
 
         editorGroup.add(user);
         adminGroup.add(user);

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java Thu Feb 16 09:01:42 2006
@@ -21,26 +21,26 @@
 
 import java.io.File;
 
-import org.apache.avalon.framework.component.ComponentSelector;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.AccessControllerResolver;
 import org.apache.lenya.ac.AccreditableManager;
 import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.PolicyManager;
 import org.apache.lenya.ac.User;
 import org.apache.lenya.ac.file.FileAccreditableManager;
 import org.apache.lenya.ac.file.FilePolicyManager;
+import org.apache.lenya.cms.LenyaTestCase;
 import org.apache.lenya.cms.ac.DocumentPolicyManagerWrapper;
 import org.apache.lenya.cms.ac.PublicationAccessControllerResolver;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationUtil;
-import org.apache.lenya.cms.repository.RepositoryTestCase;
 
 /**
  * To change the template for this generated type comment go to Window>Preferences>Java>Code
  * Generation>Code and Comments
  */
-public class AccessControlTest extends RepositoryTestCase {
+public class AccessControlTest extends LenyaTestCase {
 
     private ServiceSelector accessControllerResolverSelector;
     private AccessControllerResolver accessControllerResolver;
@@ -49,11 +49,6 @@
     private File accreditablesDirectory;
 
     /**
-     */
-    public AccessControlTest() {
-    }
-
-    /**
      * Returns the access controller.
      * @return An access controller.
      */
@@ -63,7 +58,6 @@
 
     protected static final String URL = "/test/authoring/index.html";
 
-    /** @see junit.framework.TestCase#setUp() */
     public void setUp() throws Exception {
 
         super.setUp();
@@ -139,8 +133,8 @@
      * Returns the policy manager.
      * @return A policy manager.
      */
-    protected FilePolicyManager getPolicyManager() {
-        return (FilePolicyManager) getAccessController().getPolicyManager();
+    protected PolicyManager getPolicyManager() {
+        return getAccessController().getPolicyManager();
     }
 
     /**

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java Thu Feb 16 09:01:42 2006
@@ -19,27 +19,10 @@
 
 package org.apache.lenya.ac.impl;
 
-import junit.textui.TestRunner;
-
 /**
  * Access controller test
  */
 public class AccessControllerTest extends AccessControlTest {
-
-    /**
-     * @param test A test.
-     */
-    public AccessControllerTest(String test) {
-        super(test);
-    }
-
-    /**
-     * The main method.
-     * @param args The command-line arguments.
-     */
-    public static void main(String[] args) {
-        TestRunner.run(AccessControllerTest.class);
-    }
 
     /**
      * The test.

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java Thu Feb 16 09:01:42 2006
@@ -15,37 +15,15 @@
 */
 package org.apache.lenya.ac.impl;
 
-import junit.textui.TestRunner;
-
-import org.apache.avalon.framework.component.ComponentSelector;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.AccreditableManager;
-import org.apache.lenya.cms.ExcaliburTest;
 
 /**
  * Test class for the Accreditable Manager
  */
-public class AccreditableManagerTest extends ExcaliburTest {
-
-    /**
-     * @param test The test to execute.
-     */
-    public AccreditableManagerTest(String test) {
-        super(test);
-    }
+public class AccreditableManagerTest extends AccessControllerTest {
 
-    /**
-     * The main program.
-     * The parameters are set from the command line arguments.
-     *
-     * @param args The command line arguments.
-     */
-    public static void main(String[] args) {
-        TestRunner.run(AccreditableManagerTest.class);
-    }
-    
     private AccreditableManager accreditableManager;
-    private ComponentSelector selector;
     
     protected static final String HINT = "file";
 
@@ -58,10 +36,8 @@
     public void setUp() throws Exception {
         super.setUp();
 
-        String role = AccreditableManager.ROLE + "Selector";
-        this.selector = (ComponentSelector) this.manager.lookup(role);
+        this.accreditableManager = getAccessController().getAccreditableManager();
         
-        this.accreditableManager = (AccreditableManager) this.selector.select(HINT);
         assertNotNull("AccreditableManager is null", this.accreditableManager);
     }
 

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java Thu Feb 16 09:01:42 2006
@@ -30,23 +30,6 @@
 public class GroupManagerTest extends AccessControlTest {
 
     /**
-     * Constructor for GroupManagerTest.
-     * @param arg0 command line args
-     */
-    public GroupManagerTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * Command line interface
-     *
-     * @param args command line args
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(GroupManagerTest.class);
-    }
-
-    /**
      * The test
      * @throws AccessControlException if an error occurs
      */

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java Thu Feb 16 09:01:42 2006
@@ -15,8 +15,6 @@
 */
 package org.apache.lenya.ac.impl;
 
-import junit.textui.TestRunner;
-
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.Identity;
@@ -33,14 +31,6 @@
     public static final String USER_ID = "lenya";
 
     /**
-     * Ctor.
-     * @param test The test.
-     */
-    public IdentityTest() {
-        super();
-    }
-
-    /**
      * Tests the identity.
      * 
      * @throws AccessControlException if an error occurs
@@ -49,7 +39,7 @@
         Identity identity = new Identity();
         ContainerUtil.enableLogging(identity, getLogger());
         User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
-        System.out.println("Adding user to identity: [" + user + "]");
+        getLogger().info("Adding user to identity: [" + user + "]");
         identity.addIdentifiable(user);
         
         assertSame(user, identity.getUser());

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java Thu Feb 16 09:01:42 2006
@@ -30,22 +30,6 @@
  */
 public class PolicyManagerTest extends AccessControlTest {
 
-    /**
-     * Create an instance of PolicyManagerTest
-     * @param test a test
-     */
-    public PolicyManagerTest(String test) {
-        super(test);
-    }
-
-    /**
-     * The main method.
-     * @param args The command-line arguments.
-     */
-    public static void main(String[] args) {
-        TestRunner.run(AccessControllerTest.class);
-    }
-
     private static String[] URLS = { "/test/authoring/index.html" };
 
     /**

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java Thu Feb 16 09:01:42 2006
@@ -23,8 +23,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import junit.textui.TestRunner;
-
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.Policy;
 import org.apache.lenya.ac.Role;
@@ -34,32 +32,16 @@
 
 /**
  * Policy Test
- *  
- * */
+ * 
+ */
 public class PolicyTest extends AccessControlTest {
-    /**
-     * Executes this test.
-     * @param test The test.
-     */
-    public PolicyTest(String test) {
-        super(test);
-    }
-
-    /**
-     * The main method.
-     * @param args The command-line arguments.
-     */
-    public static void main(String[] args) {
-        TestRunner.run(PolicyTest.class);
-    }
-
     protected static final String URL = "/test/authoring/index.html";
     protected static final String SAVE_URL = "/test/authoring/tutorial.html";
 
     /**
      * A test.
      * @throws AccessControlException when something went wrong.
-     * @throws PublicationException 
+     * @throws PublicationException
      */
     public void testLoadPolicy() throws AccessControlException, PublicationException {
         Publication pub = PublicationUtil.getPublication(getManager(), "test");
@@ -82,8 +64,8 @@
      * @throws AccessControlException when something went wrong.
      */
     protected Policy getPolicy(String url) throws AccessControlException {
-        Policy policy =
-            getPolicyManager().getPolicy(getAccessController().getAccreditableManager(), url);
+        Policy policy = getPolicyManager().getPolicy(getAccessController().getAccreditableManager(),
+                url);
 
         return policy;
     }
@@ -93,8 +75,9 @@
      * @throws AccessControlException when something went wrong.
      */
     public void testSavePolicy() throws AccessControlException {
-        DefaultPolicy urlPolicy =
-            getPolicyManager().buildURLPolicy(getAccessController().getAccreditableManager(), URL);
+        InheritingPolicyManager policyManager = (InheritingPolicyManager) getPolicyManager();
+        DefaultPolicy urlPolicy = policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
+                URL);
         DefaultPolicy newPolicy = new DefaultPolicy();
 
         Credential[] credentials = urlPolicy.getCredentials();
@@ -112,11 +95,9 @@
 
         assertEquals(urlPolicy.getCredentials().length, newPolicy.getCredentials().length);
 
-        getPolicyManager().saveURLPolicy(SAVE_URL, newPolicy);
+        policyManager.saveURLPolicy(SAVE_URL, newPolicy);
 
-        newPolicy =
-            getPolicyManager().buildURLPolicy(
-                getAccessController().getAccreditableManager(),
+        newPolicy = policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
                 SAVE_URL);
         assertEquals(urlPolicy.getCredentials().length, newPolicy.getCredentials().length);
 
@@ -141,11 +122,9 @@
             assertEquals(oldRoles, newRoles);
 
             /*
-            for (int j = 0; j < roles.length; j++) {
-                assertEquals(roles[j], newRoles[j]);
-                System.out.println("  Role: [" + roles[j] + "]");
-            }
-            */
+             * for (int j = 0; j < roles.length; j++) { assertEquals(roles[j], newRoles[j]);
+             * System.out.println(" Role: [" + roles[j] + "]"); }
+             */
         }
     }
 }

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java Thu Feb 16 09:01:42 2006
@@ -28,21 +28,6 @@
  * @version $Id$
  */
 public class RoleManagerTest extends AccessControlTest {
-    /**
-     * Constructor for RoleManagerTest.
-     * @param arg0 command line args
-     */
-    public RoleManagerTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * Command line interface
-     * @param args Command line args
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(RoleManagerTest.class);
-    }
 
     /**
      * Run the test

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java Thu Feb 16 09:01:42 2006
@@ -38,22 +38,6 @@
 public class UserManagerTest extends AccessControlTest {
 
     /**
-     * Constructor for UserManagerTest.
-     * @param arg0 command line args
-     */
-    public UserManagerTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * Command line interface
-     * @param args Command line args
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(UserManagerTest.class);
-    }
-
-    /**
      * @see junit.framework.TestCase#setUp()
      */
     public void setUp() throws Exception {

Copied: lenya/trunk/src/test/org/apache/lenya/ac/ldap/LDAPUserTest.java (from r377757, lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java)
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/ldap/LDAPUserTest.java?p2=lenya/trunk/src/test/org/apache/lenya/ac/ldap/LDAPUserTest.java&p1=lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java&r1=377757&r2=378298&rev=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/ldap/LDAPUserTest.java Thu Feb 16 09:01:42 2006
@@ -15,7 +15,7 @@
  *
  */
 
-package org.apache.lenya.ac.impl;
+package org.apache.lenya.ac.ldap;
 
 import java.io.File;
 
@@ -27,6 +27,7 @@
 import org.apache.lenya.ac.file.FileGroup;
 import org.apache.lenya.ac.file.FileRole;
 import org.apache.lenya.ac.file.FileUserManager;
+import org.apache.lenya.ac.impl.AccessControlTest;
 import org.apache.lenya.ac.ldap.LDAPUser;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
@@ -38,35 +39,6 @@
  * @version $Id$
  */
 public class LDAPUserTest extends AccessControlTest {
-    /**
-     * Constructor for LDAPUserTest.
-     * @param arg0 a <code>String</code>
-     */
-    public LDAPUserTest(String arg0) {
-        super(arg0);
-    }
-
-    /**
-     * 
-     * @param args an array of <code>String</code>
-     */
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(LDAPUserTest.class);
-    }
-
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    public void setUp() throws Exception {
-        super.setUp();
-    }
-
-    /**
-     * @see junit.framework.TestCase#tearDown()
-     */
-    public void tearDown() throws Exception {
-        super.tearDown();
-    }
 
     /**
      * get a publication
@@ -76,7 +48,7 @@
      * @throws PublicationException if an error occurs
      */
     final public Publication getPublication() throws PublicationException {
-        String publicationId = "default";
+        String publicationId = "test";
         return PublicationUtil.getPublication(getManager(), publicationId);
     }
 

Modified: lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java Thu Feb 16 09:01:42 2006
@@ -17,27 +17,58 @@
 package org.apache.lenya.cms;
 
 import java.io.File;
+import java.net.URL;
 
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.cocoon.core.container.ContainerTestCase;
 import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.commandline.CommandLineContext;
+import org.apache.cocoon.environment.commandline.CommandLineRequest;
+import org.apache.cocoon.environment.mock.MockEnvironment;
+import org.apache.excalibur.source.SourceResolver;
 
 /**
  * Base class for Lenya tests which need the context information.
  */
 public class LenyaTestCase extends ContainerTestCase {
-    
+
+    private DefaultContext context;
+
     protected void addContext(DefaultContext context) {
         super.addContext(context);
+
+        this.context = context;
+
         String contextRoot = System.getProperty("contextRoot");
         getLogger().info("Adding context root entry [" + contextRoot + "]");
         context.put("context-root", new File(contextRoot));
-        
+
         Context envContext = new CommandLineContext(contextRoot);
         ContainerUtil.enableLogging(envContext, getLogger());
         context.put("environment-context", envContext);
+
     }
 
+    protected void prepare() throws Exception {
+        final String resourceName = LenyaTestCase.class.getName().replace('.', '/') + ".xtest";
+        URL resource = getClass().getClassLoader().getResource(resourceName);
+
+        if (resource != null) {
+            getLogger().debug("Loading resource " + resourceName);
+            prepare(resource.openStream());
+        } else {
+            getLogger().debug("Resource not found " + resourceName);
+        }
+
+        SourceResolver resolver = (SourceResolver) getManager().lookup(SourceResolver.ROLE);
+        MockEnvironment env = new MockEnvironment(resolver);
+
+        String contextRoot = System.getProperty("contextRoot");
+        String pathInfo = "";
+
+        Request request = new CommandLineRequest(env, "", contextRoot, pathInfo);
+        context.put("object-model.request", request);
+    }
 }

Added: lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest?rev=378298&view=auto
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest (added)
+++ lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest Thu Feb 16 09:01:42 2006
@@ -0,0 +1,160 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+  
+  Licensed 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.
+-->
+
+<testcase>
+  <annotation>
+    Test Cases: Identity 
+  </annotation>
+  <context>
+    <!--
+      <entry name="environment-context" value="/c:/src/lenya-trunk/build/lenya/webapp/"/>
+      <entry name="container.rootDir" value="/c:/src/lenya-trunk/build/lenya/webapp/"/>
+    -->
+  </context>
+  
+  <roles>
+    
+    <role name="org.apache.excalibur.source.SourceFactorySelector"
+      shorthand="source-factories"
+      default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
+    </role>
+    
+    <role name="org.apache.excalibur.source.SourceResolver"
+      shorthand="source-resolver"
+      default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
+    
+    <role name="org.apache.lenya.ac.AccreditableManagerSelector"
+      shorthand="accreditable-managers"
+      default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
+      <hint shorthand="file" class="org.apache.lenya.ac.file.FileAccreditableManager"/>
+    </role>
+    
+    <role name="org.apache.lenya.ac.AuthorizerSelector"
+      shorthand="authorizers"
+      default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
+      <hint shorthand="policy" class="org.apache.lenya.ac.impl.PolicyAuthorizer"/>
+      <hint shorthand="workflow" class="org.apache.lenya.cms.ac.workflow.WorkflowAuthorizer"/>
+    </role>
+    
+    <role name="org.apache.lenya.ac.PolicyManagerSelector"
+      shorthand="policy-managers"
+      default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
+      <hint shorthand="file" class="org.apache.ac.file.FilePolicyManager"/>
+      <hint shorthand="sitemap" class="org.apache.cms.ac.SitemapPolicyManager"/>
+    </role>
+    
+    <role name="org.apache.lenya.ac.AccessControllerResolverSelector"
+      shorthand="access-controller-resolvers"
+      default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
+      <hint shorthand="composable" class="org.apache.lenya.ac.impl.ComposableAccessControllerResolver"/>
+      <hint shorthand="publication" class="org.apache.lenya.cms.ac.PublicationAccessControllerResolver"/>
+    </role>
+    
+    <role name="org.apache.lenya.ac.Authenticator"
+      shorthand="authenticator"
+      default-class="org.apache.lenya.ac.impl.UserAuthenticator"/>
+    
+    <role name="org.apache.lenya.ac.cache.SourceCache"
+      shorthand="sourcecache"
+      default-class="org.apache.lenya.ac.cache.SourceCacheImpl"/>
+    
+    <role name="org.apache.lenya.cms.publication.PublicationManager"
+      shorthand="publication-manager"
+      default-class="org.apache.lenya.cms.publication.PublicationManagerImpl"/>
+    
+    <role name="org.apache.lenya.cms.publication.DocumentBuilderSelector"
+      shorthand="document-builders"
+      default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
+    
+    <role name="org.apache.lenya.cms.site.SiteManagerSelector"
+      shorthand="site-managers"
+      default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
+    
+  </roles>
+  
+  <components>
+    
+    <source-factories>
+      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+      <!--
+        <component-instance class="org.apache.lenya.cms.cocoon.source.ContextSourceFactory" name="context"/>
+      -->
+      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+    </source-factories>
+    
+    <source-resolver class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
+    
+    <accreditable-managers>
+      <component-instance logger="lenya.ac.accreditablemanager"
+        class="org.apache.lenya.ac.file.FileAccreditableManager" name="file">
+        <parameter name="directory" value="file:///c:/src/lenya-trunk/build/webapp/lenya/pubs/test/config/ac/passwd"/>
+      </component-instance>
+    </accreditable-managers>
+    
+    <authorizers>
+      <component-instance class="org.apache.lenya.ac.impl.PolicyAuthorizer" logger="lenya.ac.authorizer" name="policy"/>
+      <component-instance class="org.apache.lenya.cms.ac.usecase.UsecaseAuthorizer" logger="lenya.ac.authorizer" name="usecase"/>
+    </authorizers>
+    
+    <policy-managers>
+      <component-instance class="org.apache.lenya.ac.file.FilePolicyManager" logger="lenya.ac.policymanager.file" name="file"/>
+      <component-instance class="org.apache.lenya.cms.ac.SitemapPolicyManager" logger="lenya.ac.policymanager.sitemap" name="sitemap"/>
+      <component-instance class="org.apache.lenya.cms.ac.DocumentPolicyManagerWrapper" logger="lenya.ac.policymanager.document" name="document"/>
+    </policy-managers>
+    
+    <component logger="lenya.ac.accesscontroller"
+      class="org.apache.lenya.ac.impl.BypassableAccessController"
+      role="org.apache.lenya.ac.AccessController/bypassable"/>
+    
+    <component logger="lenya.ac.accesscontroller"
+      class="org.apache.lenya.ac.impl.DefaultAccessController"
+      role="org.apache.lenya.ac.AccessController/default"/>
+    
+    <access-controller-resolvers>
+      <component-instance logger="lenya.ac.accesscontrollerresolver"
+        class="org.apache.lenya.cms.ac.PublicationAccessControllerResolver"
+        name="publication">
+      </component-instance>
+      <component-instance logger="lenya.ac.accesscontrollerresolver"
+        class="org.apache.lenya.ac.impl.ComposableAccessControllerResolver"
+        name="composable">
+        <resolver type="publication"/>
+      </component-instance>
+    </access-controller-resolvers>
+    
+    <component logger="lenya.ac.authenticator"
+      class="org.apache.lenya.ac.impl.UserAuthenticator"
+      role="org.apache.lenya.cms.ac.Authenticator"/>
+    
+    <component class="org.apache.lenya.cms.cocoon.components.context.ContextUtility"
+      logger="lenya.cocoon.components"
+      role="org.apache.lenya.cms.cocoon.components.context.ContextUtility"/>
+    
+    <document-builders>
+      <component-instance class="org.apache.lenya.cms.publication.DefaultDocumentBuilder" logger="lenya.publication" name="default"/>
+    </document-builders>
+    
+    <site-managers>
+      <component-instance class="org.apache.lenya.cms.site.simple.SimpleSiteManager" logger="lenya.site" name="simple"/>
+      <component-instance class="org.apache.lenya.cms.site.tree.TreeSiteManager" logger="lenya.site" name="tree"/>
+    </site-managers>
+    
+  </components>
+  
+</testcase>
+

Modified: lenya/trunk/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java?rev=378298&r1=378297&r2=378298&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java Thu Feb 16 09:01:42 2006
@@ -43,22 +43,6 @@
  * Generation>Code and Comments
  */
 public class WorkflowTest extends AccessControlTest {
-    /**
-     * Constructor.
-     * @param test The test to execute.
-     */
-    public WorkflowTest(String test) {
-        super(test);
-    }
-
-    /**
-     * The main program for the WorkflowTest class
-     * 
-     * @param args The command line arguments
-     */
-    public static void main(String[] args) {
-        TestRunner.run(getSuite());
-    }
 
     /**
      * Returns the test suite.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org