[overlord-commits] Overlord SVN: r574 - 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
Sat Apr 4 13:32:44 EDT 2009


Author: objectiser
Date: 2009-04-04 13:32:44 -0400 (Sat, 04 Apr 2009)
New Revision: 574

Added:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Flow.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Link.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FlowTest.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/Else.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntil.java
   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/Wait.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/While.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementTest.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/SequenceTest.java
Log:
Added flow with tests, and modified way sub-components are added when being stored by the activity - to update the DOM element to the one adopted by the BPEL document into which the component is being added.

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-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -82,6 +82,16 @@
 	}
 	
 	/**
+	 * This method sets the XML configuration representation
+	 * of the activity.
+	 * 
+	 * @param elem The XML configuration
+	 */
+	protected void setDOMElement(org.w3c.dom.Element elem) {
+		m_element = elem;
+	}
+	
+	/**
 	 * This method identifies whether the BPEL element
 	 * is an activity.
 	 * 
@@ -186,7 +196,11 @@
 	 * 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.
+	 * 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 existing The optional existing element to be
 	 * 						replaced
@@ -194,13 +208,15 @@
 	 * @param insertBefore Optional location to insert new element
 	 */
 	protected void setChildElement(org.w3c.dom.Element existing,
-				org.w3c.dom.Element newelem, org.w3c.dom.Node insertBefore) {
+				BPELElement newelem, org.w3c.dom.Node insertBefore) {
 			
 		if (newelem != null) {
-			org.w3c.dom.Node newNode=newelem.cloneNode(true);
+			org.w3c.dom.Node newNode=newelem.getDOMElement().cloneNode(true);
 			
 			getDOMElement().getOwnerDocument().adoptNode(newNode);
 			
+			newelem.setDOMElement((org.w3c.dom.Element)newNode);
+			
 			if (existing != null) {
 				getDOMElement().replaceChild(newNode, existing);
 			} else if (insertBefore != null) {

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Else.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Else.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Else.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -79,7 +79,7 @@
 
 		org.w3c.dom.Element insertBefore=null;
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 						insertBefore);
 	}
 	

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -79,7 +79,7 @@
 		m_condition = cond;
 		
 		setChildElement(findChildElement(Condition.CONDITION),
-				cond.getDOMElement(), getDOMElement().getFirstChild());
+				cond, getDOMElement().getFirstChild());
 	}
 	
 	/**
@@ -109,7 +109,7 @@
 
 		org.w3c.dom.Element insertBefore=null;
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 						insertBefore);
 	}
 	

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Flow.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Flow.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Flow.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -0,0 +1,243 @@
+/*
+ * 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 flow grouping activity.
+ *  
+ */
+public class Flow extends BPELActivity {
+
+	private static final long serialVersionUID = -5165269453306785719L;
+
+	public static final String FLOW = "flow";
+	public static final String LINKS = "links";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Flow(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		org.w3c.dom.Element links=findChildElement("links");
+		
+		if (links != null) {
+			org.w3c.dom.NodeList nl=links.getChildNodes();
+		
+			for (int i=0; i < nl.getLength(); i++) {
+				if (nl.item(i).getLocalName().equals(Link.LINK)
+						&& nl.item(i) instanceof org.w3c.dom.Element) {
+					m_links.add(new Link(model,
+							(org.w3c.dom.Element)nl.item(i)));
+				}
+			}
+		}
+		
+		java.util.List<BPELElement> acts=
+					findChildElements(BPELActivity.class);
+		
+		for (int i=0; i < acts.size(); i++) {
+			if (acts.get(i).isActivity() &&
+					acts.get(i) instanceof BPELActivity) {
+				m_activities.add((BPELActivity)acts.get(i));
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Flow(BPELLanguageModel model) {
+		super(model, FLOW);
+	}
+
+	/**
+	 * This method adds a link to the grouping construct.
+	 * 
+	 * @param link The link to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addLink(Link link, int pos) {
+		
+		org.w3c.dom.Element links=null;
+		
+		if (m_links.size() == 0) {
+			links = getDOMElement().getOwnerDocument().
+						createElementNS(BPEL_NS, LINKS);
+			
+			if (getDOMElement().getFirstChild() == null) {
+				getDOMElement().appendChild(links);
+			} else {
+				getDOMElement().insertBefore(links,
+						getDOMElement().getFirstChild());
+			}
+		} else {
+			links = findChildElement(LINKS);
+		}
+		
+		org.w3c.dom.Node newNode=link.getDOMElement().cloneNode(true);
+		
+		getDOMElement().getOwnerDocument().adoptNode(newNode);
+		
+		link.setDOMElement((org.w3c.dom.Element)newNode);
+		
+		if (pos == -1 && pos < m_links.size()) {
+			m_links.add(link);
+			
+			links.appendChild(newNode);
+		} else {
+			
+			Link cur=m_links.get(pos);
+			
+			m_links.add(pos, link);
+			
+			if (cur != null) {
+				links.insertBefore(newNode,
+							cur.getDOMElement());
+			} else {
+				links.appendChild(newNode);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a link from the grouping
+	 * construct.
+	 * 
+	 * @param link The link to be removed
+	 * @return Whether the link was removed
+	 */
+	public boolean removeLink(Link link) {
+		boolean ret=m_links.remove(link);
+		
+		if (ret) {
+			org.w3c.dom.Element links=
+						findChildElement(LINKS);
+			
+			if (links != null) {
+				links.removeChild(link.getDOMElement());
+				
+				if (m_links.size() == 0) {
+					getDOMElement().removeChild(links);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of links associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of links
+	 */
+	public java.util.List<Link> getLinks() {
+		return(m_links);
+	}
+
+	/**
+	 * This method adds an activity to the grouping construct.
+	 * 
+	 * @param act The activity to be added
+	 * @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()) {
+			m_activities.add(act);
+			
+			setChildElement(null, act, null);
+		} else {
+			
+			BPELActivity cur=m_activities.get(pos);
+			
+			m_activities.add(pos, act);
+			
+			if (cur != null) {
+				setChildElement(null, act,
+							cur.getDOMElement());
+			} else {
+				setChildElement(null, act, 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 activities associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of activities
+	 */
+	public java.util.List<BPELActivity> getActivities() {
+		return(m_activities);
+	}
+
+	/**
+	 * 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 java.util.List<Link> m_links=
+		new java.util.Vector<Link>();
+	private java.util.List<BPELActivity> m_activities=
+		new java.util.Vector<BPELActivity>();
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -122,7 +122,7 @@
 		}
 		
 		setChildElement(findChildElement(Condition.CONDITION),
-				cond.getDOMElement(), insertBefore);
+				cond, insertBefore);
 	}
 	
 	/**
@@ -157,7 +157,7 @@
 			insertBefore = m_elsePath.getDOMElement();
 		}
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 						insertBefore);
 	}
 
@@ -185,7 +185,7 @@
 			insertBefore = m_elsePath.getDOMElement();
 		}
 		
-		setChildElement(null, act.getDOMElement(),
+		setChildElement(null, act,
 						insertBefore);
 	}
 	
@@ -212,7 +212,7 @@
 
 		m_elsePath = act;
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 						null);
 	}
 	

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Link.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Link.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Link.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -0,0 +1,84 @@
+/*
+ * 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.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.ConversionContext;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL link element, contained within
+ * the flow activity.
+ */
+public class Link extends BPELElement {
+
+	private static final long serialVersionUID = 6889776538490515074L;
+
+	private static final String NAME = "name";
+
+	public static final String LINK="link";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Link(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Link(BPELLanguageModel model) {
+		super(model, LINK);
+	}
+
+	/**
+	 * This method returns the name associated
+	 * with the link.
+	 * 
+	 * @return The link name
+	 */
+	public String getName() {
+		return(getDOMElement().getAttribute(NAME));
+	}
+	
+	/**
+	 * This method sets the link name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntil.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntil.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -94,7 +94,7 @@
 		m_condition = cond;
 		
 		setChildElement(findChildElement(Condition.CONDITION),
-				cond.getDOMElement(), null);
+				cond, null);
 	}
 	
 	/**
@@ -127,7 +127,7 @@
 			insertBefore = m_condition.getDOMElement();
 		}
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 				insertBefore);
 	}
 

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-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -43,11 +43,12 @@
 		super(model, activity);
 		
 		java.util.List<BPELElement> acts=
-					findChildElements(BPELElement.class);
+					findChildElements(BPELActivity.class);
 		
 		for (int i=0; i < acts.size(); i++) {
-			if (acts.get(i).isActivity()) {
-				m_activities.add(acts.get(i));
+			if (acts.get(i).isActivity() &&
+					acts.get(i) instanceof BPELActivity) {
+				m_activities.add((BPELActivity)acts.get(i));
 			}
 		}
 	}
@@ -62,58 +63,27 @@
 	}
 
 	/**
-	 * 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) {
-	}
-
-	/**
 	 * This method adds an activity to the grouping construct.
 	 * 
 	 * @param act The activity to be added
 	 * @param pos The position to add, or -1 if at the end
 	 */
-	public void addActivity(BPELElement act, int pos) {
-		if (pos == -1) {
+	public void addActivity(BPELActivity act, int pos) {
+		if (pos == -1 && pos < m_activities.size()) {
 			m_activities.add(act);
-			getDOMElement().appendChild(act.getDOMElement());
+			
+			setChildElement(null, act, null);
 		} else {
-			m_activities.add(pos, act);
 			
-			org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
-			org.w3c.dom.Element elem=null;
-			int cur=-1;
+			BPELActivity cur=m_activities.get(pos);
 			
-			for (int i=0; i < nl.getLength(); i++) {
-				if (nl.item(i) instanceof org.w3c.dom.Element) {
-					cur++;
-					
-					if (cur == pos) {
-						elem = (org.w3c.dom.Element)nl.item(i);
-					}
-				}
-			}
+			m_activities.add(pos, act);
 			
-			if (elem != null) {
-				getDOMElement().insertBefore(act.getDOMElement(), elem);
+			if (cur != null) {
+				setChildElement(null, act,
+							cur.getDOMElement());
 			} else {
-				getDOMElement().appendChild(act.getDOMElement());
+				setChildElement(null, act, null);
 			}
 		}
 	}
@@ -125,7 +95,7 @@
 	 * @param act The activity to be removed
 	 * @return Whether the activity was removed
 	 */
-	public boolean removeActivity(BPELElement act) {
+	public boolean removeActivity(BPELActivity act) {
 		boolean ret=m_activities.remove(act);
 		
 		if (ret) {
@@ -141,10 +111,32 @@
 	 * 
 	 * @return The list of activities
 	 */
-	public java.util.List<BPELElement> getActivities() {
+	public java.util.List<BPELActivity> getActivities() {
 		return(m_activities);
 	}
 
-	private java.util.List<BPELElement> m_activities=
-					new java.util.Vector<BPELElement>();
+	/**
+	 * 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 java.util.List<BPELActivity> m_activities=
+					new java.util.Vector<BPELActivity>();
 }

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Wait.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Wait.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Wait.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -63,7 +63,7 @@
 	 */
 	public void setUntil(Condition cond) {
 		setChildElement(findChildElement(UNTIL),
-				cond.getDOMElement(), null);
+				cond, null);
 		
 		org.w3c.dom.Element elem=findChildElement(FOR);
 		if (elem != null) {
@@ -94,7 +94,7 @@
 	 */
 	public void setFor(Condition cond) {
 		setChildElement(findChildElement(FOR),
-				cond.getDOMElement(), null);
+				cond, null);
 		
 		org.w3c.dom.Element elem=findChildElement(UNTIL);
 		if (elem != null) {

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/While.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/While.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/While.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -100,7 +100,7 @@
 		}
 
 		setChildElement(findChildElement(Condition.CONDITION),
-				cond.getDOMElement(), insertBefore);
+				cond, insertBefore);
 	}
 	
 	/**
@@ -129,7 +129,7 @@
 
 		org.w3c.dom.Element insertBefore=null;
 		
-		setChildElement(existingElem, act.getDOMElement(),
+		setChildElement(existingElem, act,
 						insertBefore);
 	}
 

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementTest.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementTest.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -166,8 +166,10 @@
 			fail("Child element not expected");
 		}
 		
-		top.setChildElement(null, newElem, null);
+		TestBPELElement telem=new TestBPELElement(model, newElem);
 		
+		top.setChildElement(null, telem, null);
+		
 		if (top.getDOMElement().getChildNodes().getLength() != 1) {
 			fail("Should only be 1 child node: "+top.getDOMElement().getChildNodes().getLength());
 		}
@@ -231,8 +233,10 @@
 			fail("Should only be 3 child node: "+top.getDOMElement().getChildNodes().getLength());
 		}
 		
-		top.setChildElement(null, newElem, top.getDOMElement().getFirstChild());
+		TestBPELElement telem=new TestBPELElement(model, newElem);
 		
+		top.setChildElement(null, telem, top.getDOMElement().getFirstChild());
+		
 		if (top.getDOMElement().getChildNodes().getLength() != 4) {
 			fail("Should only be 4 child node: "+top.getDOMElement().getChildNodes().getLength());
 		}
@@ -296,8 +300,10 @@
 			fail("Should only be 3 child node: "+top.getDOMElement().getChildNodes().getLength());
 		}
 		
-		top.setChildElement(null, newElem, null);
+		TestBPELElement telem=new TestBPELElement(model, newElem);
 		
+		top.setChildElement(null, telem, null);
+		
 		if (top.getDOMElement().getChildNodes().getLength() != 4) {
 			fail("Should only be 4 child node: "+top.getDOMElement().getChildNodes().getLength());
 		}
@@ -368,9 +374,11 @@
 			fail("First child is not an element");
 		}
 		
+		TestBPELElement telem=new TestBPELElement(model, newElem);
+		
 		top.setChildElement((org.w3c.dom.Element)
 				top.getDOMElement().getFirstChild(),
-							newElem, null);
+							telem, null);
 		
 		if (top.getDOMElement().getChildNodes().getLength() != 1) {
 			fail("Should only be 1 child node: "+top.getDOMElement().getChildNodes().getLength());

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FlowTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FlowTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FlowTest.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -0,0 +1,395 @@
+/*
+ * 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 FlowTest extends TestCase {
+
+	public void testIsActivity() {
+		Flow act=new Flow(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		String link2="link2Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<links>"+
+				"<link name=\""+link1+"\" />"+
+				"<link name=\""+link2+"\" />"+
+				"</links>"+
+		       "<if/>"+
+		       "<if/>"+
+		       "</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getLinks().size() != 2) {
+			fail("Expecting 2 child links: "+
+							component.getLinks().size());
+		}
+		
+		if (component.getLinks().get(0).getName().equals(link1) == false) {
+			fail("First link name incorrect");
+		}
+		
+		if (component.getLinks().get(1).getName().equals(link2) == false) {
+			fail("Second link name incorrect");
+		}
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+	}
+
+	public void testAddLinkToFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<if/>"+
+		       "</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);
+		
+		if (component.getLinks().size() != 0) {
+			fail("Should be no links");
+		}
+		
+		org.w3c.dom.Element links=
+				component.findChildElement(Flow.LINKS);
+		
+		if (links != null) {
+			fail("Links element should not be found");
+		}
+
+		Link l1=new Link(model);
+		l1.setName(link1);
+		
+		component.addLink(l1, -1);
+		
+		links = component.findChildElement(Flow.LINKS);
+
+		if (links == null) {
+			fail("Links element not found");
+		}
+	}
+
+	public void testRemoveLinkFromFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<links>"+
+				"<link name=\""+link1+"\" />"+
+				"</links>"+
+		       "<if/>"+
+		       "</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);
+		
+		if (component.getLinks().size() != 1) {
+			fail("Should be one link: "+component.getLinks().size());
+		}
+		
+		org.w3c.dom.Element links=
+				component.findChildElement(Flow.LINKS);
+		
+		if (links == null) {
+			fail("Links element is null");
+		}
+
+		Link l1=component.getLinks().get(0);
+		
+		component.removeLink(l1);
+		
+		links = component.findChildElement(Flow.LINKS);
+		
+		if (links != null) {
+			fail("Links element should now be null");
+		}
+	}
+
+	public void testAddFirstActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 0);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddSecondActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}
+
+	public void testAddLastActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		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");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, -1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/SequenceTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/SequenceTest.java	2009-04-04 12:13:21 UTC (rev 573)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/SequenceTest.java	2009-04-04 17:32:44 UTC (rev 574)
@@ -68,4 +68,196 @@
 							component.getActivities().size());
 		}
 	}
+
+	public void testAddFirstActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		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");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 0);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddSecondActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		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");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}
+
+	public void testAddLastActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		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");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, -1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
 }




More information about the overlord-commits mailing list