[overlord-commits] Overlord SVN: r557 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel: src and 11 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Fri Mar 27 19:41:54 EDT 2009


Author: objectiser
Date: 2009-03-27 19:41:54 -0400 (Fri, 27 Mar 2009)
New Revision: 557

Added:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ConditionTest.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstructTest.java
Removed:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/UnsupportedActivity.java
Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELElementFactory.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/AbstractBPELElement.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/Condition.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseConstruct.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstruct.java
Log:
Initialise the condition and elseIf constructs, and define some tests.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath	2009-03-27 23:41:54 UTC (rev 557)
@@ -4,5 +4,6 @@
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src/java"/>
 	<classpathentry kind="src" path="src/plugintest"/>
+	<classpathentry kind="src" path="src/test"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELElementFactory.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELElementFactory.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELElementFactory.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -19,13 +19,12 @@
 
 import java.util.logging.Logger;
 
-import org.jboss.tools.overlord.cdl.bpel.model.activities.UnsupportedActivity;
-
 public class BPELElementFactory {
 
 	public static final String MODEL_ACTIVITIES_PACKAGE =
 			"org.jboss.tools.overlord.cdl.bpel.model.activities";
-
+	private static final String ACTIVITY_SUFFIX="Activity";
+	
 	/**
 	* This method creates a BPELActivity instance relevant to the
 	* supplied JBossESB action, associated with the supplied
@@ -40,7 +39,13 @@
 		BPELElement ret=null;
 		String activityType=activity.getNodeName();
 		
-		String clsName=MODEL_ACTIVITIES_PACKAGE+"."+activityType;
+		// Make first character capitalised
+		char ch=Character.toUpperCase(activityType.charAt(0));
+		
+		activityType = ch+activityType.substring(1);
+		
+		String clsName=MODEL_ACTIVITIES_PACKAGE+"."+activityType+
+						ACTIVITY_SUFFIX;
 	
 		try {
 			Class<?> cls=(Class<?>)
@@ -53,14 +58,9 @@
 			ret = (BPELElement)con.newInstance(new Object[]{model, activity});
 			
 		} catch(Exception e) {
-			logger.log(java.util.logging.Level.SEVERE,
+			logger.log(java.util.logging.Level.FINEST,
 					"Unable to find action class '"+clsName+"'", e);
 		}
-
-		if (ret == null) {
-			// Unrecognised or unsupported activity
-			ret = new UnsupportedActivity(model, activity);
-		}
 		
 		return(ret);
 	}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/AbstractBPELElement.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/AbstractBPELElement.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/AbstractBPELElement.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -32,6 +32,8 @@
 public abstract class AbstractBPELElement extends ModelObject
 						implements BPELElement {
 
+	private static final long serialVersionUID = -7306844554703224704L;
+
 	/**
 	 * The constructor for initializing the BPEL element based on
 	 * an existing DOM element.
@@ -104,6 +106,52 @@
 	}
 	
 	/**
+	 * This method returns the element associated with
+	 * the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The element, or null if not found
+	 */
+	protected org.w3c.dom.Element findElement(String name) {
+		org.w3c.dom.Element ret=null;
+		
+		org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+		
+		for (int i=0; ret == null && i < nl.getLength(); i++) {
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element &&
+					n.getLocalName().equals(name)) {
+				ret = (org.w3c.dom.Element)nl.item(i);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the first child BPEL activity
+	 * found within the DOM element.
+	 * 
+	 * @return The child BPEL activity, or null if not found
+	 */
+	protected BPELElement findChildActivity() {
+		BPELElement ret=null;
+		
+		org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+		
+		for (int i=0; ret == null &&
+					i < nl.getLength(); i++) {
+			if (nl.item(i) instanceof org.w3c.dom.Element) {
+				ret = BPELElementFactory.createActivity(m_model,
+								(org.w3c.dom.Element)nl.item(i));
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
 	 * This method converts the BPEL activity into an equivalent
 	 * behavioural description for conformance checking.
 	 * 

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/Condition.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/Condition.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/Condition.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -30,7 +30,7 @@
 
 	private static final long serialVersionUID = 8666349106632652777L;
 
-	private static final String CONDITION="condition";
+	public static final String CONDITION="condition";
 	
 	/**
 	 * The constructor for the element.
@@ -52,6 +52,12 @@
 		super(model, CONDITION);
 	}
 
+	/**
+	 * This method returns the expression associated
+	 * with the condition.
+	 * 
+	 * @return The expression
+	 */
 	public String getExpression() {
 		String ret=null;
 		
@@ -67,6 +73,11 @@
 		return(ret);
 	}
 	
+	/**
+	 * This method sets the expression.
+	 * 
+	 * @param expr The expression
+	 */
 	public void setExpression(String expr) {
 		
 		getDOMElement().normalize();

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseConstruct.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseConstruct.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseConstruct.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -30,6 +30,8 @@
  */
 public class ElseConstruct extends AbstractBPELElement {
 
+	private static final long serialVersionUID = 1243775332210724718L;
+
 	private static final String ELSE="else";
 	
 	/**
@@ -59,10 +61,22 @@
 		
 	}
 	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
 	public void setActivity(BPELElement act) {
 		m_activity = act;
 	}
 	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
 	public BPELElement getActivity() {
 		return(m_activity);
 	}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstruct.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstruct.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstruct.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -54,6 +54,28 @@
 		super(model, ELSEIF);
 	}
 
+	/**
+	 * This method initializes the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	@Override
+	protected void initExistingElement(BPELLanguageModel model,
+						org.w3c.dom.Element activity) {
+		super.initExistingElement(model, activity);
+		
+		org.w3c.dom.Element cond=
+				findElement(Condition.CONDITION);
+		
+		if (cond == null) {
+			m_condition = new Condition(model);
+		} else {
+			m_condition = new Condition(model, cond);
+		}
+		
+		m_activity = findChildActivity();
+	}
 
 	@Override
 	public void convert(List<Activity> activities, ConversionContext context) {
@@ -61,22 +83,44 @@
 		
 	}
 	
+	/**
+	 * This method sets the condition.
+	 * 
+	 * @param cond The condition
+	 */
 	public void setCondition(Condition cond) {
 		m_condition = cond;
 	}
 	
+	/**
+	 * This method returns the condition.
+	 * 
+	 * @return The condition
+	 */
 	public Condition getCondition() {
 		return(m_condition);
 	}
 
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
 	public void setActivity(BPELElement act) {
 		m_activity = act;
 	}
 	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
 	public BPELElement getActivity() {
 		return(m_activity);
 	}
 	
-	private Condition m_condition=null;
-	private BPELElement m_activity=null;
+	private Condition m_condition;
+	private BPELElement m_activity;
 }

Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/UnsupportedActivity.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/UnsupportedActivity.java	2009-03-27 21:04:21 UTC (rev 556)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/UnsupportedActivity.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.bpel.model.activities;
-
-import org.scribble.model.*;
-import org.scribble.model.admin.ModelListener;
-import org.jboss.tools.overlord.cdl.bpel.model.*;
-/**
- * This class represents an unsupported (or custom) action within
- * the conversation based ESB service descriptor.
- *  
- * @author gary
- */
-public class UnsupportedActivity extends AbstractBPELElement {
-
-	/**
-	 * The constructor for the activity.
-	 * 
-	 * @param model The BPEL model
-	 * @param activity The XML configuration details for the activity
-	 */
-	public UnsupportedActivity(BPELLanguageModel  model,
-					org.w3c.dom.Element activity) {
-		super(model, activity);
-	}
-
-	/**
-	 * This method validates the BPEL activity and reports warnings or
-	 * errors to the supplied model listener.
-	 * 
-	 * @param l The model listener
-	 */
-	@Override
-	public void validate(ModelListener l) {
-		// Don't validate unsupported actions
-	}
-	
-	/**
-	 * This method converts the BPEL activity into an equivalent
-	 * behavioural description for conformance checking.
-	 * 
-	 * @param activities The list of activities that will contain
-	 * 				the converted action(s)
-	 * @param context The conversion context
-	 */
-	public void convert(java.util.List<Activity> activities,
-			ConversionContext context) {
-	}
-
-}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ConditionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ConditionTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ConditionTest.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.bpel.model.activities;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class ConditionTest extends TestCase {
+
+	public void testGetExpression() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+		Condition condition=new Condition(model);
+		
+		String expr="Test Expression";
+		
+		condition.setExpression(expr);
+		
+		String result=condition.getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}
+	}
+	
+	public void testGetExpressionFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr="Test Expression";
+		
+		String xml="<condition>"+expr+"</condition>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilder builder=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);		
+		
+		String result=condition.getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}		
+	}
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstructTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstructTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/ElseIfConstructTest.java	2009-03-27 23:41:54 UTC (rev 557)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.bpel.model.activities;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class ElseIfConstructTest extends TestCase {
+
+	public void testBuildElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr="Test Expression";
+		
+		String xml="<elseif><condition>"+expr+"</condition><sequence/></elseif>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		ElseIfConstruct elseif=new ElseIfConstruct(model, elem);		
+		
+		if (elseif.getCondition() == null) {
+			fail("No condition");
+		}
+		
+		if (elseif.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		String result=elseif.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}				
+		
+		if ((elseif.getActivity() instanceof SequenceActivity) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}




More information about the overlord-commits mailing list