[overlord-commits] Overlord SVN: r582 - 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 11 18:16:04 EDT 2009
Author: objectiser
Date: 2009-04-11 18:16:03 -0400 (Sat, 11 Apr 2009)
New Revision: 582
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java
Log:
Added model component for BPELProcess and tests.
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-11 21:39:18 UTC (rev 581)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java 2009-04-11 22:16:03 UTC (rev 582)
@@ -141,19 +141,20 @@
*
* @return The child BPEL activity, or null if not found
*/
- protected BPELElement findChildActivity() {
- BPELElement ret=null;
+ protected BPELActivity findChildActivity() {
+ BPELActivity 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.createBPELElement(m_model,
+ BPELElement elem = BPELElementFactory.createBPELElement(m_model,
(org.w3c.dom.Element)nl.item(i));
- if (ret != null && ret.isActivity() == false) {
- ret = null;
+ if (elem != null && elem.isActivity() &&
+ elem instanceof BPELActivity) {
+ ret = (BPELActivity)elem;
}
}
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java 2009-04-11 22:16:03 UTC (rev 582)
@@ -0,0 +1,413 @@
+/*
+ * 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 BPEL process.
+ *
+ * @author gary
+ */
+public class BPELProcess extends BPELElement {
+
+ private static final long serialVersionUID = 3400962966628415184L;
+
+ public static final String PROCESS = "process";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public BPELProcess(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_partnerLinksElem = findChildElement("partnerLinks");
+
+ if (m_partnerLinksElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_partnerLinksElem,
+ PartnerLink.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_partnerLinks.add((PartnerLink)elems.get(i));
+ }
+ }
+
+ m_variablesElem = findChildElement("variables");
+
+ if (m_variablesElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_variablesElem,
+ Variable.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_variables.add((Variable)elems.get(i));
+ }
+ }
+
+ m_messageExchangesElem = findChildElement("messageExchanges");
+ m_correlationSetsElem = findChildElement("correlationSets");
+
+ org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
+ if (ehs != null) {
+ m_eventHandlers = new EventHandlers(model, ehs);
+ }
+
+ org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+ if (fhs != null) {
+ m_faultHandlers = new FaultHandlers(model, fhs);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public BPELProcess(BPELLanguageModel model) {
+ super(model, PROCESS);
+ }
+
+ /**
+ * This method adds a partner link to the scope.
+ *
+ * @param pl The partner link to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addPartnerLink(PartnerLink pl, int pos) {
+
+ if (m_partnerLinksElem == null) {
+ m_partnerLinksElem = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, "partnerLinks");
+
+ // Add to parent
+ org.w3c.dom.Element insertBefore=
+ findChildElement("messageExchanges");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("variables");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("correlationSets");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ BPELElement elem=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = elem.getDOMElement();
+ }
+ }
+
+ if (insertBefore != null) {
+ getDOMElement().insertBefore(m_partnerLinksElem, insertBefore);
+ } else {
+ getDOMElement().appendChild(m_partnerLinksElem);
+ }
+ }
+
+ if (pos == -1 || pos >= m_partnerLinks.size()) {
+ m_partnerLinks.add(pl);
+
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ } else {
+
+ PartnerLink cur=m_partnerLinks.get(pos);
+
+ m_partnerLinks.add(pos, pl);
+
+ if (cur != null) {
+ setChildElement(m_partnerLinksElem, null, pl,
+ cur.getDOMElement());
+ } else {
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removePartnerLink(PartnerLink pl) {
+ boolean ret=m_partnerLinks.remove(pl);
+
+ if (ret) {
+ m_partnerLinksElem.removeChild(pl.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of partner links.
+ *
+ * @return The partner links
+ */
+ public java.util.List<PartnerLink> getPartnerLinks() {
+ return(m_partnerLinks);
+ }
+
+ /**
+ * 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("correlationSets");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ 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 removeVariable(Variable var) {
+ boolean ret=m_variables.remove(var);
+
+ if (ret) {
+ m_variablesElem.removeChild(var.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(BPELActivity 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 sets the 'eventHandlers' path.
+ *
+ * @param elem The 'eventHandlers' path
+ */
+ public void setEventHandlers(EventHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_eventHandlers != null) {
+ existingElem = m_eventHandlers.getDOMElement();
+ }
+
+ m_eventHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'eventHandlers' path.
+ *
+ * @return The 'eventHandlers' path
+ */
+ public EventHandlers getEventHandlers() {
+ return(m_eventHandlers);
+ }
+
+ /**
+ * This method sets the 'faultHandlers' path.
+ *
+ * @param elem The 'faultHandlers' path
+ */
+ public void setFaultHandlers(FaultHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_faultHandlers != null) {
+ existingElem = m_faultHandlers.getDOMElement();
+ }
+
+ m_faultHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'faultHandlers' path.
+ *
+ * @return The 'faultHandlers' path
+ */
+ public FaultHandlers getFaultHandlers() {
+ return(m_faultHandlers);
+ }
+
+ /**
+ * 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_messageExchangesElem=null;
+ private org.w3c.dom.Element m_variablesElem=null;
+ private org.w3c.dom.Element m_correlationSetsElem=null;
+ private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
+ private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+ private EventHandlers m_eventHandlers=null;
+ private FaultHandlers m_faultHandlers=null;
+ private BPELActivity m_activity;
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java 2009-04-11 22:16:03 UTC (rev 582)
@@ -0,0 +1,356 @@
+/*
+ * 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 BPELProcessTest extends TestCase {
+
+ public void testIsActivity() {
+ BPELProcess act=new BPELProcess(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testProcessFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</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");
+ }
+
+ BPELProcess component=new BPELProcess(model, elem);
+
+ if (component.getPartnerLinks().size() != 1) {
+ fail("Expecting 1 partner link: "+component.getPartnerLinks().size());
+ }
+
+ if (component.getVariables().size() != 1) {
+ fail("Expecting 1 variable: "+component.getVariables().size());
+ }
+
+ if (component.getActivity() == null) {
+ fail("Activity not defined");
+ }
+
+ if (component.getEventHandlers() == null) {
+ fail("Event handlers not defined");
+ }
+
+ if (component.getFaultHandlers() == null) {
+ fail("Fault handlers not defined");
+ }
+ }
+
+ public void testAddVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=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);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ BPELProcess component=new BPELProcess(model, ifelem);
+
+ if (component.getVariables().size() != 0) {
+ fail("Should be no variables");
+ }
+
+ Variable var=new Variable(model);
+ component.addVariable(var, 0);
+
+ if (component.getVariables().size() != 1) {
+ fail("Should be one variable: "+component.getVariables().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(2).getLocalName().equals("variables") == false) {
+ fail("Child 2 not as expected: "+component.getDOMElement().getChildNodes().
+ item(2).getLocalName());
+ }
+ }
+
+ public void testAddPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</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");
+ }
+
+ BPELProcess component=new BPELProcess(model, elem);
+
+ if (component.getPartnerLinks().size() != 0) {
+ fail("Should be no partner links");
+ }
+
+ PartnerLink pl=new PartnerLink(model);
+ component.addPartnerLink(pl, 0);
+
+ if (component.getPartnerLinks().size() != 1) {
+ fail("Should be one partner link: "+component.getPartnerLinks().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(0).getLocalName().equals("partnerLinks") == false) {
+ fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
+ item(0).getLocalName());
+ }
+ }
+
+ public void testSetEventHandlers() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=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);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ BPELProcess component=new BPELProcess(model, ifelem);
+
+ if (component.getEventHandlers() != null) {
+ fail("Should be null");
+ }
+
+ EventHandlers elem=new EventHandlers(model);
+ component.setEventHandlers(elem);
+
+ if (component.getEventHandlers() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(5).getLocalName().equals("eventHandlers") == false) {
+ fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
+ item(5).getLocalName());
+ }
+ }
+
+ public void testSetFaultHandlers() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=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);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ BPELProcess component=new BPELProcess(model, ifelem);
+
+ if (component.getFaultHandlers() != null) {
+ fail("Should be null");
+ }
+
+ FaultHandlers elem=new FaultHandlers(model);
+ component.setFaultHandlers(elem);
+
+ if (component.getFaultHandlers() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(4).getLocalName().equals("faultHandlers") == false) {
+ fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
+ item(4).getLocalName());
+ }
+ }
+
+ public void testSetActivity() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=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);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ BPELProcess component=new BPELProcess(model, ifelem);
+
+ if (component.getActivity() != null) {
+ fail("Should be null");
+ }
+
+ Sequence elem=new Sequence(model);
+ component.setActivity(elem);
+
+ if (component.getActivity() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(6).getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
+ item(6).getLocalName());
+ }
+ }
+}
More information about the overlord-commits
mailing list