[jboss-svn-commits] JBL Code SVN: r9825 - in labs/jbossesb/trunk/product: samples/quickstarts/jbpm_simple1/src and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 27 19:02:00 EST 2007
Author: estebanschifman
Date: 2007-02-27 19:01:59 -0500 (Tue, 27 Feb 2007)
New Revision: 9825
Added:
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/gpd.xml
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/hibernate.cfg.xml
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processdefinition.xml
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processimage.jpg
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/jbpm/CommandInterpreter.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/JbpmActionHandler.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/TestLauncher.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/JunitTest.java
labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/TestCommandMessages.java
Log:
Attempts to make the jbpm_simple1 quickstart work.
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/jbpm/CommandInterpreter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/jbpm/CommandInterpreter.java 2007-02-27 23:27:39 UTC (rev 9824)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/jbpm/CommandInterpreter.java 2007-02-28 00:01:59 UTC (rev 9825)
@@ -129,7 +129,6 @@
try
{
prepareJbpm();
-// _jbpmCtx.getSession().beginTransaction();
ProcessDefinition def = _command.getProcessDefinition();
_jbpmCtx.deployProcessDefinition(def);
_command.setProcessDefinitionName (def.getName());
@@ -149,7 +148,6 @@
{
prepareJbpm();
_processInstance = _jbpmCtx.newProcessInstance(_command.getProcessDefinitionName());
-// _jbpmCtx.getSession().beginTransaction();
_jbpmCtx.save(_processInstance);
_command.setProcessVersion(_processInstance.getProcessDefinition().getVersion());
@@ -172,7 +170,6 @@
{
long id = _command.getInstanceId();
prepareJbpm();
-// _jbpmCtx.getSession().beginTransaction();
_processInstance = _jbpmCtx.loadProcessInstanceForUpdate(id);
_processInstance.signal();
_jbpmCtx.save(_processInstance);
@@ -198,7 +195,6 @@
{
long id = _command.getTokenId();
prepareJbpm();
-// _jbpmCtx.getSession().beginTransaction();
_token = _jbpmCtx.loadTokenForUpdate(id);
_token.signal();
_jbpmCtx.save(_token);
@@ -279,7 +275,6 @@
}
long id = _command.getInstanceId();
prepareJbpm();
-// _jbpmCtx.getSession().beginTransaction();
_processInstance = _jbpmCtx.loadProcessInstanceForUpdate(id);
_processInstance.getContextInstance().addVariables(newVals);
_jbpmCtx.save(_processInstance);
@@ -337,7 +332,6 @@
}
long id = _command.getTokenId();
prepareJbpm();
-// _jbpmCtx.getSession().beginTransaction();
_token = _jbpmCtx.loadToken(id);
_token.getProcessInstance().getContextInstance().addVariables(newVals,_token);
_jbpmCtx.save(_token);
@@ -390,24 +384,32 @@
protected void prepareJbpm()
{
- _jbpmConfig = null;
_jbpmCtx = null;
- _jbpmConfig = JbpmConfiguration.getInstance();
- _jbpmCtx = _jbpmConfig.createJbpmContext();
+ _jbpmCtx = getJbpmConfig().createJbpmContext();
} //________________________________
protected void cleanupJbpm()
{
if (null!=_jbpmCtx) _jbpmCtx.close();
- if (null!=_jbpmConfig) _jbpmConfig.close();
- _jbpmConfig = null;
_jbpmCtx = null;
_processInstance= null;
_token = null;
} //________________________________
+ protected static JbpmConfiguration getJbpmConfig()
+ {
+ if (null== s_jbpmConfig)
+ synchronized (s_oSynch)
+ {
+ if (null==s_jbpmConfig)
+ s_jbpmConfig = JbpmConfiguration.getInstance();
+ }
+ return s_jbpmConfig;
+ } //________________________________
+
protected ConfigTree _config;
protected CommandVehicle _command;
- protected JbpmConfiguration _jbpmConfig;
+ private static final Object s_oSynch = new Integer(0);
+ private static JbpmConfiguration s_jbpmConfig;
protected JbpmContext _jbpmCtx;
protected ProcessInstance _processInstance;
protected Token _token;
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/gpd.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/gpd.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/gpd.xml 2007-02-28 00:01:59 UTC (rev 9825)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-diagram name="simple" width="690" height="503">
+ <node name="start" x="0" y="0" width="140" height="40">
+ <transition name="to_state">
+ <label x="5" y="-10"/>
+ </transition>
+ </node>
+ <node name="first" x="0" y="0" width="140" height="40">
+ <transition name="to_end">
+ <label x="5" y="-10"/>
+ </transition>
+ </node>
+ <node name="end" x="0" y="0" width="140" height="40"/>
+</process-diagram>
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/gpd.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/hibernate.cfg.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/hibernate.cfg.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/hibernate.cfg.xml 2007-02-28 00:01:59 UTC (rev 9825)
@@ -0,0 +1,176 @@
+<?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>
+ <!-- jdbc connection properties -->
+<!--
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.;sql.enforce_strict_size=true</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost/juddi</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+-->
+ <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
+ <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/JbpmDB</property>
+ <property name="hibernate.connection.username">postgres</property>
+ <property name="hibernate.connection.password"></property>
+
+
+ <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
+ <!-- other hibernate properties
+ <property name="hibernate.show_sql">true</property>
+ <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.use_sql_comments">true</property>
+ -->
+
+ <!-- ############################################ -->
+ <!-- # mapping files with external dependencies # -->
+ <!-- ############################################ -->
+
+ <!-- following mapping file has a dependendy on -->
+ <!-- 'bsh-{version}.jar'. -->
+ <!-- uncomment this if you don't have bsh on your -->
+ <!-- classpath. you won't be able to use the -->
+ <!-- script element in process definition files -->
+ <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>
+
+ <!-- following mapping files have a dependendy on -->
+ <!-- 'jbpm-identity-{version}.jar', mapping files -->
+ <!-- of the pluggable jbpm identity component. -->
+ <!-- comment out the following 3 lines if you don't-->
+ <!-- want to use the default jBPM identity mgmgt -->
+ <!-- component -->
+ <mapping resource="org/jbpm/identity/User.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Group.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Membership.hbm.xml"/>
+
+ <!-- ###################### -->
+ <!-- # jbpm mapping files # -->
+ <!-- ###################### -->
+
+ <!-- hql queries and type defs -->
+ <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml" />
+
+ <!-- graph.def mapping files -->
+ <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>
+ <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>
+
+ <!-- graph.node mapping files -->
+ <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>
+
+ <!-- context.def mapping files -->
+ <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>
+
+ <!-- taskmgmt.def mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>
+
+ <!-- module.def mapping files -->
+ <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>
+
+ <!-- bytes mapping files -->
+ <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>
+
+ <!-- file.def mapping files -->
+ <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>
+
+ <!-- scheduler.def mapping files -->
+ <mapping resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>
+ <mapping resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>
+
+ <!-- graph.exe mapping files -->
+ <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>
+
+ <!-- module.exe mapping files -->
+ <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>
+
+ <!-- context.exe mapping files -->
+ <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
+
+ <!-- msg.db mapping files -->
+ <mapping resource="org/jbpm/msg/Message.hbm.xml"/>
+ <mapping resource="org/jbpm/msg/db/TextMessage.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteActionCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteNodeCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/SignalCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/TaskInstanceEndCommand.hbm.xml"/>
+
+ <!-- taskmgmt.exe mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>
+
+ <!-- scheduler.exe mapping files -->
+ <mapping resource="org/jbpm/scheduler/exe/Timer.hbm.xml"/>
+
+ <!-- logging mapping files -->
+ <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processdefinition.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processdefinition.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processdefinition.xml 2007-02-28 00:01:59 UTC (rev 9825)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition
+ xmlns="urn:jbpm.org:jpdl-3.1"
+ name="simple">
+ <start-state name="start">
+ <transition name="to_state" to="first">
+ <action name="action" class="quickstart.jbpm_simple1.JbpmActionHandler">
+ <message>Going to the first state!</message>
+ </action>
+ </transition>
+ </start-state>
+ <state name="first">
+ <transition name="to_end" to="end">
+ <action name="action" class="quickstart.jbpm_simple1.JbpmActionHandler">
+ <message>About to finish!</message>
+ </action>
+ </transition>
+ </state>
+ <end-state name="end"></end-state>
+</process-definition>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processdefinition.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Added: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processimage.jpg
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/processimage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/JbpmActionHandler.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/JbpmActionHandler.java 2007-02-27 23:27:39 UTC (rev 9824)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/JbpmActionHandler.java 2007-02-28 00:01:59 UTC (rev 9825)
@@ -6,11 +6,14 @@
public class JbpmActionHandler implements ActionHandler {
+ public String message;
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext ctx) throws Exception {
+ ctx.getContextInstance().setVariable("message", message);
ctx.getContextInstance().setVariable("invocationCounter",++_counter);
_logger.info(getClass().getSimpleName()+" invoked - count = "+_counter);
+
}
private static int _counter = 0;
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/TestLauncher.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/TestLauncher.java 2007-02-27 23:27:39 UTC (rev 9824)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/TestLauncher.java 2007-02-28 00:01:59 UTC (rev 9825)
@@ -1,20 +1,43 @@
package quickstart.jbpm_simple1;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.listeners.StandAloneBootStrapper;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
import org.jbpm.JbpmConfiguration;
+import com.arjuna.common.util.propertyservice.PropertyManager;
+
public class TestLauncher {
+ private static Logger _logger = Logger.getLogger(TestLauncher.class);
+
public static void main(String[] args) throws Exception
{
try
{
_config = JbpmConfiguration.getInstance();
createJbpmSchema();
+ setupRegistry();
+ runBeforeTest();
StandAloneBootStrapper.main(args);
}
finally
{
+ runAfterTest();
// dropJbpmSchema();
}
} //________________________________
@@ -24,16 +47,120 @@
{
try { dropJbpmSchema(); }
catch (Exception e) {}
+ _logger.info("&&&&&&&&&&&&&&& CREATING jBPM schema");
_config.createSchema();
}
static void dropJbpmSchema()
{
if (null!=_config)
{
+ _logger.info("&&&&&&&&&&&&&&& Dropping jBPM schema");
_config.dropSchema();
_config.close();
}
}
+ public static void runAfterTest()
+ {
+ try
+ {
+ Thread.sleep(2000);
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
+ HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
+ }
+ catch (Exception e) {}
+ }
+
+ public static void runBeforeTest()
+ {
+ try {
+
+ String userDir = System.getProperty("user.dir");
+ String baseDir = (userDir.endsWith("jbpm_simple1"))
+ ? userDir
+ : userDir + "/product/samples/quickstarts/jbpm_simple1";
+ DOMConfigurator.configure(baseDir + "/log4j.xml");
+ TestEnvironmentUtil.setESBPropertiesFileToUse(".");
+ //Set the juddi properties file in System so juddi will pick it up later and use the test values.
+ baseDir = (userDir.endsWith("jbpm_simple1"))
+ ? userDir+"/../../../.."
+ : userDir;
+ String juddiPropertiesFile = baseDir+"/qa/junit/src/org/jboss/soa/esb/services/registry/juddi-qatest.properties";
+
+ System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
+ //Read this properties file to get the db connection string
+ Properties props = new Properties();
+ InputStream inStream = new FileInputStream(juddiPropertiesFile);
+ props.load(inStream);
+ mDbDriver = props.getProperty("juddi.jdbcDriver");
+ mDbUrl = props.getProperty("juddi.jdbcUrl");
+ mDbUsername = props.getProperty("juddi.jdbcUsername");
+ mDbPassword = props.getProperty("juddi.jdbcPassword");
+
+ String database="not tested yet";
+ if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+ database = "hsqldb";
+ //Bring up hsql on default port 9001
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "build/hsqltestdb", "juddi");
+ } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
+ database = "mysql";
+ } //add and test your own database..
+
+ //Get the registry-schema create scripts
+ String sqlDir = baseDir+"/product/install/jUDDI-registry/sql/" + database + "/";
+ //Drop what is there now, if exists. We want to start fresh.
+ String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+ String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+ String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
+
+ try {
+ Class.forName(mDbDriver);
+ } catch (Exception e) {
+ System.out.println("ERROR: failed to load " + database + " JDBC driver.");
+ e.printStackTrace();
+ return;
+ }
+ java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
+ Statement stmnt = con.createStatement();
+ stmnt.execute(sqlDropCmd);
+ stmnt.execute(sqlCreateCmd);
+ stmnt.execute(sqlInsertPubCmd);
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.out.println("We should stop testing, since we don't have a db.");
+ assertTrue(false);
+ }
+ }
+
+ private static String mDbDriver;
+ private static String mDbUrl;
+ private static String mDbUsername;
+ private static String mDbPassword;
+
+ /**
+ * Invocation of this method should be unnecessary.
+ * Had to invoke it because I had trouble to have the properties loaded from jbossesb-properties.xml
+ * Once that is solved, you can get rid of the invocation to this method (up in the run() )
+ */
+ protected static void setupRegistry() {
+ PropertyManager mgr = null;
+
+ mgr = ModulePropertyManager.getPropertyManager("registry");
+ mgr.setProperty(Environment.REGISTRY_IMPEMENTATION_CLASS,"org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl");
+ mgr.setProperty(Environment.REGISTRY_QUERY_MANAGER_URI,"jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire");
+ mgr.setProperty(Environment.REGISTRY_LIFECYCLE_MANAGER_URI,"jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish");
+ mgr.setProperty(Environment.REGISTRY_FACTORY_CLASS,"org.apache.ws.scout.registry.ConnectionFactoryImpl");
+ mgr.setProperty(Environment.REGISTRY_SCOUT_TRANSPORT_CLASS,"org.apache.ws.scout.transport.RMITransport");
+ mgr.setProperty(Environment.REGISTRY_USER,"jbossesb");
+ mgr.setProperty(Environment.REGISTRY_PASSWORD,"password");
+ System.setProperty("javax.xml.registry.ConnectionFactoryClass", "org.apache.ws.scout.registry.ConnectionFactoryImpl");
+
+ mgr = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE) ;
+ mgr.setProperty(Environment.REGISTRY_FILE_HELPER_DIR, System.getProperty("java.io.tmpdir","/tmp")) ;
+
+ }
+
+
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/JunitTest.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/JunitTest.java 2007-02-27 23:27:39 UTC (rev 9824)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/JunitTest.java 2007-02-28 00:01:59 UTC (rev 9825)
@@ -2,7 +2,7 @@
import junit.framework.TestCase;
-import org.hibernate.Session;
+import org.apache.log4j.Logger;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
@@ -12,13 +12,11 @@
JbpmConfiguration _config;
JbpmContext _ctx;
- Session _session;
public void setUp() {
_config = JbpmConfiguration.getInstance();
_config.createSchema();
_ctx = _config.createJbpmContext();
- _session = _ctx.getSession();
}
public void tearDown() {
@@ -34,11 +32,13 @@
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("processdefinition.xml");
assertNotNull("Definition should not be null", processDefinition);
- _session.saveOrUpdate(processDefinition);
+ _ctx.getSession().saveOrUpdate(processDefinition);
String processName = processDefinition.getName();
processDefinition = null;
-
+
+ _ctx.close();
+ _ctx = _config.createJbpmContext();
ProcessInstance instance = _ctx.newProcessInstance(processName);
assertEquals(
"Instance is in start state",
@@ -52,26 +52,29 @@
_ctx.save(instance);
long instanceId = instance.getId();
+ _ctx.close();
+ _ctx = _config.createJbpmContext();
instance = _ctx.loadProcessInstanceForUpdate(instanceId);
assertEquals(
"Instance is in first state",
instance.getRootToken().getNode().getName(),
"first");
- assertEquals(
- "Message variable contains message",
- instance.getContextInstance().getVariable("message"),
- "Going to the first state!");
-
instance.signal();
_ctx.save(instance);
+
+ _ctx.close();
+ _ctx = _config.createJbpmContext();
instance = _ctx.loadProcessInstanceForUpdate(instanceId);
-
assertEquals(
"Instance is in end state",
instance.getRootToken().getNode().getName(),
"end");
+ _logger.info(
+ "Context variable invocationCounter contains "
+ +instance.getContextInstance().getVariable("invocationCounter"));
+
assertTrue("Instance has ended", instance.hasEnded());
assertEquals(
"Message variable is changed",
@@ -79,4 +82,5 @@
"About to finish!");
}
+ Logger _logger = Logger.getLogger(JunitTest.class);
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/TestCommandMessages.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/TestCommandMessages.java 2007-02-27 23:27:39 UTC (rev 9824)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jbpm_simple1/src/quickstart/jbpm_simple1/test/TestCommandMessages.java 2007-02-28 00:01:59 UTC (rev 9825)
@@ -1,24 +1,15 @@
package quickstart.jbpm_simple1.test;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Properties;
import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
import org.jboss.soa.esb.common.Environment;
import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.listeners.message.Invoker;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.testutils.FileUtil;
-import org.jboss.soa.esb.testutils.HsqldbUtil;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
import org.jboss.soa.esb.util.jbpm.CommandVehicle;
import com.arjuna.common.util.propertyservice.PropertyManager;
@@ -31,14 +22,12 @@
{
try
{
- runBeforeTest();
// following call should not be necessary - see method for comments
setupRegistry();
new TestCommandMessages().run();
}
finally
{
- runAfterTest();
System.exit(0);
}
}
@@ -182,85 +171,6 @@
return out.toString();
}
- public static void runAfterTest()
- {
- try
- {
- Thread.sleep(2000);
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
- catch (Exception e) {}
- }
-
- public static void runBeforeTest()
- {
- try {
-
- String userDir = System.getProperty("user.dir");
- String baseDir = (userDir.endsWith("jbpm_simple1"))
- ? userDir
- : userDir + "/product/samples/quickstarts/jbpm_simple1";
- DOMConfigurator.configure(baseDir + "/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse(".");
-
- //Set the juddi properties file in System so juddi will pick it up later and use the test values.
- baseDir = (userDir.endsWith("jbpm_simple1"))
- ? userDir+"/../../../.."
- : userDir;
- String juddiPropertiesFile = baseDir+"/qa/junit/src/org/jboss/soa/esb/services/registry/juddi-qatest.properties";
-
- System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- //Read this properties file to get the db connection string
- Properties props = new Properties();
- InputStream inStream = new FileInputStream(juddiPropertiesFile);
- props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- database = "hsqldb";
- //Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
- database = "mysql";
- } //add and test your own database..
-
- //Get the registry-schema create scripts
- String sqlDir = baseDir+"/product/install/jUDDI-registry/sql/" + database + "/";
- //Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try {
- Class.forName(mDbDriver);
- } catch (Exception e) {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
- e.printStackTrace();
- return;
- }
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
- Statement stmnt = con.createStatement();
- stmnt.execute(sqlDropCmd);
- stmnt.execute(sqlCreateCmd);
- stmnt.execute(sqlInsertPubCmd);
-
- } catch (Throwable e) {
- e.printStackTrace();
- System.out.println("We should stop testing, since we don't have a db.");
- assertTrue(false);
- }
- }
-
- private static String mDbDriver;
- private static String mDbUrl;
- private static String mDbUsername;
- private static String mDbPassword;
-
/**
* Invocation of this method should be unnecessary.
* Had to invoke it because I had trouble to have the properties loaded from jbossesb-properties.xml
More information about the jboss-svn-commits
mailing list