[jbpm-commits] JBoss JBPM SVN: r4971 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/util and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 2 06:19:40 EDT 2009


Author: jim.ma
Date: 2009-06-02 06:19:40 -0400 (Tue, 02 Jun 2009)
New Revision: 4971

Added:
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/IllegalCommandException.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ExceptionHandlersConverter.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
Modified:
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ConverterContext.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/DecisionConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EndStateConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventsConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
   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/StateConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TimerConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
Log:
Completed conversion tool function to parse and validate arguments;Added problems collections

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ConverterContext.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ConverterContext.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ConverterContext.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -27,6 +27,8 @@
 public class ConverterContext {
 	public static final String PROCESS_FILE = "processFile"; 
 	public static final String PROCESS_FILE_URL = "processFileURL";
+	public static final String VERBOSE = "verbose";
+	public static final String OUPUTFILE = "outputFile";
 	private Map<String, Object> paramMap = null;
 	
 	public void put(String key, Object value) {

Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/IllegalCommandException.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/IllegalCommandException.java	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/IllegalCommandException.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.convert;
+
+public class IllegalCommandException extends Exception {
+    private static final long serialVersionUID = 1L;
+
+    public IllegalCommandException() {
+        super();
+    }
+
+    public IllegalCommandException(String msg) {
+        super(msg);
+    }
+
+
+    public IllegalCommandException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public IllegalCommandException(Throwable cause) {
+        super(cause);
+    }
+}

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 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -51,6 +51,7 @@
 import org.jbpm.jpdl.internal.convert.util.DecisionConverter;
 import org.jbpm.jpdl.internal.convert.util.EndStateConverter;
 import org.jbpm.jpdl.internal.convert.util.EventsConverter;
+import org.jbpm.jpdl.internal.convert.util.ExceptionHandlersConverter;
 import org.jbpm.jpdl.internal.convert.util.ForkConverter;
 import org.jbpm.jpdl.internal.convert.util.JoinConverter;
 import org.jbpm.jpdl.internal.convert.util.NodeConverter;
@@ -60,30 +61,28 @@
 import org.jbpm.jpdl.internal.convert.util.TaskNodeConverter;
 import org.jbpm.jpdl.xml.JpdlXmlReader;
 import org.jbpm.jpdl.xml.Problem;
-import org.jbpm.jpdl.xml.ProblemListener;
+
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
 import org.jbpm.taskmgmt.def.Swimlane;
 import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
 import org.xml.sax.InputSource;
 
-public class JpdlConverter implements ProblemListener {
+public class JpdlConverter implements ProblemCollector {
 	public List<Problem> problems = new CopyOnWriteArrayList<Problem>();
 	
 	private static final long serialVersionUID = 1L;
-	private static final Log log = LogFactory.getLog(JpdlXmlReader.class);
+	private static final Log logger = LogFactory.getLog(JpdlConverter.class);
 
 	public Process run(URL url) throws ConvertException {
 		Jpdl3Reader reader = new Jpdl3Reader(new InputSource(url.toString()));
 		ProcessDefinition processDef = reader.readProcessDefinition();
-		if (!reader.isValid()) {
-			reader.getProblems();
-			// TODO:handle the exception
-		}
+		//Added warning message to converter
+		getProblems().addAll(reader.getProblems());
 		return mapProcessDef(processDef);
 	}
 
-	public Process mapProcessDef(ProcessDefinition def) {
+	public Process mapProcessDef(ProcessDefinition def) throws ConvertException {
 		Process process = new Process();
 		process.setName(def.getName());
 		
@@ -96,64 +95,68 @@
 				Map.Entry<String, Swimlane> entry = (Map.Entry<String, Swimlane>) iterator
 						.next();
 				org.jbpm.jpdl4.model.Swimlane item = SwimlaneConverter
-						.run(entry.getValue());
+						.run(entry.getValue(), this);
 				process.getSwimlaneAndOnAndTimer().add(item);
 			}
 		}
+		
 		for (Node node : def.getNodes()) {
 			Node.NodeType nodeType = node.getNodeType();
 			switch(node.getNodeType()) {
 			case StartState :
 				org.jbpm.graph.node.StartState jpdl3start = ( org.jbpm.graph.node.StartState) node;
-				Process.Start start = StartStateConverter.run(jpdl3start);
+				Process.Start start = StartStateConverter.run(jpdl3start, this);
 				process.getSwimlaneAndOnAndTimer().add(start);
 				break;
 			case State:
 				org.jbpm.graph.node.State jpdl3state = (org.jbpm.graph.node.State) node;
-				Process.State state = StateConverter.run(jpdl3state);
+				Process.State state = StateConverter.run(jpdl3state, this);
 				process.getSwimlaneAndOnAndTimer().add(state);
 				break;
 			case EndState:
 				org.jbpm.graph.node.EndState jpdl3end = (org.jbpm.graph.node.EndState) node;
-				Process.End end = EndStateConverter.run(jpdl3end);
+				Process.End end = EndStateConverter.run(jpdl3end, this);
 				process.getSwimlaneAndOnAndTimer().add(end);
 				break;
 			case Task:
 				//TaskNode
 				if (node instanceof TaskNode) {
 					org.jbpm.graph.node.TaskNode taskNode = (org.jbpm.graph.node.TaskNode)node;
-					Set<Process.Task> tasks = TaskNodeConverter.run(taskNode);
+					Set<Process.Task> tasks = TaskNodeConverter.run(taskNode, this);
 					process.getSwimlaneAndOnAndTimer().addAll(tasks);
 				}
 				break;				
 			case Fork:
 				org.jbpm.graph.node.Fork fork = (org.jbpm.graph.node.Fork)node;
-			    process.getSwimlaneAndOnAndTimer().add(ForkConverter.run(fork));
+			    process.getSwimlaneAndOnAndTimer().add(ForkConverter.run(fork, this));
 			    break;
 			case Join:
 				org.jbpm.graph.node.Join join = (org.jbpm.graph.node.Join)node;
-				process.getSwimlaneAndOnAndTimer().add(JoinConverter.run(join));				
+				process.getSwimlaneAndOnAndTimer().add(JoinConverter.run(join, this));				
                 break;
 			case Node:
 				org.jbpm.graph.def.Node tmpNode = (org.jbpm.graph.def.Node)node;
-				process.getSwimlaneAndOnAndTimer().add(NodeConverter.run(tmpNode));
+				process.getSwimlaneAndOnAndTimer().add(NodeConverter.run(tmpNode, this));
 				break;
 			case Decision :
 				try {
 					org.jbpm.graph.node.Decision decision = (org.jbpm.graph.node.Decision) node;
-					process.getSwimlaneAndOnAndTimer().add(DecisionConverter.run(decision));
-				} catch (Exception e) {
-					log.error("Failed to convert Decision node [" + node.getName() + "}", e);
-					Problem problem = new Problem(Problem.LEVEL_ERROR, e.getMessage());
-					this.addProblem(problem);
+					process.getSwimlaneAndOnAndTimer().add(DecisionConverter.run(decision, this));
+				} catch (ConvertException exe) {
+                    this.addError(exe.getMessage(), exe);
+                    throw exe;
 				}
+				break;
+				
 			}
+        
 			
 		}
 		
 		//Process Event
-	    List<On> ons = EventsConverter.run(def.getEvents());
+	    List<On> ons = EventsConverter.run(def.getEvents(), this);
 	    process.getSwimlaneAndOnAndTimer().addAll(ons);
+	    ExceptionHandlersConverter.run(def, this);
 		return process;
 	}
 
@@ -162,4 +165,27 @@
     	this.problems.add(problem);
     }
     
+    public List<Problem> getProblems() {
+    	return problems;
+    }
+    
+    
+    public void addError(String description)
+    {
+      logger.error(description);
+      addProblem(new Problem(Problem.LEVEL_ERROR, description));
+    }
+
+    public void addError(String description, Throwable exception)
+    {
+      logger.error(description, exception);
+      addProblem(new Problem(Problem.LEVEL_ERROR, description, exception));
+    }
+
+    public void addWarning(String description)
+    {
+      logger.warn(description);
+      addProblem(new Problem(Problem.LEVEL_WARNING, description));
+    }
+    
 }

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 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -21,34 +21,163 @@
  */
 package org.jbpm.jpdl.internal.convert;
 
+import java.io.File;
+
+import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.jbpm.util.ClassLoaderUtil;
+import org.jbpm.jpdl.xml.Problem;
+import org.jbpm.jpdl4.model.Process;
 
-public class JpdlConverterTool {
+public class JpdlConverterTool {   
 	public static void main(String[] args) {
 		JpdlConverterTool converter = new JpdlConverterTool();
-		ConverterContext context = converter.parseParam(args);
-		converter.run(context);
-	}
-	
-	public void run(ConverterContext context) {
+		ConverterContext context = null;
+		try {
+			context = converter.parseParam(args);
+		} catch (IllegalCommandException e1) {
+			System.err.println(e1.getMessage());
+			System.err.println(converter.getUsage());
+		}
 		
+		try {
+			converter.validate(context);
+		} catch (Exception e1) {
+			System.err.println(e1.getMessage());
+		}
+		
+		JpdlConverter jpdlConverter = new JpdlConverter();
+		Jpdl4Writer writer = new Jpdl4Writer();
+		try {
+			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));
+			writer.write(process, out, true);
+		} catch (Exception e) {
+			if (context.get(ConverterContext.VERBOSE) != null) {
+				for (Problem problem : jpdlConverter.getProblems()) {
+					System.err.print(problem);
+				}
+			} else {
+				System.err.print(e.getMessage());
+			}
+
+		}
 	}
-	
-	public ConverterContext parseParam(String[] args) {
+
+	public ConverterContext parseParam(String[] args) throws IllegalCommandException {
 		ConverterContext context = new ConverterContext();
-		context.put(ConverterContext.PROCESS_FILE, args[0]);
+		if (args.length == 0) {
+			throw new IllegalCommandException("Please input the process file needs to be converted");
+		}
+		for (int i = 0; i < args.length; i++) {
+			String token = args[i];
+			if ("-v".equalsIgnoreCase(token)
+					|| "-verbose".equalsIgnoreCase(token)) {
+				context.put(ConverterContext.VERBOSE, ConverterContext.VERBOSE);
+			} else if ("-o".equalsIgnoreCase(token)
+					|| "-output".equalsIgnoreCase(token)) {
+				int j = ++i;
+				if (j < args.length) {
+					String outputFile = args[j];					
+					context.put(ConverterContext.OUPUTFILE, args[j]);
+				} else {
+					throw new IllegalCommandException("output file name is not defined");
+				}
+			} 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");
+			}
+
+		}
+		if (context.get(ConverterContext.PROCESS_FILE) == null) {
+			throw new IllegalCommandException("No input process file defined");
+		}
+
 		return context;
 	}
-	
-	public void validate(ConverterContext context) throws IllegalArgumentException {
-		String processFile = (String)context.get(ConverterContext.PROCESS_FILE);
-		URL resourceURL = ClassLoaderUtil.getClassLoader().getResource(processFile);
-		if (resourceURL == null) {
-		    throw new IllegalArgumentException("Process file not found: " + processFile);
+
+	public void validate(ConverterContext context) throws Exception {
+		String processFile = (String) context.get(ConverterContext.PROCESS_FILE);
+		URL processURL = getFileURL(processFile);
+		if (processURL == null) {
+			throw new IllegalCommandException("Failed to load the process file [" + processFile + "]");
 		}
-		context.put(context.PROCESS_FILE_URL, resourceURL);
+	    context.put(context.PROCESS_FILE_URL, processURL);
+	    //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 = "";
+	    	int index = fileName.lastIndexOf(".");
+	    	
+	    	if (index > -1) {
+	    		baseName = fileName.substring(0, index);
+	    	    extensionName = index+1 < fileName.length() ? fileName.substring(index+1) : extensionName;	
+	    	} else {
+	    		baseName = fileName;
+	    	}
+	    	
+	    	String outputFileName = extensionName.equals("") ? baseName + ".converted.jpdl" 
+	    			: baseName + ".converted.jpdl." + extensionName;
+	        File outFile = new File(outputDir, outputFileName);
+	        context.put(ConverterContext.OUPUTFILE, outFile.getAbsolutePath());
+	    } else {
+	    	String outputFile = (String)context.get(ConverterContext.OUPUTFILE);
+	    	File file = new File(outputFile);
+			if (file.isAbsolute()) {
+				if (!file.getParentFile().exists()) {
+					throw new IllegalCommandException("Output directory [" + file.getParent() + "] does not exist");
+				}
+			} else {
+			    file = new File(".", outputFile);			    
+			}
+			if (!file.exists()) {
+					file.createNewFile();				
+			}
+			context.put(ConverterContext.OUPUTFILE, file.getAbsolutePath());
+	    }
+		
 	}
+
+	private URL getFileURL(String fileName) {
+		try {
+			URL url = new URL(fileName);
+			return url;
+		} catch (MalformedURLException e1) {
+			//Do nothing
+		}
+		File file = new File(fileName);
+		if (file.exists()) {
+			try {
+				return file.toURL();
+			} catch (MalformedURLException e) {
+				// Do nothing.
+			}
+			
+		}
+		// load in current directory
+		File tmpFile = new File(".", fileName);
+		if (file.exists()) {
+			try {
+				return tmpFile.toURL();
+			} catch (MalformedURLException e) {
+				// Do nothing
+			}
+		}
+		
+		return null;
+	}
 	
+	public String getUsage() {
+		return "Usage : java org.jbpm.jpdl.internal.convert.JpdlConverterTool <file>/r/n"
+		 +     "        java org.jbpm.jpdl.internal.convert.JpdlConverterTool -v -o <outputfile> <file>";
+		
+	}
+	
 }

Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -0,0 +1,9 @@
+package org.jbpm.jpdl.internal.convert;
+
+import org.jbpm.jpdl.xml.ProblemListener;
+
+public interface ProblemCollector extends ProblemListener{
+	 public void addError(String description, Throwable exception);
+	 public void addError(String description);
+	 public void addWarning(String description);
+}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -23,25 +23,23 @@
 
 import java.lang.reflect.Field;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-import org.jbpm.graph.def.Event;
 import org.jbpm.graph.def.Transition;
 import org.jbpm.graph.node.Decision;
 import org.jbpm.instantiation.Delegation;
 import org.jbpm.jpdl.internal.convert.ConvertException;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
 import org.jbpm.jpdl4.model.WireObjectType;
 
 public class DecisionConverter {
-	public static Process.Decision run(Decision node) throws Exception {
+	public static Process.Decision run(Decision node, ProblemCollector collector) throws ConvertException {
 		Process.Decision result = new Process.Decision();
 		result.setName(node.getName());
 		//Process transition
 		for (Transition trans : node.getLeavingTransitions()) {
-			result.getTransition().add(TransitionConverter.run(trans, Process.Decision.Transition.class));
+			result.getTransition().add(TransitionConverter.run(trans, Process.Decision.Transition.class, collector));
 		}
 		//process the class handler
 		try {
@@ -69,13 +67,13 @@
 				result.setExpr(expression);				
 			}
 		} catch (Exception e) {
-            throw new ConvertException("Failed to read the expression attribute from Decision node [" + node.getName() +']', e);
+            throw new ConvertException("Failed to read the handler calss name from Decision node [" + node.getName() +']', e);
 		}
 		
-		List<On> ons = EventsConverter.run(node.getEvents());
+		List<On> ons = EventsConverter.run(node.getEvents(), collector);
 	    result.getOn().addAll(ons);
-		//TODO: process exceptions
-
+	    //process exceptionHandler
+	    ExceptionHandlersConverter.run(node,collector);
 		return result;
 	}
 

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EndStateConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EndStateConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EndStateConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -21,17 +21,17 @@
  */
 package org.jbpm.jpdl.internal.convert.util;
 
-import java.util.List;
 
 import org.jbpm.graph.node.EndState;
-import org.jbpm.jpdl4.model.On;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.Process;
 
 public class EndStateConverter {	
-	public static Process.End run(EndState endState) {
+	public static Process.End run(EndState endState, ProblemCollector collector) {
 		Process.End end = new Process.End();
 		end.setName(endState.getName());
-		//TODO: process exception
+		//process exceptionHandler
+		ExceptionHandlersConverter.run(endState,collector);
 		return end;
 	}
 }

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -29,19 +29,17 @@
 import org.jbpm.graph.action.Script;
 import org.jbpm.graph.def.Action;
 import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.JavaType;
 import org.jbpm.jpdl4.model.ObjectFactory;
 import org.jbpm.jpdl4.model.ScriptType;
-import org.jbpm.jpdl4.model.Timer;
-import org.jbpm.scheduler.def.CreateTimerAction;
 public class EventActionConverter {
-	public static JAXBElement<?> run(Action action) {
+	public static JAXBElement<?> run(Action action, ProblemCollector collector) {
 		JAXBElement<?> result = null;
 		if (action instanceof Script) {
 			ScriptType scriptType = new ScriptType();
 			Script script = (Script) action;
 			scriptType.setText(script.getExpression());
-			//scriptType.setExpr(script.getExpression());
 			if (script.getVariableAccesses() != null) {
 				for (VariableAccess variableAccess : (Set<VariableAccess>) script.getVariableAccesses()) {
 					if (variableAccess.isWritable()) {
@@ -65,6 +63,7 @@
 				result = new ObjectFactory().createOnJava(javaType);
 			}
 		}
+		
 		return result;
 	}
 

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventsConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventsConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventsConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -26,18 +26,19 @@
 
 import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.Event;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.scheduler.def.CreateTimerAction;
 
 public class EventsConverter {
-   public static List<On> run(Map<String,Event> eventsMap) {
+   public static List<On> run(Map<String,Event> eventsMap, ProblemCollector collector) {
 	   List<On> results = new java.util.concurrent.CopyOnWriteArrayList<On>();
 	   if (eventsMap != null && !eventsMap.isEmpty()) {
 	    	for (Event event : eventsMap.values())  {
 	    		if (event.getEventType().equals(Event.EVENTTYPE_NODE_LEAVE)) {
 	    			continue;
 	    		}
-	    		org.jbpm.jpdl4.model.On on = run(event);
+	    		org.jbpm.jpdl4.model.On on = run(event, collector);
 	    		results.add(on);
 	    	}
 	    }	    
@@ -45,16 +46,16 @@
    }
 	
 	
-	public static On run(Event event) {
+	public static On run(Event event, ProblemCollector collector) {
 		On result = new On();
 		//process-start and process-end
 		result.setEvent(convertEnvetType(event.getEventType()));
 		List<Action> actions = (List<Action>)event.getActions();
 		for (Action action : actions) {
 			if (action instanceof CreateTimerAction) {
-			    result.setTimer(TimerConverter.run((CreateTimerAction)action));
+			    result.setTimer(TimerConverter.run((CreateTimerAction)action, collector));
 			} else {
-				result.getEventListenerGroup().add(EventActionConverter.run(action));
+				result.getEventListenerGroup().add(EventActionConverter.run(action, collector));
 			}
 		}
 		return result;
@@ -62,13 +63,23 @@
 	}
 	
 	private static String convertEnvetType(String type) {
-		if (type.toLowerCase().equals("process-start")) {
+		//TODO:check if jPBM4 only supports start,take and end event type 
+		String eventType = type.toLowerCase();
+		if ("process-start".equals(eventType) || "node-enter".equals(eventType) 
+				|| "task-start".equals(eventType)) {
 			return "start";
 		}
-		if (type.toLowerCase().equals("process-end")) {
+		if ("process-end".equals(eventType) || "node-leave".equals(eventType) 
+				|| "task-end".equals(eventType)) {
 			return "end";
 		}
 		
+		if ("transition".endsWith(eventType)) {
+			return "take";
+		}
+		
+		
+		
 		return type;
 	}
 

Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ExceptionHandlersConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ExceptionHandlersConverter.java	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ExceptionHandlersConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -0,0 +1,34 @@
+/*
+ * 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.util;
+
+import org.jbpm.graph.def.GraphElement;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
+
+public class ExceptionHandlersConverter {
+	public static void run(GraphElement node, ProblemCollector collector) {
+		if (node.getExceptionHandlers() != null) {
+			collector.addWarning("Unsupported ExceptionHandler conversion in node [" + node.getName() + "]");
+		}		
+	}
+
+}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -24,23 +24,25 @@
 import java.util.List;
 
 import org.jbpm.graph.def.Transition;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.TransitionType;
 import org.jbpm.jpdl4.model.Process.Fork;;
 
 public class ForkConverter {
-	public static Fork run(org.jbpm.graph.node.Fork node) {
+	public static Fork run(org.jbpm.graph.node.Fork node, ProblemCollector collector) {
 		Fork result = new Fork();
 		result.setName(node.getName());
 		
 	    for(Transition trans : node.getLeavingTransitions()) {
-	    	TransitionType transType = TransitionConverter.run(trans, TransitionType.class);
+	    	TransitionType transType = TransitionConverter.run(trans, TransitionType.class, collector);
 	    	result.getTransition().add(transType);
 	    }
 	    
-	    //TODO: process exceptions
-	    List<On> ons = EventsConverter.run(node.getEvents());
+	    List<On> ons = EventsConverter.run(node.getEvents(), collector);
 	    result.getOn().addAll(ons);
+	    
+	    ExceptionHandlersConverter.run(node,collector);
 		return result;
 	}
 

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -24,21 +24,24 @@
 import java.util.List;
 
 import org.jbpm.graph.def.Transition;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.TransitionType;
 import org.jbpm.jpdl4.model.Process.Join;
 
 public class JoinConverter {
-	public static Join run(org.jbpm.graph.node.Join node) {
+	public static Join run(org.jbpm.graph.node.Join node, ProblemCollector collector) {
 		Join join = new Join();
 		join.setName(node.getName());
 		for (Transition trans : node.getLeavingTransitions()) {
 			join.getTransition().add(
-					TransitionConverter.run(trans, TransitionType.class));
+					TransitionConverter.run(trans, TransitionType.class, collector));
 		}
-	    //TODO: process exceptions
-		List<On> ons = EventsConverter.run(node.getEvents());
+	    
+		List<On> ons = EventsConverter.run(node.getEvents(), collector);
 	    join.getOn().addAll(ons);
+	    ExceptionHandlersConverter.run(node,collector);
+	    
 		return join;
 
 	}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -21,25 +21,21 @@
  */
 package org.jbpm.jpdl.internal.convert.util;
 
+import java.util.List;
 import java.util.Set;
 
 import org.jbpm.context.def.VariableAccess;
 import org.jbpm.graph.action.Script;
 import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.Node;
-import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
+import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
-import org.jbpm.jpdl4.model.ScriptType;
 
-/*
-<action-type element="action"       class="org.jbpm.graph.def.Action" />
-<action-type element="create-timer" class="org.jbpm.scheduler.def.CreateTimerAction" />
-<action-type element="cancel-timer" class="org.jbpm.scheduler.def.CancelTimerAction" />
-<action-type element="script"       class="org.jbpm.graph.action.Script" />
-<action-type element="mail"         class="org.jbpm.graph.action.MailAction" />*/
 public class NodeConverter {	
-	public static Object run(Node node) {
+	public static Object run(Node node, ProblemCollector collector) {
 		String nodeName = node.getName();
+		List<On> ons = EventsConverter.run(node.getEvents(), collector);
 		Action action = node.getAction();
 		if (action instanceof Script) {
 			Process.Script result = new Process.Script();
@@ -55,8 +51,8 @@
 					}					
 				}
 			}
-		    
-			
+			result.getOn().addAll(ons);
+			return result;		    
 		}
 		if (action instanceof Action) {
 			Process.Java result = new Process.Java();
@@ -68,12 +64,14 @@
 			    result.setClazz(action.getActionDelegation().getClassName());
 			    result.setMethod("execute");
 			}
+			
+			result.getOn().addAll(ons);
 			return result;
 		}
 		//TODO:convert other action types:create-timer,cancel-timer, mail
-	    //TODO: Process exceptions
-		//TODO: Process events
-		//TODO: process timers
+		//process exceptionHandler
+		ExceptionHandlersConverter.run(node,collector);
+        
 		
 		return null;
 		

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 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -25,14 +25,17 @@
 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.jpdl4.model.TransitionType;
+import org.jbpm.taskmgmt.def.Task;
+import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
 
 public class StartStateConverter {
-	public static Process.Start run(StartState jpdl3start) {
+	public static Process.Start run(StartState jpdl3start, ProblemCollector collector) {
 		Process.Start start = new Process.Start();
 		start.setName(jpdl3start.getName());
 		
@@ -40,12 +43,17 @@
 		while (iterator.hasNext()) {
 			Map.Entry entry = (Map.Entry) iterator.next();
 			Transition trans = (Transition) entry.getValue();
-			start.getTransition().add(TransitionConverter.run(trans, TransitionType.class));
 		}
-		//TODO: process Task
-		List<On> ons = EventsConverter.run(jpdl3start.getEvents());
+		
+		TaskMgmtDefinition taskMgmtDef = jpdl3start.getProcessDefinition().getTaskMgmtDefinition();
+		if (taskMgmtDef != null) {
+			if (taskMgmtDef.getStartTask() != null) {
+				collector.addWarning("Unsupported task conersion in StartState [" + jpdl3start.getName() + "]");
+			}
+		}
+		List<On> ons = EventsConverter.run(jpdl3start.getEvents(), collector);
 	    start.getOn().addAll(ons);
-		//TODO: process exceptions
+	    ExceptionHandlersConverter.run(jpdl3start,collector);
 	
 		return start;
 	}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StateConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StateConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StateConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -24,28 +24,28 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
-import org.jbpm.graph.def.Event;
 import org.jbpm.graph.def.Transition;
 import org.jbpm.graph.node.State;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
 
 public class StateConverter {
 
-	public static Process.State run(State node) {
+	public static Process.State run(State node, ProblemCollector collector) {
 		Process.State state = new Process.State();
 		state.setName(node.getName());
 		Iterator iterator = node.getLeavingTransitionsMap().entrySet().iterator();
 		while (iterator.hasNext()) {
 		    Map.Entry entry = (Map.Entry)iterator.next();
 		    Transition trans = (Transition)entry.getValue();
-		    state.getTransition().add((Process.State.Transition)TransitionConverter.run(trans, Process.State.Transition.class));
-		}		
-	    List<On> ons = EventsConverter.run(node.getEvents());
+		    state.getTransition().add((Process.State.Transition)TransitionConverter.run(trans, Process.State.Transition.class, collector));
+		}
+		
+	    List<On> ons = EventsConverter.run(node.getEvents(), collector);
 	    state.getOn().addAll(ons);
-		//TODO: process exceptions
+	    ExceptionHandlersConverter.run(node,collector);
 		return state;
 		
 	}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -21,9 +21,10 @@
  */
 package org.jbpm.jpdl.internal.convert.util;
 import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.Swimlane;
 public class SwimlaneConverter {
-	public static Swimlane run(org.jbpm.taskmgmt.def.Swimlane swimlane) {
+	public static Swimlane run(org.jbpm.taskmgmt.def.Swimlane swimlane, ProblemCollector collector) {
 		Swimlane result = new Swimlane();
 		result.setName(swimlane.getName());		
 		String actoridExpress = swimlane.getActorIdExpression();

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -26,6 +26,7 @@
 
 import org.jbpm.graph.node.TaskNode;
 import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.ObjectFactory;
 import org.jbpm.jpdl4.model.On;
 import org.jbpm.jpdl4.model.Process;
@@ -34,7 +35,7 @@
 import org.jbpm.graph.def.Transition;
 
 public class TaskNodeConverter {
-	public static Set<Process.Task> run(TaskNode taskNode) {
+	public static Set<Process.Task> run(TaskNode taskNode, ProblemCollector collector) {
 		
 		String taskNodeName = taskNode.getName();
 		Set<Process.Task> result = new java.util.HashSet<Process.Task>();
@@ -46,6 +47,9 @@
 				Task tmpTask =taskArray[i];
 		         		
 				Process.Task tmpNewTask = convert(tmpTask);
+				List<On> ons = EventsConverter.run(tmpTask.getEvents(), collector);
+				tmpNewTask.getOn().addAll(ons);
+				
 				//convert the swimlane information
 				if (tmpTask.getActorIdExpression() != null) {
 					tmpNewTask.setAssignee(tmpTask.getActorIdExpression());
@@ -70,7 +74,7 @@
 				} else {
 					//The last task node 
 					for (Transition trans : taskNode.getLeavingTransitions()) {
-						tmpNewTask.getTransition().add(TransitionConverter.run(trans, Process.Task.Transition.class));
+						tmpNewTask.getTransition().add(TransitionConverter.run(trans, Process.Task.Transition.class, collector));
 					}
 					
 				}
@@ -78,14 +82,11 @@
 				
 			}
 		}
-		//TODO: Process exceptions
-        //TODO: Process events
-		//TODO: Process Timers
-
+		ExceptionHandlersConverter.run(taskNode,collector);
 		return result;
 	}
 
-	private static Process.Task convert(Task task) {
+	public static Process.Task convert(Task task) {
 		Process.Task newTask = new Process.Task();
 		Delegation delegation = task.getAssignmentDelegation();
 		if (delegation != null) {

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TimerConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TimerConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TimerConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -22,6 +22,7 @@
 package org.jbpm.jpdl.internal.convert.util;
 
 import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.JavaType;
 import org.jbpm.jpdl4.model.ObjectFactory;
 import org.jbpm.jpdl4.model.ScriptType;
@@ -29,7 +30,7 @@
 import org.jbpm.scheduler.def.CreateTimerAction;
 
 public class TimerConverter {
-	public static Timer run(CreateTimerAction node) {
+	public static Timer run(CreateTimerAction node, ProblemCollector collector) {
 		Timer timer = new Timer();
 		timer.setDuedate(node.getDueDate());
 		timer.setRepeat(node.getRepeat());

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java	2009-06-02 10:13:17 UTC (rev 4970)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -28,6 +28,7 @@
 import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.Event;
 import org.jbpm.graph.def.Transition;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
 import org.jbpm.jpdl4.model.JavaType;
 import org.jbpm.jpdl4.model.ObjectFactory;
 import org.jbpm.jpdl4.model.Process;
@@ -37,7 +38,7 @@
 
 public class TransitionConverter {
 	public static ObjectFactory objectFactory = new ObjectFactory();
-	public static <T extends TransitionType> T run(Transition transition, Class<T> claz) {
+	public static <T extends TransitionType> T run(Transition transition, Class<T> claz, ProblemCollector collector) {
 		TransitionType transType = null;
 		try {
 			transType = claz.newInstance();

Added: 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	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java	2009-06-02 10:19:40 UTC (rev 4971)
@@ -0,0 +1,152 @@
+/*
+ * 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.File;
+import java.net.URL;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+public class JpdlConverterToolTest {
+	
+	JpdlConverterTool tool = new JpdlConverterTool();
+	@Test
+	public void wrongArgs1() {
+    	String args[] = {"-v","-t"};
+		try {
+			tool.parseParam(args);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//do nothing
+		}
+	}
+	@Test
+	public void wrongArgs2() {
+		
+		String args2[] = {"-v","-o"};
+		try {
+			tool.parseParam(args2);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//do nothing
+		}
+		
+	}	
+	@Test
+	public void wrongArgs3() {
+		String args3[] = {"-v","-o", "tmp.xml"};
+		try {
+			tool.parseParam(args3);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//do nothing
+		}
+	}
+	
+	@Test
+	public void wrongArgs4() {	
+		String args4[] = {"-o", "tmp.xml", "process.xml", "myprocess.xml"};
+		try {
+			tool.parseParam(args4);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//do nothing
+		}	
+		
+	}
+	
+	
+	@Test
+	public void rightArgs() throws Exception {	
+		String args4[] = {"-o", "tmp.xml", "process.xml"};
+		tool.parseParam(args4);	
+		String args5[] = {"process.xml"};
+		tool.parseParam(args5);	
+		String args6[] = {"-v","process.xml"};
+		tool.parseParam(args6);
+		String args7[] = {"-o","process.xml", "processed.xml"};
+		tool.parseParam(args7);
+	}
+	
+	
+	@Test
+	public void validateArgs1() throws Exception {	
+		ConverterContext context = new ConverterContext();
+		context.put(ConverterContext.PROCESS_FILE, "test.xml");
+		try {
+			tool.validate(context);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//
+		}
+	}
+	
+	@Test
+	public void validateArgs2() throws Exception {
+		String fileName = getResource("simple.xml");
+		ConverterContext context = new ConverterContext();
+		context.put(ConverterContext.PROCESS_FILE, fileName);
+		context.put(ConverterContext.OUPUTFILE, "/mytest/histest");
+		try {
+			tool.validate(context);
+			Assert.fail("No Illegal command exception thrown");
+		} catch (Exception e) {
+			//
+		}
+	}
+	
+
+	
+	
+
+	@Test
+	public void runConcretProcess() throws Exception {
+		String fileName = getResource("simple.xml");
+		String args[] = new String[]{"-v",fileName};
+		JpdlConverterTool.main(args);
+		URL url = new URL(fileName);
+		File tmpFile = new File(url.getFile());
+		File destFile = new File(tmpFile.getParentFile(), "simple.converted.jpdl.xml");
+		Assert.assertTrue(destFile.exists());		
+	}
+	
+	@Test
+	public void runConcretProcess2() throws Exception {
+		String fileName = getResource("simple.xml");
+		URL url = new URL(fileName);
+		File tmpFile = new File(url.getFile());
+		File outputfile = new File(tmpFile.getParentFile(), "output.xml");
+			
+		String args[] = new String[]{"-v","-o", outputfile.getAbsolutePath(),fileName};
+		JpdlConverterTool.main(args);
+	
+		Assert.assertTrue(outputfile.exists());	
+	}
+	
+	
+	
+    public String getResource(String file) throws Exception {
+    	URL url = getClass().getClassLoader().getResource(file);
+    	return url.toString();
+    }
+}

Added: jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/log4j.xml	2009-06-02 10:19:40 UTC (rev 4971)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out" />
+    <param name="Threshold" value="WARN" />
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
+    </layout>
+  </appender>
+
+  <root>
+    <appender-ref ref="CONSOLE"/>
+  </root>
+
+</log4j:configuration>




More information about the jbpm-commits mailing list