[jbpm-commits] JBoss JBPM SVN: r5117 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/action and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jun 25 06:01:30 EDT 2009
Author: jim.ma
Date: 2009-06-25 06:01:29 -0400 (Thu, 25 Jun 2009)
New Revision: 5117
Added:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Access.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/VariableAccess.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/ProcessState.java
jbpm4/branches/jimma/modules/migration/src/test/resources/process-state.xml
jbpm4/branches/jimma/modules/migration/src/test/resources/script.xml
jbpm4/branches/jimma/modules/migration/src/test/resources/test-transition-resolve.xml
jbpm4/branches/jimma/modules/migration/src/test/resources/tmp-output.xml
Modified:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java
jbpm4/branches/jimma/modules/migration/src/main/resources/node.converter.types.xml
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
jbpm4/branches/jimma/modules/migration/src/test/resources/simple.xml
Log:
Added more tests and sub-process element conversion support
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Access.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Access.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Access.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,84 @@
+/*
+ * 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.jpdl.internal.convert;
+
+import java.io.Serializable;
+
+public class Access implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ String access = "read,write";
+
+ public Access() {
+ }
+
+ public Access(String access) {
+ if (access!=null) {
+ if ("".equals(access)) {
+ this.access = " ";
+ } else {
+ this.access = access;
+ }
+ }
+ }
+
+ public boolean isReadable() {
+ return hasAccess("read");
+ }
+
+ public boolean isWritable() {
+ return hasAccess("write");
+ }
+
+ public boolean isRequired() {
+ return hasAccess("required");
+ }
+
+ public boolean isLock() {
+ return hasAccess("lock");
+ }
+
+ /**
+ * verifies if the given accessLiteral is included in the access text.
+ */
+ public boolean hasAccess(String accessLiteral) {
+ if (access==null) return false;
+ return (access.indexOf(accessLiteral.toLowerCase())!=-1);
+ }
+
+ public String toString() {
+ return access;
+ }
+
+ public boolean equals(Object object) {
+ if (object instanceof Access) {
+ Access other = (Access) object;
+ return (isReadable()==other.isReadable())
+ && (isWritable()==other.isWritable())
+ && (isRequired()==other.isRequired())
+ && (isLock()==other.isLock());
+ } else {
+ return false;
+ }
+ }
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -180,7 +180,8 @@
// second pass processing
resolveTransitionDestinations();
- resolveActionReferences();
+ //TODO: Resolve action reference
+ //resolveActionReferences();
verifySwimlaneAssignments();
}
@@ -261,6 +262,10 @@
Element nodeElement = (Element)nodeElementIter.next();
String nodeName = nodeElement.getName();
// get the node type
+
+ if ("super-state".equalsIgnoreCase(nodeName) || "mail-node".equalsIgnoreCase(nodeName)) {
+ this.addError("Unsupported " + nodeName + " conversion : <" + nodeName + " name=\"" + element.attributeValue("name") + "\"");
+ }
Class<?> nodeType = NodeConverterTypes.getNodeType(nodeName);
if (nodeType != null)
{
@@ -380,7 +385,7 @@
if (duedateText != null) {
//TODO: Unsupported duedateText
- addWarning("Unsupported duedateText attribute converstion for task : " + taskElement.asXML());
+ addWarning("Unsupported duedateDate attribute converstion for task : " + taskElement.asXML());
}
@@ -477,14 +482,14 @@
protected void readAssignmentDelegation(Element assignmentElement, Element task4)
{
- //TODO:Ask question about this, How to convert the ExpressionAssignmentHandler
+
String expression = assignmentElement.attributeValue("expression");
String actorId = assignmentElement.attributeValue("actor-id");
String pooledActors = assignmentElement.attributeValue("pooled-actors");
if (expression != null)
{
- //How to convert default assignmenthandler
+ //TODO:How to convert default assignmenthandler
//assignmentDelegation.setClassName("org.jbpm.identity.assignment.ExpressionAssignmentHandler");
//assignmentDelegation.setConfiguration("<expression>" + expression + "</expression>");
@@ -492,7 +497,7 @@
else if ((actorId != null) || (pooledActors != null))
{
//TODO:Ask question
- task4.addComment("Please Update the Assignment handler to jpdl4");
+ task4.addComment("Please Update the AssignmentHandler and implement org.jbpm.api.task.AssignmentHandler to create your own AssignmentHandler");
Element assignmentHandler = task4.addElement("assignment-handler");
assignmentHandler.addAttribute("class", "org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
@@ -516,21 +521,29 @@
}
}
- /*
- protected TaskController readTaskController(Element taskControllerElement)
- {
- return null;
- }
public List<VariableAccess> readVariableAccesses(Element element)
{
- return null;
- }
+ List<VariableAccess> variableAccesses = new ArrayList<VariableAccess>();
+ Iterator<?> iter = element.elementIterator("variable");
+ while (iter.hasNext())
+ {
+ Element variableElement = (Element)iter.next();
- public void readStartStateTask(Element startTaskElement, StartState startState)
- {
+ String variableName = variableElement.attributeValue("name");
+ if (variableName == null)
+ {
+ addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: " + variableElement.asXML()));
+ }
+ String access = variableElement.attributeValue("access", "read,write");
+ String mappedName = variableElement.attributeValue("mapped-name");
+
+ variableAccesses.add(new VariableAccess(variableName, access, mappedName));
+ }
+ return variableAccesses;
}
-*/
+
+
public void readNode(Element nodeElement, Element jpdl4Element)
{
@@ -592,10 +605,7 @@
createTimerAction.createConvertedElement(timerElement, onElement);
createTimerAction.read(timerElement, this);
- //TODO: investigate if there is equivalent cancel timer action in jpdl4...
- /*CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
- cancelTimerAction.setTimerName(name);
- addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);*/
+ //TODO: if there is equivalent cancel timer action in jpdl4...
}
private String generateTimerName()
@@ -659,35 +669,8 @@
}
- //TODO: handle createTimerAction and cancelTimerAction
- /*createTimerAction.setTimerAction(action);
- addAction(task, Event.EVENTTYPE_TASK_CREATE, createTimerAction);
-
- // read the cancel-event types
- Collection<String> cancelEventTypes = new ArrayList<String>();
-
- String cancelEventTypeText = timerElement.attributeValue("cancel-event");
- if (cancelEventTypeText != null)
- {
- // cancel-event is a comma separated list of events
- StringTokenizer tokenizer = new StringTokenizer(cancelEventTypeText, ",");
- while (tokenizer.hasMoreTokens())
- {
- cancelEventTypes.add(tokenizer.nextToken().trim());
- }
- }
- else
- {
- // set the default
- cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
- }
-
- for (String cancelEventType : cancelEventTypes)
- {
- CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
- cancelTimerAction.setTimerName(name);
- addAction(task, cancelEventType, cancelTimerAction);
- }*/
+ //TODO: Revist if we need to handle cancelTimerAction
+
}
public void readEvents(Element parentElement, Element jpdl4Element)
@@ -715,9 +698,14 @@
{
Element actionElement = (Element)nodeElementIter.next();
String actionName = actionElement.getName();
+
+ if("cancel-timer".equalsIgnoreCase(actionName) || "mail".equalsIgnoreCase(actionName)) {
+ this.addWarning("Unsupported " + actionName + " conversion on Element : " + actionElement.asXML());
+ }
+
if (ActionConverterTypes.hasActionName(actionName))
{
- Element action4 = createAction(actionElement, jpdl4Element);
+ createAction(actionElement, jpdl4Element);
}
}
@@ -744,7 +732,7 @@
{
// create a new instance of the action
Action action = null;
- String actionName = actionElement.getName();
+ String actionName = actionElement.getName();
Class<? extends Action> actionType = ActionConverterTypes.getActionType(actionName);
try
{
@@ -763,16 +751,15 @@
protected void readExceptionHandlers(Element graphElement, Element jpdl4Element)
{
- this.addWarning("Unsupported exception handler conversion for element : <" + graphElement.getName()
- + "name=" + graphElement.attributeValue("name") + "/>" );
+ Iterator<?> iter = graphElement.elementIterator("exception-handler");
+ if (iter.hasNext()) {
+ addWarning("Unsupported exception handler conversion for element : <"
+ + graphElement.getName()
+ + " name=\""
+ + graphElement.attributeValue("name") + "\"/>");
+ }
}
-/*
- protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement)
- {
- // create the exception handler
-
- }
-*/
+
// transition destinations are parsed in a second pass //////////////////////
public void addUnresolvedTransitionDestination(Element nodeElement, Element jpdl4Element)
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/VariableAccess.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/VariableAccess.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/VariableAccess.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,93 @@
+/*
+ * 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.jpdl.internal.convert;
+
+import java.io.Serializable;
+
+/**
+ * This is orignally from jbpm3 codebase.
+ * specifies access to a variable.
+ * Variable access is used in 3 situations:
+ * 1) process-state
+ * 2) script
+ * 3) task controllers
+ */
+public class VariableAccess implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ long id = 0;
+ protected String variableName = null;
+ protected Access access = null;
+ protected String mappedName = null;
+
+ // constructors /////////////////////////////////////////////////////////////
+
+ public VariableAccess() {
+ }
+
+ public VariableAccess(String variableName, String access, String mappedName) {
+ this.variableName = variableName;
+ if (access!=null) access = access.toLowerCase();
+ this.access = new Access(access);
+ this.mappedName = mappedName;
+ }
+
+ // getters and setters //////////////////////////////////////////////////////
+
+ /**
+ * the mapped name. The mappedName defaults to the variableName in case
+ * no mapped name is specified.
+ */
+ public String getMappedName() {
+ if (mappedName==null) {
+ return variableName;
+ }
+ return mappedName;
+ }
+
+ /**
+ * specifies a comma separated list of access literals {read, write, required}.
+ */
+ public Access getAccess() {
+ return access;
+ }
+ public String getVariableName() {
+ return variableName;
+ }
+
+ public boolean isReadable() {
+ return access.isReadable();
+ }
+
+ public boolean isWritable() {
+ return access.isWritable();
+ }
+
+ public boolean isRequired() {
+ return access.isRequired();
+ }
+
+ public boolean isLock() {
+ return access.isLock();
+ }
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -58,8 +58,9 @@
convertedElement.addAttribute("lang", "juel");
} else if (actionElement.attribute("ref-name")!=null) {
- //TODO: action reference ...
- //jpdlReader.addUnresolvedActionReference(actionElement, this);
+ //TODO: Unsupported ref-name
+ //jpdlReader.addUnresolvedActionReference(actionElement, this);
+ jpdlReader.addWarning("Unsupported ref-name attribute conversion in element " + actionElement.asXML());
} else if (actionElement.attribute("class")!=null) {
convertedElement.addAttribute("class", actionElement.attributeValue("class"));
convertedElement.addAttribute("method", "execute");
@@ -74,13 +75,12 @@
|| "off".equalsIgnoreCase(acceptPropagatedEvents)) {
isPropagationAllowed = false;
}
- //TODO:Async
+
String asyncText = actionElement.attributeValue("async");
if ("true".equalsIgnoreCase(asyncText)) {
- isAsync = true;
+ convertedElement.addAttribute("async", "true");
} else if ("exclusive".equalsIgnoreCase(asyncText)) {
- isAsync = true;
- isAsyncExclusive = true;
+ convertedElement.addAttribute("async", "exclusive");
}
}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -26,5 +26,21 @@
public class Script extends Action {
-
+ public Element createConvertedElement(Element actionElement, Element jpdl4Doc) {
+ convertedElement = jpdl4Doc.addElement("script");
+ return convertedElement;
+ }
+
+ public void read(Element actionElement, Jpdl3ConverterReader jpdlReader) {
+ String expression = null;
+ if (actionElement.isTextOnly()) {
+ expression = actionElement.getText();
+ } else {
+ //TODO:Unsupported variable conversion
+ //List<VariableAccess> vias = jpdlReader.readVariableAccesses(actionElement);
+ expression = actionElement.element("expression").getText();
+ }
+ convertedElement.addAttribute("expr", expression);
+ convertedElement.addAttribute("lang", "juel");
+ }
}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/ProcessState.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/ProcessState.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/ProcessState.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,41 @@
+package org.jbpm.jpdl.internal.convert.node;
+
+import java.util.List;
+
+import org.dom4j.Element;
+import org.jbpm.jpdl.internal.convert.Jpdl3ConverterReader;
+import org.jbpm.jpdl.internal.convert.VariableAccess;
+
+public class ProcessState extends Node {
+ public Element createConvertedElement(Element jpdl4Doc) {
+ convertedElement = jpdl4Doc.addElement("sub-process");
+ return convertedElement;
+ }
+
+ public void read(Jpdl3ConverterReader reader) {
+
+ String name = nodeElement.attributeValue("name");
+
+ convertedElement.attributeValue("name", name);
+
+ Element subProcessElement = nodeElement.element("sub-process");
+ if (subProcessElement!=null) {
+ String subProcessName = subProcessElement.attributeValue("name");
+ //String subProcessVersion = subProcessElement.attributeValue("version");
+ convertedElement.attributeValue("sub-process-id", subProcessName);
+ }
+
+ List<VariableAccess> readVariableAccesses = reader.readVariableAccesses(nodeElement);
+ for (VariableAccess via : readVariableAccesses) {
+ Element para = null;
+ if (via.isReadable()) {
+ para = convertedElement.addElement("parameter-in");
+ } else {
+ para = convertedElement.addElement("parameter-out");
+ }
+ para.addAttribute("var", via.getVariableName());
+ para.addAttribute("subvar", via.getMappedName());
+ }
+
+ }
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/resources/node.converter.types.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/resources/node.converter.types.xml 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/main/resources/node.converter.types.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -8,9 +8,9 @@
<node-type element="join" class="org.jbpm.jpdl.internal.convert.node.Join" />
<node-type element="decision" class="org.jbpm.jpdl.internal.convert.node.Decision" />
<node-type element="process-state" class="org.jbpm.jpdl.internal.convert.node.ProcessState" />
- <node-type element="super-state" class="org.jbpm.jpdl.internal.convert.node.SuperState" />
+ <!--node-type element="super-state" class="org.jbpm.jpdl.internal.convert.node.SuperState" />
<node-type element="mail-node" class="org.jbpm.jpdl.internal.convert.node.MailNode" />
- <!--node-type element="merge" class="org.jbpm.jpdl.internal.convert.node.Merge" />
+ <node-type element="merge" class="org.jbpm.jpdl.internal.convert.node.Merge" />
<node-type element="milestone-node" class="oorg.jbpm.jpdl.internal.convert.node.MilestoneNode" />
<node-type element="interleave-start" class="org.jbpm.jpdl.internal.convert.node.InterleaveStart" />
<node-type element="interleave-end" class="org.jbpm.jpdl.internal.convert.node.InterleaveEnd"/>
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-06-25 10:01:29 UTC (rev 5117)
@@ -34,22 +34,22 @@
import org.junit.Test;
import org.xml.sax.InputSource;
-public class Jpdl3ConverterReaderTest {
+public class Jpdl3ConverterReaderTest {
@Test
public void testSimpleProcesss() throws Exception {
testConvert("simple.xml");
}
-
+
@Ignore
public void testBusinessTrip() throws Exception {
testConvert("businesstrip.xml");
}
-
+
@Test
public void testAssignment() throws Exception {
testConvert("assignment.xml");
}
-
+
@Test
public void testEvent() throws Exception {
setUpScriptManager();
@@ -60,48 +60,108 @@
public void testDescision() throws Exception {
testConvert("testDecision.xml");
}
+
+ @Test
+ public void testProcessState() throws Exception {
+ testConvert("process-state.xml");
+ }
+
+ @Test
+ public void testScript() throws Exception {
+ setUpScriptManager();
+ testConvert("script.xml");
+ }
+
+ @Test
+ // Unsupported exception handler conversion test
+ public void testExceptionHandler() throws Exception {
+ InputStream inputStream = getClass().getClassLoader()
+ .getResourceAsStream("exception-handler.xml");
+ // Convert to process file to jpdl4
+ InputSource ins = new InputSource(inputStream);
+ Jpdl3ConverterReader converter = new Jpdl3ConverterReader(ins);
+ Document doc = converter.readAndConvert();
+ Assert.assertEquals(converter.problems.size(), 2);
+ Assert.assertTrue(converter.problems.get(0).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
+ Assert.assertTrue(converter.problems.get(1).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
+ }
+
+ @Test
+ //Unsupported super-sate and mail node conversion
+ public void testSuperStateAndMailNode() {
+ InputStream inputStream = getClass().getClassLoader()
+ .getResourceAsStream("superstate-mail.xml");
+ // Convert to process file to jpdl4
+ InputSource ins = new InputSource(inputStream);
+ Jpdl3ConverterReader converter = new Jpdl3ConverterReader(ins);
+ try {
+ Document doc = converter.readAndConvert();
+ Assert.fail("The unsupported exception does not throw");
+ } catch (java.lang.Throwable e) {
+ }
+ }
@Test
+ public void testTransitionResolved() {
+ InputStream inputStream = getClass().getClassLoader()
+ .getResourceAsStream("test-transition-resolve.xml");
+ // Convert to process file to jpdl4
+ InputSource ins = new InputSource(inputStream);
+ Jpdl3ConverterReader converter = new Jpdl3ConverterReader(ins);
+ Document doc = converter.readAndConvert();
+ Assert.assertEquals(converter.problems.size(), 2);
+ for (org.jbpm.jpdl.internal.convert.Problem pb : converter.problems) {
+ System.out.println(pb);
+ }
+ Assert.assertTrue(converter.problems.get(0).toString().startsWith(
+ "[WARNING] transition to='first2'"));
+ Assert.assertTrue(converter.problems.get(1).toString().startsWith(
+ "[WARNING] transition to='end2'"));
+
+ }
+
+ @Test
public void testTimer() throws Exception {
String xml = convert("timer.xml");
- List<Problem> problems = new JpdlParser().createParse().setString(xml).execute().getProblems();
- Assert.assertEquals(2, problems.size());
- Assert.assertTrue(problems.get(0).getMsg().startsWith("unrecognized event listener"));
- Assert.assertTrue(problems.get(1).getMsg().startsWith("unrecognized event listener"));
+ List<Problem> problems = new JpdlParser().createParse().setString(xml)
+ .execute().getProblems();
+ Assert.assertEquals(2, problems.size());
+ Assert.assertTrue(problems.get(0).getMsg().startsWith(
+ "unrecognized event listener"));
+ Assert.assertTrue(problems.get(1).getMsg().startsWith(
+ "unrecognized event listener"));
}
-
+
private void testConvert(String resourcefile) throws Exception {
- String xml = convert(resourcefile);
- List<Problem> problems = new JpdlParser().createParse().setString(xml).execute().getProblems();
+ String xml = convert(resourcefile);
+ List<Problem> problems = new JpdlParser().createParse().setString(xml)
+ .execute().getProblems();
Assert.assertEquals(problems.toString(), 0, problems.size());
}
-
-
+
private String convert(String resouceFile) throws Exception {
- InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resouceFile);
- //Convert to process file to jpdl4
+ InputStream inputStream = getClass().getClassLoader()
+ .getResourceAsStream(resouceFile);
+ // Convert to process file to jpdl4
InputSource ins = new InputSource(inputStream);
Jpdl3ConverterReader converter = new Jpdl3ConverterReader(ins);
Document doc = converter.readAndConvert();
- return doc.asXML();
+ // System.out.println(doc.asXML());
+ return doc.asXML();
}
-
-
- private String format(String test) {
-
- }
private void setUpScriptManager() throws Exception {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
- + " <process-engine-context>"
- + " <script-manager default-expression-language='juel'"
- + " default-script-language='juel'"
- + " read-contexts='execution, environment, process-engine' "
- + " write-context='execution'>"
- + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
- + " </script-manager>"
- + " </process-engine-context> </jbpm-configuration>");
-
- environmentFactory.openEnvironment();
+ EnvironmentFactory environmentFactory = JbpmConfiguration
+ .parseXmlString("<jbpm-configuration>"
+ + " <process-engine-context>"
+ + " <script-manager default-expression-language='juel'"
+ + " default-script-language='juel'"
+ + " read-contexts='execution, environment, process-engine' "
+ + " write-context='execution'>"
+ + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
+ + " </script-manager>"
+ + " </process-engine-context> </jbpm-configuration>");
+
+ environmentFactory.openEnvironment();
}
}
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/process-state.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/process-state.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/process-state.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="hire">
+ <start-state>
+ <transition to="initial interview" />
+ </start-state>
+ <process-state name="initial interview">
+ <sub-process name="interview" />
+ <variable name="a" access="read,write" mapped-name="aa" />
+ <variable name="b" access="read" mapped-name="bb" />
+ <transition to="end" />
+ </process-state>
+ <end-state name="end"></end-state>
+</process-definition>
+
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/script.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/script.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/script.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,36 @@
+<process-definition
+ xmlns="urn:jbpm.org:jpdl-3.2"
+ name="action process">
+
+ <event type="node-enter">
+ <script>
+ <variable name="var1" />
+ <variable name="var2" />
+ <expression>
+ System.out.println("blabla");
+ </expression>
+ </script>
+ <script>
+ System.out.println("blabla");
+ </script>
+ </event>
+
+ <start-state name="start">
+ <transition name="to_state" to="first">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>Going to the first state!</message>
+ </action>
+ </transition>
+ </start-state>
+ <state name="first">
+ <event type="node-enter">
+ <action class="org.jbpm.AnotherTest"/>
+ </event>
+ <transition name="to_end" to="end">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>About to finish!</message>
+ </action>
+ </transition>
+ </state>
+ <end-state name="end"></end-state>
+</process-definition>
\ No newline at end of file
Modified: jbpm4/branches/jimma/modules/migration/src/test/resources/simple.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/simple.xml 2009-06-25 09:51:41 UTC (rev 5116)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/simple.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -11,6 +11,9 @@
</transition>
</start-state>
<state name="first">
+ <event type="node-enter">
+ <action class="org.jbpm.AnotherTest"/>
+ </event>
<transition name="to_end" to="end">
<action name="action" class="com.sample.action.MessageActionHandler">
<message>About to finish!</message>
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/test-transition-resolve.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/test-transition-resolve.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/test-transition-resolve.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition
+ xmlns="urn:jbpm.org:jpdl-3.2"
+ name="simple">
+ <start-state name="start">
+ <transition name="to_state" to="first2">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>Going to the first state!</message>
+ </action>
+ </transition>
+ </start-state>
+ <state name="first">
+ <event type="node-enter">
+ <action class="org.jbpm.AnotherTest"/>
+ </event>
+ <transition name="to_end" to="end2">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>About to finish!</message>
+ </action>
+ </transition>
+ </state>
+ <end-state name="end"></end-state>
+</process-definition>
\ No newline at end of file
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/tmp-output.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/tmp-output.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/tmp-output.xml 2009-06-25 10:01:29 UTC (rev 5117)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://jbpm.org/4.0/jpdl" name="hire">
+ <start>
+ <transition to="initial interview" />
+ </start>
+ <sub-process name="initial interview">
+ <parameter-in var="a" subvar="aa" />
+ <parameter-in var="b" subvar="bb" />
+ <transition to="end" />
+ </sub-process>
+ <end name="end" />
+</process>
More information about the jbpm-commits
mailing list