Author: thomas.heute(a)jboss.com
Date: 2008-10-29 10:56:32 -0400 (Wed, 29 Oct 2008)
New Revision: 12209
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/AbstractWorkflowTestCase.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestApprovedPublish.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestDeniedPublish.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestWorkflowEnvironment.java
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-beans-workflow.xml
Log:
FIx workflow tests to run on multiple DB
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/AbstractWorkflowTestCase.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/AbstractWorkflowTestCase.java 2008-10-29
08:02:33 UTC (rev 12208)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/AbstractWorkflowTestCase.java 2008-10-29
14:56:32 UTC (rev 12209)
@@ -28,9 +28,11 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.jboss.beans.metadata.api.annotations.Inject;
import org.jboss.portal.cms.impl.interceptors.ApprovalWorkflowInterceptor;
import org.jboss.portal.cms.impl.jcr.JCRCMS;
import org.jboss.portal.cms.test.AbstractCMSTestCase;
+import org.jboss.portal.cms.test.commands.AbstractCommandTestCase;
import org.jboss.portal.cms.test.commands.CMSInterceptorStackFactory;
import org.jboss.portal.cms.workflow.ApprovePublish;
import org.jboss.portal.cms.workflow.ApprovePublishImpl;
@@ -45,25 +47,30 @@
import org.jboss.portal.identity.db.HibernateRoleImpl;
import org.jboss.portal.identity.db.HibernateUserImpl;
import org.jboss.portal.server.impl.invocation.JBossInterceptorStack;
+import org.jboss.portal.workflow.service.WorkflowService;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
import org.jboss.unit.api.pojo.annotations.Parameter;
import org.w3c.dom.Document;
/** @author Sohil Shah - sohil.shah(a)jboss.com - Nov 30, 2006 */
-public abstract class AbstractWorkflowTestCase extends AbstractCMSTestCase
+public abstract class AbstractWorkflowTestCase extends AbstractCommandTestCase
{
private String standardIdentityConfig;
private String identityConfig;
- protected JCRCMS service = null;
-
/**
*
*/
protected UserModule userModule = null;
+
+ private WorkflowService workflowService;
+
+ private IdentityServiceController identityServiceController;
+ private ApprovePublishImpl approvePublish;
+
/**
*
*/
@@ -72,32 +79,41 @@
super();
}
- @Create
public void setUp() throws Exception
{
- //override the configration location to include workflow services
- // this.configuration = "jboss-beans-workflow.xml";
-
- LoaderResource res = new
CLResourceLoader().getResource("jcr/repository.xml");
- Document config =
res.asDocument(XMLTools.getDocumentBuilderFactory().newDocumentBuilder());
-
- service = new JCRCMS();
- service.setDoChecking(true);
- service.setDefaultLocale(Locale.ENGLISH.getLanguage());
- service.setDefaultContentLocation("default-content/default");
-
- service.setConfig(config.getDocumentElement());
- service.setRepositoryName("repo");
- service.setHomeDir("repotest-" + getDataSourceName());
- service.setJNDIName("java:portal/CMS");
- service.startService();
-
- /*
super.setUp();
- */
ApprovalWorkflowInterceptor workflowInterceptor =
this.getApprovalWorkflowInterceptor();
- ApprovePublish approvePublish = this.getApprovePublish();
+// ApprovePublish approvePublish = this.getApprovePublish();
+
+
+ approvePublish = new ApprovePublishImpl();
+ approvePublish.setWorkflowService(workflowService);
+ approvePublish.setIdentityServiceController(identityServiceController);
+ approvePublish.setOverwrite(false);
+ approvePublish.setManagerRoles("Admin");
+ approvePublish.setJNDIName("java:/portal/ApprovePublishWorkflow");
+ approvePublish.setProcess("<process-definition
name=\"approval_workflow\">" +
+" <start-state>" +
+" <transition to=\"request_approval\"/>" +
+" </start-state>" +
+" <task-node name=\"request_approval\"
signal=\"first\">" +
+" <task name=\"approve_publish\">" +
+" <assignment
class=\"org.jboss.portal.cms.workflow.PublishAssignmentHandler\"/>" +
+" <event type=\"task-start\">" +
+" <action
class=\"org.jboss.portal.cms.workflow.FinalizePublish\"/>" +
+" </event>" +
+" <exception-handler>" +
+" <action
class=\"org.jboss.portal.cms.workflow.TaskExceptionHandler\"/>" +
+" </exception-handler>" +
+" </task> " +
+" <transition name=\"approval\"
to=\"end\"/>" +
+" <transition name=\"rejection\"
to=\"end\"/> " +
+" </task-node> " +
+" <end-state name=\"end\"/> " +
+" </process-definition>");
+ approvePublish.startService();
+
IdentityServiceController identityService =
((ApprovePublishImpl)approvePublish).getIdentityServiceController();
//Setup bootstrapped Identity data into the Identity store
@@ -117,11 +133,11 @@
this.userModule =
(UserModule)identityService.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
}
- @Destroy
public void tearDown() throws Exception
{
- service.stopService();
+ approvePublish.stopService();
this.userModule = null;
+ super.tearDown();
}
@@ -138,7 +154,7 @@
*/
protected ApprovePublish getApprovePublish() throws Exception
{
- return (ApprovePublish)new
InitialContext().lookup("java:/portal/ApprovePublishWorkflow");
+ return approvePublish;
}
/**
@@ -231,4 +247,18 @@
{
this.identityConfig = identityConfig;
}
+
+ @Inject(bean="WorkflowService")
+ public void setWorkflowService(WorkflowService workflowService)
+ {
+ this.workflowService = workflowService;
+ }
+
+ @Inject(bean="IdentityServiceController")
+ public void setIdentityServiceController(IdentityServiceController
identityServiceController)
+ {
+ this.identityServiceController = identityServiceController;
+ }
+
+
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestApprovedPublish.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestApprovedPublish.java 2008-10-29
08:02:33 UTC (rev 12208)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestApprovedPublish.java 2008-10-29
14:56:32 UTC (rev 12209)
@@ -77,12 +77,10 @@
@Create
public void setUp() throws Exception
{
- super.setUp();
- JCRCMS.turnOnWorkflow();
-
SessionFactory sessionFactory = (SessionFactory)new
InitialContext().lookup("java:/SessionFactory");
this.session = sessionFactory.openSession();
this.tx = session.beginTransaction();
+ super.setUp();
}
/**
@@ -91,10 +89,10 @@
@Destroy
public void tearDown() throws Exception
{
+ super.tearDown();
this.tx.commit();
this.session.close();
- super.tearDown();
}
@@ -105,6 +103,8 @@
//Execute file creation as a regular user/non-manager
this.runAs("user");
+ JCRCMS.turnOnWorkflow();
+
//Add a new file to the CMS
File file = new FileImpl();
file.setBasePath(this.file);
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestDeniedPublish.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestDeniedPublish.java 2008-10-29
08:02:33 UTC (rev 12208)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestDeniedPublish.java 2008-10-29
14:56:32 UTC (rev 12209)
@@ -79,12 +79,10 @@
@Create
public void setUp() throws Exception
{
- super.setUp();
- JCRCMS.turnOnWorkflow();
-
SessionFactory sessionFactory = (SessionFactory)new
InitialContext().lookup("java:/SessionFactory");
this.session = sessionFactory.openSession();
this.tx = session.beginTransaction();
+ super.setUp();
}
/**
@@ -93,10 +91,9 @@
@Destroy
public void tearDown() throws Exception
{
+ super.tearDown();
this.tx.commit();
this.session.close();
-
- super.tearDown();
}
@@ -104,6 +101,8 @@
@Test
public void testPublishExistingFile() throws Exception
{
+ JCRCMS.turnOnWorkflow();
+
ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
Set managers = approvePublish.getManagers();
String manager = (String)managers.iterator().next();
@@ -171,6 +170,8 @@
@Test
public void testPublishNewFile() throws Exception
{
+ JCRCMS.turnOnWorkflow();
+
//Execute file creation as a regular user/non-manager
this.runAs("user");
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestWorkflowEnvironment.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestWorkflowEnvironment.java 2008-10-29
08:02:33 UTC (rev 12208)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/workflow/TestWorkflowEnvironment.java 2008-10-29
14:56:32 UTC (rev 12209)
@@ -23,20 +23,30 @@
package org.jboss.portal.cms.test.workflow;
import junit.framework.Assert;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.workflow.ApprovePublish;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.unit.mc.api.annotations.Bootstrap;
import java.util.Set;
+import javax.naming.InitialContext;
+
/** @author Sohil Shah - sohil.shah(a)jboss.com - Nov 30, 2006 */
@Bootstrap(beanName = "TestCase",
resourceName="/jboss-beans-workflow.xml")
public class TestWorkflowEnvironment extends AbstractWorkflowTestCase
{
String rejectPath = "/default/private/license.html";
String allowedPath = "/default/images/check.gif";
+ private Transaction tx = null;
+ private Session session = null;
/**
@@ -48,16 +58,28 @@
}
/**
- *
- *
- */
- /*
- public static TestSuite suite() throws Exception
- {
- return createTestSuite(TestWorkflowEnvironment.class);
- }
+ *
*/
+ @Create
+ public void setUp() throws Exception
+ {
+ SessionFactory sessionFactory = (SessionFactory)new
InitialContext().lookup("java:/SessionFactory");
+ this.session = sessionFactory.openSession();
+ this.tx = session.beginTransaction();
+ super.setUp();
+ }
+ /**
+ *
+ */
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ this.tx.commit();
+ this.session.close();
+ }
+
/** @throws CMSException */
@Test
public void test() throws Exception
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-beans-workflow.xml
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-beans-workflow.xml 2008-10-29
08:02:33 UTC (rev 12208)
+++
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-beans-workflow.xml 2008-10-29
14:56:32 UTC (rev 12209)
@@ -26,7 +26,6 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
<bean name="DataSourceConfig"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
<constructor factoryMethod="obtainConfig"
factoryClass="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
<parameter><inject bean="TestCase"
property="datasources" state="Instantiated"/></parameter>
@@ -210,8 +209,8 @@
<property name="identityServiceController"><inject
bean="IdentityServiceController"/></property>
<property
name="identitySessionFactory">java:/SessionFactory</property>
</bean>
-
- <!-- setup for cms workflow testing -->
+
+ <!-- setup for cms workflow testing -->
<bean name="WorkflowService"
class="org.jboss.portal.workflow.service.WorkflowServiceImpl">
<property name="jbpmConfigurationXml">
<![CDATA[
@@ -231,7 +230,8 @@
]]>
</property>
</bean>
-
+
+<!--
<bean name="ApprovePublish"
class="org.jboss.portal.cms.workflow.ApprovePublishImpl">
<property name="workflowService"><inject
bean="WorkflowService"/></property>
<property name="identityServiceController"><inject
bean="IdentityServiceController"/></property>
@@ -240,7 +240,6 @@
<property
name="JNDIName">java:/portal/ApprovePublishWorkflow</property>
<property name="process">
<![CDATA[
- <!-- cms approval workflow -->
<process-definition name="approval_workflow">
<start-state>
<transition to="request_approval"/>
@@ -263,8 +262,10 @@
]]>
</property>
</bean>
-
+-->
+
<bean
class="org.jboss.portal.cms.impl.interceptors.ApprovalWorkflowInterceptor"
name="ApprovalWorkflowInterceptor">
<property
name="JNDIName">java:/portal/cms/ApprovalWorkflowInterceptor</property>
</bean>
+
</deployment>
Show replies by date