提交 c7d5fc29 编写于 作者: M meyerd

ACT-1060 started porting activiti-cdi testsuite to jboss arquillian to be able...

ACT-1060 started porting activiti-cdi testsuite to jboss arquillian to be able to run against both Jboss Weld and Apache OWB
上级 a33b6bd5
...@@ -15,19 +15,152 @@ ...@@ -15,19 +15,152 @@
<version>5.10-SNAPSHOT</version> <version>5.10-SNAPSHOT</version>
</parent> </parent>
<profiles>
<profile>
<id>weld-embedded-11</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>2.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>xalan</artifactId>
<groupId>org.apache.xalan</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-bom</artifactId>
<version>1.1.5.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>openwebbeans-embedded-1</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-openwebbeans-embedded-1</artifactId>
<version>1.0.0.CR2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-el_2.2_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-validation_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans</artifactId>
<version>1.1.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>distro</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies> <dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.activiti</groupId> <groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId> <artifactId>activiti-engine</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.jboss.arquillian.junit</groupId>
<artifactId>spring-context</artifactId> <artifactId>arquillian-junit-container</artifactId>
<version>1.0.0.CR7</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -40,16 +173,6 @@ ...@@ -40,16 +173,6 @@
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
...@@ -71,28 +194,4 @@ ...@@ -71,28 +194,4 @@
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>distro</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>
...@@ -46,7 +46,7 @@ public class ProcessVariables { ...@@ -46,7 +46,7 @@ public class ProcessVariables {
} }
@Produces @Produces
@ProcessVariable("") @ProcessVariable
protected Object getProcessVariable(InjectionPoint ip) { protected Object getProcessVariable(InjectionPoint ip) {
String processVariableName = getVariableName(ip); String processVariableName = getVariableName(ip);
......
...@@ -12,10 +12,9 @@ ...@@ -12,10 +12,9 @@
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.enterprise.util.Nonbinding; import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier; import javax.inject.Qualifier;
...@@ -48,8 +47,8 @@ import javax.inject.Qualifier; ...@@ -48,8 +47,8 @@ import javax.inject.Qualifier;
* @author Daniel Meyer * @author Daniel Meyer
*/ */
@Qualifier @Qualifier
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ProcessVariable { public @interface ProcessVariable {
/** /**
......
...@@ -38,7 +38,7 @@ public class CompleteTaskInterceptor implements Serializable { ...@@ -38,7 +38,7 @@ public class CompleteTaskInterceptor implements Serializable {
@Inject BusinessProcess businessProcess; @Inject BusinessProcess businessProcess;
@AroundInvoke @AroundInvoke
public Object invoke(InvocationContext ctx) throws Throwable { public Object invoke(InvocationContext ctx) throws Exception {
try { try {
Object result = ctx.proceed(); Object result = ctx.proceed();
......
...@@ -42,7 +42,7 @@ public class StartProcessInterceptor implements Serializable { ...@@ -42,7 +42,7 @@ public class StartProcessInterceptor implements Serializable {
@Inject BusinessProcess businessProcess; @Inject BusinessProcess businessProcess;
@AroundInvoke @AroundInvoke
public Object invoke(InvocationContext ctx) throws Throwable { public Object invoke(InvocationContext ctx) throws Exception {
try { try {
Object result = ctx.proceed(); Object result = ctx.proceed();
...@@ -61,7 +61,12 @@ public class StartProcessInterceptor implements Serializable { ...@@ -61,7 +61,12 @@ public class StartProcessInterceptor implements Serializable {
return result; return result;
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
throw e.getCause(); Throwable cause = e.getCause();
if(cause != null && cause instanceof Exception) {
throw (Exception) cause;
} else {
throw e;
}
} catch (Exception e) { } catch (Exception e) {
throw new ActivitiException("Error while starting process using @StartProcess on method '"+ctx.getMethod()+"': " + e.getMessage(), e); throw new ActivitiException("Error while starting process using @StartProcess on method '"+ctx.getMethod()+"': " + e.getMessage(), e);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
package org.activiti.cdi.impl.util; package org.activiti.cdi.impl.util;
import java.lang.reflect.Type;
import java.util.Iterator; import java.util.Iterator;
import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.context.spi.CreationalContext;
...@@ -45,7 +46,9 @@ public class ProgrammaticBeanLookup { ...@@ -45,7 +46,9 @@ public class ProgrammaticBeanLookup {
} }
Bean bean = iter.next(); Bean bean = iter.next();
CreationalContext ctx = bm.createCreationalContext(bean); CreationalContext ctx = bm.createCreationalContext(bean);
return bm.getReference(bean, bean.getBeanClass(), ctx); // select one beantype randomly. A bean has a non-empty set of beantypes.
Type type = (Type) bean.getTypes().iterator().next();
return bm.getReference(bean, type, ctx);
} }
public static <T> T lookup(Class<T> clazz) { public static <T> T lookup(Class<T> clazz) {
......
/* 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.
*/
package org.activiti.cdi.impl.context;
import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.test.Deployment;
/**
*
* @author Daniel Meyer
*/
public class ContextScopingTest extends CdiActivitiTestCase {
@Override
public void beginConversation() {
// do not activate conversation
}
@Override
public void endConversation() {
// do not deactivate conversation
}
@Deployment
public void testFallbackToRequestContext() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
String pid = businessProcess.startProcessByKey("processkey").getId();
assertEquals(pid, businessProcess.getProcessInstanceId());
endRequest();
beginRequest();
// assert that now the process is not associated with the new request.
assertNull(businessProcess.getProcessInstanceId());
runtimeService.deleteProcessInstance(pid, null);
}
}
...@@ -12,24 +12,36 @@ ...@@ -12,24 +12,36 @@
*/ */
package org.activiti.cdi.test; package org.activiti.cdi.test;
import java.util.HashMap; import java.util.Timer;
import java.util.Map; import java.util.TimerTask;
import java.util.logging.Level; import java.util.concurrent.Callable;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.BeanManager;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.impl.util.BeanManagerLookup;
import org.activiti.cdi.impl.util.ProgrammaticBeanLookup; import org.activiti.cdi.impl.util.ProgrammaticBeanLookup;
import org.activiti.cdi.test.util.ProcessEngineLookupForTestsuite;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.test.PluggableActivitiTestCase; import org.activiti.engine.FormService;
import org.jboss.weld.context.bound.BoundConversationContext; import org.activiti.engine.HistoryService;
import org.jboss.weld.context.bound.BoundRequestContext; import org.activiti.engine.IdentityService;
import org.jboss.weld.context.bound.BoundSessionContext; import org.activiti.engine.ManagementService;
import org.jboss.weld.context.bound.MutableBoundRequest; import org.activiti.engine.ProcessEngine;
import org.jboss.weld.environment.se.Weld; import org.activiti.engine.RepositoryService;
import org.jboss.weld.environment.se.WeldContainer; import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.jobexecutor.JobExecutor;
import org.activiti.engine.test.ActivitiRule;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
/** /**
* Abstract base class for executing activiti-cdi tests in a Java SE * Abstract base class for executing activiti-cdi tests in a Java SE
...@@ -37,185 +49,139 @@ import org.jboss.weld.environment.se.WeldContainer; ...@@ -37,185 +49,139 @@ import org.jboss.weld.environment.se.WeldContainer;
* *
* @author Daniel Meyer * @author Daniel Meyer
*/ */
public abstract class CdiActivitiTestCase extends PluggableActivitiTestCase { @RunWith(Arquillian.class)
public abstract class CdiActivitiTestCase {
protected Logger logger = Logger.getLogger(getClass().getName()); protected Logger logger = Logger.getLogger(getClass().getName());
protected WeldContainer weldContainer;
protected BeanManager beanManager;
protected Weld weld;
// hide from subclasses
private HashMap<String, Object> currentRequestMap;
private HashMap<String, Object> currentSessionMap;
@Override
protected void setUp() throws Exception {
// set the process engine in the TestProcessEngineLookup-bean.
ProcessEngineLookupForTestsuite.processEngine = processEngine;
// bootstrap the CDI container
weld = new Weld();
weldContainer = weld.initialize();
beanManager = weldContainer.getBeanManager();
BeanManagerLookup.localInstance = beanManager;
beginRequest(); @Deployment
beginSession(); public static JavaArchive createDeployment() {
beginConversation();
return ShrinkWrap.create(JavaArchive.class)
.addPackages(true, "org.activiti.cdi")
.addAsManifestResource("META-INF/beans.xml", "beans.xml");
} }
public void beginSession() { @Rule
currentSessionMap = new HashMap<String, Object>(); public ActivitiRule activitiRule = new ActivitiRule(getBeanInstance(ProcessEngine.class));
beginSession(currentSessionMap);
}
public void beginSession(Map<String, Object> sessionDataMap) { protected BeanManager beanManager;
BoundSessionContext sessionContext = getSessionContext();
sessionContext.associate(currentSessionMap);
sessionContext.activate();
if (logger.isLoggable(Level.FINE)) {
logger.fine(" ----------------------------- Started a new Session -----------------------");
}
}
public void endSession() { protected ProcessEngine processEngine;
endSession(currentSessionMap); protected FormService formService;
currentSessionMap = null; protected HistoryService historyService;
} protected IdentityService identityService;
protected ManagementService managementService;
public void endSession(Map<String, Object> sessionDataMap) { protected RepositoryService repositoryService;
BoundSessionContext sessionContext = getSessionContext(); protected RuntimeService runtimeService;
try { protected TaskService taskService;
sessionContext.invalidate(); protected ProcessEngineConfigurationImpl processEngineConfiguration;
sessionContext.deactivate();
if (logger.isLoggable(Level.FINE)) { @Before
logger.fine(" ----------------------------- Ended the current Session -----------------------"); public void setUp() throws Exception {
}
} finally { beanManager = ProgrammaticBeanLookup.lookup(BeanManager.class);
sessionContext.dissociate(sessionDataMap); processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class);
} processEngineConfiguration = ((ProcessEngineImpl)ProcessEngineLookupForTestsuite.processEngine).getProcessEngineConfiguration();
formService = processEngine.getFormService();
historyService = processEngine.getHistoryService();
identityService = processEngine.getIdentityService();
managementService = processEngine.getManagementService();
repositoryService = processEngine.getRepositoryService();
runtimeService = processEngine.getRuntimeService();
taskService = processEngine.getTaskService();
} }
public void beginRequest() { protected void endConversationAndBeginNew(String processInstanceId) {
currentRequestMap = new HashMap<String, Object>(); getBeanInstance(BusinessProcess.class).associateExecutionById(processInstanceId);
beginRequest(currentRequestMap);
} }
public void beginRequest(Map<String, Object> requestDataStore) { protected <T> T getBeanInstance(Class<T> clazz) {
// Associate the store with the context and acticate the context return ProgrammaticBeanLookup.lookup(clazz);
BoundRequestContext requestContext = getRequestContext();
requestContext.associate(requestDataStore);
requestContext.activate();
if (logger.isLoggable(Level.FINE)) {
logger.fine(" ----------------------------- Started a new Request -----------------------");
}
} }
public void endRequest() { protected Object getBeanInstance(String name) {
endRequest(currentRequestMap); return ProgrammaticBeanLookup.lookup(name);
currentRequestMap = null;
} }
//////////////////////// copied from AbstractActivitiTestcase
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
jobExecutor.start();
public void endRequest(Map<String, Object> requestDataStore) {
BoundRequestContext requestContext = getRequestContext();
try { try {
requestContext.invalidate(); Timer timer = new Timer();
requestContext.deactivate(); InteruptTask task = new InteruptTask(Thread.currentThread());
if (logger.isLoggable(Level.FINE)) { timer.schedule(task, maxMillisToWait);
logger.fine(" ----------------------------- Ended the current Request -----------------------"); boolean areJobsAvailable = true;
try {
while (areJobsAvailable && !task.isTimeLimitExceeded()) {
Thread.sleep(intervalMillis);
areJobsAvailable = areJobsAvailable();
}
} catch (InterruptedException e) {
} finally {
timer.cancel();
}
if (areJobsAvailable) {
throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
} }
} finally {
requestContext.dissociate(requestDataStore);
}
}
public void beginConversation() {
if (currentRequestMap == null) {
throw new ActivitiException("Cannot start conversation: no request active.");
}
if(currentSessionMap == null) {
throw new ActivitiException("Cannot start conversation: no session active.");
}
currentSessionMap = new HashMap<String, Object>();
startTransientConversation(currentRequestMap, currentSessionMap);
}
public void endConversation() { } finally {
if (currentRequestMap == null) { jobExecutor.shutdown();
throw new ActivitiException("Cannot end conversation: no request active.");
}
if(currentSessionMap == null) {
throw new ActivitiException("Cannot end conversation: no session active.");
} }
endOrPassivateConversation(currentRequestMap, currentSessionMap);
} }
public void startTransientConversation(Map<String, Object> requestDataStore, Map<String, Object> sessionDataStore) { public void waitForJobExecutorOnCondition(long maxMillisToWait, long intervalMillis, Callable<Boolean> condition) {
resumeOrStartConversation(requestDataStore, sessionDataStore, null); JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
} jobExecutor.start();
public void resumeOrStartConversation(Map<String, Object> requestDataStore, Map<String, Object> sessionDataStore, String cid) {
BoundConversationContext conversationContext = getConversationContext();
conversationContext.associate(new MutableBoundRequest(requestDataStore, sessionDataStore));
conversationContext.activate(cid);
if (logger.isLoggable(Level.FINE)) {
logger.fine("---------------------------------------- Started a new Conversation -----------------------");
}
}
public void endOrPassivateConversation(Map<String, Object> requestDataStore, Map<String, Object> sessionDataStore) {
BoundConversationContext conversationContext = getConversationContext();
try { try {
conversationContext.invalidate(); Timer timer = new Timer();
conversationContext.deactivate(); InteruptTask task = new InteruptTask(Thread.currentThread());
if (logger.isLoggable(Level.FINE)) { timer.schedule(task, maxMillisToWait);
logger.fine("---------------------------------------- Ended the current Conversation -----------------------"); boolean conditionIsViolated = true;
try {
while (conditionIsViolated) {
Thread.sleep(intervalMillis);
conditionIsViolated = !condition.call();
}
} catch (InterruptedException e) {
} catch (Exception e) {
throw new ActivitiException("Exception while waiting on condition: "+e.getMessage(), e);
} finally {
timer.cancel();
}
if (conditionIsViolated) {
throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
} }
} finally { } finally {
conversationContext.dissociate(new MutableBoundRequest(requestDataStore, sessionDataStore)); jobExecutor.shutdown();
} }
} }
@Override public boolean areJobsAvailable() {
protected void tearDown() throws Exception { return !managementService
endConversation(); .createJobQuery()
endRequest(); .executable()
endSession(); .list()
// https://issues.jboss.org/browse/WELD-891 .isEmpty();
weld.shutdown();
}
protected void endConversationAndBeginNew() {
endConversation();
beginConversation();
}
protected void endConversationAndBeginNew(String processInstanceId) {
endConversation();
beginConversation();
getBeanInstance(BusinessProcess.class).associateExecutionById(processInstanceId);
} }
protected BoundConversationContext getConversationContext() { private static class InteruptTask extends TimerTask {
return getBeanInstance(BoundConversationContext.class); protected boolean timeLimitExceeded = false;
} protected Thread thread;
public InteruptTask(Thread thread) {
protected BoundSessionContext getSessionContext() { this.thread = thread;
return getBeanInstance(BoundSessionContext.class); }
} public boolean isTimeLimitExceeded() {
return timeLimitExceeded;
protected BoundRequestContext getRequestContext() { }
return getBeanInstance(BoundRequestContext.class); public void run() {
} timeLimitExceeded = true;
thread.interrupt();
protected <T> T getBeanInstance(Class<T> clazz) { }
return ProgrammaticBeanLookup.lookup(clazz);
}
protected Object getBeanInstance(String name) {
return ProgrammaticBeanLookup.lookup(name);
} }
} }
...@@ -10,13 +10,19 @@ ...@@ -10,13 +10,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi; package org.activiti.cdi.test.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.runtime.Execution; import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
/** /**
* @author Daniel Meyer * @author Daniel Meyer
...@@ -24,6 +30,7 @@ import org.activiti.engine.test.Deployment; ...@@ -24,6 +30,7 @@ import org.activiti.engine.test.Deployment;
public class BusinessProcessBeanTest extends CdiActivitiTestCase { public class BusinessProcessBeanTest extends CdiActivitiTestCase {
/* General test asserting that the business process bean is functional */ /* General test asserting that the business process bean is functional */
@Test
@Deployment @Deployment
public void test() throws Exception { public void test() throws Exception {
...@@ -55,7 +62,8 @@ public class BusinessProcessBeanTest extends CdiActivitiTestCase { ...@@ -55,7 +62,8 @@ public class BusinessProcessBeanTest extends CdiActivitiTestCase {
} }
@Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml") @Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveProcessInstanceBean() { public void testResolveProcessInstanceBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
...@@ -75,7 +83,8 @@ public class BusinessProcessBeanTest extends CdiActivitiTestCase { ...@@ -75,7 +83,8 @@ public class BusinessProcessBeanTest extends CdiActivitiTestCase {
taskService.complete(taskService.createTaskQuery().singleResult().getId()); taskService.complete(taskService.createTaskQuery().singleResult().getId());
} }
@Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml") @Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveTaskBean() { public void testResolveTaskBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
......
...@@ -10,18 +10,22 @@ ...@@ -10,18 +10,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.test.api.annotation;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.impl.util.ProgrammaticBeanLookup;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Test;
/** /**
* *
* @author Daniel Meyer * @author Daniel Meyer
*/ */
public class BusinessKeyTest extends CdiActivitiTestCase { public class BusinessKeyTest extends CdiActivitiTestCase {
@Test
@Deployment @Deployment
public void testBusinessKeyInjectable() { public void testBusinessKeyInjectable() {
String businessKey = "Activiti"; String businessKey = "Activiti";
...@@ -29,8 +33,7 @@ public class BusinessKeyTest extends CdiActivitiTestCase { ...@@ -29,8 +33,7 @@ public class BusinessKeyTest extends CdiActivitiTestCase {
getBeanInstance(BusinessProcess.class).associateExecutionById(pid); getBeanInstance(BusinessProcess.class).associateExecutionById(pid);
// assert that now the businessKey-Bean can be looked up: // assert that now the businessKey-Bean can be looked up:
assertEquals(businessKey, getBeanInstance("businessKey")); Assert.assertEquals(businessKey, ProgrammaticBeanLookup.lookup("businessKey"));
} }
} }
...@@ -10,14 +10,17 @@ ...@@ -10,14 +10,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.test.api.annotation;
import static org.junit.Assert.assertNull;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.impl.annotation.CompleteTaskInterceptor; import org.activiti.cdi.impl.annotation.CompleteTaskInterceptor;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.DeclarativeProcessController; import org.activiti.cdi.test.impl.beans.DeclarativeProcessController;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
/** /**
* Testcase for assuring that the {@link CompleteTaskInterceptor} works as * Testcase for assuring that the {@link CompleteTaskInterceptor} works as
...@@ -27,7 +30,8 @@ import org.activiti.engine.test.Deployment; ...@@ -27,7 +30,8 @@ import org.activiti.engine.test.Deployment;
*/ */
public class CompleteTaskTest extends CdiActivitiTestCase { public class CompleteTaskTest extends CdiActivitiTestCase {
@Deployment(resources = "org/activiti/cdi/annotation/CompleteTaskTest.bpmn20.xml") @Test
@Deployment(resources = "org/activiti/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testCompleteTask() { public void testCompleteTask() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
......
...@@ -10,22 +10,28 @@ ...@@ -10,22 +10,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.test.api.annotation;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /**
* *
* @author Daniel Meyer * @author Daniel Meyer
*/ */
@RunWith(Arquillian.class)
public class ProcessIdTest extends CdiActivitiTestCase { public class ProcessIdTest extends CdiActivitiTestCase {
@Test
@Deployment @Deployment
public void testProcessIdInjectable() { public void testProcessIdInjectable() {
getBeanInstance(BusinessProcess.class).startProcessByKey("keyOfTheProcess"); getBeanInstance(BusinessProcess.class).startProcessByKey("keyOfTheProcess");
assertNotNull(getBeanInstance("processInstanceId")); Assert.assertNotNull(getBeanInstance("processInstanceId"));
} }
} }
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.test.api.annotation;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.impl.annotation.StartProcessInterceptor; import org.activiti.cdi.impl.annotation.StartProcessInterceptor;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.DeclarativeProcessController; import org.activiti.cdi.test.impl.beans.DeclarativeProcessController;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
import static org.junit.Assert.*;
/** /**
* Testcase for assuring that the {@link StartProcessInterceptor} behaves as * Testcase for assuring that the {@link StartProcessInterceptor} behaves as
...@@ -26,7 +29,8 @@ import org.activiti.engine.test.Deployment; ...@@ -26,7 +29,8 @@ import org.activiti.engine.test.Deployment;
*/ */
public class StartProcessTest extends CdiActivitiTestCase { public class StartProcessTest extends CdiActivitiTestCase {
@Deployment(resources = "org/activiti/cdi/annotation/StartProcessTest.bpmn20.xml") @Test
@Deployment(resources = "org/activiti/cdi/test/api/annotation/StartProcessTest.bpmn20.xml")
public void testStartProcessByKey() { public void testStartProcessByKey() {
assertNull(runtimeService.createProcessInstanceQuery().singleResult()); assertNull(runtimeService.createProcessInstanceQuery().singleResult());
...@@ -42,7 +46,8 @@ public class StartProcessTest extends CdiActivitiTestCase { ...@@ -42,7 +46,8 @@ public class StartProcessTest extends CdiActivitiTestCase {
businessProcess.completeTask(); businessProcess.completeTask();
} }
@Deployment(resources = "org/activiti/cdi/annotation/StartProcessTest.bpmn20.xml") @Test
@Deployment(resources = "org/activiti/cdi/test/api/annotation/StartProcessTest.bpmn20.xml")
public void testStartProcessByName() { public void testStartProcessByName() {
assertNull(runtimeService.createProcessInstanceQuery().singleResult()); assertNull(runtimeService.createProcessInstanceQuery().singleResult());
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.annotation; package org.activiti.cdi.test.api.annotation;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
import static org.junit.Assert.*;
/** /**
* *
...@@ -22,6 +25,7 @@ import org.activiti.engine.test.Deployment; ...@@ -22,6 +25,7 @@ import org.activiti.engine.test.Deployment;
*/ */
public class TaskIdTest extends CdiActivitiTestCase { public class TaskIdTest extends CdiActivitiTestCase {
@Test
@Deployment @Deployment
public void testTaskIdInjectable() { public void testTaskIdInjectable() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test.beans; package org.activiti.cdi.test.impl.beans;
import java.io.Serializable; import java.io.Serializable;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test.beans; package org.activiti.cdi.test.impl.beans;
import org.activiti.cdi.annotation.CompleteTask; import org.activiti.cdi.annotation.CompleteTask;
import org.activiti.cdi.annotation.ProcessVariable; import org.activiti.cdi.annotation.ProcessVariable;
......
...@@ -10,18 +10,18 @@ ...@@ -10,18 +10,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test.beans; package org.activiti.cdi.test.impl.beans;
import java.io.Serializable; import java.io.Serializable;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named; import javax.inject.Named;
/** /**
* @author Daniel Meyer * @author Daniel Meyer
*/ */
@Named @Named
@ConversationScoped @ApplicationScoped
public class MessageBean implements Serializable { public class MessageBean implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test.beans; package org.activiti.cdi.test.impl.beans;
import java.io.Serializable; import java.io.Serializable;
......
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.context; package org.activiti.cdi.test.impl.context;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.CreditCard; import org.activiti.cdi.test.impl.beans.CreditCard;
import org.activiti.cdi.test.beans.ProcessScopedMessageBean; import org.activiti.cdi.test.impl.beans.ProcessScopedMessageBean;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
import static org.junit.Assert.*;
/** /**
* *
...@@ -24,6 +27,7 @@ import org.activiti.engine.test.Deployment; ...@@ -24,6 +27,7 @@ import org.activiti.engine.test.Deployment;
*/ */
public class BusinessProcessContextTest extends CdiActivitiTestCase { public class BusinessProcessContextTest extends CdiActivitiTestCase {
@Test
@Deployment @Deployment
public void testResolution() throws Exception { public void testResolution() throws Exception {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
...@@ -33,19 +37,21 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase { ...@@ -33,19 +37,21 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase {
assertNotNull(getBeanInstance(CreditCard.class)); assertNotNull(getBeanInstance(CreditCard.class));
} }
@Test
// no @Deployment for this test // no @Deployment for this test
public void testResolutionBeforeProcessStart() throws Exception { public void testResolutionBeforeProcessStart() throws Exception {
// assert that @BusinessProcessScoped beans can be resolved in the absence of an underlying process instance: // assert that @BusinessProcessScoped beans can be resolved in the absence of an underlying process instance:
assertNotNull(getBeanInstance(CreditCard.class)); assertNotNull(getBeanInstance(CreditCard.class));
} }
@Test
@Deployment @Deployment
public void testConversationalBeanStoreFlush() throws Exception { public void testConversationalBeanStoreFlush() throws Exception {
getBeanInstance(BusinessProcess.class).setVariable("testVariable", "testValue"); getBeanInstance(BusinessProcess.class).setVariable("testVariable", "testValue");
String pid = getBeanInstance(BusinessProcess.class).startProcessByKey("testConversationalBeanStoreFlush").getId(); String pid = getBeanInstance(BusinessProcess.class).startProcessByKey("testConversationalBeanStoreFlush").getId();
endConversationAndBeginNew(pid); ///////////////////////////////////////////// 2nd Conversation getBeanInstance(BusinessProcess.class).associateExecutionById(pid);
// assert that the variable assigned on the businessProcess bean is flushed // assert that the variable assigned on the businessProcess bean is flushed
assertEquals("testValue", runtimeService.getVariable(pid, "testVariable")); assertEquals("testValue", runtimeService.getVariable(pid, "testVariable"));
...@@ -57,14 +63,13 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase { ...@@ -57,14 +63,13 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase {
taskService.complete(taskService.createTaskQuery().singleResult().getId()); taskService.complete(taskService.createTaskQuery().singleResult().getId());
} }
@Test
@Deployment @Deployment
public void testChangeProcessScopedBeanProperty() throws Exception { public void testChangeProcessScopedBeanProperty() throws Exception {
// resolve the creditcard bean (@BusinessProcessScoped) and set a value: // resolve the creditcard bean (@BusinessProcessScoped) and set a value:
getBeanInstance(CreditCard.class).setCreditcardNumber("123"); getBeanInstance(CreditCard.class).setCreditcardNumber("123");
String pid = getBeanInstance(BusinessProcess.class).startProcessByKey("testConversationalBeanStoreFlush").getId(); String pid = getBeanInstance(BusinessProcess.class).startProcessByKey("testConversationalBeanStoreFlush").getId();
endConversationAndBeginNew(); ///////////////////////////////////////////// 2nd Conversation
getBeanInstance(BusinessProcess.class).startTask(taskService.createTaskQuery().singleResult().getId()); getBeanInstance(BusinessProcess.class).startTask(taskService.createTaskQuery().singleResult().getId());
...@@ -75,7 +80,7 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase { ...@@ -75,7 +80,7 @@ public class BusinessProcessContextTest extends CdiActivitiTestCase {
// complete the task // complete the task
getBeanInstance(BusinessProcess.class).completeTask(); getBeanInstance(BusinessProcess.class).completeTask();
endConversationAndBeginNew(pid); ///////////////////////////////////////////// 3rd Conversation getBeanInstance(BusinessProcess.class).associateExecutionById(pid);
// now assert that the value of creditcard is "321": // now assert that the value of creditcard is "321":
assertEquals("321", getBeanInstance(CreditCard.class).getCreditcardNumber()); assertEquals("321", getBeanInstance(CreditCard.class).getCreditcardNumber());
......
...@@ -10,49 +10,22 @@ ...@@ -10,49 +10,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.context; package org.activiti.cdi.test.impl.context;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.ProcessScopedMessageBean; import org.activiti.cdi.test.impl.beans.ProcessScopedMessageBean;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
import static org.junit.Assert.*;
/** /**
* *
* @author Daniel Meyer * @author Daniel Meyer
*/ */
public class ThreadContextAssociationTest extends CdiActivitiTestCase { public class ThreadContextAssociationTest extends CdiActivitiTestCase {
@Override
public void beginConversation() {
// do not activate conversation
}
@Override
public void endConversation() {
// do not deactivate conversation
}
@Override
public void beginRequest() {
// do not activate
}
@Override
public void endRequest() {
// do not deactivate
}
@Override
public void beginSession() {
// do not activate
}
@Override
public void endSession() {
// do not deactivate
}
@Test
@Deployment @Deployment
public void testBusinessProcessScopedWithJobExecutor() throws InterruptedException { public void testBusinessProcessScopedWithJobExecutor() throws InterruptedException {
String pid = runtimeService.startProcessInstanceByKey("processkey").getId(); String pid = runtimeService.startProcessInstanceByKey("processkey").getId();
......
...@@ -10,17 +10,21 @@ ...@@ -10,17 +10,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.el; package org.activiti.cdi.test.impl.el;
import static org.junit.Assert.assertEquals;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.MessageBean; import org.activiti.cdi.test.impl.beans.MessageBean;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
/** /**
* @author Daniel Meyer * @author Daniel Meyer
*/ */
public class ElTest extends CdiActivitiTestCase { public class ElTest extends CdiActivitiTestCase {
@Test
@Deployment @Deployment
public void testSetBeanProperty() throws Exception { public void testSetBeanProperty() throws Exception {
MessageBean messageBean = getBeanInstance(MessageBean.class); MessageBean messageBean = getBeanInstance(MessageBean.class);
......
...@@ -10,16 +10,21 @@ ...@@ -10,16 +10,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.event; package org.activiti.cdi.test.impl.event;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Test;
import static org.junit.Assert.*;
public class EventNotificationTest extends CdiActivitiTestCase { public class EventNotificationTest extends CdiActivitiTestCase {
@Deployment(resources = {"org/activiti/cdi/impl/event/EventNotificationTest.process1.bpmn20.xml"}) @Test
@Deployment(resources = {"org/activiti/cdi/test/impl/event/EventNotificationTest.process1.bpmn20.xml"})
public void testReceiveAll() { public void testReceiveAll() {
TestEventListener listenerBean = getBeanInstance(TestEventListener.class); TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
listenerBean.reset();
// assert that the bean has received 0 events // assert that the bean has received 0 events
assertEquals(0, listenerBean.getEventsReceived().size()); assertEquals(0, listenerBean.getEventsReceived().size());
...@@ -29,12 +34,13 @@ public class EventNotificationTest extends CdiActivitiTestCase { ...@@ -29,12 +34,13 @@ public class EventNotificationTest extends CdiActivitiTestCase {
assertEquals(11, listenerBean.getEventsReceived().size()); assertEquals(11, listenerBean.getEventsReceived().size());
} }
@Test
@Deployment(resources = { @Deployment(resources = {
"org/activiti/cdi/impl/event/EventNotificationTest.process1.bpmn20.xml", "org/activiti/cdi/test/impl/event/EventNotificationTest.process1.bpmn20.xml",
"org/activiti/cdi/impl/event/EventNotificationTest.process2.bpmn20.xml" }) "org/activiti/cdi/test/impl/event/EventNotificationTest.process2.bpmn20.xml" })
public void testSelectEventsPerProcessDefinition() { public void testSelectEventsPerProcessDefinition() {
TestEventListener listenerBean = getBeanInstance(TestEventListener.class); TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
listenerBean.reset();
assertEquals(0, listenerBean.getEventsReceivedByKey().size()); assertEquals(0, listenerBean.getEventsReceivedByKey().size());
//start the 2 processes //start the 2 processes
...@@ -45,10 +51,12 @@ public class EventNotificationTest extends CdiActivitiTestCase { ...@@ -45,10 +51,12 @@ public class EventNotificationTest extends CdiActivitiTestCase {
assertEquals(11, listenerBean.getEventsReceivedByKey().size()); assertEquals(11, listenerBean.getEventsReceivedByKey().size());
} }
@Deployment(resources = {"org/activiti/cdi/impl/event/EventNotificationTest.process1.bpmn20.xml"}) @Test
@Deployment(resources = {"org/activiti/cdi/test/impl/event/EventNotificationTest.process1.bpmn20.xml"})
public void testSelectEventsPerActivity() { public void testSelectEventsPerActivity() {
TestEventListener listenerBean = getBeanInstance(TestEventListener.class); TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
listenerBean.reset();
assertEquals(0, listenerBean.getEndActivityService1()); assertEquals(0, listenerBean.getEndActivityService1());
assertEquals(0, listenerBean.getStartActivityService1()); assertEquals(0, listenerBean.getStartActivityService1());
assertEquals(0, listenerBean.getTakeTransitiont1()); assertEquals(0, listenerBean.getTakeTransitiont1());
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.event; package org.activiti.cdi.test.impl.event;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
...@@ -26,6 +26,15 @@ import org.activiti.cdi.annotation.event.TakeTransition; ...@@ -26,6 +26,15 @@ import org.activiti.cdi.annotation.event.TakeTransition;
@ApplicationScoped @ApplicationScoped
public class TestEventListener { public class TestEventListener {
public void reset() {
startActivityService1 = 0;
endActivityService1 = 0;
takeTransitiont1 = 0;
eventsReceivedByKey.clear();
eventsReceived.clear();
}
private final Set<BusinessProcessEvent> eventsReceivedByKey = new HashSet<BusinessProcessEvent>(); private final Set<BusinessProcessEvent> eventsReceivedByKey = new HashSet<BusinessProcessEvent>();
......
package org.activiti.cdi.impl.task; package org.activiti.cdi.test.impl.task;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.junit.Test;
public class CdiTaskServiceTest extends CdiActivitiTestCase { public class CdiTaskServiceTest extends CdiActivitiTestCase {
@Test
public void testClaimTask() { public void testClaimTask() {
Task newTask = taskService.newTask(); Task newTask = taskService.newTask();
taskService.saveTask(newTask); taskService.saveTask(newTask);
......
...@@ -10,19 +10,13 @@ ...@@ -10,19 +10,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test; package org.activiti.cdi.test.util;
import javax.enterprise.inject.Alternative;
import org.activiti.cdi.spi.ProcessEngineLookup; import org.activiti.cdi.spi.ProcessEngineLookup;
import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
/** /**
* {@link Alternative} implementation of the {@link ProcessEngineLookup}
* -interface, providing access to the ProcessEngine built for unit-tests.
*
* @see CdiActivitiTestCase
*
* @author Daniel Meyer * @author Daniel Meyer
*/ */
public class ProcessEngineLookupForTestsuite implements ProcessEngineLookup { public class ProcessEngineLookupForTestsuite implements ProcessEngineLookup {
...@@ -36,6 +30,9 @@ public class ProcessEngineLookupForTestsuite implements ProcessEngineLookup { ...@@ -36,6 +30,9 @@ public class ProcessEngineLookupForTestsuite implements ProcessEngineLookup {
@Override @Override
public ProcessEngine getProcessEngine() { public ProcessEngine getProcessEngine() {
if(processEngine == null) {
processEngine = ProcessEngines.getDefaultProcessEngine();
}
return processEngine; return processEngine;
} }
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.test.beans; package org.activiti.experimental;
import org.activiti.cdi.annotation.ProcessVariable;
import javax.inject.Inject; import javax.inject.Inject;
import org.activiti.cdi.annotation.ProcessVariable;
public class InjectProcessVariable { public class InjectProcessVariable {
@Inject @ProcessVariable public Object testKeyString; @Inject @ProcessVariable public Object testKeyString;
......
...@@ -10,18 +10,23 @@ ...@@ -10,18 +10,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.cdi.impl.context; package org.activiti.experimental;
import static org.junit.Assert.assertEquals;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.activiti.cdi.BusinessProcess; import org.activiti.cdi.BusinessProcess;
import org.activiti.cdi.test.CdiActivitiTestCase; import org.activiti.cdi.test.CdiActivitiTestCase;
import org.activiti.cdi.test.beans.InjectProcessVariable;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.junit.Ignore;
import org.junit.Test;
public class ProcessVariablesTest extends CdiActivitiTestCase { public class ProcessVariablesTest extends CdiActivitiTestCase {
@Ignore
@Test
@Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml") @Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveString() { public void testResolveString() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class); BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
......
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
org.activiti.cdi.test.ProcessEngineLookupForTestsuite org.activiti.cdi.test.util.ProcessEngineLookupForTestsuite
\ No newline at end of file \ No newline at end of file
...@@ -402,22 +402,7 @@ ...@@ -402,22 +402,7 @@
<classifier>lgpl</classifier> <classifier>lgpl</classifier>
<version>2.0.0</version> <version>2.0.0</version>
</dependency> </dependency>
<!-- cdi integration --> <!-- cdi integration -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-SP2</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
<version>1.1.4.Final</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.uuid</groupId> <groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId> <artifactId>java-uuid-generator</artifactId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册