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 16:26:51 UTC

svn commit: r378277 - in /lenya/trunk/src: targets/ test/org/apache/lenya/ac/impl/ test/org/apache/lenya/cms/publication/

Author: andreas
Date: Thu Feb 16 07:26:48 2006
New Revision: 378277

URL: http://svn.apache.org/viewcvs?rev=378277&view=rev
Log:
Make tests run again. Setting reasonable context attributes in PublicationTestCase.

Modified:
    lenya/trunk/src/targets/test-build.xml
    lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java
    lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest
    lenya/trunk/src/test/org/apache/lenya/cms/publication/PublicationTestCase.java

Modified: lenya/trunk/src/targets/test-build.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/targets/test-build.xml?rev=378277&r1=378276&r2=378277&view=diff
==============================================================================
--- lenya/trunk/src/targets/test-build.xml (original)
+++ lenya/trunk/src/targets/test-build.xml Thu Feb 16 07:26:48 2006
@@ -28,6 +28,15 @@
   <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"/>
+  
+  <!--
+  DEBUG 0
+  INFO  1
+  WARN  2
+  ERROR 3
+  FATAL 4
+  -->
 
   <path id="classpath.default">
     <path refid="classpath"/>
@@ -45,18 +54,13 @@
   
   <!-- Prepares the test publication -->
   <target name="test.pub.prepare">
-  <!--
-    
     <property name="test.pub.dir" value="${build.webapp}/lenya/pubs/${test.pub.id}"/>
-    
+    <echo>Creating test publication at ${test.pub.dir}</echo>
     <delete dir="${test.pub.dir}"/>
     <mkdir dir="${test.pub.dir}"/>
-    
     <copy todir="${test.pub.dir}">
       <fileset dir="${build.webapp}/lenya/pubs/${test.pub.source.id}"/>
     </copy>
-    
-  -->
   </target>
   
   <!-- prepares the tests. -->
@@ -104,10 +108,11 @@
 
   
   <!-- Identity Test -->
-  <target name="test.identity">
-    <java fork="no" classname="org.apache.lenya.ac.impl.IdentityTest">
-      <arg value="${build.webapp}"/>
-      <arg value="default"/>
+  <target name="test.identity" 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"/>
+      <formatter type="plain"/>
       <classpath refid="classpath"/>
       <classpath>
         <pathelement location="${build.test}" />
@@ -115,7 +120,8 @@
         <pathelement path="${build.webapp}/WEB-INF/lib" />
         <pathelement path="${src.test.dir}"/>
       </classpath>
-    </java>
+      <test name="org.apache.lenya.ac.impl.IdentityTest"/>
+    </junit>
   </target>
   
     

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=378277&r1=378276&r2=378277&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 07:26:48 2006
@@ -30,6 +30,7 @@
 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.ac.DocumentPolicyManagerWrapper;
 import org.apache.lenya.cms.ac.PublicationAccessControllerResolver;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationTestCase;
@@ -48,9 +49,8 @@
     private File accreditablesDirectory;
 
     /**
-     * @param test The test.
      */
-    public AccessControlTest(String test) {
+    public AccessControlTest() {
     }
 
     /**
@@ -88,7 +88,9 @@
         getLogger().info("Resolved access controller: [" + this.accessController.getClass() + "]");
 
         File servletContext = pub.getServletContext();
-        ((FilePolicyManager) this.accessController.getPolicyManager()).setPoliciesDirectory(servletContext);
+        DocumentPolicyManagerWrapper wrapper = (DocumentPolicyManagerWrapper) this.accessController.getPolicyManager();
+        FilePolicyManager policyManager = (FilePolicyManager) wrapper.getPolicyManager();
+        policyManager.setPoliciesDirectory(servletContext);
 
         this.accreditablesDirectory = new File(pub.getDirectory(), "config/ac/passwd".replace('/',
                 File.separatorChar));
@@ -101,7 +103,6 @@
      * @exception Exception if an error occurs
      */
     public void tearDown() throws Exception {
-        super.tearDown();
 
         if (this.accessControllerResolverSelector != null) {
             if (this.accessControllerResolver != null) {
@@ -112,6 +113,7 @@
             }
             getManager().release(this.accessControllerResolver);
         }
+        super.tearDown();
     }
 
     protected static final String USERNAME = "lenya";

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=378277&r1=378276&r2=378277&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 07:26:48 2006
@@ -17,6 +17,7 @@
 
 import junit.textui.TestRunner;
 
+import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.ac.User;
@@ -35,25 +36,18 @@
      * Ctor.
      * @param test The test.
      */
-    public IdentityTest(String test) {
-        super(test);
+    public IdentityTest() {
+        super();
     }
 
     /**
-     * The main method.
-     * @param args The command-line arguments.
-     */
-    public static void main(String[] args) {
-        TestRunner.run(IdentityTest.class);
-    }
-    
-    /**
      * Tests the identity.
      * 
      * @throws AccessControlException if an error occurs
      */
     public void testIdentity() throws AccessControlException {
         Identity identity = new Identity();
+        ContainerUtil.enableLogging(identity, getLogger());
         User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
         System.out.println("Adding user to identity: [" + user + "]");
         identity.addIdentifiable(user);

Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest?rev=378277&r1=378276&r2=378277&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.xtest Thu Feb 16 07:26:48 2006
@@ -20,11 +20,10 @@
     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/"/>
-    <entry name="context-root" value="/c:/src/lenya-trunk/build/lenya/webapp/"/>
-  -->
+    -->
   </context>
 
    <roles>
@@ -69,11 +68,10 @@
           shorthand="authenticator"
           default-class="org.apache.lenya.ac.impl.UserAuthenticator"/>
   
-  <!--
-    <role name="org.apache.lenya.ac.cache.PolicyCache"
-          shorthand="sourcecache"
-          default-class="org.apache.lenya.ac.cache.PolicyCacheImpl"/>
-  -->
+     <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"/>
@@ -84,10 +82,10 @@
   
   <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>
 
@@ -102,6 +100,7 @@
     
   <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>

Modified: lenya/trunk/src/test/org/apache/lenya/cms/publication/PublicationTestCase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/publication/PublicationTestCase.java?rev=378277&r1=378276&r2=378277&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/publication/PublicationTestCase.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/cms/publication/PublicationTestCase.java Thu Feb 16 07:26:48 2006
@@ -16,7 +16,14 @@
  */
 package org.apache.lenya.cms.publication;
 
+import java.io.File;
+
+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.commandline.CommandLineContext;
+import org.apache.cocoon.environment.mock.MockContext;
 import org.apache.lenya.transaction.IdentityMap;
 import org.apache.lenya.transaction.IdentityMapImpl;
 
@@ -30,6 +37,17 @@
             this.identityMap = new DocumentIdentityMap(map, getManager(), getLogger());
         }
         return this.identityMap;
+    }
+
+    protected void addContext(DefaultContext context) {
+        super.addContext(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);
     }
     
 }



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