[overlord-commits] Overlord SVN: r578 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src: test/org/jboss/tools/overlord/cdl/bpel/model/component and 1 other directory.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Fri Apr 10 17:56:58 EDT 2009


Author: objectiser
Date: 2009-04-10 17:56:57 -0400 (Fri, 10 Apr 2009)
New Revision: 578

Added:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ForEach.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Variable.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ForEachTest.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/VariableTest.java
Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java
Log:
Added forEach, scope and variable. Further work required on scope.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java	2009-04-10 17:13:57 UTC (rev 577)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -209,20 +209,45 @@
 	 */
 	protected void setChildElement(org.w3c.dom.Element existing,
 				BPELElement newelem, org.w3c.dom.Node insertBefore) {
+		
+		setChildElement(getDOMElement(), existing, newelem, insertBefore);
+	}
+	
+	/**
+	 * This method sets a new element. If an existing element
+	 * is specified, then it is replaced with the new element.
+	 * Otherwise if an insertBefore node is specified, then
+	 * the new element is inserted before it. If no existing
+	 * or insertBefore parameters are specified, then the
+	 * new element will be appended.<b>
+	 * <b>
+	 * The new BPEL element will be updated to be associated
+	 * with a DOM element that is adopted by the document
+	 * into which it is being added.
+	 * 
+	 * @param root The root element to add child to
+	 * @param existing The optional existing element to be
+	 * 						replaced
+	 * @param newelem The new element
+	 * @param insertBefore Optional location to insert new element
+	 */
+	protected void setChildElement(org.w3c.dom.Element root,
+					org.w3c.dom.Element existing,
+				BPELElement newelem, org.w3c.dom.Node insertBefore) {
 			
 		if (newelem != null) {
 			org.w3c.dom.Node newNode=newelem.getDOMElement().cloneNode(true);
 			
-			getDOMElement().getOwnerDocument().adoptNode(newNode);
+			root.getOwnerDocument().adoptNode(newNode);
 			
 			newelem.setDOMElement((org.w3c.dom.Element)newNode);
 			
 			if (existing != null) {
-				getDOMElement().replaceChild(newNode, existing);
+				root.replaceChild(newNode, existing);
 			} else if (insertBefore != null) {
-				getDOMElement().insertBefore(newNode, insertBefore);
+				root.insertBefore(newNode, insertBefore);
 			} else {
-				getDOMElement().appendChild(newNode);
+				root.appendChild(newNode);
 			}
 		}
 	}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ForEach.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ForEach.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ForEach.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,110 @@
+/*
+ * 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.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents a forEach grouping activity.
+ *  
+ * @author gary
+ */
+public class ForEach extends BPELGroupingConstruct {
+
+	private static final long serialVersionUID = -4302270930464272401L;
+
+	public static final String FOREACH = "forEach";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public ForEach(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	
+		org.w3c.dom.Element scopeElem=
+			findChildElement(Scope.SCOPE);
+
+		if (scopeElem == null) {
+			m_scope = new Scope(model);
+		} else {
+			m_scope = new Scope(model, scopeElem);
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public ForEach(BPELLanguageModel model) {
+		super(model, FOREACH);
+	}
+
+	/**
+	 * This method sets the scope.
+	 * 
+	 * @param scope The scope
+	 */
+	public void setScope(Scope scope) {
+		m_scope = scope;
+		
+		org.w3c.dom.Element existingElem=this.findChildElement(Scope.SCOPE);
+		
+		setChildElement(existingElem, scope,
+						null);
+	}
+
+	/**
+	 * This method returns the scope.
+	 * 
+	 * @return The scope
+	 */
+	public Scope getScope() {
+		return(m_scope);
+	}
+	
+	/**
+	 * 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) {
+	}
+	
+	/**
+	 * 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) {
+	}
+
+	private Scope m_scope=null;
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java	2009-04-10 17:13:57 UTC (rev 577)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -132,12 +132,6 @@
 		return(getDOMElement().getAttribute(VARIABLE));
 	}
 
-	@Override
-	public void convert(List<Activity> activities, ConversionContext context) {
-		// TODO Auto-generated method stub
-		
-	}
-	
 	/**
 	 * This method sets the activity associated with
 	 * the 'else' construct.
@@ -170,5 +164,11 @@
 		return(m_activity);
 	}
 	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
 	private BPELElement m_activity;
 }

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,232 @@
+/*
+ * 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.component;
+
+import java.util.List;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents a scope grouping activity.
+ *  
+ * @author gary
+ */
+public class Scope extends BPELActivity {
+
+	private static final long serialVersionUID = 7132062003047468101L;
+
+	public static final String SCOPE = "scope";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Scope(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_partnerLinksElem = findChildElement("partnerLinks");
+		m_variablesElem = findChildElement("variables");
+		m_messageExchangesElem = findChildElement("messageExchanges");
+		m_correlationSetsElem = findChildElement("correlationSets");
+		m_eventHandlersElem = findChildElement("eventHandlers");
+		m_faultHandlersElem = findChildElement("faultHandlers");
+		m_compensationHandlerElem = findChildElement("compensationHandler");
+		m_terminationHandlerElem = findChildElement("terminationHandler");
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Scope(BPELLanguageModel model) {
+		super(model, SCOPE);
+	}
+
+	/**
+	 * This method adds a variable to the scope.
+	 * 
+	 * @param var The variable to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addVariable(Variable var, int pos) {
+		
+		if (m_variablesElem == null) {
+			m_variablesElem = getDOMElement().getOwnerDocument().
+				createElementNS(BPEL_NS, "variables");
+			
+			// Add to parent
+			org.w3c.dom.Element insertBefore=
+					findChildElement("partnerLinks");
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("messageExchanges");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("correlationSets");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("eventHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("faultHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("compensationHandler");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("terminationHandler");
+			}
+			
+			if (insertBefore == null) {
+				BPELElement elem=findChildActivity();
+				
+				if (elem != null) {
+					insertBefore = elem.getDOMElement();
+				}
+			}
+			
+			if (insertBefore != null) {
+				getDOMElement().insertBefore(m_variablesElem, insertBefore);
+			} else {
+				getDOMElement().appendChild(m_variablesElem);
+			}
+		}
+		
+		if (pos == -1 && pos < m_variables.size()) {
+			m_variables.add(var);
+			
+			setChildElement(m_variablesElem, null, var, null);
+		} else {
+			
+			Variable cur=m_variables.get(pos);
+			
+			m_variables.add(pos, var);
+			
+			if (cur != null) {
+				setChildElement(m_variablesElem, null, var,
+							cur.getDOMElement());
+			} else {
+				setChildElement(m_variablesElem, null, var, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	/*
+	public boolean removeActivity(BPELActivity act) {
+		boolean ret=m_activities.remove(act);
+		
+		if (ret) {
+			getDOMElement().removeChild(act.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	*/
+	
+	/**
+	 * This method returns the list of variables.
+	 * 
+	 * @return The 
+	 */
+	public java.util.List<Variable> getVariables() {
+		return(m_variables);
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_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) {
+	}
+	
+	/**
+	 * 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) {
+	}
+
+	private org.w3c.dom.Element m_partnerLinksElem=null;
+	private org.w3c.dom.Element m_variablesElem=null;
+	private org.w3c.dom.Element m_messageExchangesElem=null;
+	private org.w3c.dom.Element m_correlationSetsElem=null;
+	private org.w3c.dom.Element m_eventHandlersElem=null;
+	private org.w3c.dom.Element m_faultHandlersElem=null;
+	private org.w3c.dom.Element m_compensationHandlerElem=null;
+	private org.w3c.dom.Element m_terminationHandlerElem=null;
+	private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+	private BPELElement m_activity;
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java	2009-04-10 17:13:57 UTC (rev 577)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -69,7 +69,7 @@
 	 * @param pos The position to add, or -1 if at the end
 	 */
 	public void addActivity(BPELActivity act, int pos) {
-		if (pos == -1 && pos < m_activities.size()) {
+		if (pos == -1 || pos >= m_activities.size()) {
 			m_activities.add(act);
 			
 			setChildElement(null, act, null);

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Variable.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Variable.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Variable.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,117 @@
+/*
+ * 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.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents the variable.
+ *  
+ * @author gary
+ */
+public class Variable extends BPELElement {
+
+	private static final long serialVersionUID = -3824104482191549444L;
+
+	public static final String VARIABLE = "variable";
+	
+	private static final String NAME = "name";
+	private static final String TYPE = "type";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param element The XML configuration details for the element
+	 */
+	public Variable(BPELLanguageModel  model,
+					org.w3c.dom.Element element) {
+		super(model, element);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Variable(BPELLanguageModel model) {
+		super(model, VARIABLE);
+	}
+
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {		
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(getDOMElement().getAttribute(NAME));
+	}
+
+	/**
+	 * This method sets the variable type.
+	 * 
+	 * @param type The type
+	 */
+	public void setType(String type) {		
+		getDOMElement().setAttribute(TYPE, type);
+	}
+	
+	/**
+	 * This method returns the variable type.
+	 * 
+	 * @return The type
+	 */
+	public String getType() {
+		return(getDOMElement().getAttribute(TYPE));
+	}
+
+	/**
+	 * 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/component/ForEachTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ForEachTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ForEachTest.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,128 @@
+/*
+ * 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.component;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class ForEachTest extends TestCase {
+
+	public void testIsActivity() {
+		ForEach act=new ForEach(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testForEachFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<startCounterValue/>"+
+			"<finalCounterValue/>"+
+			"<completionCondition/>"+
+			"<scope/>"+
+			"</forEach>";
+		
+		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");
+		}
+		
+		ForEach component=new ForEach(model, elem);		
+		
+		if (component.getScope() == null) {
+			fail("Scope not set");
+		}
+	}
+
+	public void testSetScopeInInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<startCounterValue/>"+
+			"<finalCounterValue/>"+
+			"<completionCondition/>"+
+			"</forEach>";
+		
+		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");
+		}
+		
+		ForEach component=new ForEach(model, elem);		
+		
+		if (component.getScope() == null) {
+			fail("Scope should not be null");
+		}
+		
+		Scope scope=new Scope(model);
+		component.setScope(scope);
+		
+		if (component.getScope() == null) {
+			fail("Scope should still not be null");
+		}
+
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a 'scope': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,72 @@
+/*
+ * 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.component;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class ScopeTest extends TestCase {
+
+	public void testIsActivity() {
+		Scope act=new Scope(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testScopeFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks/>"+
+				"<variable/>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+	       "</scope>";
+		
+		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");
+		}
+		
+		Scope component=new Scope(model, elem);		
+	}
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/VariableTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/VariableTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/VariableTest.java	2009-04-10 21:56:57 UTC (rev 578)
@@ -0,0 +1,110 @@
+/*
+ * 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.component;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class VariableTest extends TestCase {
+
+	public void testIsActivity() {
+		Variable act=
+			new Variable(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String type="testType";
+		
+		String xml="<variable xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "name=\""+var+"\" "+
+		       "type=\""+type+"\" "+
+		       "/>";
+		
+		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");
+		}
+		
+		Variable component=new Variable(model, elem);		
+		
+		if (component.getName().equals(var) == false) {
+			fail("Variable name not correct, expecting '"+var+"': "+
+							component.getName());
+		}
+		
+		if (component.getType().equals(type) == false) {
+			fail("Type not correct, expecting '"+type+"': "+
+							component.getType());
+		}
+	}
+
+	public void testGetVariableName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Variable component=new Variable(model);		
+		
+		component.setName(var);
+		
+		if (component.getName().equals(var) == false) {
+			fail("Variable name not correct, expecting '"+var+"': "+
+							component.getName());
+		}
+	}
+
+	public void testGetType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String type="testType";
+		
+		Variable component=new Variable(model);		
+		
+		component.setType(type);
+		
+		if (component.getType().equals(type) == false) {
+			fail("Type not correct, expecting '"+type+"': "+
+							component.getType());
+		}
+	}
+}




More information about the overlord-commits mailing list