Overlord SVN: r581 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src: java/org/jboss/tools/overlord/cdl/bpel/generator and 2 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-11 17:39:18 -0400 (Sat, 11 Apr 2009)
New Revision: 581
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
Log:
Renamed 'getBPELProcess' to 'getBPELProcessElement', to allow for method returning the equivalent model object (when defined) - instead of just returning a 'sequence'.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java 2009-04-11 21:37:43 UTC (rev 580)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java 2009-04-11 21:39:18 UTC (rev 581)
@@ -62,7 +62,7 @@
BPELLanguageModel model=(BPELLanguageModel)modelObject;
try {
- String text=XMLUtils.toText(model.getBPELProcess());
+ String text=XMLUtils.toText(model.getBPELProcessElement());
context.getFormatter().record(text.getBytes());
} catch(Exception e) {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-04-11 21:37:43 UTC (rev 580)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-04-11 21:39:18 UTC (rev 581)
@@ -147,7 +147,7 @@
lcm);
generateRoleProject(projectName,
- target.getBPELProcess(),
+ target.getBPELProcessElement(),
lcm, target);
} else {
logger.error("Unable to find model generator");
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2009-04-11 21:37:43 UTC (rev 580)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2009-04-11 21:39:18 UTC (rev 581)
@@ -64,6 +64,6 @@
*
* @return The BPEL process
*/
- public org.w3c.dom.Element getBPELProcess();
+ public org.w3c.dom.Element getBPELProcessElement();
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2009-04-11 21:37:43 UTC (rev 580)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2009-04-11 21:39:18 UTC (rev 581)
@@ -162,7 +162,7 @@
*
* @return The BPEL Process
*/
- public org.w3c.dom.Element getBPELProcess() {
+ public org.w3c.dom.Element getBPELProcessElement() {
return(m_bpelProcess);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-11 21:37:43 UTC (rev 580)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-11 21:39:18 UTC (rev 581)
@@ -97,9 +97,9 @@
model.getModelName().getLocatedRole(),
target, model);
- if (target.getBPELProcess() != null) {
+ if (target.getBPELProcessElement() != null) {
try {
- String text=XMLUtils.toText(target.getBPELProcess());
+ String text=XMLUtils.toText(target.getBPELProcessElement());
checkResults(result, text);
} catch(Exception e) {
result.addError(this, e);
15 years, 2 months
Overlord SVN: r580 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-11 17:37:43 -0400 (Sat, 11 Apr 2009)
New Revision: 580
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAll.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlers.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnEvent.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLink.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandler.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAllTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlersTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlersTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnEventTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLinkTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandlerTest.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/FaultHandlers.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/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java
Log:
Finished required aspects of scope and sub-components, plus 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-10 22:48:28 UTC (rev 579)
+++ 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:37:43 UTC (rev 580)
@@ -56,7 +56,7 @@
String elemName) {
m_model = model;
- m_element = model.getBPELProcess().
+ m_element = model.getBPELProcessElement().
getOwnerDocument().createElementNS(BPEL_NS, elemName);
getSource().setObject(this);
@@ -170,9 +170,23 @@
* by the supplied class
*/
protected java.util.List<BPELElement> findChildElements(Class<? extends BPELElement> cls) {
+ return(findChildElements(getDOMElement(), cls));
+ }
+
+ /**
+ * This method returns the child elements that conform to
+ * the supplied class.
+ *
+ * @param root The root element
+ * @param cls The class
+ * @return The list of child elements of the type specified
+ * by the supplied class
+ */
+ protected java.util.List<BPELElement> findChildElements(org.w3c.dom.Element root,
+ Class<? extends BPELElement> cls) {
java.util.List<BPELElement> ret=new java.util.Vector<BPELElement>();
- org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+ org.w3c.dom.NodeList nl=root.getChildNodes();
for (int i=0; i < nl.getLength(); i++) {
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,136 @@
+/*
+ * 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 'catch' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class Catch extends BPELElement {
+
+ private static final long serialVersionUID = 8191152745680660045L;
+
+ public static final String CATCH="catch";
+
+ private static final String FAULT_NAME = "faultName";
+ private static final String FAULT_VARIABLE = "faultVariable";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Catch(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Catch(BPELLanguageModel model) {
+ super(model, CATCH);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * 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 sets the fault name.
+ *
+ * @param faultName The fault name
+ */
+ public void setFaultName(String faultName) {
+ getDOMElement().setAttribute(FAULT_NAME, faultName);
+ }
+
+ /**
+ * This method returns the fault name.
+ *
+ * @return The fault name
+ */
+ public String getFaultName() {
+ return(getDOMElement().getAttribute(FAULT_NAME));
+ }
+
+ /**
+ * This method sets the fault variable.
+ *
+ * @param faultVariable The fault variable
+ */
+ public void setFaultVariable(String faultVariable) {
+ getDOMElement().setAttribute(FAULT_VARIABLE, faultVariable);
+ }
+
+ /**
+ * This method returns the fault variable.
+ *
+ * @return The fault variable
+ */
+ public String getFaultVariable() {
+ return(getDOMElement().getAttribute(FAULT_VARIABLE));
+ }
+
+ 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/CatchAll.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAll.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAll.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,97 @@
+/*
+ * 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 'catchAll' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class CatchAll extends BPELElement {
+
+ private static final long serialVersionUID = 975038289163694699L;
+
+ public static final String CATCHALL="catchAll";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public CatchAll(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public CatchAll(BPELLanguageModel model) {
+ super(model, CATCHALL);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * 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);
+ }
+
+ 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/EventHandlers.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlers.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlers.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,218 @@
+/*
+ * 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 'eventHandlers' component within
+ * a 'scope' element.
+ *
+ * @author gary
+ */
+public class EventHandlers extends BPELElement {
+
+ private static final long serialVersionUID = 118381918664522750L;
+
+ public static final String EVENTHANDLERS = "eventHandlers";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public EventHandlers(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> onevts=
+ findChildElements(OnEvent.class);
+
+ for (int i=0; i < onevts.size(); i++) {
+ if (onevts.get(i) instanceof OnEvent) {
+ m_onEvents.add((OnEvent)onevts.get(i));
+ }
+ }
+
+ java.util.List<BPELElement> onalrms=
+ findChildElements(OnAlarm.class);
+
+ for (int i=0; i < onalrms.size(); i++) {
+ if (onalrms.get(i) instanceof OnAlarm) {
+ m_onAlarms.add((OnAlarm)onalrms.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public EventHandlers(BPELLanguageModel model) {
+ super(model, EVENTHANDLERS);
+ }
+
+ /**
+ * This method adds an 'onEvent' to the grouping construct.
+ *
+ * @param on The 'onEvent' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnEvent(OnEvent on, int pos) {
+ if (pos == -1 || pos >= m_onEvents.size()) {
+ m_onEvents.add(on);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ } else {
+
+ OnEvent cur=m_onEvents.get(pos);
+
+ m_onEvents.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onEvent' from the grouping
+ * construct.
+ *
+ * @param on The 'onEvent' to be removed
+ * @return Whether the 'onEvent' was removed
+ */
+ public boolean removeOnEvent(OnEvent on) {
+ boolean ret=m_onEvents.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onEvent' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onEvent' elements
+ */
+ public java.util.List<OnEvent> getOnEvents() {
+ return(m_onEvents);
+ }
+
+ /**
+ * This method adds an 'onAlarm' to the grouping construct.
+ *
+ * @param on The 'onAlarm' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnAlarm(OnAlarm on, int pos) {
+ if (pos == -1 || pos >= m_onAlarms.size()) {
+ m_onAlarms.add(on);
+
+ setChildElement(null, on, null);
+ } else {
+
+ OnAlarm cur=m_onAlarms.get(pos);
+
+ m_onAlarms.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, on, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onAlarm' from the grouping
+ * construct.
+ *
+ * @param on The 'onAlarm' to be removed
+ * @return Whether the 'onAlarm' was removed
+ */
+ public boolean removeOnAlarm(OnAlarm on) {
+ boolean ret=m_onAlarms.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onAlarm' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onAlarm' elements
+ */
+ public java.util.List<OnAlarm> getOnAlarms() {
+ return(m_onAlarms);
+ }
+
+ /**
+ * 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<OnEvent> m_onEvents=
+ new java.util.Vector<OnEvent>();
+ private java.util.List<OnAlarm> m_onAlarms=
+ new java.util.Vector<OnAlarm>();
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java 2009-04-10 22:48:28 UTC (rev 579)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -19,6 +19,7 @@
import java.util.List;
+import org.apache.log4j.Logger;
import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
import org.jboss.tools.overlord.cdl.bpel.model.ConversionContext;
import org.scribble.model.Activity;
@@ -42,6 +43,23 @@
public FaultHandlers(BPELLanguageModel model,
org.w3c.dom.Element activity) {
super(model, activity);
+
+ java.util.List<BPELElement> paths=
+ findChildElements(Catch.class);
+
+ for (int i=0; i < paths.size(); i++) {
+ m_catchPaths.add((Catch)paths.get(i));
+ }
+
+ paths = findChildElements(CatchAll.class);
+
+ if (paths.size() > 0) {
+ m_catchAll = (CatchAll)paths.get(0);
+
+ if (paths.size() > 1) {
+ logger.error("BPEL 'faultHandlers' has multiple 'catchAll' constructs");
+ }
+ }
}
/**
@@ -53,9 +71,69 @@
super(model, FAULTHANDLERS);
}
+ /**
+ * This method adds a 'catch' path.
+ *
+ * @param act The 'catch' path
+ */
+ public void addCatch(Catch act) {
+ m_catchPaths.add(act);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_catchAll != null) {
+ insertBefore = m_catchAll.getDOMElement();
+ }
+
+ setChildElement(null, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the list of 'catch' paths.
+ *
+ * @return The list of 'catch' paths
+ */
+ public java.util.List<Catch> getCatchPaths() {
+ return(m_catchPaths);
+ }
+
+ /**
+ * This method sets the 'catchAll' path.
+ *
+ * @param act The 'catchAll' path
+ */
+ public void setCatchAll(CatchAll act) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_catchAll != null) {
+ existingElem = m_catchAll.getDOMElement();
+ }
+
+ m_catchAll = act;
+
+ setChildElement(existingElem, act,
+ null);
+ }
+
+ /**
+ * This method returns the 'catchAll' path.
+ *
+ * @return The 'catchAll' path
+ */
+ public CatchAll getCatchAll() {
+ return(m_catchAll);
+ }
+
@Override
public void convert(List<Activity> activities, ConversionContext context) {
// TODO Auto-generated method stub
}
+
+ private static Logger logger=Logger.getLogger(FaultHandlers.class);
+
+ private CatchAll m_catchAll=null;
+ private java.util.List<Catch> m_catchPaths=
+ new java.util.Vector<Catch>();
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnEvent.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnEvent.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnEvent.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,178 @@
+/*
+ * 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 'onEvent' construct contained
+ * within the 'EventHandler' element.
+ */
+public class OnEvent extends BPELElement {
+
+ private static final long serialVersionUID = -2444989267977027500L;
+
+ private static final String PARTNER_LINK = "partnerLink";
+ private static final String PORT_TYPE = "portType";
+ private static final String OPERATION = "operation";
+ private static final String VARIABLE = "variable";
+
+ public static final String ONEVENT="onEvent";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnEvent(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ BPELElement elem=findChildActivity();
+
+ if (elem instanceof Scope) {
+ m_scope = (Scope)elem;
+ }
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnEvent(BPELLanguageModel model) {
+ super(model, ONEVENT);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param op The operation
+ */
+ public void setOperation(String op) {
+ getDOMElement().setAttribute(OPERATION, op);
+ }
+
+ /**
+ * This method returns the operation.
+ *
+ * @return The operation
+ */
+ public String getOperation() {
+ return(getDOMElement().getAttribute(OPERATION));
+ }
+
+ /**
+ * This method sets the partner link.
+ *
+ * @param pl The partner link
+ */
+ public void setPartnerLink(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK, pl);
+ }
+
+ /**
+ * This method returns the partner link.
+ *
+ * @return The partner link
+ */
+ public String getPartnerLink() {
+ return(getDOMElement().getAttribute(PARTNER_LINK));
+ }
+
+ /**
+ * This method sets the port type.
+ *
+ * @param pt The port type
+ */
+ public void setPortType(String pt) {
+ getDOMElement().setAttribute(PORT_TYPE, pt);
+ }
+
+ /**
+ * This method returns the port type.
+ *
+ * @return The port type
+ */
+ public String getPortType() {
+ return(getDOMElement().getAttribute(PORT_TYPE));
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ return(getDOMElement().getAttribute(VARIABLE));
+ }
+
+ /**
+ * This method sets the scope associated with
+ * the 'onEvent' construct.
+ *
+ * @param scope The scope
+ */
+ public void setScope(Scope scope) {
+ m_scope = scope;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, scope,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the scope associated with
+ * the 'onEvent' construct.
+ *
+ * @return The scope
+ */
+ public Scope getScope() {
+ return(m_scope);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private Scope m_scope;
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLink.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLink.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLink.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,137 @@
+/*
+ * 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 'partnerLink' construct.
+ */
+public class PartnerLink extends BPELElement {
+
+ private static final long serialVersionUID = 8342639172267763736L;
+
+ private static final String NAME = "name";
+ private static final String PARTNER_LINK_TYPE = "partnerLinkType";
+ private static final String MY_ROLE = "myRole";
+ private static final String PARTNER_ROLE = "partnerRole";
+
+ public static final String PARTNERLINK="partnerLink";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public PartnerLink(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public PartnerLink(BPELLanguageModel model) {
+ super(model, PARTNERLINK);
+ }
+
+ /**
+ * 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 partner link type.
+ *
+ * @param pl The partner link type
+ */
+ public void setPartnerLinkType(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK_TYPE, pl);
+ }
+
+ /**
+ * This method returns the partner link type.
+ *
+ * @return The partner link type
+ */
+ public String getPartnerLinkType() {
+ return(getDOMElement().getAttribute(PARTNER_LINK_TYPE));
+ }
+
+ /**
+ * This method sets my role.
+ *
+ * @param role My role
+ */
+ public void setMyRole(String role) {
+ getDOMElement().setAttribute(MY_ROLE, role);
+ }
+
+ /**
+ * This method returns my role.
+ *
+ * @return My role
+ */
+ public String getMyRole() {
+ return(getDOMElement().getAttribute(MY_ROLE));
+ }
+
+ /**
+ * This method sets partner role.
+ *
+ * @param role Partner role
+ */
+ public void setPartnerRole(String role) {
+ getDOMElement().setAttribute(PARTNER_ROLE, role);
+ }
+
+ /**
+ * This method returns partner role.
+ *
+ * @return Partner role
+ */
+ public String getPartnerRole() {
+ return(getDOMElement().getAttribute(PARTNER_ROLE));
+ }
+
+ @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/Scope.java
===================================================================
--- 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 22:48:28 UTC (rev 579)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -45,21 +45,53 @@
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");
- m_eventHandlersElem = findChildElement("eventHandlers");
- m_terminationHandlerElem = findChildElement("terminationHandler");
- org.w3c.dom.Element ch=findChildElement(CompensationHandler.COMPENSATIONHANDLER);
- if (ch != null) {
- m_compensationHandler = new CompensationHandler(model, ch);
+ 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);
}
+
+ org.w3c.dom.Element ch=findChildElement(CompensationHandler.COMPENSATIONHANDLER);
+ if (ch != null) {
+ m_compensationHandler = new CompensationHandler(model, ch);
+ }
+
+ org.w3c.dom.Element th=findChildElement(TerminationHandler.TERMINATIONHANDLER);
+ if (th != null) {
+ m_terminationHandler = new TerminationHandler(model, th);
+ }
+
+ m_activity = findChildActivity();
}
/**
@@ -126,7 +158,7 @@
}
}
- if (pos == -1 && pos < m_variables.size()) {
+ if (pos == -1 || pos >= m_variables.size()) {
m_variables.add(var);
setChildElement(m_variablesElem, null, var, null);
@@ -152,17 +184,15 @@
* @param act The activity to be removed
* @return Whether the activity was removed
*/
- /*
- public boolean removeActivity(BPELActivity act) {
- boolean ret=m_activities.remove(act);
+ public boolean removeVariable(Variable var) {
+ boolean ret=m_variables.remove(var);
if (ret) {
- getDOMElement().removeChild(act.getDOMElement());
+ m_variablesElem.removeChild(var.getDOMElement());
}
return(ret);
}
- */
/**
* This method returns the list of variables.
@@ -174,6 +204,102 @@
}
/**
+ * 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("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_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 sets the activity associated with
* the 'else' construct.
*
@@ -206,6 +332,100 @@
}
/**
+ * 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) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ 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("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ 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 sets the 'compensationHandler' path.
*
* @param elem The 'compensationHandler' path
@@ -219,8 +439,22 @@
m_compensationHandler = elem;
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
setChildElement(existingElem, elem,
- null);
+ insertBefore);
}
/**
@@ -233,6 +467,43 @@
}
/**
+ * This method sets the 'terminationHandler' path.
+ *
+ * @param elem The 'terminationHandler' path
+ */
+ public void setTerminationHandler(TerminationHandler elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_terminationHandler != null) {
+ existingElem = m_terminationHandler.getDOMElement();
+ }
+
+ m_terminationHandler = 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 'terminationHandler' path.
+ *
+ * @return The 'terminationHandler' path
+ */
+ public TerminationHandler getTerminationHandler() {
+ return(m_terminationHandler);
+ }
+
+ /**
* This method validates the BPEL activity and reports warnings or
* errors to the supplied model listener.
*
@@ -258,10 +529,11 @@
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_terminationHandlerElem=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 CompensationHandler m_compensationHandler=null;
- private FaultHandlers m_faultHandlers=null;
+ private TerminationHandler m_terminationHandler=null;
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/TerminationHandler.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandler.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandler.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,97 @@
+/*
+ * 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 'terminationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class TerminationHandler extends BPELElement {
+
+ private static final long serialVersionUID = 7316551859410369824L;
+
+ public static final String TERMINATIONHANDLER="terminationHandler";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public TerminationHandler(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public TerminationHandler(BPELLanguageModel model) {
+ super(model, TERMINATIONHANDLER);
+ }
+
+ /**
+ * 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);
+ }
+
+ @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/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAllTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAllTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchAllTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,74 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Else;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CatchAllTest extends TestCase {
+
+ public void testIsActivity() {
+ CatchAll act=new CatchAll(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildCatchAll() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<catchAll xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<sequence/></catchAll>";
+ 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");
+ }
+
+ CatchAll construct=new CatchAll(model, elem);
+
+ if (construct.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((construct.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CatchTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,108 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CatchTest extends TestCase {
+
+ public void testIsActivity() {
+ Catch act=new Catch(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildCatchAll() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVar";
+ String fault="testFault";
+
+ String xml="<catch xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+ "faultVariable=\""+var+"\" "+
+ "faultName=\""+fault+"\" >"+
+ "<sequence/></catch>";
+ 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");
+ }
+
+ Catch construct=new Catch(model, elem);
+
+ if (construct.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((construct.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+
+ public void testGetFaultVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVariable";
+
+ Catch component=new Catch(model);
+
+ component.setFaultVariable(var);
+
+ if (component.getFaultVariable().equals(var) == false) {
+ fail("Fault Variable not correct, expecting '"+var+"': "+
+ component.getFaultVariable());
+ }
+ }
+
+ public void testGetFaultName() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String fault="testFault";
+
+ Catch component=new Catch(model);
+
+ component.setFaultName(fault);
+
+ if (component.getFaultName().equals(fault) == false) {
+ fail("Fault name not correct, expecting '"+fault+"': "+
+ component.getFaultName());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlersTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlersTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/EventHandlersTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,216 @@
+/*
+ * 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 EventHandlersTest extends TestCase {
+
+ public void testIsActivity() {
+ EventHandlers act=new EventHandlers(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testEventHandlersFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<onEvent/>"+
+ "<onEvent/>"+
+ "<onAlarm/>"+
+ "</eventHandlers>";
+
+ 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");
+ }
+
+ EventHandlers component=new EventHandlers(model, elem);
+
+ if (component.getOnEvents().size() != 2) {
+ fail("Expecting 2 onEvent: "+
+ component.getOnEvents().size());
+ }
+
+ if (component.getOnAlarms().size() != 1) {
+ fail("Expecting 1 onAlarm: "+
+ component.getOnAlarms().size());
+ }
+ }
+
+ public void testAddOnMessageToEventHandlersInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<onAlarm/>"+
+ "<onAlarm/>"+
+ "</eventHandlers>";
+
+ 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");
+ }
+
+ EventHandlers component=new EventHandlers(model, elem);
+
+ if (component.getOnAlarms().size() != 2) {
+ fail("Expecting 2 onAlarms: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getOnEvents().size() != 0) {
+ fail("Expecting 0 onEvents: "+
+ component.getOnEvents().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ OnEvent sub=new OnEvent(model);
+
+ component.addOnEvent(sub, 0);
+
+ if (component.getOnEvents().size() != 1) {
+ fail("Expecting 1 onEvent: "+
+ component.getOnEvents().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(OnEvent.ONEVENT) == false) {
+ fail("Second element was not a 'onEvent': "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
+
+ public void testAddOnAlarmToEventHandlersInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<onEvent/>"+
+ "<onEvent/>"+
+ "</eventHandlers>";
+
+ 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");
+ }
+
+ EventHandlers component=new EventHandlers(model, elem);
+
+ if (component.getOnEvents().size() != 2) {
+ fail("Expecting 2 onEvents: "+
+ component.getOnEvents().size());
+ }
+
+ if (component.getOnAlarms().size() != 0) {
+ fail("Expecting 0 onAlarms: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ OnAlarm sub=new OnAlarm(model);
+
+ component.addOnAlarm(sub, 0);
+
+ if (component.getOnAlarms().size() != 1) {
+ fail("Expecting 1 onAlarm: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(3).
+ getLocalName().equals(OnAlarm.ONALARM) == false) {
+ fail("Second element was not a 'onAlarm': "+
+ 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/FaultHandlersTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlersTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlersTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,230 @@
+/*
+ * 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 FaultHandlersTest extends TestCase {
+
+ public void testIsActivity() {
+ FaultHandlers act=new FaultHandlers(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testFaultHandlersCatchFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<catch/>"+
+ "<catch/>"+
+ "</faultHandlers>";
+
+ 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");
+ }
+
+ FaultHandlers component=new FaultHandlers(model, elem);
+
+ if (component.getCatchAll() != null) {
+ fail("CatchAll path should be null");
+ }
+
+ if (component.getCatchPaths().size() != 2) {
+ fail("Should have 2 catch paths: "+component.getCatchPaths().size());
+ }
+ }
+
+ public void testFaultHandlersCatchAllFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<catchAll/>"+
+ "</faultHandlers>";
+
+ 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");
+ }
+
+ FaultHandlers component=new FaultHandlers(model, elem);
+
+ if (component.getCatchAll() == null) {
+ fail("CatchAll path should NOT be null");
+ }
+
+ if (component.getCatchPaths().size() != 0) {
+ fail("Should have 0 catch paths: "+component.getCatchPaths().size());
+ }
+ }
+
+ public void testAddCatch() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "</faultHandlers>";
+
+ 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");
+ }
+
+ FaultHandlers component=new FaultHandlers(model, ifelem);
+
+ if (component.getCatchPaths().size() != 0) {
+ fail("Should be no catch paths");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 0) {
+ fail("Zero child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+ Catch elem=new Catch(model);
+ elem.setActivity(seq);
+
+ component.addCatch(elem);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 1) {
+ fail("One child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(0).
+ getLocalName().equals(Catch.CATCH) == false) {
+ fail("First element was not a catch: "+
+ component.getDOMElement().getChildNodes().item(0).
+ getLocalName());
+ }
+ }
+
+ public void testAddCatchInsertBeforeCatchAll() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<catchAll>"+
+ "<sequence/>"+
+ "</catchAll>"+
+ "</faultHandlers>";
+
+ 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");
+ }
+
+ FaultHandlers component=new FaultHandlers(model, ifelem);
+
+ if (component.getCatchPaths().size() != 0) {
+ fail("Should be no catch paths");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 1) {
+ fail("One child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+ Catch catchElem=new Catch(model);
+ catchElem.setActivity(seq);
+
+ component.addCatch(catchElem);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(0).
+ getLocalName().equals(Catch.CATCH) == false) {
+ fail("First element was not a catch: "+
+ component.getDOMElement().getChildNodes().item(0).
+ getLocalName());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnEventTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnEventTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnEventTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,158 @@
+/*
+ * 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 OnEventTest extends TestCase {
+
+ public void testIsActivity() {
+ OnEvent act=new OnEvent(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildEHOnEvent() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVar";
+ String op="testOp";
+ String portType="testPortType";
+ String partnerLink="testPartnerLink";
+
+ String xml="<onEvent xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+ "operation=\""+op+"\" "+
+ "partnerLink=\""+partnerLink+"\" "+
+ "portType=\""+portType+"\" "+
+ "variable=\""+var+"\" "+
+ " >"+
+ "<scope/></onEvent>";
+ 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");
+ }
+
+ OnEvent component=new OnEvent(model, elem);
+
+ if (component.getScope() == null) {
+ fail("No scope");
+ }
+
+ if (component.getVariable().equals(var) == false) {
+ fail("Variable not correct, expecting '"+var+"': "+
+ component.getVariable());
+ }
+
+ if (component.getOperation().equals(op) == false) {
+ fail("Operation not correct, expecting '"+op+"': "+
+ component.getOperation());
+ }
+
+ if (component.getPartnerLink().equals(partnerLink) == false) {
+ fail("PartnerLink not correct, expecting '"+partnerLink+"': "+
+ component.getPartnerLink());
+ }
+
+ if (component.getPortType().equals(portType) == false) {
+ fail("Port type not correct, expecting '"+portType+"': "+
+ component.getPortType());
+ }
+ }
+
+ public void testGetVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVariable";
+
+ OnEvent component=new OnEvent(model);
+
+ component.setVariable(var);
+
+ if (component.getVariable().equals(var) == false) {
+ fail("Variable not correct, expecting '"+var+"': "+
+ component.getVariable());
+ }
+ }
+
+ public void testGetOperation() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String op="testOp";
+
+ OnEvent component=new OnEvent(model);
+
+ component.setOperation(op);
+
+ if (component.getOperation().equals(op) == false) {
+ fail("Operation not correct, expecting '"+op+"': "+
+ component.getOperation());
+ }
+ }
+
+ public void testGetPortType() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String pt="testPortType";
+
+ OnEvent component=new OnEvent(model);
+
+ component.setPortType(pt);
+
+ if (component.getPortType().equals(pt) == false) {
+ fail("Port type not correct, expecting '"+pt+"': "+
+ component.getPortType());
+ }
+ }
+
+ public void testGetPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String pl="testPartnerLink";
+
+ OnEvent component=new OnEvent(model);
+
+ component.setPartnerLink(pl);
+
+ if (component.getPartnerLink().equals(pl) == false) {
+ fail("Partner link not correct, expecting '"+pl+"': "+
+ component.getPartnerLink());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLinkTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLinkTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PartnerLinkTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,153 @@
+/*
+ * 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 PartnerLinkTest extends TestCase {
+
+ public void testIsActivity() {
+ PartnerLink act=new PartnerLink(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String partnerRole="testPartnerRole";
+ String name="testName";
+ String myRole="testMyRole";
+ String partnerLinkType="testPartnerLinkType";
+
+ String xml="<partnerLink xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+ "name=\""+name+"\" "+
+ "partnerLinkType=\""+partnerLinkType+"\" "+
+ "myRole=\""+myRole+"\" "+
+ "partnerRole=\""+partnerRole+"\" "+
+ " />";
+ 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");
+ }
+
+ PartnerLink component=new PartnerLink(model, elem);
+
+ if (component.getPartnerRole().equals(partnerRole) == false) {
+ fail("PartnerRole not correct, expecting '"+partnerRole+"': "+
+ component.getPartnerRole());
+ }
+
+ if (component.getName().equals(name) == false) {
+ fail("Name not correct, expecting '"+name+"': "+
+ component.getName());
+ }
+
+ if (component.getPartnerLinkType().equals(partnerLinkType) == false) {
+ fail("PartnerLinkType not correct, expecting '"+partnerLinkType+"': "+
+ component.getPartnerLinkType());
+ }
+
+ if (component.getMyRole().equals(myRole) == false) {
+ fail("MyRole not correct, expecting '"+myRole+"': "+
+ component.getMyRole());
+ }
+ }
+
+ public void testGetName() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String name="testName";
+
+ PartnerLink component=new PartnerLink(model);
+
+ component.setName(name);
+
+ if (component.getName().equals(name) == false) {
+ fail("Name not correct, expecting '"+name+"': "+
+ component.getName());
+ }
+ }
+
+ public void testGetPartnerLinkType() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String plt="testPartnerLinkType";
+
+ PartnerLink component=new PartnerLink(model);
+
+ component.setPartnerLinkType(plt);
+
+ if (component.getPartnerLinkType().equals(plt) == false) {
+ fail("PartnerLinkType not correct, expecting '"+plt+"': "+
+ component.getPartnerLinkType());
+ }
+ }
+
+ public void testGetMyRole() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String mr="testMyRole";
+
+ PartnerLink component=new PartnerLink(model);
+
+ component.setMyRole(mr);
+
+ if (component.getMyRole().equals(mr) == false) {
+ fail("MyRole not correct, expecting '"+mr+"': "+
+ component.getMyRole());
+ }
+ }
+
+ public void testGetPartnerRole() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String pr="testPartnerRole";
+
+ PartnerLink component=new PartnerLink(model);
+
+ component.setPartnerRole(pr);
+
+ if (component.getPartnerRole().equals(pr) == false) {
+ fail("PartnerRole not correct, expecting '"+pr+"': "+
+ component.getPartnerRole());
+ }
+ }
+}
Modified: 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 2009-04-10 22:48:28 UTC (rev 579)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -36,14 +36,15 @@
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
- "<partnerLinks/>"+
- "<variable/>"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<variables><variable/></variables>"+
"<messageExchanges/>"+
"<correlationSets/>"+
"<eventHandlers/>"+
"<faultHandlers/>"+
"<compensationHandler/>"+
"<terminationHandler/>"+
+ "<sequence/>"+
"</scope>";
org.w3c.dom.Element elem=null;
@@ -67,6 +68,419 @@
fail("Failed to convert to doc");
}
- Scope component=new Scope(model, elem);
+ Scope component=new Scope(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.getCompensationHandler() == null) {
+ fail("Compensation handler not defined");
+ }
+
+ if (component.getEventHandlers() == null) {
+ fail("Event handlers not defined");
+ }
+
+ if (component.getFaultHandlers() == null) {
+ fail("Fault handlers not defined");
+ }
+
+ if (component.getTerminationHandler() == null) {
+ fail("Termination handler 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/>"+
+ "<eventHandlers/>"+
+ "<faultHandlers/>"+
+ "<compensationHandler/>"+
+ "<terminationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(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(0).getLocalName().equals("variables") == false) {
+ fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
+ item(0).getLocalName());
+ }
+ }
+
+ public void testAddPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<faultHandlers/>"+
+ "<compensationHandler/>"+
+ "<terminationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(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(1).getLocalName().equals("partnerLinks") == false) {
+ fail("Child 1 not as expected: "+component.getDOMElement().getChildNodes().
+ item(1).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>"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<compensationHandler/>"+
+ "<terminationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(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(4).getLocalName().equals("eventHandlers") == false) {
+ fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
+ item(4).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>"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<compensationHandler/>"+
+ "<terminationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(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(5).getLocalName().equals("faultHandlers") == false) {
+ fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
+ item(5).getLocalName());
+ }
+ }
+
+ public void testSetCompensationHandler() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<faultHandlers/>"+
+ "<terminationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(model, ifelem);
+
+ if (component.getCompensationHandler() != null) {
+ fail("Should be null");
+ }
+
+ CompensationHandler elem=new CompensationHandler(model);
+ component.setCompensationHandler(elem);
+
+ if (component.getCompensationHandler() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(6).getLocalName().equals("compensationHandler") == false) {
+ fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
+ item(6).getLocalName());
+ }
+ }
+
+ public void testSetTerminationHandler() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<faultHandlers/>"+
+ "<compensationHandler/>"+
+ "<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");
+ }
+
+ Scope component=new Scope(model, ifelem);
+
+ if (component.getTerminationHandler() != null) {
+ fail("Should be null");
+ }
+
+ TerminationHandler elem=new TerminationHandler(model);
+ component.setTerminationHandler(elem);
+
+ if (component.getTerminationHandler() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(7).getLocalName().equals("terminationHandler") == false) {
+ fail("Child 7 not as expected: "+component.getDOMElement().getChildNodes().
+ item(7).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>"+
+ "<variables><variable/></variables>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<faultHandlers/>"+
+ "<compensationHandler/>"+
+ "<terminationHandler/>"+
+ "</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");
+ }
+
+ Scope component=new Scope(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(8).getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Child 8 not as expected: "+component.getDOMElement().getChildNodes().
+ item(8).getLocalName());
+ }
+ }
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandlerTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandlerTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TerminationHandlerTest.java 2009-04-11 21:37:43 UTC (rev 580)
@@ -0,0 +1,74 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class TerminationHandlerTest extends TestCase {
+
+ public void testIsActivity() {
+ TerminationHandler act=
+ new TerminationHandler(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildTerminationHandler() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<terminationHandler xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<sequence/></terminationHandler>";
+ 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");
+ }
+
+ TerminationHandler construct=new TerminationHandler(model, elem);
+
+ if (construct.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((construct.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+}
15 years, 2 months
Overlord SVN: r579 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-10 18:48:28 -0400 (Fri, 10 Apr 2009)
New Revision: 579
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandler.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandlerTest.java
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/Scope.java
Log:
Modelling compensation and fault handlers as directly contained components within the scope. May also be required for some of the other components of the scope - and fault handlers still needs to be completed with tests.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandler.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandler.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandler.java 2009-04-10 22:48:28 UTC (rev 579)
@@ -0,0 +1,97 @@
+/*
+ * 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 'compensationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class CompensationHandler extends BPELElement {
+
+ private static final long serialVersionUID = -1994083560689296558L;
+
+ public static final String COMPENSATIONHANDLER="compensationHandler";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public CompensationHandler(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public CompensationHandler(BPELLanguageModel model) {
+ super(model, COMPENSATIONHANDLER);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * 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);
+ }
+
+ 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/FaultHandlers.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/FaultHandlers.java 2009-04-10 22:48:28 UTC (rev 579)
@@ -0,0 +1,61 @@
+/*
+ * 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 'faultHandlers' construct contained
+ * within the 'scope' activity.
+ */
+public class FaultHandlers extends BPELElement {
+
+ private static final long serialVersionUID = 4136137332367247503L;
+
+ public static final String FAULTHANDLERS="faultHandlers";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public FaultHandlers(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public FaultHandlers(BPELLanguageModel model) {
+ super(model, FAULTHANDLERS);
+ }
+
+ @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/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-10 21:56:57 UTC (rev 578)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java 2009-04-10 22:48:28 UTC (rev 579)
@@ -216,6 +216,11 @@
null);
}
+ /**
+ * This method returns the 'else' path.
+ *
+ * @return The 'else' path
+ */
public Else getElsePath() {
return(m_elsePath);
}
Modified: 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 2009-04-10 21:56:57 UTC (rev 578)
+++ 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 22:48:28 UTC (rev 579)
@@ -49,9 +49,17 @@
m_messageExchangesElem = findChildElement("messageExchanges");
m_correlationSetsElem = findChildElement("correlationSets");
m_eventHandlersElem = findChildElement("eventHandlers");
- m_faultHandlersElem = findChildElement("faultHandlers");
- m_compensationHandlerElem = findChildElement("compensationHandler");
m_terminationHandlerElem = findChildElement("terminationHandler");
+
+ org.w3c.dom.Element ch=findChildElement(CompensationHandler.COMPENSATIONHANDLER);
+ if (ch != null) {
+ m_compensationHandler = new CompensationHandler(model, ch);
+ }
+
+ org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+ if (fhs != null) {
+ m_faultHandlers = new FaultHandlers(model, fhs);
+ }
}
/**
@@ -198,6 +206,33 @@
}
/**
+ * This method sets the 'compensationHandler' path.
+ *
+ * @param elem The 'compensationHandler' path
+ */
+ public void setCompensationHandler(CompensationHandler elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_compensationHandler != null) {
+ existingElem = m_compensationHandler.getDOMElement();
+ }
+
+ m_compensationHandler = elem;
+
+ setChildElement(existingElem, elem,
+ null);
+ }
+
+ /**
+ * This method returns the 'compensationHandler' path.
+ *
+ * @return The 'compensationHandler' path
+ */
+ public CompensationHandler getCompensationHandler() {
+ return(m_compensationHandler);
+ }
+
+ /**
* This method validates the BPEL activity and reports warnings or
* errors to the supplied model listener.
*
@@ -224,9 +259,9 @@
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 CompensationHandler m_compensationHandler=null;
+ private FaultHandlers m_faultHandlers=null;
private BPELElement m_activity;
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandlerTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandlerTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/CompensationHandlerTest.java 2009-04-10 22:48:28 UTC (rev 579)
@@ -0,0 +1,74 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CompensationHandlerTest extends TestCase {
+
+ public void testIsActivity() {
+ CompensationHandler act=
+ new CompensationHandler(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildCompensationHandler() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<compensationHandler xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<sequence/></compensationHandler>";
+ 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");
+ }
+
+ CompensationHandler construct=new CompensationHandler(model, elem);
+
+ if (construct.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((construct.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+}
15 years, 2 months
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.
by overlord-commits@lists.jboss.org
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());
+ }
+ }
+}
15 years, 2 months
Overlord SVN: r577 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-10 13:13:57 -0400 (Fri, 10 Apr 2009)
New Revision: 577
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractCondition.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/For.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Until.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PickTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Condition.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java
Log:
Refactored conditions into an abstract class with three concrete representations - the condition used by if activity, and for/until used by onAlarm element. Finished onAlarm and pick tests.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractCondition.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractCondition.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractCondition.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -0,0 +1,126 @@
+/*
+ * 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 condition element.
+ */
+public abstract class AbstractCondition extends BPELElement {
+
+ private static final long serialVersionUID = 178873060670041144L;
+
+ private static final String EXPRESSION_LANGUAGE = "expressionLanguage";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public AbstractCondition(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elemName The condition's element name
+ */
+ public AbstractCondition(BPELLanguageModel model, String elemName) {
+ super(model, elemName);
+ }
+
+ /**
+ * This method returns the expression associated
+ * with the condition.
+ *
+ * @return The expression
+ */
+ public String getExpression() {
+ String ret=null;
+
+ getDOMElement().normalize();
+
+ if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+ org.w3c.dom.Text text=(org.w3c.dom.Text)
+ getDOMElement().getFirstChild();
+
+ ret = text.getNodeValue();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the expression.
+ *
+ * @param expr The expression
+ */
+ public void setExpression(String expr) {
+
+ getDOMElement().normalize();
+
+ if (getDOMElement().getFirstChild() == null) {
+ org.w3c.dom.Text text=
+ getDOMElement().getOwnerDocument().createTextNode(expr);
+
+ getDOMElement().appendChild(text);
+
+ } else if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+ org.w3c.dom.Text text=(org.w3c.dom.Text)
+ getDOMElement().getFirstChild();
+
+ text.setNodeValue(expr);
+ }
+ }
+
+ /**
+ * This method returns the expression language associated
+ * with the condition.
+ *
+ * @return The expression language
+ */
+ public String getExpressionLanguage() {
+ return(getDOMElement().getAttribute(EXPRESSION_LANGUAGE));
+ }
+
+ /**
+ * This method sets the expression language.
+ *
+ * @param lang The expression language
+ */
+ public void setExpressionLanguage(String lang) {
+ getDOMElement().setAttribute(EXPRESSION_LANGUAGE, lang);
+ }
+
+ @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/Condition.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Condition.java 2009-04-08 21:57:45 UTC (rev 576)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Condition.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -17,19 +17,13 @@
*/
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 condition element.
*/
-public class Condition extends BPELElement {
+public class Condition extends AbstractCondition {
- private static final String EXPRESSION_LANGUAGE = "expressionLanguage";
-
private static final long serialVersionUID = 8666349106632652777L;
public static final String CONDITION="condition";
@@ -54,74 +48,4 @@
super(model, CONDITION);
}
- /**
- * This method returns the expression associated
- * with the condition.
- *
- * @return The expression
- */
- public String getExpression() {
- String ret=null;
-
- getDOMElement().normalize();
-
- if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
- org.w3c.dom.Text text=(org.w3c.dom.Text)
- getDOMElement().getFirstChild();
-
- ret = text.getNodeValue();
- }
-
- return(ret);
- }
-
- /**
- * This method sets the expression.
- *
- * @param expr The expression
- */
- public void setExpression(String expr) {
-
- getDOMElement().normalize();
-
- if (getDOMElement().getFirstChild() == null) {
- org.w3c.dom.Text text=
- getDOMElement().getOwnerDocument().createTextNode(expr);
-
- getDOMElement().appendChild(text);
-
- } else if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
- org.w3c.dom.Text text=(org.w3c.dom.Text)
- getDOMElement().getFirstChild();
-
- text.setNodeValue(expr);
- }
- }
-
- /**
- * This method returns the expression language associated
- * with the condition.
- *
- * @return The expression language
- */
- public String getExpressionLanguage() {
- return(getDOMElement().getAttribute(EXPRESSION_LANGUAGE));
- }
-
- /**
- * This method sets the expression language.
- *
- * @param lang The expression language
- */
- public void setExpressionLanguage(String lang) {
- getDOMElement().setAttribute(EXPRESSION_LANGUAGE, lang);
- }
-
- @Override
- public void convert(List<Activity> activities, ConversionContext context) {
- // TODO Auto-generated method stub
-
- }
-
-
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/For.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/For.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/For.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+/**
+ * This class represents the BPEL 'for' element.
+ */
+public class For extends AbstractCondition {
+
+ private static final long serialVersionUID = -3123540793706121742L;
+
+ public static final String FOR="for";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public For(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public For(BPELLanguageModel model) {
+ super(model, FOR);
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java 2009-04-08 21:57:45 UTC (rev 576)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -31,9 +31,6 @@
private static final long serialVersionUID = 271323368015539L;
- public static final String FOR = "for";
- public static final String UNTIL = "until";
-
public static final String ONALARM="onAlarm";
/**
@@ -69,11 +66,17 @@
*
* @param cond The 'until' condition
*/
- public void setUntil(Condition cond) {
- setChildElement(findChildElement(UNTIL),
- cond, null);
+ public void setUntil(Until cond) {
+ org.w3c.dom.Element insertBefore=null;
- org.w3c.dom.Element elem=findChildElement(FOR);
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
+ setChildElement(findChildElement(Until.UNTIL),
+ cond, insertBefore);
+
+ org.w3c.dom.Element elem=findChildElement(For.FOR);
if (elem != null) {
getDOMElement().removeChild(elem);
}
@@ -84,12 +87,12 @@
*
* @return The 'until' condition
*/
- public Condition getUntil() {
- Condition ret=null;
+ public Until getUntil() {
+ Until ret=null;
- org.w3c.dom.Element elem=findChildElement(UNTIL);
+ org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
if (elem != null) {
- ret = new Condition(getModel(), elem);
+ ret = new Until(getModel(), elem);
}
return(ret);
@@ -100,11 +103,17 @@
*
* @param cond The 'for' condition
*/
- public void setFor(Condition cond) {
- setChildElement(findChildElement(FOR),
- cond, null);
+ public void setFor(For cond) {
+ org.w3c.dom.Element insertBefore=null;
- org.w3c.dom.Element elem=findChildElement(UNTIL);
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
+ setChildElement(findChildElement(For.FOR),
+ cond, insertBefore);
+
+ org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
if (elem != null) {
getDOMElement().removeChild(elem);
}
@@ -115,12 +124,12 @@
*
* @return The 'for' condition
*/
- public Condition getFor() {
- Condition ret=null;
+ public For getFor() {
+ For ret=null;
- org.w3c.dom.Element elem=findChildElement(FOR);
+ org.w3c.dom.Element elem=findChildElement(For.FOR);
if (elem != null) {
- ret = new Condition(getModel(), elem);
+ ret = new For(getModel(), elem);
}
return(ret);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java 2009-04-08 21:57:45 UTC (rev 576)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -77,10 +77,16 @@
* @param pos The position to add, or -1 if at the end
*/
public void addOnMessage(OnMessage on, int pos) {
- if (pos == -1 && pos < m_onMessages.size()) {
+ if (pos == -1 || pos >= m_onMessages.size()) {
m_onMessages.add(on);
- setChildElement(null, on, null);
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
} else {
OnMessage cur=m_onMessages.get(pos);
@@ -91,7 +97,13 @@
setChildElement(null, on,
cur.getDOMElement());
} else {
- setChildElement(null, on, null);
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
}
}
}
@@ -130,7 +142,7 @@
* @param pos The position to add, or -1 if at the end
*/
public void addOnAlarm(OnAlarm on, int pos) {
- if (pos == -1 && pos < m_onAlarms.size()) {
+ if (pos == -1 || pos >= m_onAlarms.size()) {
m_onAlarms.add(on);
setChildElement(null, on, null);
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Until.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Until.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Until.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+/**
+ * This class represents the BPEL 'until' element.
+ */
+public class Until extends AbstractCondition {
+
+ private static final long serialVersionUID = 5398291987513467996L;
+
+ public static final String UNTIL="until";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Until(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Until(BPELLanguageModel model) {
+ super(model, UNTIL);
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java 2009-04-08 21:57:45 UTC (rev 576)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -184,7 +184,7 @@
fail("Failed to convert to doc");
}
- Condition condition=new Condition(model, elem);
+ Until condition=new Until(model, elem);
OnAlarm component=new OnAlarm(model);
@@ -253,7 +253,7 @@
fail("Failed to convert to doc");
}
- Condition condition1=new Condition(model, elem1);
+ Until condition1=new Until(model, elem1);
OnAlarm component=new OnAlarm(model);
@@ -278,7 +278,7 @@
expr1+"' but got '"+result+"'");
}
- Condition condition2=new Condition(model, elem2);
+ Until condition2=new Until(model, elem2);
component.setUntil(condition2);
@@ -332,7 +332,7 @@
fail("Failed to convert to doc");
}
- Condition condition=new Condition(model, elem);
+ For condition=new For(model, elem);
OnAlarm component=new OnAlarm(model);
@@ -401,7 +401,7 @@
fail("Failed to convert to doc");
}
- Condition condition1=new Condition(model, elem1);
+ For condition1=new For(model, elem1);
OnAlarm component=new OnAlarm(model);
@@ -426,7 +426,7 @@
expr1+"' but got '"+result+"'");
}
- Condition condition2=new Condition(model, elem2);
+ For condition2=new For(model, elem2);
component.setFor(condition2);
@@ -493,7 +493,7 @@
fail("Failed to convert to doc");
}
- Condition condition1=new Condition(model, elem1);
+ For condition1=new For(model, elem1);
OnAlarm component=new OnAlarm(model);
@@ -518,7 +518,7 @@
expr1+"' but got '"+result+"'");
}
- Condition condition2=new Condition(model, elem2);
+ Until condition2=new Until(model, elem2);
component.setUntil(condition2);
@@ -585,7 +585,7 @@
fail("Failed to convert to doc");
}
- Condition condition1=new Condition(model, elem1);
+ Until condition1=new Until(model, elem1);
OnAlarm component=new OnAlarm(model);
@@ -610,7 +610,7 @@
expr1+"' but got '"+result+"'");
}
- Condition condition2=new Condition(model, elem2);
+ For condition2=new For(model, elem2);
component.setFor(condition2);
@@ -822,12 +822,11 @@
fail("Activity is not a sequence");
}
- Condition cond=new Condition(model);
+ For cond=new For(model);
cond.setExpression(expr1);
component.setFor(cond);
- /*
String result=component.getFor().getExpression();
if (result == null) {
@@ -840,7 +839,7 @@
}
if (component.getDOMElement().getChildNodes().item(0).
- getLocalName().equals(OnAlarm.FOR) == false) {
+ getLocalName().equals(For.FOR) == false) {
fail("First element was not a 'for': "+
component.getDOMElement().getChildNodes().item(0).
getLocalName());
@@ -852,6 +851,84 @@
component.getDOMElement().getChildNodes().item(1).
getLocalName());
}
- */
}
+
+ public void testAddUntilOnAlarm() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<sequence/>"+
+ "</onAlarm>";
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getFor() != null) {
+ fail("For condition should not be set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should not be set");
+ }
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+
+ Until cond=new Until(model);
+ cond.setExpression(expr1);
+
+ component.setUntil(cond);
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ if (component.getDOMElement().getChildNodes().item(0).
+ getLocalName().equals(Until.UNTIL) == false) {
+ fail("First element was not a 'until': "+
+ component.getDOMElement().getChildNodes().item(0).
+ getLocalName());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Second element was not a sequence: "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PickTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PickTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/PickTest.java 2009-04-10 17:13:57 UTC (rev 577)
@@ -0,0 +1,216 @@
+/*
+ * 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 PickTest extends TestCase {
+
+ public void testIsActivity() {
+ Pick act=new Pick(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == false) {
+ fail("Should be an activity");
+ }
+ }
+
+ public void testPickFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<onMessage/>"+
+ "<onMessage/>"+
+ "<onAlarm/>"+
+ "</pick>";
+
+ 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");
+ }
+
+ Pick component=new Pick(model, elem);
+
+ if (component.getOnMessages().size() != 2) {
+ fail("Expecting 2 onMessage: "+
+ component.getOnMessages().size());
+ }
+
+ if (component.getOnAlarms().size() != 1) {
+ fail("Expecting 1 onAlarm: "+
+ component.getOnAlarms().size());
+ }
+ }
+
+ public void testAddOnMessageToPickInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<onAlarm/>"+
+ "<onAlarm/>"+
+ "</pick>";
+
+ 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");
+ }
+
+ Pick component=new Pick(model, elem);
+
+ if (component.getOnAlarms().size() != 2) {
+ fail("Expecting 2 onAlarms: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getOnMessages().size() != 0) {
+ fail("Expecting 0 onMessages: "+
+ component.getOnMessages().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ OnMessage sub=new OnMessage(model);
+
+ component.addOnMessage(sub, 0);
+
+ if (component.getOnMessages().size() != 1) {
+ fail("Expecting 1 onMessage: "+
+ component.getOnMessages().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(OnMessage.ONMESSAGE) == false) {
+ fail("Second element was not a 'onMessage': "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
+
+ public void testAddOnAlarmToPickInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<onMessage/>"+
+ "<onMessage/>"+
+ "</pick>";
+
+ 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");
+ }
+
+ Pick component=new Pick(model, elem);
+
+ if (component.getOnMessages().size() != 2) {
+ fail("Expecting 2 onMessages: "+
+ component.getOnMessages().size());
+ }
+
+ if (component.getOnAlarms().size() != 0) {
+ fail("Expecting 0 onAlarms: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ OnAlarm sub=new OnAlarm(model);
+
+ component.addOnAlarm(sub, 0);
+
+ if (component.getOnAlarms().size() != 1) {
+ fail("Expecting 1 onAlarm: "+
+ component.getOnAlarms().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(3).
+ getLocalName().equals(OnAlarm.ONALARM) == false) {
+ fail("Second element was not a 'onAlarm': "+
+ component.getDOMElement().getChildNodes().item(3).
+ getLocalName());
+ }
+ }
+}
15 years, 2 months
Overlord SVN: r576 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-08 17:57:45 -0400 (Wed, 08 Apr 2009)
New Revision: 576
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.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/Pick.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessageTest.java
Log:
Added pick and some associated tests. Need to resolve issue with setting conditions - on onAlarm and also on wait.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarm.java 2009-04-08 21:57:45 UTC (rev 576)
@@ -0,0 +1,162 @@
+/*
+ * 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 'onAlarm' construct contained
+ * within the 'pick' activity.
+ */
+public class OnAlarm extends BPELElement {
+
+ private static final long serialVersionUID = 271323368015539L;
+
+ public static final String FOR = "for";
+ public static final String UNTIL = "until";
+
+ public static final String ONALARM="onAlarm";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnAlarm(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnAlarm(BPELLanguageModel model) {
+ super(model, ONALARM);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method sets the 'until' condition.
+ *
+ * @param cond The 'until' condition
+ */
+ public void setUntil(Condition cond) {
+ setChildElement(findChildElement(UNTIL),
+ cond, null);
+
+ org.w3c.dom.Element elem=findChildElement(FOR);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'until' condition.
+ *
+ * @return The 'until' condition
+ */
+ public Condition getUntil() {
+ Condition ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(UNTIL);
+ if (elem != null) {
+ ret = new Condition(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the 'for' condition.
+ *
+ * @param cond The 'for' condition
+ */
+ public void setFor(Condition cond) {
+ setChildElement(findChildElement(FOR),
+ cond, null);
+
+ org.w3c.dom.Element elem=findChildElement(UNTIL);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'for' condition.
+ *
+ * @return The 'for' condition
+ */
+ public Condition getFor() {
+ Condition ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(FOR);
+ if (elem != null) {
+ ret = new Condition(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * 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);
+ }
+
+ 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/OnMessage.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessage.java 2009-04-08 21:57:45 UTC (rev 576)
@@ -0,0 +1,174 @@
+/*
+ * 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 'onMessage' construct contained
+ * within the 'pick' activity.
+ */
+public class OnMessage extends BPELElement {
+
+ private static final long serialVersionUID = -827946684365823245L;
+
+ private static final String PARTNER_LINK = "partnerLink";
+ private static final String PORT_TYPE = "portType";
+ private static final String OPERATION = "operation";
+ private static final String VARIABLE = "variable";
+
+ public static final String ONMESSAGE="onMessage";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnMessage(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnMessage(BPELLanguageModel model) {
+ super(model, ONMESSAGE);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param op The operation
+ */
+ public void setOperation(String op) {
+ getDOMElement().setAttribute(OPERATION, op);
+ }
+
+ /**
+ * This method returns the operation.
+ *
+ * @return The operation
+ */
+ public String getOperation() {
+ return(getDOMElement().getAttribute(OPERATION));
+ }
+
+ /**
+ * This method sets the partner link.
+ *
+ * @param pl The partner link
+ */
+ public void setPartnerLink(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK, pl);
+ }
+
+ /**
+ * This method returns the partner link.
+ *
+ * @return The partner link
+ */
+ public String getPartnerLink() {
+ return(getDOMElement().getAttribute(PARTNER_LINK));
+ }
+
+ /**
+ * This method sets the port type.
+ *
+ * @param pt The port type
+ */
+ public void setPortType(String pt) {
+ getDOMElement().setAttribute(PORT_TYPE, pt);
+ }
+
+ /**
+ * This method returns the port type.
+ *
+ * @return The port type
+ */
+ public String getPortType() {
+ return(getDOMElement().getAttribute(PORT_TYPE));
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ 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.
+ *
+ * @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);
+ }
+
+ 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/Pick.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Pick.java 2009-04-08 21:57:45 UTC (rev 576)
@@ -0,0 +1,205 @@
+/*
+ * 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 pick grouping activity.
+ *
+ * @author gary
+ */
+public class Pick extends BPELActivity {
+
+ private static final long serialVersionUID = -2235972351406517577L;
+
+ public static final String PICK = "pick";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Pick(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> onmesgs=
+ findChildElements(OnMessage.class);
+
+ for (int i=0; i < onmesgs.size(); i++) {
+ if (onmesgs.get(i) instanceof OnMessage) {
+ m_onMessages.add((OnMessage)onmesgs.get(i));
+ }
+ }
+
+ java.util.List<BPELElement> onalrms=
+ findChildElements(OnAlarm.class);
+
+ for (int i=0; i < onalrms.size(); i++) {
+ if (onalrms.get(i) instanceof OnAlarm) {
+ m_onAlarms.add((OnAlarm)onalrms.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Pick(BPELLanguageModel model) {
+ super(model, PICK);
+ }
+
+ /**
+ * This method adds an 'onMessage' to the grouping construct.
+ *
+ * @param on The 'onMessage' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnMessage(OnMessage on, int pos) {
+ if (pos == -1 && pos < m_onMessages.size()) {
+ m_onMessages.add(on);
+
+ setChildElement(null, on, null);
+ } else {
+
+ OnMessage cur=m_onMessages.get(pos);
+
+ m_onMessages.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, on, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onMessage' from the grouping
+ * construct.
+ *
+ * @param on The 'onMessage' to be removed
+ * @return Whether the 'onMessage' was removed
+ */
+ public boolean removeOnMessage(OnMessage on) {
+ boolean ret=m_onMessages.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onMessage' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onMessage' elements
+ */
+ public java.util.List<OnMessage> getOnMessages() {
+ return(m_onMessages);
+ }
+
+ /**
+ * This method adds an 'onAlarm' to the grouping construct.
+ *
+ * @param on The 'onAlarm' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnAlarm(OnAlarm on, int pos) {
+ if (pos == -1 && pos < m_onAlarms.size()) {
+ m_onAlarms.add(on);
+
+ setChildElement(null, on, null);
+ } else {
+
+ OnAlarm cur=m_onAlarms.get(pos);
+
+ m_onAlarms.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, on, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onAlarm' from the grouping
+ * construct.
+ *
+ * @param on The 'onAlarm' to be removed
+ * @return Whether the 'onAlarm' was removed
+ */
+ public boolean removeOnAlarm(OnAlarm on) {
+ boolean ret=m_onAlarms.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onAlarm' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onAlarm' elements
+ */
+ public java.util.List<OnAlarm> getOnAlarms() {
+ return(m_onAlarms);
+ }
+
+ /**
+ * 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<OnMessage> m_onMessages=
+ new java.util.Vector<OnMessage>();
+ private java.util.List<OnAlarm> m_onAlarms=
+ new java.util.Vector<OnAlarm>();
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnAlarmTest.java 2009-04-08 21:57:45 UTC (rev 576)
@@ -0,0 +1,857 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class OnAlarmTest extends TestCase {
+
+ public void testIsActivity() {
+ OnAlarm act=new OnAlarm(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildOnAlarmUntil() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<until>"+expr1+"</until>"+
+ "<sequence/></onAlarm>";
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should is set");
+ }
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+
+ public void testBuildOnAlarmFor() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<for>"+expr1+"</for>"+
+ "<sequence/>"+
+ "</onAlarm>";
+
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("For condition should is set");
+ }
+
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+ }
+
+ public void testSetUntilNew() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</until>";
+
+ 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");
+ }
+
+ Condition condition=new Condition(model, elem);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setUntil(condition);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should not be set");
+ }
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+ }
+
+ public void testSetUntilReplace() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+
+ String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</until>";
+
+ String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr2+
+ "</until>";
+
+ org.w3c.dom.Element elem1=null;
+ org.w3c.dom.Element elem2=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(xml1.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem1 = doc.getDocumentElement();
+
+ is.close();
+
+ is=new java.io.ByteArrayInputStream(xml2.getBytes());
+
+ doc=builder.parse(is);
+ elem2 = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Condition condition1=new Condition(model, elem1);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setUntil(condition1);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should not be set");
+ }
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression1 is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Condition condition2=new Condition(model, elem2);
+
+ component.setUntil(condition2);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should still not be set");
+ }
+
+ result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr2) == false) {
+ fail("Expression2 is not valid: expecting '"+
+ expr2+"' but got '"+result+"'");
+ }
+ }
+
+ public void testSetForNew() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</for>";
+
+ 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");
+ }
+
+ Condition condition=new Condition(model, elem);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setFor(condition);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should not be set");
+ }
+
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+ }
+
+ public void testSetForReplace() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+
+ String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</for>";
+
+ String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr2+
+ "</for>";
+
+ org.w3c.dom.Element elem1=null;
+ org.w3c.dom.Element elem2=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(xml1.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem1 = doc.getDocumentElement();
+
+ is.close();
+
+ is=new java.io.ByteArrayInputStream(xml2.getBytes());
+
+ doc=builder.parse(is);
+ elem2 = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Condition condition1=new Condition(model, elem1);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setFor(condition1);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should not be set");
+ }
+
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression1 is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Condition condition2=new Condition(model, elem2);
+
+ component.setFor(condition2);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should still not be set");
+ }
+
+ result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr2) == false) {
+ fail("Expression2 is not valid: expecting '"+
+ expr2+"' but got '"+result+"'");
+ }
+ }
+
+ public void testSetForThenUntil() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+
+ String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</for>";
+
+ String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr2+
+ "</until>";
+
+ org.w3c.dom.Element elem1=null;
+ org.w3c.dom.Element elem2=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(xml1.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem1 = doc.getDocumentElement();
+
+ is.close();
+
+ is=new java.io.ByteArrayInputStream(xml2.getBytes());
+
+ doc=builder.parse(is);
+ elem2 = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Condition condition1=new Condition(model, elem1);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setFor(condition1);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should not be set");
+ }
+
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression1 is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Condition condition2=new Condition(model, elem2);
+
+ component.setUntil(condition2);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should still not be set");
+ }
+
+ result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr2) == false) {
+ fail("Expression2 is not valid: expecting '"+
+ expr2+"' but got '"+result+"'");
+ }
+ }
+
+ public void testSetUntilThenFor() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+
+ String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr1+
+ "</until>";
+
+ String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ expr2+
+ "</for>";
+
+ org.w3c.dom.Element elem1=null;
+ org.w3c.dom.Element elem2=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(xml1.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem1 = doc.getDocumentElement();
+
+ is.close();
+
+ is=new java.io.ByteArrayInputStream(xml2.getBytes());
+
+ doc=builder.parse(is);
+ elem2 = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Condition condition1=new Condition(model, elem1);
+
+ OnAlarm component=new OnAlarm(model);
+
+ component.setUntil(condition1);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should not be set");
+ }
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression1 is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Condition condition2=new Condition(model, elem2);
+
+ component.setFor(condition2);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should still not be set");
+ }
+
+ result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr2) == false) {
+ fail("Expression2 is not valid: expecting '"+
+ expr2+"' but got '"+result+"'");
+ }
+ }
+
+ public void testAddActivityOnAlarmUntil() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<until>"+expr1+"</until>"+
+ "</onAlarm>";
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getUntil() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getFor() != null) {
+ fail("For condition should is set");
+ }
+
+ String result=component.getUntil().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Sequence sub=new Sequence(model);
+ component.setActivity(sub);
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Second element was not a sequence: "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
+ public void testAddActivityOnAlarmFor() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<for>"+expr1+"</for>"+
+ "</onAlarm>";
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getFor() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should is set");
+ }
+
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ Sequence sub=new Sequence(model);
+ component.setActivity(sub);
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Second element was not a sequence: "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
+ public void testAddForOnAlarm() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+ "<sequence/>"+
+ "</onAlarm>";
+ 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");
+ }
+
+ OnAlarm component=new OnAlarm(model, elem);
+
+ if (component.getFor() != null) {
+ fail("For condition should not be set");
+ }
+
+ if (component.getUntil() != null) {
+ fail("Until condition should not be set");
+ }
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+
+ Condition cond=new Condition(model);
+ cond.setExpression(expr1);
+
+ component.setFor(cond);
+
+ /*
+ String result=component.getFor().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr1+"' but got '"+result+"'");
+ }
+
+ if (component.getDOMElement().getChildNodes().item(0).
+ getLocalName().equals(OnAlarm.FOR) == false) {
+ fail("First element was not a 'for': "+
+ component.getDOMElement().getChildNodes().item(0).
+ getLocalName());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Second element was not a sequence: "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ */
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessageTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessageTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/OnMessageTest.java 2009-04-08 21:57:45 UTC (rev 576)
@@ -0,0 +1,163 @@
+/*
+ * 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 org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class OnMessageTest extends TestCase {
+
+ public void testIsActivity() {
+ OnMessage act=new OnMessage(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildOnMessage() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVar";
+ String op="testOp";
+ String portType="testPortType";
+ String partnerLink="testPartnerLink";
+
+ String xml="<onMessage xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+ "operation=\""+op+"\" "+
+ "partnerLink=\""+partnerLink+"\" "+
+ "portType=\""+portType+"\" "+
+ "variable=\""+var+"\" "+
+ " >"+
+ "<sequence/></onMessage>";
+ 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");
+ }
+
+ OnMessage component=new OnMessage(model, elem);
+
+ if (component.getActivity() == null) {
+ fail("No activity");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity is not a sequence");
+ }
+
+ if (component.getVariable().equals(var) == false) {
+ fail("Variable not correct, expecting '"+var+"': "+
+ component.getVariable());
+ }
+
+ if (component.getOperation().equals(op) == false) {
+ fail("Operation not correct, expecting '"+op+"': "+
+ component.getOperation());
+ }
+
+ if (component.getPartnerLink().equals(partnerLink) == false) {
+ fail("PartnerLink not correct, expecting '"+partnerLink+"': "+
+ component.getPartnerLink());
+ }
+
+ if (component.getPortType().equals(portType) == false) {
+ fail("Port type not correct, expecting '"+portType+"': "+
+ component.getPortType());
+ }
+ }
+
+ public void testGetVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVariable";
+
+ OnMessage component=new OnMessage(model);
+
+ component.setVariable(var);
+
+ if (component.getVariable().equals(var) == false) {
+ fail("Variable not correct, expecting '"+var+"': "+
+ component.getVariable());
+ }
+ }
+
+ public void testGetOperation() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String op="testOp";
+
+ OnMessage component=new OnMessage(model);
+
+ component.setOperation(op);
+
+ if (component.getOperation().equals(op) == false) {
+ fail("Operation not correct, expecting '"+op+"': "+
+ component.getOperation());
+ }
+ }
+
+ public void testGetPortType() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String pt="testPortType";
+
+ OnMessage component=new OnMessage(model);
+
+ component.setPortType(pt);
+
+ if (component.getPortType().equals(pt) == false) {
+ fail("Port type not correct, expecting '"+pt+"': "+
+ component.getPortType());
+ }
+ }
+
+ public void testGetPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String pl="testPartnerLink";
+
+ OnMessage component=new OnMessage(model);
+
+ component.setPartnerLink(pl);
+
+ if (component.getPartnerLink().equals(pl) == false) {
+ fail("Partner link not correct, expecting '"+pl+"': "+
+ component.getPartnerLink());
+ }
+ }
+}
15 years, 2 months
Overlord SVN: r575 - cdl/trunk/runtime/jbossesb-assembly.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2009-04-07 05:47:47 -0400 (Tue, 07 Apr 2009)
New Revision: 575
Modified:
cdl/trunk/runtime/jbossesb-assembly/pom.xml
Log:
[SOAG-98] Remove the mvel library in distro, as it is already included in jbossesb.
Modified: cdl/trunk/runtime/jbossesb-assembly/pom.xml
===================================================================
--- cdl/trunk/runtime/jbossesb-assembly/pom.xml 2009-04-04 17:32:44 UTC (rev 574)
+++ cdl/trunk/runtime/jbossesb-assembly/pom.xml 2009-04-07 09:47:47 UTC (rev 575)
@@ -118,7 +118,7 @@
<exclude>org.hibernate:ejb3-persistence</exclude>
<exclude>c3p0:c3p0</exclude>
<exclude>log4j:log4j</exclude>
- <exclude>org.jboss.jbossesb:rosetta</exclude>
+ <exclude>org.jboss.jbossesb:rosetta</exclude> <exclude>org.mvel:mvel</exclude>
</excludes>
</configuration>
</plugin>
15 years, 2 months
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.
by overlord-commits@lists.jboss.org
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());
+ }
+ }
}
15 years, 2 months
Overlord SVN: r573 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-04 08:13:21 -0400 (Sat, 04 Apr 2009)
New Revision: 573
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/While.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntilTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/WhileTest.java
Log:
Update to cope with additional 'standard elements' in BPEL activities.
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-03 22:50:19 UTC (rev 572)
+++ 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)
@@ -121,8 +121,14 @@
existingElem = existing.getDOMElement();
}
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_condition != null) {
+ insertBefore = m_condition.getDOMElement();
+ }
+
setChildElement(existingElem, act.getDOMElement(),
- getDOMElement().getFirstChild());
+ insertBefore);
}
/**
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-03 22:50:19 UTC (rev 572)
+++ 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)
@@ -93,8 +93,14 @@
public void setCondition(Condition cond) {
m_condition = cond;
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
setChildElement(findChildElement(Condition.CONDITION),
- cond.getDOMElement(), getDOMElement().getFirstChild());
+ cond.getDOMElement(), insertBefore);
}
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntilTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntilTest.java 2009-04-03 22:50:19 UTC (rev 572)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/RepeatUntilTest.java 2009-04-04 12:13:21 UTC (rev 573)
@@ -89,6 +89,69 @@
}
}
+ public void testSetActivityInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<condition>"+expr1+"</condition>"+
+ "</repeatUntil>";
+
+ 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");
+ }
+
+ RepeatUntil component=new RepeatUntil(model, elem);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ if (component.getActivity() != null) {
+ fail("Activity should be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ If sub=new If(model);
+
+ component.setActivity(sub);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(If.IF) == false) {
+ fail("Second element was not an 'if': "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
public void testSetConditionNew() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/WhileTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/WhileTest.java 2009-04-03 22:50:19 UTC (rev 572)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/WhileTest.java 2009-04-04 12:13:21 UTC (rev 573)
@@ -89,6 +89,67 @@
}
}
+ public void testSetConditionInitFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<targets/>"+
+ "<sequence/>"+
+ "</while>";
+
+ 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");
+ }
+
+ While component=new While(model, elem);
+
+ if (component.getActivity() == null) {
+ fail("Activity should be set");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Condition cond=new Condition(model);
+
+ cond.setExpression(expr1);
+
+ component.setCondition(cond);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(1).
+ getLocalName().equals(Condition.CONDITION) == false) {
+ fail("Second element was not a 'condition': "+
+ component.getDOMElement().getChildNodes().item(1).
+ getLocalName());
+ }
+ }
+
public void testSetConditionNew() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
15 years, 2 months
Overlord SVN: r572 - 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.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-04-03 18:50:19 -0400 (Fri, 03 Apr 2009)
New Revision: 572
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/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java
Log:
Updated 'if' to enable condition to be added after other standard elements, but before any activity, elseif or else elements.
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-03 22:17:52 UTC (rev 571)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java 2009-04-03 22:50:19 UTC (rev 572)
@@ -111,8 +111,18 @@
public void setCondition(Condition cond) {
m_condition = cond;
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ } else if (m_elseIfPaths.size() > 0) {
+ insertBefore = m_elseIfPaths.get(0).getDOMElement();
+ } else if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
setChildElement(findChildElement(Condition.CONDITION),
- cond.getDOMElement(), getDOMElement().getFirstChild());
+ cond.getDOMElement(), insertBefore);
}
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java 2009-04-03 22:17:52 UTC (rev 571)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java 2009-04-03 22:50:19 UTC (rev 572)
@@ -489,6 +489,64 @@
}
}
+ public void testSetConditionInsertBeforeElse() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ "<sources/>"+
+ "<else>"+
+ "<sequence/>"+
+ "</else>"+
+ "</if>";
+
+ 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");
+ }
+
+ If component=new If(model, ifelem);
+
+ String expr1="Test Expression 1";
+
+ Condition cond=new Condition(model);
+ cond.setExpression(expr1);
+
+ component.setCondition(cond);
+
+ String result=component.getCondition().getExpression();
+
+ if (result == null) {
+ fail("Expression not set");
+ }
+
+ if (result.equals(expr1) == false) {
+ fail("Expression not same");
+ }
+
+ // Check position of condition
+ org.w3c.dom.NodeList nl=component.getDOMElement().getChildNodes();
+
+ if (nl.item(1).getLocalName().equals(Condition.CONDITION) == false) {
+ fail("Second child not is not condition: "+nl.item(1).getLocalName());
+ }
+ }
+
public void testSetActivityInsertBeforeElseIf() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
15 years, 2 months