Author: objectiser
Date: 2009-03-30 16:19:51 -0400 (Mon, 30 Mar 2009)
New Revision: 561
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractGroupingActivity.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractInteractionActivity.java
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/BPELElementFactory.java
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/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/Invoke.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Receive.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Reply.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/While.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/
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/ConditionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseIfTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseTest.java
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/SequenceTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TestBPELElement.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/activities/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/activities/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.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/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java
Log:
Refactoring to remove 'activity' distinction, and additional tests around the
model for if/elseif/else constructs, built from DOM and also programmatically.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF 2009-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF 2009-03-30
20:19:51 UTC (rev 561)
@@ -13,7 +13,8 @@
org.scribble.osgi,
org.eclipse.jdt.core,
org.junit,
- org.scribble.conversation.parser
+ org.scribble.conversation.parser,
+ org.apache.log4j;bundle-version="1.2.13"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor:
www.jboss.org
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java 2009-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.cdl.bpel.actions;
-import java.util.logging.Logger;
-
+import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
@@ -65,8 +64,7 @@
try {
dialog.open();
} catch(Throwable e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to open generate dialog", e);
+ logger.error("Failed to open generate dialog", e);
}
} else {
warn(CANNOT_GENERATE);
@@ -110,7 +108,7 @@
mbox.open();
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.actions");
+ private static Logger logger = Logger.getLogger(GenerateAction.class);
private ISelection m_selection=null;
private IWorkbenchPart m_targetPart=null;
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java 2009-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.cdl.bpel.dialogs;
-import java.util.logging.Logger;
-
+import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
@@ -366,10 +365,10 @@
mbox.setMessage(mesg);
mbox.open();
- logger.log(java.util.logging.Level.SEVERE, mesg, ex);
+ logger.error(mesg, ex);
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.dialogs");
+ private static Logger logger = Logger.getLogger(GenerateDialog.class);
private IFile m_file=null;
private ConversationModel m_conversationModel=null;
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java 2009-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -1,7 +1,6 @@
package org.jboss.tools.overlord.cdl.bpel.eclipse;
-import java.util.logging.Logger;
-
+import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -66,9 +65,9 @@
getDefault().getLog().log(status);
}
- logger.severe("LOG ERROR: "+mesg+
- (t == null ? "" : ": "+t));
+ logger.error("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t), t);
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.eclipse");
+ private static Logger logger = Logger.getLogger(Activator.class);
}
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-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -17,14 +17,7 @@
*/
package org.jboss.tools.overlord.cdl.bpel.generator;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
+import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.jboss.tools.overlord.cdl.bpel.generator.BuildSystem;
import org.jboss.tools.overlord.cdl.bpel.model.*;
@@ -92,7 +85,7 @@
}
if (m_conversationModel == null) {
- logger.severe("Unable to load model used to generate " +
+ logger.error("Unable to load model used to generate " +
"the ESB artefacts");
}
}
@@ -117,8 +110,8 @@
public void generateRole(Role role, String projectName)
throws Exception {
- if (logger.isLoggable(Level.FINEST)) {
- logger.finest("Generate role '"+role+"' for: "+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Generate role '"+role+"' for: "+
m_conversationModel);
}
@@ -157,7 +150,7 @@
target.getBPELProcess(),
lcm, target);
} else {
- logger.severe("Unable to find model generator");
+ logger.error("Unable to find model generator");
}
}
}
@@ -208,7 +201,7 @@
return(m_buildSystem);
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.generator");
+ private static Logger logger = Logger.getLogger(Generator.class);
private IFile m_file=null;
private java.util.List<Role> m_roles=null;
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-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -17,7 +17,7 @@
*/
package org.jboss.tools.overlord.cdl.bpel.model;
-import org.jboss.tools.overlord.cdl.bpel.model.activities.SequenceActivity;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
import org.scribble.model.*;
import org.scribble.model.admin.ModelListener;
@@ -56,7 +56,7 @@
*
* @return The top level grouping activity
*/
- public SequenceActivity getActivity();
+ public Sequence getActivity();
/**
* This method returns the reference to the DOM
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-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -17,13 +17,9 @@
*/
package org.jboss.tools.overlord.cdl.bpel.model;
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.bpel.model.activities.SequenceActivity;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryFactory;
+import org.apache.log4j.Logger;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
import org.scribble.model.*;
-import org.scribble.model.admin.DependencyType;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
import org.scribble.model.resolutions.*;
@@ -36,6 +32,7 @@
public class DefaultBPELLanguageModel extends org.scribble.lang.model.LanguageModel
implements BPELLanguageModel {
+ private static final long serialVersionUID = 7625564863751533521L;
public static final String BPEL_NOTATION = "bpel";
@@ -82,7 +79,7 @@
m_bpelProcess = doc.createElement("process");
} catch(Exception e) {
- logger.severe("Failed to create initial BPEL document: "+e);
+ logger.error("Failed to create initial BPEL document: "+e, e);
}
}
@@ -141,7 +138,7 @@
*
* @return The top level grouping activity
*/
- public SequenceActivity getActivity() {
+ public Sequence getActivity() {
return(m_activity);
}
@@ -150,7 +147,7 @@
*
* @param act The top level activity
*/
- public void setActivity(SequenceActivity act) {
+ public void setActivity(Sequence act) {
m_activity = act;
m_bpelProcess.appendChild(act.getDOMElement());
@@ -166,12 +163,12 @@
return(m_bpelProcess);
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.model");
+ private static Logger logger = Logger.getLogger(DefaultBPELLanguageModel.class);
private ModelReference m_source=null;
private org.w3c.dom.Element m_bpelProcess=null;
private String m_contents=null;
- private SequenceActivity m_activity=null;
+ private Sequence m_activity=null;
public class InnerModelListener implements ModelListener {
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractGroupingActivity.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractGroupingActivity.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractGroupingActivity.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,83 @@
+/*
+ * 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.apache.log4j.Logger;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This is the generic BPEL activity class.
+ *
+ * @author gary
+ */
+public abstract class AbstractGroupingActivity extends BPELElement {
+
+ private static final long serialVersionUID = -5550042312010190598L;
+
+ /**
+ * The constructor for initializing the activity based on
+ * an existing DOM element.
+ */
+ protected AbstractGroupingActivity(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The contructor for initializing a new activity.
+ */
+ protected AbstractGroupingActivity(BPELLanguageModel model,
+ String activityName) {
+ super(model, activityName);
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ @Override
+ public boolean isActivity() {
+ return(true);
+ }
+
+ /**
+ * This method sets the contained activity.
+ *
+ * @param act The contained activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ getDOMElement().appendChild(act.getDOMElement());
+ }
+
+ /**
+ * This method returns the contained activity.
+ *
+ * @return The contained activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ private static Logger logger = Logger.getLogger(AbstractGroupingActivity.class);
+
+ private BPELElement m_activity=null;
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractInteractionActivity.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractInteractionActivity.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/AbstractInteractionActivity.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,93 @@
+/*
+ * 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.conversation.model.ConversationInteraction;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents an abstract interaction activity.
+ *
+ * @author gary
+ */
+public abstract class AbstractInteractionActivity extends BPELElement {
+
+ private static final long serialVersionUID = -5048477859609625462L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public AbstractInteractionActivity(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param interaction The conversation
+ */
+ public AbstractInteractionActivity(BPELLanguageModel model,
+ String name, ConversationInteraction interaction) {
+ super(model, name);
+
+ initialize(interaction);
+ }
+
+ /**
+ * This method initializes the invoke interaction.
+ *
+ * @param interaction The invoke interaction
+ */
+ protected void initialize(ConversationInteraction interaction) {
+
+ getDOMElement().setAttribute("operation",
+ interaction.getMessageSignature().getOperation());
+
+ // TODO: Record variables against relevant interaction
+ // based activity - probably only mechanism for
+ // establishing message type
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ @Override
+ public boolean isActivity() {
+ return(true);
+ }
+
+ /**
+ * 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) {
+ }
+
+}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElement.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,220 @@
+/*
+ * 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.apache.log4j.Logger;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This is the generic BPEL element class.
+ *
+ * @author gary
+ */
+public abstract class BPELElement extends ModelObject {
+
+ public static final String BPEL_NS =
"http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+
+ private static final long serialVersionUID = -7306844554703224704L;
+
+ /**
+ * The constructor for initializing the BPEL element based on
+ * an existing DOM element.
+ */
+ protected BPELElement(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ m_model = model;
+
+ m_element = elem;
+
+ // TODO: Set the start/end position information
+ // in the source details
+
+ getSource().setObject(this);
+ }
+
+ /**
+ * The contructor for initializing a new element.
+ */
+ protected BPELElement(BPELLanguageModel model,
+ String elemName) {
+ m_model = model;
+
+ m_element = model.getBPELProcess().
+ getOwnerDocument().createElementNS(BPEL_NS, elemName);
+
+ getSource().setObject(this);
+ }
+
+ /**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method returns the XML configuration representation
+ * of the activity.
+ *
+ * @return The XML configuration for the BPEL node
+ */
+ public org.w3c.dom.Element getDOMElement() {
+ return(m_element);
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ public boolean isActivity() {
+ return(false);
+ }
+
+ /**
+ * This method returns the element associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @return The element, or null if not found
+ */
+ protected org.w3c.dom.Element findElement(String name) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ n.getLocalName() != null &&
+ n.getLocalName().equals(name)) {
+ ret = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the first child BPEL activity
+ * found within the DOM element.
+ *
+ * @return The child BPEL activity, or null if not found
+ */
+ protected BPELElement findChildActivity() {
+ BPELElement ret=null;
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+
+ for (int i=0; ret == null &&
+ i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ ret = BPELElementFactory.createBPELElement(m_model,
+ (org.w3c.dom.Element)nl.item(i));
+
+ if (ret != null && ret.isActivity() == false) {
+ ret = null;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the child elements that conform to
+ * the supplied class.
+ *
+ * @param cls The class
+ * @return The list of child elements of the type specified
+ * by the supplied class
+ */
+ protected java.util.List<BPELElement> findChildElements(Class<? extends
BPELElement> cls) {
+ java.util.List<BPELElement> ret=new java.util.Vector<BPELElement>();
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ BPELElement elem=BPELElementFactory.createBPELElement(m_model,
+ (org.w3c.dom.Element)nl.item(i));
+
+ if (elem != null &&
+ cls.isAssignableFrom(elem.getClass())) {
+ ret.add(elem);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * 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.
+ *
+ * @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 existing,
+ org.w3c.dom.Element newelem, org.w3c.dom.Node insertBefore) {
+
+ if (newelem != null) {
+ org.w3c.dom.Node newNode=newelem.cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ if (existing != null) {
+ getDOMElement().replaceChild(newNode, existing);
+ } else if (insertBefore != null) {
+ getDOMElement().insertBefore(newNode, insertBefore);
+ } else {
+ getDOMElement().appendChild(newNode);
+ }
+ }
+ }
+
+ /**
+ * 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 abstract void convert(java.util.List<Activity> activities,
+ ConversionContext context);
+
+ private static Logger logger = Logger.getLogger(BPELElement.class);
+
+ private BPELLanguageModel m_model=null;
+ private org.w3c.dom.Element m_element=null;
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementFactory.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementFactory.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementFactory.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,68 @@
+/*
+ * 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.apache.log4j.Logger;
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+
+public class BPELElementFactory {
+
+ public static final String MODEL_COMPONENTS_PACKAGE =
+ "org.jboss.tools.overlord.cdl.bpel.model.component";
+
+ /**
+ * This method creates a BPELElement instance relevant to the
+ * supplied JBossESB action, associated with the supplied
+ * service.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration of the BPEL activity
+ * @return The BPEL element instance
+ */
+ public static BPELElement createBPELElement(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ BPELElement ret=null;
+ String activityType=elem.getNodeName();
+
+ // Make first character capitalised
+ char ch=Character.toUpperCase(activityType.charAt(0));
+
+ activityType = ch+activityType.substring(1);
+
+ String clsName=MODEL_COMPONENTS_PACKAGE+"."+activityType;
+
+ try {
+ Class<?> cls=(Class<?>)
+ Class.forName(clsName);
+
+ java.lang.reflect.Constructor<?> con=
+ cls.getConstructor(new Class<?>[]{BPELLanguageModel.class,
+ org.w3c.dom.Element.class});
+
+ ret = (BPELElement)con.newInstance(new Object[]{model, elem});
+
+ } catch(Exception e) {
+ logger.error("Unable to find BPEL element class '"+
+ clsName+"'", e);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger(BPELElementFactory.class);
+}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Condition.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,106 @@
+/*
+ * 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 class Condition extends BPELElement {
+
+ private static final long serialVersionUID = 8666349106632652777L;
+
+ public static final String CONDITION="condition";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Condition(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Condition(BPELLanguageModel model) {
+ 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);
+ }
+ }
+
+ @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/Else.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Else.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Else.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -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 'else' construct contained
+ * within the 'if' activity.
+ */
+public class Else extends BPELElement {
+
+ private static final long serialVersionUID = 1243775332210724718L;
+
+ public static final String ELSE="else";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Else(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Else(BPELLanguageModel model) {
+ super(model, ELSE);
+ }
+
+ @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.getDOMElement(),
+ 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/Elseif.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Elseif.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -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 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 'elseif' construct contained
+ * within the 'if' activity.
+ */
+public class Elseif extends BPELElement {
+
+ private static final long serialVersionUID = 6371029130621912170L;
+
+ public static final String ELSEIF="elseif";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Elseif(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element cond=
+ findElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Elseif(BPELLanguageModel model) {
+ super(model, ELSEIF);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ setChildElement(findElement(Condition.CONDITION),
+ cond.getDOMElement(), getDOMElement().getFirstChild());
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * 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.getDOMElement(),
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ private Condition m_condition;
+ 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/If.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/If.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,231 @@
+/*
+ * 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.apache.log4j.Logger;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents an 'if' grouping construct.
+ *
+ * @author gary
+ */
+public class If extends BPELElement {
+
+ private static final long serialVersionUID = -763221632866464831L;
+
+ public static final String IF = "if";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public If(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element cond=
+ findElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+
+ m_activity = findChildActivity();
+
+ java.util.List<BPELElement> paths=
+ findChildElements(Elseif.class);
+
+ for (int i=0; i < paths.size(); i++) {
+ m_elseIfPaths.add((Elseif)paths.get(i));
+ }
+
+ paths = findChildElements(Else.class);
+
+ if (paths.size() > 0) {
+ m_elsePath = (Else)paths.get(0);
+
+ if (paths.size() > 1) {
+ logger.error("BPEL 'if' has multiple 'else' constructs");
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public If(BPELLanguageModel model) {
+ super(model, IF);
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ @Override
+ public boolean isActivity() {
+ return(true);
+ }
+
+ /**
+ * 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 sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ setChildElement(findElement(Condition.CONDITION),
+ cond.getDOMElement(), getDOMElement().getFirstChild());
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * This method sets the main 'if' activity.
+ *
+ * @param act The activity associated with the 'if'
+ */
+ 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;
+
+ if (m_elseIfPaths.size() > 0) {
+ insertBefore = m_elseIfPaths.get(0).getDOMElement();
+ } else if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
+ setChildElement(existingElem, act.getDOMElement(),
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'if' path.
+ *
+ * @return The 'if' activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method adds an 'else if' path.
+ *
+ * @param act The 'else if' path
+ */
+ public void addElseIfPath(Elseif act) {
+ m_elseIfPaths.add(act);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
+ setChildElement(null, act.getDOMElement(),
+ insertBefore);
+ }
+
+ /**
+ * This method returns the list of 'else if' paths.
+ *
+ * @return The list of 'else if' paths
+ */
+ public java.util.List<Elseif> getElseIfPaths() {
+ return(m_elseIfPaths);
+ }
+
+ /**
+ * This method sets the 'else' path.
+ *
+ * @param act The 'else' path
+ */
+ public void setElsePath(Else act) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_elsePath != null) {
+ existingElem = m_elsePath.getDOMElement();
+ }
+
+ m_elsePath = act;
+
+ setChildElement(existingElem, act.getDOMElement(),
+ null);
+ }
+
+ public Else getElsePath() {
+ return(m_elsePath);
+ }
+
+ private static Logger logger=Logger.getLogger(If.class);
+
+ private Condition m_condition=null;
+ private BPELElement m_activity=null;
+ private Else m_elsePath=null;
+ private java.util.List<Elseif> m_elseIfPaths=
+ new java.util.Vector<Elseif>();
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,82 @@
+/*
+ * 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.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class Invoke extends AbstractInteractionActivity {
+
+ private static final String INVOKE = "invoke";
+ private static final long serialVersionUID = 928076947383263387L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Invoke(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param interaction The conversation
+ */
+ public Invoke(BPELLanguageModel model,
+ ConversationInteraction interaction) {
+ super(model, INVOKE, interaction);
+
+ initialize(interaction);
+ }
+
+ /**
+ * 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) {
+ }
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Receive.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Receive.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Receive.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,82 @@
+/*
+ * 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.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class Receive extends AbstractInteractionActivity {
+
+ private static final String RECEIVE = "receive";
+ private static final long serialVersionUID = -3041725198724191842L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Receive(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param interaction The conversation
+ */
+ public Receive(BPELLanguageModel model,
+ ConversationInteraction interaction) {
+ super(model, RECEIVE, interaction);
+
+ initialize(interaction);
+ }
+
+ /**
+ * 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/java/org/jboss/tools/overlord/cdl/bpel/model/component/Reply.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Reply.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Reply.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,82 @@
+/*
+ * 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.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * This class represents a BPEL reply activity.
+ *
+ * @author gary
+ */
+public class Reply extends AbstractInteractionActivity {
+
+ private static final String REPLY = "reply";
+ private static final long serialVersionUID = 8582738107125170604L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Reply(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param interaction The conversation
+ */
+ public Reply(BPELLanguageModel model,
+ ConversationInteraction interaction) {
+ super(model, REPLY, interaction);
+
+ initialize(interaction);
+ }
+
+ /**
+ * 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/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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Sequence.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,161 @@
+/*
+ * 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 sequence grouping activity.
+ *
+ * @author gary
+ */
+public class Sequence extends BPELElement {
+
+ public static final String SEQUENCE = "sequence";
+
+ private static final long serialVersionUID = 6656299352423612770L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Sequence(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> acts=
+ findChildElements(BPELElement.class);
+
+ for (int i=0; i < acts.size(); i++) {
+ if (acts.get(i).isActivity()) {
+ m_activities.add(acts.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Sequence(BPELLanguageModel model) {
+ super(model, SEQUENCE);
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ @Override
+ public boolean isActivity() {
+ return(true);
+ }
+
+ /**
+ * 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) {
+ m_activities.add(act);
+ getDOMElement().appendChild(act.getDOMElement());
+ } else {
+ m_activities.add(pos, act);
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+ org.w3c.dom.Element elem=null;
+ int cur=-1;
+
+ 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);
+ }
+ }
+ }
+
+ if (elem != null) {
+ getDOMElement().insertBefore(act.getDOMElement(), elem);
+ } else {
+ getDOMElement().appendChild(act.getDOMElement());
+ }
+ }
+ }
+
+ /**
+ * 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(BPELElement 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<BPELElement> getActivities() {
+ return(m_activities);
+ }
+
+ private java.util.List<BPELElement> m_activities=
+ new java.util.Vector<BPELElement>();
+}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/While.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,76 @@
+/*
+ * 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 while grouping activity.
+ *
+ * @author gary
+ */
+public class While extends AbstractGroupingActivity {
+
+ private static final long serialVersionUID = -4173984531470466407L;
+ private static final String WHILE = "while";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public While(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public While(BPELLanguageModel model) {
+ super(model, WHILE);
+ }
+
+ /**
+ * 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) {
+ }
+
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java 2009-03-30
19:51:42 UTC (rev 560)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -18,14 +18,13 @@
package org.jboss.tools.overlord.cdl.bpel.parser;
import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.scribble.model.*;
import org.scribble.model.admin.ModelListener;
+import org.apache.log4j.Logger;
import org.jboss.tools.overlord.cdl.bpel.model.*;
import org.scribble.extensions.*;
import org.scribble.parser.Parser;
@@ -79,12 +78,11 @@
new String(b));
} catch(Exception e) {
- logger.log(Level.SEVERE,
- "Failed to load model", e);
+ logger.error("Failed to load model", e);
}
return(ret);
}
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.parser");
+ private static Logger logger = Logger.getLogger(BPELParser.class);
}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELElementTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,389 @@
+/*
+ * 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.Condition;
+
+import junit.framework.TestCase;
+
+public class BPELElementTest extends TestCase {
+
+ public void testFindChildElements() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<elem
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<first/>"+
+ "<else/>"+
+ "<sequence/>"+
+ "<second/>"+
+ "<if/>"+
+ "</elem>";
+ 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");
+ }
+
+ TestBPELElement top=new TestBPELElement(model, elem);
+
+ java.util.List<BPELElement> elems=
+ top.findChildElements(BPELElement.class);
+
+ if (elems == null) {
+ fail("Null list");
+ }
+
+ if (elems.size() != 3) {
+ fail("Expecting three child elements: "+elems.size());
+ }
+
+ if ((elems.get(0) instanceof Else) == false) {
+ fail("Element 0 not else: "+elems.get(0));
+ }
+
+ if ((elems.get(1) instanceof Sequence) == false) {
+ fail("Element 1 not sequence: "+elems.get(1));
+ }
+
+ if ((elems.get(2) instanceof If) == false) {
+ fail("Element 2 not 'if': "+elems.get(2));
+ }
+
+ elems = top.findChildElements(Sequence.class);
+
+ if (elems == null) {
+ fail("Null sequence list");
+ }
+
+ if (elems.size() != 1) {
+ fail("Expecting one child element: "+elems.size());
+ }
+
+ if ((elems.get(0) instanceof Sequence) == false) {
+ fail("Element 0 not sequence: "+elems.get(0));
+ }
+ }
+
+ public void testFindChildActivity() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<elem
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<first/>"+
+ "<else/>"+
+ "<sequence/>"+
+ "<second/>"+
+ "<if/>"+
+ "</elem>";
+ 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");
+ }
+
+ TestBPELElement top=new TestBPELElement(model, elem);
+
+ BPELElement act=top.findChildActivity();
+
+ if (act == null) {
+ fail("Null activity");
+ }
+
+ if ((act instanceof Sequence) == false) {
+ fail("Activity not sequence");
+ }
+ }
+
+ public void testSetChildElement() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ TestBPELElement top=new TestBPELElement(model);
+
+ org.w3c.dom.Element newElem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ newElem = builder.newDocument().createElement("newelem");
+
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ if (top.getDOMElement().getFirstChild() != null) {
+ fail("Child element not expected");
+ }
+
+ top.setChildElement(null, newElem, null);
+
+ if (top.getDOMElement().getChildNodes().getLength() != 1) {
+ fail("Should only be 1 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+ equals(newElem.getNodeName()) == false) {
+ fail("Node name of new child element not correct");
+ }
+ }
+
+ public void testSetChildElementAtBeginning() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<elem>"+
+ "<first/>"+
+ "<second/>"+
+ "<third/>"+
+ "</elem>";
+
+ 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");
+ }
+
+ TestBPELElement top=new TestBPELElement(model, elem);
+
+ org.w3c.dom.Element newElem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ newElem = builder.newDocument().createElement("newelem");
+
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ if (top.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Should only be 3 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ top.setChildElement(null, newElem, top.getDOMElement().getFirstChild());
+
+ if (top.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Should only be 4 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+ equals(newElem.getNodeName()) == false) {
+ fail("Node name of new child element not correct");
+ }
+ }
+
+ public void testSetChildElementAtEnd() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<elem>"+
+ "<first/>"+
+ "<second/>"+
+ "<third/>"+
+ "</elem>";
+
+ 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");
+ }
+
+ TestBPELElement top=new TestBPELElement(model, elem);
+
+ org.w3c.dom.Element newElem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ newElem = builder.newDocument().createElement("newelem");
+
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ if (top.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Should only be 3 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ top.setChildElement(null, newElem, null);
+
+ if (top.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Should only be 4 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (top.getDOMElement().getChildNodes().item(3).getNodeName().
+ equals(newElem.getNodeName()) == false) {
+ fail("Node name of new child element not correct");
+ }
+ }
+
+ public void testSetChildElementReplace() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String first="first";
+ String second="second";
+
+ String xml="<elem>"+
+ "<newelem name=\""+first+"\" />"+
+ "</elem>";
+
+ 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");
+ }
+
+ TestBPELElement top=new TestBPELElement(model, elem);
+
+ org.w3c.dom.Element newElem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ newElem = builder.newDocument().createElement("newelem");
+ newElem.setAttribute("name", second);
+
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ if (top.getDOMElement().getFirstChild() == null) {
+ fail("First child element expected");
+ }
+
+ if ((top.getDOMElement().getFirstChild() instanceof
+ org.w3c.dom.Element) == false) {
+ fail("First child is not an element");
+ }
+
+ top.setChildElement((org.w3c.dom.Element)
+ top.getDOMElement().getFirstChild(),
+ newElem, null);
+
+ if (top.getDOMElement().getChildNodes().getLength() != 1) {
+ fail("Should only be 1 child node:
"+top.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+ equals(newElem.getNodeName()) == false) {
+ fail("Node name of new child element not correct");
+ }
+
+ if (((org.w3c.dom.Element)top.getDOMElement().getChildNodes().
+ item(0)).getAttribute("name").equals(second) == false) {
+ fail("Attribute is not as expected");
+ }
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ConditionTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ConditionTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ConditionTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,96 @@
+/*
+ * 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.Condition;
+
+import junit.framework.TestCase;
+
+public class ConditionTest extends TestCase {
+
+ public void testIsActivity() {
+ Condition act=new Condition(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testGetExpression() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+ Condition condition=new Condition(model);
+
+ String expr="Test Expression";
+
+ condition.setExpression(expr);
+
+ String result=condition.getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr+"' but got '"+result+"'");
+ }
+ }
+
+ public void testGetExpressionFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr="Test Expression";
+
+ String xml="<condition
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...;
+ 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);
+
+ String result=condition.getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr+"' but got '"+result+"'");
+ }
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseIfTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseIfTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseIfTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,91 @@
+/*
+ * 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.Elseif;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class ElseIfTest extends TestCase {
+
+ public void testIsActivity() {
+ Elseif act=new Elseif(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildElseIf() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr="Test Expression";
+
+ String xml="<elseif
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu... +
+ "<condition>"+expr+"</condition><sequence/></elseif>";
+ 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");
+ }
+
+ Elseif elseif=new Elseif(model, elem);
+
+ if (elseif.getCondition() == null) {
+ fail("No condition");
+ }
+
+ if (elseif.getActivity() == null) {
+ fail("No activity");
+ }
+
+ String result=elseif.getCondition().getExpression();
+
+ if (result == null) {
+ fail("Expression is null");
+ }
+
+ if (result.equals(expr) == false) {
+ fail("Expression is not valid: expecting '"+
+ expr+"' but got '"+result+"'");
+ }
+
+ if ((elseif.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/ElseTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ElseTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -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 ElseTest extends TestCase {
+
+ public void testIsActivity() {
+ Else act=new Else(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testBuildElse() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<else
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu... +
+ "<sequence/></else>";
+ 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");
+ }
+
+ Else construct=new Else(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/IfTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/IfTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,808 @@
+/*
+ * 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 IfTest extends TestCase {
+
+ public void testIsActivity() {
+ If act=new If(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == false) {
+ fail("Should be an activity");
+ }
+ }
+
+ public void testIfFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition>"+expr1+"</condition>"+
+ "<sequence/>"+
+ "</if>";
+
+ 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");
+ }
+
+ If component=new If(model, elem);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ String result=component.getCondition().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("Activity not set");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity not a sequence");
+ }
+
+ if (component.getElsePath() != null) {
+ fail("Else path should be null");
+ }
+
+ if (component.getElseIfPaths().size() > 0) {
+ fail("No elseif paths should be set");
+ }
+ }
+
+ public void testIfElseFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition>"+expr1+"</condition>"+
+ "<sequence/>"+
+ "<else>"+
+ "<sequence/>"+
+ "</else>"+
+ "</if>";
+
+ 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");
+ }
+
+ If component=new If(model, elem);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ String result=component.getCondition().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("Activity not set");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity not a sequence");
+ }
+
+ if (component.getElsePath() == null) {
+ fail("Else path is not set");
+ }
+
+ if ((component.getElsePath().getActivity() instanceof Sequence) == false) {
+ fail("Else path Activity not a sequence");
+ }
+
+ }
+
+ public void testIfElseIfsElseFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+ String expr3="Test Expression 3";
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition>"+expr1+"</condition>"+
+ "<sequence/>"+
+ "<elseif>"+
+ "<condition>"+expr2+"</condition>"+
+ "<sequence/>"+
+ "</elseif>"+
+ "<elseif>"+
+ "<condition>"+expr3+"</condition>"+
+ "<sequence/>"+
+ "</elseif>"+
+ "<else>"+
+ "<sequence/>"+
+ "</else>"+
+ "</if>";
+
+ 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");
+ }
+
+ If component=new If(model, elem);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ String result=component.getCondition().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("Activity not set");
+ }
+
+ if ((component.getActivity() instanceof Sequence) == false) {
+ fail("Activity not a sequence");
+ }
+
+ if (component.getElsePath() == null) {
+ fail("Else path is not set");
+ }
+
+ if ((component.getElsePath().getActivity() instanceof Sequence) == false) {
+ fail("Else path Activity not a sequence");
+ }
+
+ if (component.getElseIfPaths().size() != 2) {
+ fail("Two elseif paths expected: "+component.getElseIfPaths().size());
+ }
+
+ if (component.getElseIfPaths().get(0).getCondition() == null) {
+ fail("Elseif 0 no condition");
+ }
+
+ result=component.getElseIfPaths().get(0).getCondition().getExpression();
+
+ if (result == null) {
+ fail("Elseif 0 Expression is null");
+ }
+
+ if (result.equals(expr2) == false) {
+ fail("Elseif 0 Expression is not valid: expecting '"+
+ expr2+"' but got '"+result+"'");
+ }
+
+ if (component.getElseIfPaths().get(0).getActivity() == null) {
+ fail("Elseif 0 no activity");
+ }
+
+ if ((component.getElseIfPaths().get(0).getActivity() instanceof Sequence) == false) {
+ fail("Elseif 0 Activity not a sequence");
+ }
+
+ if (component.getElseIfPaths().get(1).getCondition() == null) {
+ fail("Elseif 1 no condition");
+ }
+
+ result=component.getElseIfPaths().get(1).getCondition().getExpression();
+
+ if (result == null) {
+ fail("Elseif 1 Expression is null");
+ }
+
+ if (result.equals(expr3) == false) {
+ fail("Elseif 1 Expression is not valid: expecting '"+
+ expr3+"' but got '"+result+"'");
+ }
+
+ if (component.getElseIfPaths().get(1).getActivity() == null) {
+ fail("Elseif 1 no activity");
+ }
+
+ if ((component.getElseIfPaths().get(1).getActivity() instanceof Sequence) == false) {
+ fail("Elseif 1 Activity not a sequence");
+ }
+ }
+
+ public void testSetConditionNew() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+
+ String xml="<condition
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ expr1+
+ "</condition>";
+
+ 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);
+
+ If component=new If(model);
+
+ component.setCondition(condition);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ String result=component.getCondition().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 testSetConditionReplace() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String expr1="Test Expression 1";
+ String expr2="Test Expression 2";
+
+ String xml1="<condition
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ expr1+
+ "</condition>";
+
+ String xml2="<condition
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ expr2+
+ "</condition>";
+
+ 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);
+
+ If component=new If(model);
+
+ component.setCondition(condition1);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ String result=component.getCondition().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.setCondition(condition2);
+
+ if (component.getCondition() == null) {
+ fail("Condition not set");
+ }
+
+ result=component.getCondition().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 testSetActivityInsertBeforeElse() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<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);
+
+ if (component.getActivity() != null) {
+ fail("Activity should be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+
+ component.setActivity(seq);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ 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 testSetActivityInsertBeforeElseIf() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<elseif>"+
+ "<condition/>"+
+ "<sequence/>"+
+ "</elseif>"+
+ "<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);
+
+ if (component.getActivity() != null) {
+ fail("Activity should be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+
+ component.setActivity(seq);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ 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 testAddElseIf() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<sequence/>"+
+ "</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);
+
+ if (component.getElseIfPaths().size() != 0) {
+ fail("Should be no elseif paths");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+ Elseif elseif=new Elseif(model);
+ elseif.setActivity(seq);
+
+ component.addElseIfPath(elseif);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).
+ getLocalName().equals(Elseif.ELSEIF) == false) {
+ fail("Third element was not an elseif: "+
+ component.getDOMElement().getChildNodes().item(2).
+ getLocalName());
+ }
+ }
+
+ public void testAddElseIfInsertBeforeElse() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<sequence/>"+
+ "<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);
+
+ if (component.getElseIfPaths().size() != 0) {
+ fail("Should be no elseif paths");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+ Elseif elseif=new Elseif(model);
+ elseif.setActivity(seq);
+
+ component.addElseIfPath(elseif);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 4) {
+ fail("Four child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).
+ getLocalName().equals(Elseif.ELSEIF) == false) {
+ fail("Third element was not an elseif: "+
+ component.getDOMElement().getChildNodes().item(2).
+ getLocalName());
+ }
+ }
+
+ public void testSetElseNew() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<sequence/>"+
+ "</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);
+
+ if (component.getElsePath() != null) {
+ fail("Should be no else path");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 2) {
+ fail("Two child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ Sequence seq=new Sequence(model);
+ Else elseElem=new Else(model);
+ elseElem.setActivity(seq);
+
+ component.setElsePath(elseElem);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).
+ getLocalName().equals(Else.ELSE) == false) {
+ fail("Third element was not an else: "+
+ component.getDOMElement().getChildNodes().item(2).
+ getLocalName());
+ }
+ }
+
+
+ public void testSetElseReplace() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<if
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<condition/>"+
+ "<sequence/>"+
+ "<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);
+
+ if (component.getElsePath() == null) {
+ fail("Should have else path");
+ }
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ If sub=new If(model);
+ Else elseElem=new Else(model);
+ elseElem.setActivity(sub);
+
+ component.setElsePath(elseElem);
+
+ if (component.getDOMElement().getChildNodes().getLength() != 3) {
+ fail("Three child elements expected: "+
+ component.getDOMElement().getChildNodes().getLength());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).
+ getLocalName().equals(Else.ELSE) == false) {
+ fail("Third element was not an else: "+
+ component.getDOMElement().getChildNodes().item(2).
+ getLocalName());
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).getFirstChild() == null) {
+ fail("Third element has no child");
+ }
+
+ if (component.getDOMElement().getChildNodes().item(2).getFirstChild().
+ getLocalName().equals(If.IF) == false) {
+ fail("Third element child was not an if: "+
+ component.getDOMElement().getChildNodes().item(2).
+ getFirstChild().getLocalName());
+ }
+ }
+}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/SequenceTest.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,71 @@
+/*
+ * 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 SequenceTest extends TestCase {
+
+ public void testIsActivity() {
+ Sequence act=new Sequence(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == false) {
+ fail("Should be an activity");
+ }
+ }
+
+ public void testSequenceFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<sequence
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<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());
+ }
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TestBPELElement.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TestBPELElement.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/TestBPELElement.java 2009-03-30
20:19:51 UTC (rev 561)
@@ -0,0 +1,45 @@
+/*
+ * 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;
+import org.w3c.dom.Element;
+
+public class TestBPELElement extends BPELElement {
+
+ private static final long serialVersionUID = 6428569513605691840L;
+
+ public TestBPELElement(BPELLanguageModel model, Element elem) {
+ super(model, elem);
+ }
+
+ public TestBPELElement(BPELLanguageModel model) {
+ super(model, "test");
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}