[jbpm-commits] JBoss JBPM SVN: r5953 - in jbpm4/trunk/modules: test-cfg/src/test/java/org/jbpm/test/spring and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Dec 11 09:03:18 EST 2009
Author: jbarrez
Date: 2009-12-11 09:03:18 -0500 (Fri, 11 Dec 2009)
New Revision: 5953
Added:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties
Modified:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java
Log:
JBPM-2529: Resolving eventListeners as a Spring bean doesn't work
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java 2009-12-11 12:41:00 UTC (rev 5952)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -72,6 +72,17 @@
taskService = processEngine.getTaskService();
identityService = processEngine.getIdentityService();
}
+
+ /**
+ * By default, the applicationContext.xml file in the same package as the test class
+ * is used to initialize the Spring container.
+ *
+ * Override this method if you don't need this default behaviour.
+ */
+ @Override
+ protected String getConfigPath() {
+ return "applicationContext.xml";
+ }
/**
* Default configuration name. Overwrite this if the jbpm configuration is
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.spring.expression.eventlistener;
+
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class MyEventListener implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String VARIABLE = "testVar";
+
+ public void notify(EventListenerExecution execution) throws Exception {
+ Integer var = (Integer) execution.getVariable(VARIABLE);
+ var = var + 1;
+ execution.setVariable(VARIABLE, var);
+ }
+
+}
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.spring.expression.eventlistener;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.AbstractTransactionalSpringJbpmTestCase;
+
+/**
+ * Tests if event listeners can be resolved when they are defined as Spring beans.
+ *
+ * Test originally created for JBPM-2529
+ *
+ * @author Joram Barrez
+ */
+public class ResolveEventListenerTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ private final String TEST_PROCESS =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<process name='testProcess'>" +
+ " <start name='start'>" +
+ " <transition name='to a' to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <on event='start'>" +
+ " <event-listener expr='${myEventListener}' />" +
+ " </on>" +
+ " <transition name='to end' to='theEnd' />" +
+ " </state>" +
+ " <end name='theEnd' />" +
+ "</process>";
+
+ public void testResolveEventListener() {
+
+ deployJpdlXmlString(TEST_PROCESS);
+
+ // We start a process and insert a variable with value 1234
+ Map<String, Object> vars = new HashMap<String, Object>();
+ final String var = "testVar";
+ final Integer varValue = new Integer(1234);
+ vars.put(var, varValue);
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("testProcess", vars);
+ assertTrue(pi.isActive("a"));
+
+ // The event listener should've added 1 to the variable value
+ Integer value = (Integer) executionService.getVariable(pi.getId(), var);
+ assertEquals(new Integer(varValue + 1), value);
+ }
+
+}
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+
+ <bean id="myEventListener" class="org.jbpm.test.spring.expression.eventlistener.MyEventListener" />
+
+ <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
+ <constructor-arg value="org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml" />
+ </bean>
+
+ <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+</beans>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.bpmn.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
+
+ <!-- Spring configuration -->
+ <import resource="jbpm.tx.spring.cfg.xml" />
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,4 @@
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=info, stdout
\ No newline at end of file
More information about the jbpm-commits
mailing list