JBoss JBPM SVN: r6798 - in projects/migration_tool/trunk/src: main/java/org/jbpm/migration/util and 1 other directories.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-06 23:40:32 -0400 (Sat, 06 Nov 2010)
New Revision: 6798
Modified:
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
Log:
Fixed concatenation of the input XML files (simply added a common root element).
Modified: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java 2010-11-04 11:40:47 UTC (rev 6797)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java 2010-11-07 03:40:32 UTC (rev 6798)
@@ -43,6 +43,9 @@
/* XML Schema file for jPDL version 3.2 on the classpath. */
private static final String JPDL_3_2_SCHEMA = "Schemas/jPDL/jpdl-3.2.xsd";
+ /** Tag name for the root node (document element) of the concatenated document. */
+ private static final String CONCATENATED_ROOT_NODE = "concatenated-root";
+
/** Logging facility. */
private static final Logger LOGGER = Logger.getLogger(JpdlValidator.class);
@@ -52,8 +55,6 @@
/**
* Parse and validate a given jDPL/GPD process definition against the applicable schema.
- * <p>
- * TODO: Correct the concatenation process, throws a DOMException like this.
*
* @param jpdl
* The process definition.
@@ -63,15 +64,19 @@
* not successful.
*/
public static Document validateDefinition(File jpdl, File gpd) {
- Document jpdlDoc = validateDefinition(jpdl);
+ Document jpdlDoc = validateProcess(jpdl);
Document gpdDoc = validatePositioning(gpd);
Document concatenated = null;
if (jpdlDoc != null && gpdDoc != null) {
try {
concatenated = XmlUtils.createEmptyDocument();
- concatenated.appendChild(jpdlDoc);
- concatenated.appendChild(gpdDoc);
+ Node rootNode = concatenated.createElement(CONCATENATED_ROOT_NODE);
+ concatenated.appendChild(rootNode);
+ Node jpdlNode = concatenated.importNode(jpdlDoc.getDocumentElement(), true);
+ rootNode.appendChild(jpdlNode);
+ Node gpdNode = concatenated.importNode(gpdDoc.getDocumentElement(), true);
+ rootNode.appendChild(gpdNode);
} catch (Exception ex) {
LOGGER.error("Problem concatenating the jDPL and GPD definitions.", ex);
}
@@ -79,7 +84,7 @@
return concatenated;
}
- private static Document validateDefinition(File jpdl) {
+ private static Document validateProcess(File jpdl) {
// Parse the jDPL definition into a DOM tree.
Document document = XmlUtils.parseFile(jpdl);
if (document == null) {
Modified: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java 2010-11-04 11:40:47 UTC (rev 6797)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java 2010-11-07 03:40:32 UTC (rev 6798)
@@ -38,6 +38,7 @@
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.xml.sax.SAXParseException;
/**
@@ -165,13 +166,13 @@
}
/**
- * Format an XML document to a pretty-printable <code>String</code>.
+ * Format an XML document (fragment) to a pretty-printable <code>String</code>.
*
* @param input
- * The input XML document.
+ * The uppermost node of the input XML document (fragment).
* @return The formatted <code>String</code>.
*/
- public static String format(Document input) {
+ public static String format(Node input) {
StreamResult result = null;
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Modified: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java 2010-11-04 11:40:47 UTC (rev 6797)
+++ projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java 2010-11-07 03:40:32 UTC (rev 6798)
@@ -51,9 +51,7 @@
public void validDefinition() throws Exception {
File jpdl = new File("src/test/resources/jpdl3/singleNode/processdefinition.xml");
File gpd = new File("src/test/resources/jpdl3/singleNode/gpd.xml");
-
- // TODO: fix this part.
-// Document document = JpdlValidator.validateDefinition(jpdl, gpd);
-// assertThat(document, is(notNullValue()));
+ Document document = JpdlValidator.validateDefinition(jpdl, gpd);
+ assertThat(document, is(notNullValue()));
}
}
13 years, 6 months
JBoss JBPM SVN: r6797 - projects/migration_tool/trunk/src/test/java/org/jbpm/migration.
by do-not-reply@jboss.org
Author: eschabell
Date: 2010-11-04 07:40:47 -0400 (Thu, 04 Nov 2010)
New Revision: 6797
Modified:
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
Log:
Added todo for test that was broken, commented out borked code.
Modified: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java 2010-11-03 22:41:52 UTC (rev 6796)
+++ projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java 2010-11-04 11:40:47 UTC (rev 6797)
@@ -51,7 +51,9 @@
public void validDefinition() throws Exception {
File jpdl = new File("src/test/resources/jpdl3/singleNode/processdefinition.xml");
File gpd = new File("src/test/resources/jpdl3/singleNode/gpd.xml");
- Document document = JpdlValidator.validateDefinition(jpdl, gpd);
- assertThat(document, is(notNullValue()));
+
+ // TODO: fix this part.
+// Document document = JpdlValidator.validateDefinition(jpdl, gpd);
+// assertThat(document, is(notNullValue()));
}
}
13 years, 6 months
JBoss JBPM SVN: r6796 - projects/migration_tool/trunk/src/test/java/org/jbpm/migration.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-03 18:41:52 -0400 (Wed, 03 Nov 2010)
New Revision: 6796
Added:
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/BpmnValidatorTest.java
Log:
Added test for BPMN validator.
Added: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/BpmnValidatorTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/org/jbpm/migration/BpmnValidatorTest.java (rev 0)
+++ projects/migration_tool/trunk/src/test/java/org/jbpm/migration/BpmnValidatorTest.java 2010-11-03 22:41:52 UTC (rev 6796)
@@ -0,0 +1,58 @@
+/*
+ * 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.migration;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jbpm.migration.util.XmlUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+/**
+ * Tests for the BPMN process definition validator.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public class BpmnValidatorTest {
+ @BeforeClass
+ public static void oneTimeSetUp() {
+ BasicConfigurator.configure();
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ }
+
+ @Test
+ public void validDefinition() throws Exception {
+ File bpmn = new File("src/test/resources/bpmn/Test.bpmn.xml");
+ Document bpmnDoc = XmlUtils.parseFile(bpmn);
+ assertThat(bpmnDoc, is(notNullValue()));
+ assertThat(BpmnValidator.validateDefinition(bpmnDoc), is(true));
+ }
+}
Property changes on: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/BpmnValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 6 months
JBoss JBPM SVN: r6795 - projects/migration_tool/trunk/src/test/resources/bpmn.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-03 18:41:08 -0400 (Wed, 03 Nov 2010)
New Revision: 6795
Modified:
projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn.xml
Log:
Updated test process definition to comply with BPMN 2.0 beta.
Modified: projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn.xml
===================================================================
--- projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn.xml 2010-11-03 22:40:11 UTC (rev 6794)
+++ projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn.xml 2010-11-03 22:41:08 UTC (rev 6795)
@@ -1,10 +1,16 @@
-<definitions id="defId" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.omg.org/bpmn20">
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions id="defId"
+ xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
+ xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
+ xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
+ xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
+ targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL">
<process id="procesId">
<laneSet id="laneSetId">
<lane name="DefaultLane" id="laneId">
- <flowElementRef>taskId</flowElementRef>
- <flowElementRef>startEventId</flowElementRef>
- <flowElementRef>endEventId</flowElementRef>
+ <flowNodeRef>taskId</flowNodeRef>
+ <flowNodeRef>startEventId</flowNodeRef>
+ <flowNodeRef>endEventId</flowNodeRef>
</lane>
</laneSet>
<task completionQuantity="1" startQuantity="1" isForCompensation="false" name="" id="taskId"/>
@@ -13,13 +19,34 @@
<sequenceFlow targetRef="taskId" sourceRef="startEventId" name="" id="fou"/>
<sequenceFlow targetRef="endEventId" sourceRef="taskId" name="" id="fiv"/>
</process>
- <bpmndi:processDiagram processRef="procesId" id="procesId_gui">
- <bpmndi:laneCompartment isVisible="false" height="0.0" width="0.0" y="0.0" x="0.0" name="DefaultLane" id="laneId_gui">
- <bpmndi:activityShape activityRef="taskId" height="40.0" width="50.0" y="105.0" x="90.0" name="" id="taskId_gui"/>
- <bpmndi:eventShape eventRef="startEventId" height="30.0" width="30.0" y="35.0" x="100.0" name="" id="startEventId_gui"/>
- <bpmndi:eventShape eventRef="endEventId" height="28.0" width="28.0" y="182.0" x="101.0" name="" id="endEventId_gui"/>
- </bpmndi:laneCompartment>
- <bpmndi:sequenceFlowConnector sequenceFlowRef="fou" label="" targetRef="taskId_gui" sourceRef="startEventId_gui" id="fou_gui"/>
- <bpmndi:sequenceFlowConnector sequenceFlowRef="fiv" label="" targetRef="endEventId_gui" sourceRef="taskId_gui" id="fiv_gui"/>
- </bpmndi:processDiagram>
-</definitions>
\ No newline at end of file
+ <bpmndi:BPMNDiagram>
+ <bpmndi:BPMNPlane bpmnElement="procesId">
+ <bpmndi:BPMNShape bpmnElement="laneId" isHorizontal="true" id="laneId_gui">
+ <dc:Bounds height="0" width="0" x="0" y="0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape bpmnElement="startEventId" id="startEventId_gui">
+ <dc:Bounds height="30.0" width="30.0" x="100.0" y="35.0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape bpmnElement="taskId" id="taskId_gui">
+ <dc:Bounds height="40.0" width="50.0" x="90.0" y="105.0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape bpmnElement="endEventId" id="endEventId_gui">
+ <dc:Bounds height="28.0" width="28.0" x="101.0" y="182.0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge bpmnElement="fou" id="fou_gui">
+ <di:waypoint x="115.0" y="65.0"/>
+ <di:waypoint x="115.0" y="105.0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge bpmnElement="fiv" id="fiv_gui">
+ <di:waypoint x="115.0" y="145.0"/>
+ <di:waypoint x="115.0" y="182.0"/>
+ <bpmndi:BPMNLabel/>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</definitions>
13 years, 6 months
JBoss JBPM SVN: r6794 - projects/migration_tool/trunk/src/test/resources/bpmn.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-03 18:40:11 -0400 (Wed, 03 Nov 2010)
New Revision: 6794
Removed:
projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn_diagram
Log:
Removed old, outdated definition.
Deleted: projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn_diagram
===================================================================
--- projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn_diagram 2010-11-02 22:49:52 UTC (rev 6793)
+++ projects/migration_tool/trunk/src/test/resources/bpmn/Test.bpmn_diagram 2010-11-03 22:40:11 UTC (rev 6794)
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:bpmn="http://stp.eclipse.org/bpmn" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_Pdrh8IhqEd-1RIOw4wJNOg" type="Bpmn" name="Test.bpmn_diagram" measurementUnit="Pixel">
- <children xmi:type="notation:Node" xmi:id="_PeqZYIhqEd-1RIOw4wJNOg" type="1001">
- <children xmi:type="notation:Node" xmi:id="_PfF3MIhqEd-1RIOw4wJNOg" type="4008"/>
- <children xmi:type="notation:Node" xmi:id="_PfHsYIhqEd-1RIOw4wJNOg" type="5001">
- <children xmi:type="notation:Node" xmi:id="_PfJhkIhqEd-1RIOw4wJNOg" type="2001">
- <children xmi:type="notation:Node" xmi:id="_PfKIoIhqEd-1RIOw4wJNOg" type="4001"/>
- <styles xmi:type="notation:FontStyle" xmi:id="_PfJhkYhqEd-1RIOw4wJNOg" fontName="Arial"/>
- <styles xmi:type="notation:DescriptionStyle" xmi:id="_PfJhkohqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:FillStyle" xmi:id="_PfJhk4hqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:LineStyle" xmi:id="_PfJhlIhqEd-1RIOw4wJNOg" lineColor="0"/>
- <element xmi:type="bpmn:Activity" href="Test.bpmn#_PehPcYhqEd-1RIOw4wJNOg"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_PfKIoYhqEd-1RIOw4wJNOg" x="55" y="70" width="111" height="61"/>
- </children>
- <styles xmi:type="notation:DrawerStyle" xmi:id="_PfHsYYhqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:SortingStyle" xmi:id="_PfHsYohqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:FilteringStyle" xmi:id="_PfHsY4hqEd-1RIOw4wJNOg"/>
- </children>
- <styles xmi:type="notation:FontStyle" xmi:id="_PeqZYYhqEd-1RIOw4wJNOg" fontName="Arial"/>
- <styles xmi:type="notation:DescriptionStyle" xmi:id="_PeqZYohqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:FillStyle" xmi:id="_PeqZY4hqEd-1RIOw4wJNOg" fillColor="16771304"/>
- <styles xmi:type="notation:LineStyle" xmi:id="_PeqZZIhqEd-1RIOw4wJNOg" lineColor="11119017"/>
- <element xmi:type="bpmn:Pool" href="Test.bpmn#_PeBgMYhqEd-1RIOw4wJNOg"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_PfITcIhqEd-1RIOw4wJNOg" x="16" y="16" width="1500" height="200"/>
- </children>
- <styles xmi:type="notation:PageStyle" xmi:id="_Pdrh8YhqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:GuideStyle" xmi:id="_Pdrh8ohqEd-1RIOw4wJNOg"/>
- <styles xmi:type="notation:DescriptionStyle" xmi:id="_Pdrh84hqEd-1RIOw4wJNOg"/>
- <element xmi:type="bpmn:BpmnDiagram" href="Test.bpmn#_PZvdIIhqEd-1RIOw4wJNOg"/>
-</notation:Diagram>
13 years, 6 months
JBoss JBPM SVN: r6793 - projects/migration_tool/trunk/src/test/resources/jpdl3.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-02 18:49:52 -0400 (Tue, 02 Nov 2010)
New Revision: 6793
Removed:
projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml
Log:
Deleted: projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml
===================================================================
--- projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml 2010-11-02 22:48:56 UTC (rev 6792)
+++ projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml 2010-11-02 22:49:52 UTC (rev 6793)
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<root-container name="Generated" width="856" height="396"/>
13 years, 6 months
JBoss JBPM SVN: r6791 - in projects/migration_tool/trunk/src: main/java/org and 10 other directories.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-02 18:46:42 -0400 (Tue, 02 Nov 2010)
New Revision: 6791
Added:
projects/migration_tool/trunk/src/main/java/org/
projects/migration_tool/trunk/src/main/java/org/jbpm/
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/BpmnValidator.java
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/Migrator.java
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/ProcessTransformer.java
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/
projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java
projects/migration_tool/trunk/src/test/java/org/
projects/migration_tool/trunk/src/test/java/org/jbpm/
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
projects/migration_tool/trunk/src/test/java/org/jbpm/migration/ProcessTransformerTest.java
projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml
Modified:
projects/migration_tool/trunk/src/main/resources/jpdl3-bpmn2.xsl
projects/migration_tool/trunk/src/test/java/test/XSLTTest.java
Log:
Corrected the XSD validation.
Improved the transformation a little.
Added some first tests.
Added: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/BpmnValidator.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/BpmnValidator.java (rev 0)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/BpmnValidator.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.migration;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import org.apache.log4j.Logger;
+import org.jbpm.migration.util.XmlUtils;
+import org.w3c.dom.Document;
+
+/**
+ * This class validates a resulting jDPL definition against the applicable XML schema.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public final class BpmnValidator {
+ /* XML Schema file for BPMN version 2.0 on the classpath. */
+ private static final String BPMN_2_0_SCHEMA = "Schemas/BPMN/BPMN20.xsd";
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(BpmnValidator.class);
+
+ /** Private constructor to enforce non-instantiability. */
+ private BpmnValidator() {
+ }
+
+ /**
+ * Validate a given BPMN process definition against the applicable schema.
+ *
+ * @param bpmn
+ * The process definition.
+ * @param gpd
+ * The graphical positioning for the process definition.
+ * @return The concatenated document containing both process definition and positioning, or null if (one of) the validations was
+ * not successful.
+ */
+ public static boolean validateDefinition(Document bpmn) {
+ // Validate against the jPDL schema.
+ File schema = null;
+ try {
+ schema = new File(BpmnValidator.class.getClassLoader().getResource(BPMN_2_0_SCHEMA).toURI());
+ } catch (URISyntaxException usEx) {
+ LOGGER.error("Cannot locate BPMN schema.", usEx);
+ return false;
+ }
+ return XmlUtils.validate(bpmn, schema);
+ }
+}
Property changes on: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/BpmnValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java (rev 0)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.migration;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jbpm.migration.util.XmlUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * This class validates an original jDPL definition against the applicable XML schema.
+ * <p>
+ * TODO: Make jPDL version flexible (now only 3.2 is supported).<br>
+ * TODO: Include validation for GPD.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public final class JpdlValidator {
+ /* XML Schema file for jPDL version 3.2 on the classpath. */
+ private static final String JPDL_3_2_SCHEMA = "Schemas/jPDL/jpdl-3.2.xsd";
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(JpdlValidator.class);
+
+ /** Private constructor to enforce non-instantiability. */
+ private JpdlValidator() {
+ }
+
+ /**
+ * Parse and validate a given jDPL/GPD process definition against the applicable schema.
+ * <p>
+ * TODO: Correct the concatenation process, throws a DOMException like this.
+ *
+ * @param jpdl
+ * The process definition.
+ * @param gpd
+ * The graphical positioning for the process definition.
+ * @return The concatenated document containing both process definition and positioning, or null if (one of) the validations was
+ * not successful.
+ */
+ public static Document validateDefinition(File jpdl, File gpd) {
+ Document jpdlDoc = validateDefinition(jpdl);
+ Document gpdDoc = validatePositioning(gpd);
+
+ Document concatenated = null;
+ if (jpdlDoc != null && gpdDoc != null) {
+ try {
+ concatenated = XmlUtils.createEmptyDocument();
+ concatenated.appendChild(jpdlDoc);
+ concatenated.appendChild(gpdDoc);
+ } catch (Exception ex) {
+ LOGGER.error("Problem concatenating the jDPL and GPD definitions.", ex);
+ }
+ }
+ return concatenated;
+ }
+
+ private static Document validateDefinition(File jpdl) {
+ // Parse the jDPL definition into a DOM tree.
+ Document document = XmlUtils.parseFile(jpdl);
+ if (document == null) {
+ return null;
+ }
+
+ // Get the jPDL version from the process definition.
+ Node xmlnsNode = document.getFirstChild().getAttributes().getNamedItem("xmlns");
+ if (xmlnsNode != null && StringUtils.isNotBlank(xmlnsNode.getNodeValue())) {
+ String version = xmlnsNode.getNodeValue().substring(xmlnsNode.getNodeValue().length() - 3);
+ LOGGER.info("jPDL version == " + version);
+ }
+
+ // Validate against the jPDL schema.
+ File schema = null;
+ try {
+ schema = new File(JpdlValidator.class.getClassLoader().getResource(JPDL_3_2_SCHEMA).toURI());
+ } catch (URISyntaxException usEx) {
+ LOGGER.error("Cannot locate jPDL schema.", usEx);
+ return null;
+ }
+ return XmlUtils.validate(document, schema) ? document : null;
+ }
+
+ private static Document validatePositioning(File gpd) {
+ // Parse the GPD definition into a DOM tree.
+ Document document = XmlUtils.parseFile(gpd);
+ if (document == null) {
+ return null;
+ }
+
+ // TODO: Validate the document before returning it.
+ return document;
+ }
+}
Property changes on: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/JpdlValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/Migrator.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/Migrator.java (rev 0)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/Migrator.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,67 @@
+/*
+ * 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.migration;
+
+import java.io.File;
+
+import org.apache.commons.lang.StringUtils;
+import org.jbpm.migration.util.XmlUtils;
+import org.w3c.dom.Document;
+
+/**
+ * This class migrate a jPDL process definition to an equivalent BPMN 2.0 process definition.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public class Migrator {
+ /**
+ * @param args
+ * The input for this method:<br>
+ * <ul>
+ * <li>args[0]: The (full) path of the jPDL process definition that's to be migrated.</li>
+ * <li>args[1]: The (full) path of the corresponding GPD positioning file.</li>
+ * </ul>
+ * Any further arguments are ignored.
+ */
+ public static void main(String[] args) {
+ // Check the input.
+ if (args.length != 2 || StringUtils.isBlank(args[0]) || StringUtils.isBlank(args[1])) {
+ throw new IllegalArgumentException("Insufficient arguments for the migrator (must be 2).");
+ }
+ File jpdl = new File(args[0]);
+ File gpd = new File(args[1]);
+ if (!jpdl.isFile() || !gpd.isFile()) {
+ throw new IllegalArgumentException("Both of the input arguments must be files.");
+ }
+
+ // Validate the jPDL and GPD files.
+ Document input = JpdlValidator.validateDefinition(jpdl, gpd);
+ System.out.println(XmlUtils.format(input));
+
+ // Transform the process.
+ Document output = ProcessTransformer.transform(input);
+ System.out.println(XmlUtils.format(output));
+
+ // TODO: Validate the BPMN file.
+ }
+}
Property changes on: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/Migrator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/ProcessTransformer.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/ProcessTransformer.java (rev 0)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/ProcessTransformer.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,58 @@
+/*
+ * 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.migration;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import org.apache.log4j.Logger;
+import org.jbpm.migration.util.XmlUtils;
+import org.w3c.dom.Document;
+
+/**
+ * Transforms a given jPDL/GPD definition to an equivalent BPMN 2.0 definition.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public final class ProcessTransformer {
+ /* XSL Transformation file for jPDL version 3.2 on the classpath. */
+ private static final String MIGRATION_STYLE_SHEET = "jpdl3-bpmn2.xsl";
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(ProcessTransformer.class);
+
+ /** Private contractor to prevent instantiation. */
+ private ProcessTransformer() {
+ }
+
+ public static Document transform(Document jpdl) {
+ File styleSheet = null;
+ try {
+ styleSheet = new File(JpdlValidator.class.getClassLoader().getResource(MIGRATION_STYLE_SHEET).toURI());
+ } catch (URISyntaxException usEx) {
+ LOGGER.error("Cannot locate jPDL to BPMN style sheet.", usEx);
+ return null;
+ }
+ return XmlUtils.transform(jpdl, styleSheet);
+ }
+}
Property changes on: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/ProcessTransformer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java
===================================================================
--- projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java (rev 0)
+++ projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,210 @@
+/*
+ * 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.migration.util;
+
+import java.io.File;
+import java.io.StringWriter;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Convenience class for working with XML documents.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public final class XmlUtils {
+ private static final Logger LOGGER = Logger.getLogger(XmlUtils.class);
+
+ private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();
+ static {
+ FACTORY.setNamespaceAware(true);
+ }
+
+ /** Private constructor to prevent instantiation. */
+ private XmlUtils() {
+ }
+
+ /**
+ * Create an empty XML structure.
+ *
+ * @return An empty DOM tree.
+ */
+ public static Document createEmptyDocument() {
+ Document output = null;
+ try {
+ output = FACTORY.newDocumentBuilder().newDocument();
+ } catch (Exception ex) {
+ LOGGER.error("Problem creating empty XML document.", ex);
+ }
+
+ return output;
+ }
+
+ /**
+ * Parse a <code>File</code> containing an XML structure into a DOM tree.
+ *
+ * @param input
+ * The input XML file.
+ * @return The corresponding DOM tree, or <code>null</code> if the input could not be parsed successfully.
+ */
+ public static Document parseFile(File input) {
+ Document output = null;
+ try {
+ output = FACTORY.newDocumentBuilder().parse(input);
+ } catch (Exception ex) {
+ String msg = "Problem parsing the input XML file";
+ if (ex instanceof SAXParseException) {
+ msg += " at line #" + ((SAXParseException) ex).getLineNumber();
+ }
+ LOGGER.error(msg, ex);
+ }
+
+ return output;
+ }
+
+ /**
+ * Parse a <code>String</code> containing an XML structure into a DOM tree.
+ *
+ * @param input
+ * The input XML <code>String</code>.
+ * @return The corresponding DOM tree, or <code>null</code> if the input could not be parsed successfully.
+ */
+ public static Document parseString(String input) {
+ Document output = null;
+ try {
+ output = FACTORY.newDocumentBuilder().parse(input);
+ } catch (Exception ex) {
+ String msg = "Problem parsing the input XML file";
+ if (ex instanceof SAXParseException) {
+ msg += " at line #" + ((SAXParseException) ex).getLineNumber();
+ }
+ LOGGER.error(msg, ex);
+ }
+
+ return output;
+ }
+
+ /**
+ * Validate an XML document against an XML Schema definition.
+ *
+ * @param input
+ * The input XML document.
+ * @param schemaFile
+ * The XML Schema against which the document must be validated.
+ * @return Whether the validation was successful.
+ */
+ public static boolean validate(Document input, File schemaFile) {
+ boolean isValid = true;
+ try {
+ SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = factory.newSchema(new StreamSource(schemaFile));
+ // TODO: Experiment with ErrorHandler on Validator for more concise error messages.
+ schema.newValidator().validate(new DOMSource(input));
+ } catch (Exception ex) {
+ LOGGER.error("Problem validating the given process definition.", ex);
+ isValid = false;
+ }
+
+ return isValid;
+ }
+
+ /**
+ * Transform an XML document according to an XSL style sheet.
+ *
+ * @param input
+ * The input XML document.
+ * @param styleSheet
+ * The XSL style sheet according to which the document must be transformed.
+ * @return The transformed document, or <code>null</code> if a problem occurred while transforming.
+ */
+ public static Document transform(Document input, File styleSheet) {
+ Document output = null;
+ try {
+ output = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(styleSheet));
+ transformer.transform(new DOMSource(input), new DOMResult(output));
+ } catch (Exception ex) {
+ LOGGER.error("Problem transforming XML file.", ex);
+ }
+
+ return output;
+ }
+
+ /**
+ * Format an XML document to a pretty-printable <code>String</code>.
+ *
+ * @param input
+ * The input XML document.
+ * @return The formatted <code>String</code>.
+ */
+ public static String format(Document input) {
+ StreamResult result = null;
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ result = new StreamResult(new StringWriter());
+ transformer.transform(new DOMSource(input), result);
+ } catch (Exception ex) {
+ LOGGER.error("Problem formatting DOM representation.", ex);
+ return null;
+ }
+
+ return result.getWriter().toString();
+ }
+
+ /**
+ * Format an XML <code>String</code> to a pretty-printable <code>String</code>.
+ *
+ * @param input
+ * The input XML <code>String</code>.
+ * @return The formatted <code>String</code>.
+ */
+ public static String format(String input) {
+ StreamResult result = null;
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ result = new StreamResult(new StringWriter());
+ transformer.transform(new StreamSource(input), result);
+ } catch (Exception ex) {
+ LOGGER.error("Problem formatting DOM representation.", ex);
+ return null;
+ }
+
+ return result.getWriter().toString();
+ }
+}
Property changes on: projects/migration_tool/trunk/src/main/java/org/jbpm/migration/util/XmlUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/migration_tool/trunk/src/main/resources/jpdl3-bpmn2.xsl
===================================================================
--- projects/migration_tool/trunk/src/main/resources/jpdl3-bpmn2.xsl 2010-11-02 22:45:50 UTC (rev 6790)
+++ projects/migration_tool/trunk/src/main/resources/jpdl3-bpmn2.xsl 2010-11-02 22:46:42 UTC (rev 6791)
@@ -3,21 +3,68 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/process-definition">
- <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
- xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
- xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
+ xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
targetNamespace="http://www.jbpm.org/">
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:apply-templates />
+ <xsl:apply-templates select="//transition" />
</definitions>
</xsl:template>
+ <xsl:template match="//start-state">
+ <startEvent>
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name" />
+ </xsl:attribute>
+ <xsl:attribute name="id">
+ <xsl:value-of select="@name" /><xsl:text>_id</xsl:text>
+ </xsl:attribute>
+ </startEvent>
+ </xsl:template>
+
+ <xsl:template match="//end-state">
+ <endEvent>
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name" />
+ </xsl:attribute>
+ <xsl:attribute name="id">
+ <xsl:value-of select="@name" /><xsl:text>_id</xsl:text>
+ </xsl:attribute>
+ </endEvent>
+ </xsl:template>
+
+ <xsl:template match="//node">
+ <serviceTask>
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name" />
+ </xsl:attribute>
+ <xsl:attribute name="id">
+ <xsl:value-of select="@name" /><xsl:text>_id</xsl:text>
+ </xsl:attribute>
+ </serviceTask>
+ </xsl:template>
+
+ <xsl:template match="//transition">
+ <sequenceFlow>
+ <xsl:attribute name="sourceRef">
+ <xsl:value-of select="../@name" /><xsl:text>_id</xsl:text>
+ </xsl:attribute>
+ <xsl:attribute name="targetRef">
+ <xsl:value-of select="@to" /><xsl:text>_id</xsl:text>
+ </xsl:attribute>
+ </sequenceFlow>
+ </xsl:template>
+
<!-- TODO: Include templates for the missing jPDL elements. -->
+ <!-- Strip the white space from the result. -->
+ <xsl:template match="text()">
+ <xsl:value-of select="normalize-space()" />
+ </xsl:template>
+
</xsl:stylesheet>
Added: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java (rev 0)
+++ projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,57 @@
+/*
+ * 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.migration;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+/**
+ * Tests for the jDPL process definition validator.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public class JpdlValidatorTest {
+ @BeforeClass
+ public static void oneTimeSetUp() {
+ BasicConfigurator.configure();
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ }
+
+ @Test
+ public void validDefinition() throws Exception {
+ File jpdl = new File("src/test/resources/jpdl3/singleNode/processdefinition.xml");
+ File gpd = new File("src/test/resources/jpdl3/singleNode/gpd.xml");
+ Document document = JpdlValidator.validateDefinition(jpdl, gpd);
+ assertThat(document, is(notNullValue()));
+ }
+}
Property changes on: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/JpdlValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/ProcessTransformerTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/org/jbpm/migration/ProcessTransformerTest.java (rev 0)
+++ projects/migration_tool/trunk/src/test/java/org/jbpm/migration/ProcessTransformerTest.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,65 @@
+/*
+ * 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.migration;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jbpm.migration.util.XmlUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+/**
+ * Tests for the jDPL process definition transformer.
+ *
+ * @author Eric D. Schabell
+ * @author Maurice de Chateau
+ */
+public class ProcessTransformerTest {
+ @BeforeClass
+ public static void oneTimeSetUp() {
+ BasicConfigurator.configure();
+ Logger.getRootLogger().setLevel(Level.FATAL);
+ }
+
+ @Test
+ public void validDefinition() throws Exception {
+ File jpdlFile = new File("src/test/resources/jpdl3/singleNode/processdefinition.xml");
+ assertThat(jpdlFile.exists(), is(equalTo(true)));
+ Document jpdlDoc = XmlUtils.parseFile(jpdlFile);
+ assertThat(jpdlDoc, is(notNullValue()));
+ System.out.println("jPDL:\n" + XmlUtils.format(jpdlDoc));
+
+ Document bpmnDoc = ProcessTransformer.transform(jpdlDoc);
+ assertThat(bpmnDoc, is(notNullValue()));
+ System.out.println("BPMN:\n" + XmlUtils.format(bpmnDoc));
+ assertThat(BpmnValidator.validateDefinition(bpmnDoc), is(equalTo(true)));
+ }
+}
Property changes on: projects/migration_tool/trunk/src/test/java/org/jbpm/migration/ProcessTransformerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/migration_tool/trunk/src/test/java/test/XSLTTest.java
===================================================================
--- projects/migration_tool/trunk/src/test/java/test/XSLTTest.java 2010-11-02 22:45:50 UTC (rev 6790)
+++ projects/migration_tool/trunk/src/test/java/test/XSLTTest.java 2010-11-02 22:46:42 UTC (rev 6791)
@@ -23,7 +23,6 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;
Added: projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml
===================================================================
--- projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml (rev 0)
+++ projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml 2010-11-02 22:46:42 UTC (rev 6791)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="Generated" width="856" height="396"/>
Property changes on: projects/migration_tool/trunk/src/test/resources/jpdl3/.gpd.jpdl-3.2.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 6 months
JBoss JBPM SVN: r6790 - projects/migration_tool/trunk.
by do-not-reply@jboss.org
Author: MohReece
Date: 2010-11-02 18:45:50 -0400 (Tue, 02 Nov 2010)
New Revision: 6790
Modified:
projects/migration_tool/trunk/pom.xml
Log:
Added Log4J.
Modified: projects/migration_tool/trunk/pom.xml
===================================================================
--- projects/migration_tool/trunk/pom.xml 2010-10-29 07:04:27 UTC (rev 6789)
+++ projects/migration_tool/trunk/pom.xml 2010-11-02 22:45:50 UTC (rev 6790)
@@ -67,6 +67,12 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
13 years, 6 months