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/17 17:57:45 UTC

svn commit: r378570 - in /lenya/trunk/src: targets/test-build.xml test/org/apache/lenya/cms/LenyaTestCase.java test/org/apache/lenya/cms/LenyaTestCase.xtest test/org/apache/lenya/cms/workflow/WorkflowTest.java

Author: andreas
Date: Fri Feb 17 08:57:42 2006
New Revision: 378570

URL: http://svn.apache.org/viewcvs?rev=378570&view=rev
Log:
Allow to provide custom request URLs for tests. Starting to fix WorkflowTest.

Modified:
    lenya/trunk/src/targets/test-build.xml
    lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java
    lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest
    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=378570&r1=378569&r2=378570&view=diff
==============================================================================
--- lenya/trunk/src/targets/test-build.xml (original)
+++ lenya/trunk/src/targets/test-build.xml Fri Feb 17 08:57:42 2006
@@ -160,6 +160,7 @@
         </fileset>
         <pathelement path="${src.test.dir}"/>
       </classpath>
+
       <test name="org.apache.lenya.ac.impl.IdentityTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.impl.AccessControllerTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.impl.AccreditableManagerTest" todir="${junit.dir}"/>
@@ -168,9 +169,7 @@
       <test name="org.apache.lenya.ac.impl.RoleManagerTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.impl.PolicyManagerTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.impl.PolicyTest" todir="${junit.dir}"/>
-      <!--
-        <test name="org.apache.lenya.ac.ldap.LDAPUserTest" todir="${junit.dir}"/>
-      -->
+
       <test name="org.apache.lenya.ac.file.FileUserTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.file.FileGroupTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.ac.file.FileRoleTest" todir="${junit.dir}"/>
@@ -179,11 +178,13 @@
       <test name="org.apache.lenya.cms.publication.DefaultDocumentBuilderTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.cms.publication.DublinCoreTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.cms.publication.file.FilePublicationTest" todir="${junit.dir}"/>
+
       <!--
+      <test name="org.apache.lenya.ac.ldap.LDAPUserTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.cms.rc.RCMLTest" todir="${junit.dir}"/>
       <test name="org.apache.lenya.cms.rc.RevisionControllerTest" todir="${junit.dir}"/>
+      <test name="org.apache.lenya.cms.workflow.WorkflowTest" todir="${junit.dir}"/>
       -->
-      
     </junit>
   </target>
   

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=378570&r1=378569&r2=378570&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.java Fri Feb 17 08:57:42 2006
@@ -38,7 +38,7 @@
  */
 public class LenyaTestCase extends ContainerTestCase {
 
-    private DefaultContext context;
+    protected DefaultContext context;
 
     protected void addContext(DefaultContext context) {
         super.addContext(context);
@@ -89,10 +89,14 @@
         MockEnvironment env = new MockEnvironment(resolver);
 
         String contextRoot = System.getProperty("contextRoot");
-        String pathInfo = "";
+        String pathInfo = getWebappUrl();
 
-        Request request = new CommandLineRequest(env, "", contextRoot, pathInfo);
+        Request request = new CommandLineRequest(env, contextRoot, "", pathInfo);
         context.put("object-model.request", request);
+    }
+    
+    protected String getWebappUrl() {
+        return "";
     }
 
     /**

Modified: 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=378570&r1=378569&r2=378570&view=diff
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest (original)
+++ lenya/trunk/src/test/org/apache/lenya/cms/LenyaTestCase.xtest Fri Feb 17 08:57:42 2006
@@ -92,6 +92,17 @@
       default-class="org.apache.lenya.cms.jcr.JCRNodeFactory"/>
     -->
     
+    <role name="org.apache.lenya.workflow.WorkflowManager"
+      shorthand="workflow-manager"
+      default-class="org.apache.lenya.workflow.impl.WorkflowManagerImpl"/>
+    
+    <role name="org.apache.lenya.cms.publication.ResourceTypeSelector"
+      shorthand="resource-types"
+      default-class="org.apache.lenya.cms.publication.ResourceTypeSelector"/>
+    
+    <role name="org.apache.lenya.cms.publication.templating.PublicationTemplateManager"
+      shorthand="publication-template-manager"
+      default-class="org.apache.lenya.cms.publication.templating.PublicationTemplateManagerImpl"/>
     
   </roles>
   
@@ -102,6 +113,7 @@
       <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
       <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
       <component-instance class="org.apache.lenya.cms.cocoon.source.LenyaSourceFactory" name="lenya" scheme="context:"/>
+      <component-instance class="org.apache.lenya.cms.cocoon.source.FallbackSourceFactory" name="fallback"/>
     </source-factories>
     
     <source-resolver class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
@@ -160,6 +172,41 @@
       <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>
+    
+    <resource-types>
+      
+      <component-instance class="org.apache.lenya.cms.publication.ResourceTypeImpl" logger="lenya.resourcetypes.homepage" name="homepage">
+        <schema language="http://relaxng.org/ns/structure/0.9" src="fallback://lenya/modules/homepage/resources/schemas/homepage.rng"/>
+        <creator src="org.apache.lenya.cms.authoring.DefaultBranchCreator">
+          <sample-name>homepage.xml</sample-name>
+        </creator>
+        <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/>
+        <format name="xhtml" uri="cocoon://modules/homepage/xhtml.xml"/>
+        <format name="luceneIndex" uri="cocoon://modules/xhtml/lucene-index.xml"/>
+      </component-instance>
+      
+      <component-instance class="org.apache.lenya.cms.publication.ResourceTypeImpl" logger="lenya.resourcetypes.links" name="links">
+        <schema language="http://relaxng.org/ns/structure/0.9" src="fallback://lenya/modules/links/resources/schema/links.rng"/>
+        <creator src="org.apache.lenya.cms.authoring.DefaultBranchCreator">
+          <sample-name>fallback://lenya/modules/links/samples/links.xml</sample-name>
+        </creator>
+        <format name="xhtml" uri="cocoon://modules/links/xhtml.xml"/>
+        <format name="luceneIndex" uri="cocoon://modules/xhtml/lucene-index.xml"/>
+      </component-instance>
+      
+      <component-instance class="org.apache.lenya.cms.publication.ResourceTypeImpl" logger="lenya.resourcetypes.xhtml" name="xhtml">
+        <schema language="http://relaxng.org/ns/structure/0.9" src="fallback://lenya/modules/xhtml/resources/schemas/xhtml.rng"/>
+        <creator src="org.apache.lenya.cms.authoring.DefaultBranchCreator">
+          <sample-name>fallback://lenya/modules/xhtml/samples/xhtml.xml</sample-name>
+          <!-- <sample-name name="Two Column Layout">fallback://lenya/modules/xhtml/samples/xhtml-2col.xml</sample-name> -->
+        </creator>
+        <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/>
+        <format name="xhtml" uri="cocoon://modules/xhtml/xhtml.xml"/>
+        <format name="webdavGET" uri="cocoon://modules/xhtml/davget.xml"/>
+        <format name="luceneIndex" uri="cocoon://modules/xhtml/lucene-index.xml"/>
+      </component-instance>
+      
+    </resource-types>
     
   </components>
   

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=378570&r1=378569&r2=378570&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 Fri Feb 17 08:57:42 2006
@@ -21,6 +21,12 @@
 
 import java.io.File;
 
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.commandline.CommandLineRequest;
+import org.apache.cocoon.environment.mock.MockEnvironment;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.ac.Policy;
 import org.apache.lenya.ac.Role;
@@ -43,6 +49,10 @@
     private static final String variableName = "is-live";
     protected static final String URL = "/authoring/index.html";
 
+    protected String getWebappUrl() {
+        return "/test" + URL;
+    }
+
     /**
      * Tests the workflow.
      * @throws Exception when something went wrong.
@@ -52,7 +62,6 @@
         String url = "/" + publication.getId() + URL;
         DocumentIdentityMap map = getIdentityMap();
         Document document = map.getFromURL(url);
-        Session session = new Session(map.getIdentityMap(), getIdentity(), getLogger());
 
         File configDir = new File(publication.getDirectory(), "config" + File.separator + "ac"
                 + File.separator + "passwd");
@@ -66,47 +75,54 @@
 
             String[] emptyRoles = {};
 
-            Workflowable instance = new DocumentWorkflowable(getManager(),
-                    session,
-                    document,
-                    getLogger());
-
             for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
-                assertNotNull(instance);
-
-                System.out.println("Current state: " + instance.getLatestVersion().getState());
 
                 Identity identity = new Identity();
+                ContainerUtil.enableLogging(identity, getLogger());
                 User user = getAccreditableManager().getUserManager()
                         .getUser(situations[situationIndex].getUser());
+                ContainerUtil.enableLogging(user, getLogger());
                 identity.addIdentifiable(user);
 
                 Role[] roles = policy.getRoles(identity);
-                System.out.print("Roles:");
+                getLogger().info("Roles:");
 
                 for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
-                    System.out.print(" " + roles[roleIndex]);
+                    getLogger().info(" " + roles[roleIndex]);
                 }
 
-                System.out.println();
-
                 String[] roleIds = new String[roles.length];
                 for (int i = 0; i < roles.length; i++) {
                     roleIds[i] = roles[i].getId();
                 }
+                Session session = new Session(map.getIdentityMap(), identity, getLogger());
+                Workflowable instance = new DocumentWorkflowable(getManager(),
+                        session,
+                        document,
+                        getLogger());
+                assertNotNull(instance);
+                
+                if (situationIndex > 0) {
+                    getLogger().info("Current state: " + instance.getLatestVersion().getState());
+                }
 
+                WorkflowUtil.invoke(getManager(),
+                        session,
+                        getLogger(),
+                        document,
+                        situations[situationIndex].getEvent());
 
                 assertTrue(instance.getLatestVersion().getValue(variableName) == situations[situationIndex].getValue());
 
-                System.out.println("Variable: " + variableName + " = "
+                getLogger().info("Variable: " + variableName + " = "
                         + instance.getLatestVersion().getValue(variableName));
-                System.out.println("------------------------------------------------------");
+                getLogger().info("------------------------------------------------------");
             }
         } finally {
             // this.manager.release(resolver);
         }
 
-        System.out.println("Test completed.");
+        getLogger().info("Test completed.");
     }
 
     private static final TestSituation[] situations = {



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