[overlord-commits] Overlord SVN: r567 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src: test/org/jboss/tools/overlord/cdl/bpel/model/component and 1 other directory.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Thu Apr 2 16:14:28 EDT 2009
Author: objectiser
Date: 2009-04-02 16:14:28 -0400 (Thu, 02 Apr 2009)
New Revision: 567
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Throw.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ThrowTest.java
Log:
Added throw activity and test.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Throw.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Throw.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Throw.java 2009-04-02 20:14:28 UTC (rev 567)
@@ -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 throw activity.
+ *
+ * @author gary
+ */
+public class Throw extends BPELActivity {
+
+ private static final long serialVersionUID = 9187657888490480490L;
+
+ public static final String THROW = "throw";
+
+ private static final String FAULT_NAME = "faultName";
+ private static final String FAULT_VARIABLE = "faultVariable";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Throw(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Throw(BPELLanguageModel model) {
+ super(model, THROW);
+ }
+
+ /**
+ * 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));
+ }
+
+ /**
+ * 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/ThrowTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ThrowTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ThrowTest.java 2009-04-02 20:14:28 UTC (rev 567)
@@ -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 ThrowTest extends TestCase {
+
+ public void testIsActivity() {
+ Throw act=
+ new Throw(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == false) {
+ fail("Should be an activity");
+ }
+ }
+
+ public void testBuildFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVar";
+ String fault="testFault";
+
+ String xml="<throw xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+ "faultVariable=\""+var+"\" "+
+ "faultName=\""+fault+"\" "+
+ "/>";
+
+ 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");
+ }
+
+ Throw component=new Throw(model, elem);
+
+ if (component.getFaultVariable().equals(var) == false) {
+ fail("Fault Variable not correct, expecting '"+var+"': "+
+ component.getFaultVariable());
+ }
+
+ if (component.getFaultName().equals(fault) == false) {
+ fail("Fault not correct, expecting '"+fault+"': "+
+ component.getFaultName());
+ }
+ }
+
+ public void testGetFaultVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String var="testVariable";
+
+ Throw component=new Throw(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";
+
+ Throw component=new Throw(model);
+
+ component.setFaultName(fault);
+
+ if (component.getFaultName().equals(fault) == false) {
+ fail("Fault name not correct, expecting '"+fault+"': "+
+ component.getFaultName());
+ }
+ }
+}
More information about the overlord-commits
mailing list