[jbpm-commits] JBoss JBPM SVN: r4978 - in jbpm4/branches/jimma/modules/migration: scripts and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jun 3 04:43:36 EDT 2009


Author: jim.ma
Date: 2009-06-03 04:43:36 -0400 (Wed, 03 Jun 2009)
New Revision: 4978

Added:
   jbpm4/branches/jimma/modules/migration/scripts/
   jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml
   jbpm4/branches/jimma/modules/migration/src/test/resources/invalid.xml
Modified:
   jbpm4/branches/jimma/modules/migration/pom.xml
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java
   jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java
   jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml
Log:
Added test for system error message;Added 'distro' profile to package all jars in one directory : mvn install -Pdistro

Modified: jbpm4/branches/jimma/modules/migration/pom.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/pom.xml	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/pom.xml	2009-06-03 08:43:36 UTC (rev 4978)
@@ -31,7 +31,7 @@
 
 	<name>jBPM 4 - Migration - Tool</name>
 	<groupId>org.jbpm.jbpm4</groupId>
-	<artifactId>migration</artifactId>
+	<artifactId>jbpm-migration</artifactId>
 	<packaging>jar</packaging>
 
 	<!-- Parent -->
@@ -57,10 +57,6 @@
 					<groupId>org.apache.ant</groupId>
 					<artifactId>ant</artifactId>
 				</exclusion>
-				<!--
-					exclusion> <groupId>bsh</groupId> <artifactId>bsh</artifactId>
-					</exclusion
-				-->
 
 				<exclusion>
 					<groupId>org.apache.jackrabbit</groupId>
@@ -101,6 +97,14 @@
 		</dependency>
 
 
+                <dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.14</version>
+		</dependency>
+                
+
+
 		<!-- JBPM4 -->
 
 		<dependency>
@@ -150,16 +154,6 @@
 					<packageName>org.jbpm.jpdl4.model</packageName>
 				</configuration>
 			</plugin>
-
-			<!--Add classpath to menifest -->
-			<!--
-				plugin> <groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-jar-plugin</artifactId> <configuration>
-				<finalName>jbpm-migration</finalName> <archive> <manifest>
-				<addClasspath>true</addClasspath> </manifest> </archive>
-				</configuration> </plugin
-			-->
-
 		</plugins>
 	</build>
 
@@ -180,6 +174,47 @@
 				<skipTests>true</skipTests>
 			</properties>
 		</profile>
+
+               <profile> 
+                      <id>distro</id>
+                      <build>
+                       <plugins>
+                        <plugin>
+                         <artifactId>maven-assembly-plugin</artifactId>
+                         <!--version>2.2-beta-3</version-->
+                         <executions>
+                             <execution>
+                              <id>distribution-package</id>
+                              <phase>package</phase>
+                              <goals>
+                                 <goal>single</goal>
+                              </goals>
+                             <configuration>
+                                <descriptors>
+                                  <descriptor>scripts/assembly-distro.xml</descriptor>
+                                </descriptors>
+                             </configuration>
+                            </execution>
+                          </executions>
+                        </plugin>
+
+			<!--Add classpath to menifest -->
+			<plugin> 
+                               <groupId>org.apache.maven.plugins</groupId>
+			       <artifactId>maven-jar-plugin</artifactId> 
+                               <configuration>
+			        <finalName>jbpm-migration</finalName> 
+                                <archive> 
+                                   <manifest>
+				     <addClasspath>true</addClasspath>
+                                     <mainClass>org.jbpm.jpdl.internal.convert.JpdlConverterTool</mainClass>
+                                   </manifest> 
+                                 </archive>
+			       </configuration> 
+                        </plugin>
+                       </plugins>
+                     </build>
+               </profile>
 	</profiles>
 
 

Added: jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml	2009-06-03 08:43:36 UTC (rev 4978)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<assembly xmlns="http://maven.apache.org/POM/4.0.0" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+
+  <id>jbpm.migration</id>
+  <finalName>jbpm-migration-${version}</finalName>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <formats>
+    <format>zip</format>
+    <format>dir</format>
+  </formats>
+  
+  
+<!--fileSets> 
+    <fileSet> 
+       <directory>target</directory>
+       <outputDirectory>jbpm-migration-${version}</outputDirectory>
+       <includes> 
+             <include>*.jar</include>
+       </includes>
+    </fileSet>
+</fileSets-->
+      
+
+<!-- Dependency Sets -->
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>jbpm-migration-${version}</outputDirectory>
+      <!-- useStrictFiltering>true</useStrictFiltering -->
+      <unpack>false</unpack>
+      <scope>runtime</scope>
+    </dependencySet>
+   </dependencySets>
+</assembly>

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java	2009-06-03 08:43:36 UTC (rev 4978)
@@ -26,6 +26,7 @@
 
 import org.jbpm.jpdl.xml.JpdlXmlReader;
 import org.jbpm.jpdl.xml.Problem;
+import org.jbpm.jpdl.xml.ProblemListener;
 import org.xml.sax.InputSource;
 
 public class Jpdl3Reader extends JpdlXmlReader {
@@ -34,6 +35,10 @@
 		super(ins);
 	}
 	
+ 	public Jpdl3Reader(InputSource inputSource, ProblemListener problemListener) {
+	    super(inputSource, problemListener);
+    }
+	
 	public boolean isValid() {
 		Iterator iter = problems.iterator();
 	    while (iter.hasNext()) {

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java	2009-06-03 08:43:36 UTC (rev 4978)
@@ -75,10 +75,8 @@
 	private static final Log logger = LogFactory.getLog(JpdlConverter.class);
 
 	public Process run(URL url) throws ConvertException {
-		Jpdl3Reader reader = new Jpdl3Reader(new InputSource(url.toString()));
+		Jpdl3Reader reader = new Jpdl3Reader(new InputSource(url.toString()), this);
 		ProcessDefinition processDef = reader.readProcessDefinition();
-		//Added warning message to converter
-		getProblems().addAll(reader.getProblems());
 		return mapProcessDef(processDef);
 	}
 

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java	2009-06-03 08:43:36 UTC (rev 4978)
@@ -35,40 +35,64 @@
 		ConverterContext context = null;
 		try {
 			context = converter.parseParam(args);
+			converter.validate(context);
 		} catch (IllegalCommandException e1) {
 			System.err.println(e1.getMessage());
 			System.err.println(converter.getUsage());
-		}
-		
-		try {
-			converter.validate(context);
+			return;
 		} catch (Exception e1) {
 			System.err.println(e1.getMessage());
+			return;
 		}
-		
+		boolean verbose = false;
+		if (context.get(ConverterContext.VERBOSE) != null) {
+			verbose = true;
+		}
 		JpdlConverter jpdlConverter = new JpdlConverter();
 		Jpdl4Writer writer = new Jpdl4Writer();
 		try {
+			if (verbose) {
+				System.out.println("Loading process file from URL [" + context.get(context.PROCESS_FILE_URL) + "]...");
+			}
 			Process process = jpdlConverter.run((URL)context.get(context.PROCESS_FILE_URL));
-			String outputFile = (String)context.get(context.OUPUTFILE);
-			java.io.OutputStream out = new java.io.FileOutputStream(new File(outputFile));
+			
+			if (verbose) {
+				System.out.println("Converting the process file to jPDL4 version....");
+			}			
+			
+			String outputFilePath = (String)context.get(context.OUPUTFILE);
+			File outputFile = new File(outputFilePath);
+			java.io.OutputStream out = new java.io.FileOutputStream(outputFile);
 			writer.write(process, out, true);
+			
+			if (verbose) {
+				System.out.println("Generating converted file :" + (outputFile.isAbsolute() ? outputFile.getCanonicalPath() : outputFile.getName()));
+			}
+			
 		} catch (Exception e) {
-			if (context.get(ConverterContext.VERBOSE) != null) {
-				for (Problem problem : jpdlConverter.getProblems()) {
-					System.err.print(problem);
+
+	      for (Problem problem : jpdlConverter.getProblems()) {
+				if (problem.getLevel() == problem.LEVEL_WARNING) {
+					System.err.println(problem);
 				}
-			} else {
-				System.err.print(e.getMessage());
+				if (problem.getLevel() < problem.LEVEL_WARNING) {
+					System.err.println(problem);
+					if (problem.getException() != null
+							&& context.get(ConverterContext.VERBOSE) != null) {
+						problem.getException().printStackTrace(System.err);
+						System.err.println();
+					}
+				}
 			}
-
+			
+			
 		}
 	}
 
 	public ConverterContext parseParam(String[] args) throws IllegalCommandException {
 		ConverterContext context = new ConverterContext();
 		if (args.length == 0) {
-			throw new IllegalCommandException("Please input the process file needs to be converted");
+			throw new IllegalCommandException("Missing process file needs to be converted");
 		}
 		for (int i = 0; i < args.length; i++) {
 			String token = args[i];
@@ -82,14 +106,14 @@
 					String outputFile = args[j];					
 					context.put(ConverterContext.OUPUTFILE, args[j]);
 				} else {
-					throw new IllegalCommandException("output file name is not defined");
+					throw new IllegalCommandException("Missing output file name");
 				}
 			} else if (token.startsWith("-")) {
 				throw new IllegalCommandException("Unknow flag [" + token +"]");
 		    } else if(context.get(ConverterContext.PROCESS_FILE) == null) {
 				context.put(ConverterContext.PROCESS_FILE, token);
 			} else {
-				throw new IllegalCommandException("Duplicate input process file defined");
+				throw new IllegalCommandException("Duplicate input process file");
 			}
 
 		}
@@ -110,7 +134,6 @@
 	    //handle the output filename
 	    if (context.get(ConverterContext.OUPUTFILE) == null) {
 	    	File tmpFile = new File(processURL.getFile());
-	    	File outputDir = tmpFile.getParentFile();
 	    	String fileName = tmpFile.getName();
 	    	String baseName = fileName;
 	    	String extensionName = "";
@@ -125,7 +148,7 @@
 	    	
 	    	String outputFileName = extensionName.equals("") ? baseName + ".converted.jpdl" 
 	    			: baseName + ".converted.jpdl." + extensionName;
-	        File outFile = new File(outputDir, outputFileName);
+	        File outFile = new File(".", outputFileName);
 	        context.put(ConverterContext.OUPUTFILE, outFile.getAbsolutePath());
 	    } else {
 	    	String outputFile = (String)context.get(ConverterContext.OUPUTFILE);
@@ -175,7 +198,7 @@
 	}
 	
 	public String getUsage() {
-		return "Usage : java org.jbpm.jpdl.internal.convert.JpdlConverterTool <file>/r/n"
+		return "Usage : java org.jbpm.jpdl.internal.convert.JpdlConverterTool <file>\r\n"
 		 +     "        java org.jbpm.jpdl.internal.convert.JpdlConverterTool -v -o <outputfile> <file>";
 		
 	}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java	2009-06-03 08:43:36 UTC (rev 4978)
@@ -25,13 +25,12 @@
 import java.util.List;
 import java.util.Map;
 
-import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.Transition;
 import org.jbpm.graph.node.StartState;
 import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
-import org.jbpm.taskmgmt.def.Task;
+
 import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
 
 public class StartStateConverter {

Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java	2009-06-03 08:43:36 UTC (rev 4978)
@@ -22,14 +22,41 @@
 package org.jbpm.jpdl.internal.convert;
 
 import java.io.File;
+import java.io.PrintStream;
 import java.net.URL;
 
 import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 public class JpdlConverterToolTest {
 	
 	JpdlConverterTool tool = new JpdlConverterTool();
+	java.io.ByteArrayOutputStream bout = null;
+	PrintStream oldOut = null;
+	
+	java.io.ByteArrayOutputStream errorOut = null;
+	PrintStream oldError = null;
+	
+	@Before
+	public void replaceSystemOut() {
+		oldOut = System.out;
+        bout = new java.io.ByteArrayOutputStream();		
+		System.setOut(new java.io.PrintStream(bout));
+		
+		oldError = System.err;
+		errorOut = new java.io.ByteArrayOutputStream();	
+		System.setErr(new java.io.PrintStream(errorOut));
+	}
+	
+	@After
+	public void restoreSystemOut() {
+		System.setErr(oldError);
+		System.setOut(oldOut);		
+	}
+	
 	@Test
 	public void wrongArgs1() {
     	String args[] = {"-v","-t"};
@@ -115,10 +142,6 @@
 		}
 	}
 	
-
-	
-	
-
 	@Test
 	public void runConcretProcess() throws Exception {
 		String fileName = getResource("simple.xml");
@@ -143,6 +166,14 @@
 		Assert.assertTrue(outputfile.exists());	
 	}
 	
+	@Test
+	public void testErrorMessage() throws Exception {
+		String fileName = getResource("invalid.xml");
+		String args[] = new String[]{fileName};			
+		JpdlConverterTool.main(args);
+		String str = new String(errorOut.toByteArray());		
+		Assert.assertTrue(str.indexOf("[ERROR] cvc-complex-type.2.4.a:") > -1);				
+	}
 	
 	
     public String getResource(String file) throws Exception {

Added: jbpm4/branches/jimma/modules/migration/src/test/resources/invalid.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/invalid.xml	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/invalid.xml	2009-06-03 08:43:36 UTC (rev 4978)
@@ -0,0 +1,21 @@
+<?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="first">
+         <action name="action" class="com.sample.action.MessageActionHandler">
+            <message>Going to the first state!</message>
+         </action>
+      </transition>
+   </start-state>
+   <state name="first">
+      <transition name="to_end" to="end">
+         <action name="action" class="com.sample.action.MessageActionHandler">
+            <message>About to finish!</message>
+         </action>
+      </transition>
+   </state>
+   <end-state1 name="end"></end-state1>
+</process-definition>
\ No newline at end of file

Modified: jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml	2009-06-02 17:37:31 UTC (rev 4977)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml	2009-06-03 08:43:36 UTC (rev 4978)
@@ -9,7 +9,7 @@
 
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
     <param name="Target" value="System.out" />
-    <param name="Threshold" value="WARN" />
+    <param name="Threshold" value="ERROR" />
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
     </layout>




More information about the jbpm-commits mailing list