Overlord SVN: r104 - sam/trunk/src/main/java/org/jboss/sam.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-07-03 03:27:00 -0400 (Thu, 03 Jul 2008)
New Revision: 104
Modified:
sam/trunk/src/main/java/org/jboss/sam/EventProcessor.java
Log:
Fix signature names
Modified: sam/trunk/src/main/java/org/jboss/sam/EventProcessor.java
===================================================================
--- sam/trunk/src/main/java/org/jboss/sam/EventProcessor.java 2008-07-02 16:54:49 UTC (rev 103)
+++ sam/trunk/src/main/java/org/jboss/sam/EventProcessor.java 2008-07-03 07:27:00 UTC (rev 104)
@@ -24,7 +24,7 @@
import java.util.Iterator;
/**
- * The hub glues together {@link org.jboss.sam.StreamInput} and {@link org.jboss.sam.StreamOutput}
+ * An event processor glues together {@link org.jboss.sam.StreamInput} and {@link org.jboss.sam.StreamOutput}
* and provides a way to register {@link org.jboss.sam.Statement}'s,
* both bound (event forwarding) and unbound (event aggregation and filtering).
* <p>
@@ -62,13 +62,13 @@
* Iterate over input stream names
* @return
*/
- Iterator<String> getInputStreamNames();
+ Iterator<String> getStreamInputNames();
/**
* Iterate over output stream names
* @return
*/
- Iterator<String> getOutputStreamNames();
+ Iterator<String> getStreamOutputNames();
/**
* Creates a statement
15 years, 10 months
Overlord SVN: r103 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 12:54:49 -0400 (Wed, 02 Jul 2008)
New Revision: 103
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageActionTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java
Log:
Unit tests for validating ReceiveMessageAction - and added test for SendMessageAction.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageActionTest.java 2008-07-02 16:54:49 UTC (rev 103)
@@ -0,0 +1,79 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class ReceiveMessageActionTest extends TestCase {
+
+ public void testValidateNoMessageType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("identities", "");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"messageType"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNoIdentities() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("messageType", "");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"identities"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java 2008-07-02 15:51:41 UTC (rev 102)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java 2008-07-02 16:54:49 UTC (rev 103)
@@ -108,4 +108,43 @@
fail(l.invalidMessage());
}
}
+
+ public void testValidateResponseService() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("messageType", "");
+ props.put("identities", "");
+ props.put("serviceCategory", "cat1");
+ props.put("serviceName", "name1");
+ props.put("responseServiceCategory", "cat2");
+ props.put("responseServiceName", "name2");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ SendMessageAction action=new SendMessageAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2", "name2"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
}
15 years, 10 months
Overlord SVN: r102 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 11:51:41 -0400 (Wed, 02 Jul 2008)
New Revision: 102
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java
Log:
Unit test for validating SendMessageAction.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageActionTest.java 2008-07-02 15:51:41 UTC (rev 102)
@@ -0,0 +1,111 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class SendMessageActionTest extends TestCase {
+
+ public void testValidateNoMessageType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("identities", "");
+ props.put("serviceCategory", "");
+ props.put("serviceName", "");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ SendMessageAction action=new SendMessageAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"messageType"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNoIdentities() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("messageType", "");
+ props.put("clientEPR", "");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ SendMessageAction action=new SendMessageAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"identities"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNoDestination() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("messageType", "");
+ props.put("identities", "");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ SendMessageAction action=new SendMessageAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_NOT_SPECIFIED_REQ_RESP_EPR",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
15 years, 10 months
Overlord SVN: r101 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: test/org/jboss/tools/overlord/jbossesb/model/actions and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 11:29:45 -0400 (Wed, 02 Jul 2008)
New Revision: 101
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhileActionTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
Log:
Unit tests for validating WhileAction.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 14:49:42 UTC (rev 100)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 15:29:45 UTC (rev 101)
@@ -20,6 +20,8 @@
_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER=Cannot define MessageRouterAction with session based actions in service descriptor
_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
_MULTIPLE_JOINS=Action has multiple joins
+_MUST_DEFINE_SINGLE_WHILE_PATH=While action must have a single 'while' path
+_MUST_DEFINE_SINGLE_WHILE_EXIT=While action must have a single 'exit' path
_MUST_INITIATE_ROOT=Must 'initiate' root service descriptor for category '{0}' and name '{1}'
_NOT_FOUND_VARIABLE=Variable '{0}' could not be found on session type '{1}'
_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor that starts with a CreateSessionAction
@@ -33,3 +35,4 @@
_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
_WHEN_ONE_OR_MORE_PATHS=When action must specify atleast one entry
_WHEN_PATH_AFTER_JOIN=When path must not be defined after a join
+_WHILE_PATH_AFTER_EXIT=While path must not be defined after an exit
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-02 14:49:42 UTC (rev 100)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-02 15:29:45 UTC (rev 101)
@@ -117,6 +117,10 @@
public void validate(ModelListener l) {
super.validate(l);
+ // TODO: Valid if decision-method
+ // specified, that method exists, if expression, then
+ // validate the expression etc.
+
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
int pathCount=0;
boolean f_joined=false;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-02 14:49:42 UTC (rev 100)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-02 15:29:45 UTC (rev 101)
@@ -63,31 +63,37 @@
if (n instanceof org.w3c.dom.Element) {
if (n.getNodeName().equals(WHILE)) {
- m_loopCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- m_loopName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- m_loopService=getService().getModel().getService(m_loopCategory, m_loopName);
-
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ m_loopCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ m_loopName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ m_loopService=getService().getModel().getService(m_loopCategory, m_loopName);
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(m_loopCategory, m_loopName, m_loopService,
- (immediate != null && immediate.equalsIgnoreCase("true"))));
+ String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(m_loopCategory, m_loopName, m_loopService,
+ (immediate != null && immediate.equalsIgnoreCase("true"))));
+ }
} else if (n.getNodeName().equals(EXIT)) {
- m_exitCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- m_exitName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- m_exitService=getService().getModel().getService(m_exitCategory, m_exitName);
-
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ m_exitCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ m_exitName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ m_exitService=getService().getModel().getService(m_exitCategory, m_exitName);
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(m_exitCategory, m_exitName, m_exitService,
- (immediate != null && immediate.equalsIgnoreCase("true"))));
+ String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(m_exitCategory, m_exitName, m_exitService,
+ (immediate != null && immediate.equalsIgnoreCase("true"))));
+ }
}
}
}
@@ -144,6 +150,83 @@
// TODO: Validate that the loop service returns back to the
// while action for all paths
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ boolean f_while=false;
+ boolean f_exit=false;
+ boolean f_multipleWhiles=false;
+ boolean f_multipleExits=false;
+ boolean f_serviceDetailsMissing=false;
+ boolean f_pathAfterExit=false;
+
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(WHILE)) {
+
+ if (f_while) {
+ f_multipleWhiles = true;
+ }
+
+ if (f_exit) {
+ f_pathAfterExit = true;
+ }
+
+ f_while = true;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ } else if (n.getNodeName().equals(EXIT)) {
+
+ if (f_exit) {
+ f_multipleExits = true;
+ }
+
+ f_exit = true;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && (f_while == false || f_multipleWhiles)) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_DEFINE_SINGLE_WHILE_PATH",
+ new String[]{}), null);
+ }
+
+ if (nl != null && (f_exit == false || f_multipleExits)) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_DEFINE_SINGLE_WHILE_EXIT",
+ new String[]{}), null);
+ }
+
+ if (f_pathAfterExit) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHILE_PATH_AFTER_EXIT",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
}
/**
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhileActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhileActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhileActionTest.java 2008-07-02 15:29:45 UTC (rev 101)
@@ -0,0 +1,327 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class WhileActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ WhileAction action=new WhileAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><while service-category=\"cat1\" " +
+ "service-name=\"name1\" /><exit service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2","name2"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOneWhilePath() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><while service-category=\"cat1\" " +
+ "service-name=\"name1\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat3");
+ other2.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_DEFINE_SINGLE_WHILE_EXIT",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOneWhileExit() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><exit service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_DEFINE_SINGLE_WHILE_PATH",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails1() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><while " +
+ "service-name=\"name2\" /><exit service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails2() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><while service-category=\"cat2\" " +
+ "service-name=\"name2\" /><exit " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOutOfOrderExit() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><exit service-category=\"cat1\" " +
+ "service-name=\"name1\" /><while service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhileAction action=new WhileAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHILE_PATH_AFTER_EXIT",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
15 years, 10 months
Overlord SVN: r100 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: test/org/jboss/tools/overlord/jbossesb/model/actions and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 10:49:42 -0400 (Wed, 02 Jul 2008)
New Revision: 100
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java
Log:
Added unit test for validating WhenAction.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 14:16:46 UTC (rev 99)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 14:49:42 UTC (rev 100)
@@ -19,6 +19,7 @@
_CANNOT_INITIATE_NON_ROOT=Cannot 'initiate' non-root service descriptor for category '{0}' and name '{1}'
_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER=Cannot define MessageRouterAction with session based actions in service descriptor
_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
+_MULTIPLE_JOINS=Action has multiple joins
_MUST_INITIATE_ROOT=Must 'initiate' root service descriptor for category '{0}' and name '{1}'
_NOT_FOUND_VARIABLE=Variable '{0}' could not be found on session type '{1}'
_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor that starts with a CreateSessionAction
@@ -26,8 +27,9 @@
_NOT_SPECIFIED_REQ_RESP_EPR=Send does not contain request service category/name or response client EPR
_MUST_BE_FIRST_ACTION='{0}' action must be first in the service descriptor
_PARALLEL_MORE_THAN_TWO_PATHS=Parallel action must specify two or more paths
-_PARALLEL_MULTIPLE_JOINS=Parallel action has multiple joins
_PARALLEL_PATH_AFTER_JOIN=Parallel path must not be defined after a join
_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
_ROUTER_ONE_OR_MORE_PATHS=MessageRouter action must specify one or more routes
-_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify one or more cases
+_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
+_WHEN_ONE_OR_MORE_PATHS=When action must specify atleast one entry
+_WHEN_PATH_AFTER_JOIN=When path must not be defined after a join
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-02 14:16:46 UTC (rev 99)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-02 14:49:42 UTC (rev 100)
@@ -176,7 +176,7 @@
l.error(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
"org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_PARALLEL_MULTIPLE_JOINS",
+ "_MULTIPLE_JOINS",
new String[]{}), null);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-02 14:16:46 UTC (rev 99)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-02 14:49:42 UTC (rev 100)
@@ -62,30 +62,36 @@
if (n instanceof org.w3c.dom.Element) {
if (n.getNodeName().equals(WHEN)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- ESBService service=getService().getModel().getService(category, name);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(category, name, service, true));
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
- if (service != null) {
- m_services.add(service);
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+
+ if (service != null) {
+ m_services.add(service);
+ }
}
} else if (n.getNodeName().equals(JOIN)) {
- m_joinCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- m_joinName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- m_joinService=getService().getModel().getService(m_joinCategory, m_joinName);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(m_joinCategory, m_joinName, m_joinService, true));
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ m_joinCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ m_joinName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ m_joinService=getService().getModel().getService(m_joinCategory, m_joinName);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(m_joinCategory, m_joinName, m_joinService, true));
+ }
}
}
}
@@ -111,10 +117,72 @@
public void validate(ModelListener l) {
super.validate(l);
- // TODO: Validate only one 'when' element, if decision-method
- // specified, that method exists, if expression, then
- // validate the expression etc.
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ int pathCount=0;
+ boolean f_joined=false;
+ boolean f_pathAfterJoin=false;
+ boolean f_multipleJoins=false;
+ boolean f_serviceDetailsMissing=false;
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(WHEN)) {
+ pathCount++;
+
+ if (f_joined) {
+ f_pathAfterJoin = true;
+ }
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ } else if (n.getNodeName().equals(JOIN)) {
+
+ if (f_joined) {
+ f_multipleJoins = true;
+ }
+
+ f_joined = true;
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && pathCount < 1) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHEN_ONE_OR_MORE_PATHS",
+ new String[]{}), null);
+ }
+
+ if (f_pathAfterJoin) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHEN_PATH_AFTER_JOIN",
+ new String[]{}), null);
+ }
+
+ if (f_multipleJoins) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MULTIPLE_JOINS",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
}
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java 2008-07-02 14:16:46 UTC (rev 99)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java 2008-07-02 14:49:42 UTC (rev 100)
@@ -180,7 +180,7 @@
l.addExpectedError(org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
"org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_PARALLEL_MULTIPLE_JOINS",
+ "_MULTIPLE_JOINS",
new String[]{}));
action.validate(l);
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java 2008-07-02 14:49:42 UTC (rev 100)
@@ -0,0 +1,292 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class WhenActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ WhenAction action=new WhenAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><when service-category=\"cat1\" " +
+ "service-name=\"name1\" /><when service-category=\"cat2\" " +
+ "service-name=\"name2\" /><when service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhenAction action=new WhenAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2","name2"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat3","name3"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateLessThanOnePath() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat3");
+ other2.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhenAction action=new WhenAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHEN_ONE_OR_MORE_PATHS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><when service-category=\"cat1\" " +
+ "service-name=\"name1\" /><when " +
+ "service-name=\"name2\" /><when service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhenAction action=new WhenAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOutOfOrderJoin() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><when service-category=\"cat1\" " +
+ "service-name=\"name1\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /><when service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhenAction action=new WhenAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_WHEN_PATH_AFTER_JOIN",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOnlyOneJoin() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><when service-category=\"cat1\" " +
+ "service-name=\"name1\" /><when service-category=\"cat2\" " +
+ "service-name=\"name2\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ WhenAction action=new WhenAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MULTIPLE_JOINS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
15 years, 10 months
Overlord SVN: r99 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: test/org/jboss/tools/overlord/jbossesb/model/actions and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 10:16:46 -0400 (Wed, 02 Jul 2008)
New Revision: 99
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/IfActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SwitchActionTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
Log:
Unit tests for IfAction and SwitchAction.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-02 13:36:41 UTC (rev 98)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-02 14:16:46 UTC (rev 99)
@@ -65,15 +65,18 @@
(n.getNodeName().equals(IF) ||
n.getNodeName().equals(ELSEIF) ||
n.getNodeName().equals(ELSE))) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- ESBService service=getService().getModel().getService(category, name);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(category, name, service, true));
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+ }
}
}
}
@@ -98,9 +101,70 @@
public void validate(ModelListener l) {
super.validate(l);
- // TODO: Validate if/elseif/else order, if decision-method
- // specified, that method exists, if expression, then
- // validate the expression etc.
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ boolean f_if=false;
+ boolean f_else=false;
+ boolean f_orderWrong=false;
+ boolean f_serviceDetailsMissing=false;
+
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(IF)) {
+ if (f_if) {
+ f_orderWrong = true;
+ }
+
+ f_if = true;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ } else if (n.getNodeName().equals(ELSEIF)) {
+
+ if (f_if == false || f_else) {
+ f_orderWrong = true;
+ }
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ } else if (n.getNodeName().equals(ELSE)) {
+
+ if (f_if == false || f_else) {
+ f_orderWrong = true;
+ }
+
+ f_else = true;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && (f_if == false || f_orderWrong)) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_IF_ORDER_WRONG",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
}
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 13:36:41 UTC (rev 98)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 14:16:46 UTC (rev 99)
@@ -18,6 +18,7 @@
_CANNOT_INITIATE_NON_ROOT=Cannot 'initiate' non-root service descriptor for category '{0}' and name '{1}'
_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER=Cannot define MessageRouterAction with session based actions in service descriptor
+_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
_MUST_INITIATE_ROOT=Must 'initiate' root service descriptor for category '{0}' and name '{1}'
_NOT_FOUND_VARIABLE=Variable '{0}' could not be found on session type '{1}'
_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor that starts with a CreateSessionAction
@@ -29,3 +30,4 @@
_PARALLEL_PATH_AFTER_JOIN=Parallel path must not be defined after a join
_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
_ROUTER_ONE_OR_MORE_PATHS=MessageRouter action must specify one or more routes
+_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify one or more cases
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-07-02 13:36:41 UTC (rev 98)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-07-02 14:16:46 UTC (rev 99)
@@ -56,9 +56,11 @@
m_category=getPropertyValue(SERVICE_CATEGORY);
m_name=getPropertyValue(SERVICE_NAME);
- m_service=getService().getModel().getService(m_category, m_name);
+ if (m_category != null && m_name != null) {
+ m_service=getService().getModel().getService(m_category, m_name);
- getLinks().add(new ESBLink(m_category, m_name, m_service, true));
+ getLinks().add(new ESBLink(m_category, m_name, m_service, true));
+ }
m_joinCategory=getPropertyValue(JOIN_SERVICE_CATEGORY);
m_joinName=getPropertyValue(JOIN_SERVICE_NAME);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-02 13:36:41 UTC (rev 98)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-02 14:16:46 UTC (rev 99)
@@ -61,15 +61,18 @@
if (n instanceof org.w3c.dom.Element &&
n.getNodeName().equals(CASE)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- ESBService service=getService().getModel().getService(category, name);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(category, name, service, true));
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+ }
}
}
}
@@ -85,6 +88,54 @@
}
/**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ super.validate(l);
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ int pathCount=0;
+ boolean f_serviceDetailsMissing=false;
+
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(CASE)) {
+ pathCount++;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && pathCount < 1) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_SWITCH_ONE_OR_MORE_PATHS",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
+ }
+
+ /**
* This method converts the ESB action into an equivalent
* behavioural description for conformance checking.
*
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/IfActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/IfActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/IfActionTest.java 2008-07-02 14:16:46 UTC (rev 99)
@@ -0,0 +1,292 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class IfActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ IfAction action=new IfAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><if service-category=\"cat1\" " +
+ "service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+ "service-name=\"name2\" /><else service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ IfAction action=new IfAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2","name2"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat3","name3"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNoPathsContent() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat3");
+ other2.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ IfAction action=new IfAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_IF_ORDER_WRONG",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOnlyOneIf() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><if service-category=\"cat1\" " +
+ "service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+ "service-name=\"name2\" /><if service-category=\"cat3\" " +
+ "service-name=\"name3\" /><else service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ IfAction action=new IfAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_IF_ORDER_WRONG",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOutOfOrderElse() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><if service-category=\"cat1\" " +
+ "service-name=\"name1\" /><else service-category=\"cat3\" " +
+ "service-name=\"name3\" /><elseif service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ IfAction action=new IfAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_IF_ORDER_WRONG",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><if service-category=\"cat1\" " +
+ "service-name=\"name1\" /><elseif " +
+ "service-name=\"name2\" /><else service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ IfAction action=new IfAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SwitchActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SwitchActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SwitchActionTest.java 2008-07-02 14:16:46 UTC (rev 99)
@@ -0,0 +1,189 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class SwitchActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ SwitchAction action=new SwitchAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><case service-category=\"cat1\" " +
+ "service-name=\"name1\" /><case service-category=\"cat2\" " +
+ "service-name=\"name2\" /><case service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ SwitchAction action=new SwitchAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2","name2"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat3","name3"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateLessThanOnePath() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat3");
+ other2.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ SwitchAction action=new SwitchAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_SWITCH_ONE_OR_MORE_PATHS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><case service-category=\"cat1\" " +
+ "service-name=\"name1\" /><case " +
+ "service-name=\"name2\" /><case service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ SwitchAction action=new SwitchAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
15 years, 10 months
Overlord SVN: r98 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: test/org/jboss/tools/overlord/jbossesb/model/actions and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-02 09:36:41 -0400 (Wed, 02 Jul 2008)
New Revision: 98
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBLanguageModel.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
Log:
Unit tests for message router and parallel - also validating the structure of the custom properties.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-02 11:28:53 UTC (rev 97)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -62,28 +62,31 @@
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
- for (int i=0; i < nl.getLength(); i++) {
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
org.w3c.dom.Node n=nl.item(i);
if (n instanceof org.w3c.dom.Element) {
if (n.getNodeName().equals(ROUTE)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
- String initiate=((org.w3c.dom.Element)n).getAttribute(INITIATE);
-
- // Lookup service associated with category and name
- ESBService service=getService().getModel().getService(category, name);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(category, name, service, true));
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+ String initiate=((org.w3c.dom.Element)n).getAttribute(INITIATE);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
- if (service != null) {
- if (initiate != null && initiate.equalsIgnoreCase("true")) {
- m_initiateServices.add(service);
- } else {
- m_services.add(service);
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+
+ if (service != null) {
+ if (initiate != null && initiate.equalsIgnoreCase("true")) {
+ m_initiateServices.add(service);
+ } else {
+ m_services.add(service);
+ }
}
}
}
@@ -160,6 +163,43 @@
service.getName()}), null);
}
}
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ boolean f_serviceDetailsMissing=false;
+ int routeCount=0;
+
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(ROUTE)) {
+ routeCount++;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && routeCount < 1) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_ROUTER_ONE_OR_MORE_PATHS",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
}
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 11:28:53 UTC (rev 97)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-02 13:36:41 UTC (rev 98)
@@ -23,4 +23,9 @@
_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor that starts with a CreateSessionAction
_NOT_SPECIFIED_CONVERSATION_TYPE=Conversation type must be specified on root service descriptor
_NOT_SPECIFIED_REQ_RESP_EPR=Send does not contain request service category/name or response client EPR
-_MUST_BE_FIRST_ACTION='{0}' action must be first in the service descriptor
\ No newline at end of file
+_MUST_BE_FIRST_ACTION='{0}' action must be first in the service descriptor
+_PARALLEL_MORE_THAN_TWO_PATHS=Parallel action must specify two or more paths
+_PARALLEL_MULTIPLE_JOINS=Parallel action has multiple joins
+_PARALLEL_PATH_AFTER_JOIN=Parallel path must not be defined after a join
+_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
+_ROUTER_ONE_OR_MORE_PATHS=MessageRouter action must specify one or more routes
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-02 11:28:53 UTC (rev 97)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -62,29 +62,35 @@
if (n instanceof org.w3c.dom.Element) {
if (n.getNodeName().equals(PATH)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
- // Lookup service associated with category and name
- ESBService service=getService().getModel().getService(category, name);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(category, name, service, true));
-
- if (service != null) {
- m_services.add(service);
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+
+ if (service != null) {
+ m_services.add(service);
+ }
}
} else if (n.getNodeName().equals(JOIN)) {
- m_joinCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- m_joinName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+ m_joinCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ m_joinName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
- // Lookup service associated with category and name
- m_joinService=getService().getModel().getService(m_joinCategory, m_joinName);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(m_joinCategory, m_joinName, m_joinService, true));
+ // Lookup service associated with category and name
+ m_joinService=getService().getModel().getService(m_joinCategory, m_joinName);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(m_joinCategory, m_joinName, m_joinService, true));
+ }
}
}
}
@@ -101,6 +107,89 @@
}
/**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ super.validate(l);
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+ boolean f_joined=false;
+ int pathCount=0;
+ boolean f_pathAfterJoin=false;
+ boolean f_multipleJoins=false;
+ boolean f_serviceDetailsMissing=false;
+
+ for (int i=0; nl != null && i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(PATH)) {
+ pathCount++;
+
+ if (f_joined) {
+ f_pathAfterJoin = true;
+ }
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ } else if (n.getNodeName().equals(JOIN)) {
+
+ if (f_joined) {
+ f_multipleJoins = true;
+ }
+
+ f_joined = true;
+
+ if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+ ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+ f_serviceDetailsMissing = true;
+ }
+ }
+ }
+ }
+
+ // Report any errors
+ if (nl != null && pathCount < 2) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_MORE_THAN_TWO_PATHS",
+ new String[]{}), null);
+ }
+
+ if (f_pathAfterJoin) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_PATH_AFTER_JOIN",
+ new String[]{}), null);
+ }
+
+ if (f_multipleJoins) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_MULTIPLE_JOINS",
+ new String[]{}), null);
+ }
+
+ if (f_serviceDetailsMissing) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}), null);
+ }
+ }
+
+ /**
* This method converts the ESB action into an equivalent
* behavioural description for conformance checking.
*
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java 2008-07-02 11:28:53 UTC (rev 97)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -17,11 +17,14 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
public class ESBActionTestUtil {
public static org.w3c.dom.Element getAction(String actionClass,
java.util.Map<String,String> simpleProps,
- java.util.Map<String,org.w3c.dom.Element> customProps) {
+ java.util.Map<String,String> customProps) {
org.w3c.dom.Element ret=null;
@@ -51,6 +54,45 @@
property.setAttribute("value", value);
}
}
+
+ if (customProps != null) {
+ java.util.Iterator<String> props=customProps.keySet().iterator();
+
+ while (props.hasNext()) {
+ String key=props.next();
+ String value=customProps.get(key);
+
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(value.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document valuedoc=builder.parse(xmlstr);
+ org.w3c.dom.Element valueroot=valuedoc.getDocumentElement();
+
+ org.w3c.dom.NodeList nl=valueroot.getChildNodes();
+
+ org.w3c.dom.Element property=ret.getOwnerDocument().createElement("property");
+ ret.appendChild(property);
+
+ property.setAttribute("name", key);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Node valueelem=
+ nl.item(i).cloneNode(true);
+
+ doc.adoptNode(valueelem);
+
+ property.appendChild(valueelem);
+ }
+ }
+ }
+
+ }
}
} catch(Exception e) {
e.printStackTrace();
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterActionTest.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -0,0 +1,247 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class MessageRouterActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateSessionBasedService() {
+ TestESBService service=new TestESBService();
+ service.setSessionBased(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><route service-category=\"cat1\" " +
+ "service-name=\"name1\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><route service-category=\"cat1\" " +
+ "service-name=\"name1\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateInitiateServiceNotRoot() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><route service-category=\"cat1\" " +
+ "service-name=\"name1\" initiate=\"true\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other=new TestESBService();
+ other.setCategory("cat1");
+ other.setName("name1");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other);
+ model.addService(service);
+
+ service.setModel(model);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_CANNOT_INITIATE_NON_ROOT",
+ new String[]{other.getCategory(),
+ other.getName()}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNotInitiateRootService() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><route service-category=\"cat1\" " +
+ "service-name=\"name1\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other=new TestESBService();
+ other.setCategory("cat1");
+ other.setName("name1");
+ other.setRoot(true);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other);
+ model.addService(service);
+
+ service.setModel(model);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_INITIATE_ROOT",
+ new String[]{other.getCategory(),
+ other.getName()}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNoRoutes() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_ROUTER_ONE_OR_MORE_PATHS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceDetailsMissing() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><route service-category=\"cat1\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ MessageRouterAction action=new MessageRouterAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ParallelActionTest.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -0,0 +1,294 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class ParallelActionTest extends TestCase {
+
+ public void testValidatePathsSpecified() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ ParallelAction action=new ParallelAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"paths"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateServiceNotFound() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><path service-category=\"cat1\" " +
+ "service-name=\"name1\" /><path service-category=\"cat2\" " +
+ "service-name=\"name2\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(service);
+
+ service.setModel(model);
+
+ ParallelAction action=new ParallelAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat1","name1"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat2","name2"}));
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{"cat3","name3"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateLessThanTwoPaths() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><path service-category=\"cat1\" " +
+ "service-name=\"name1\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat3");
+ other2.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(service);
+
+ service.setModel(model);
+
+ ParallelAction action=new ParallelAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_MORE_THAN_TWO_PATHS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOnlyOneJoin() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><path service-category=\"cat1\" " +
+ "service-name=\"name1\" /><path service-category=\"cat2\" " +
+ "service-name=\"name2\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ ParallelAction action=new ParallelAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_MULTIPLE_JOINS",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateOutOfOrderJoin() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><path service-category=\"cat1\" " +
+ "service-name=\"name1\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /><path service-category=\"cat2\" " +
+ "service-name=\"name2\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ ParallelAction action=new ParallelAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PARALLEL_PATH_AFTER_JOIN",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateMissingServiceDetails() {
+ TestESBService service=new TestESBService();
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("paths", "<property><path service-category=\"cat1\" " +
+ "service-name=\"name1\" /><path " +
+ "service-name=\"name2\" /><join service-category=\"cat3\" " +
+ "service-name=\"name3\" /></property>");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+
+ TestESBService other1=new TestESBService();
+ other1.setCategory("cat1");
+ other1.setName("name1");
+
+ TestESBService other2=new TestESBService();
+ other2.setCategory("cat2");
+ other2.setName("name2");
+
+ TestESBService other3=new TestESBService();
+ other3.setCategory("cat3");
+ other3.setName("name3");
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+ model.addService(other1);
+ model.addService(other2);
+ model.addService(other3);
+ model.addService(service);
+
+ service.setModel(model);
+
+ ParallelAction action=new ParallelAction(service, elem);
+ action.initializeLinks();
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_PATH_SERVICE_DETAILS_MISSING",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBLanguageModel.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBLanguageModel.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -0,0 +1,56 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import java.util.Collection;
+
+import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.scribble.model.ModelListener;
+import org.scribble.model.ModelReference;
+
+public class TestESBLanguageModel implements org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel {
+
+ public String getContents() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ModelReference getModelReference() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addService(ESBService service) {
+ m_services.put(service.getCategory()+":"+service.getName(), service);
+ }
+
+ public ESBService getService(String category, String name) {
+ return(m_services.get(category+":"+name));
+ }
+
+ public Collection<ESBService> getServices() {
+ return(m_services.values());
+ }
+
+ public void validate(ModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-02 11:28:53 UTC (rev 97)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-02 13:36:41 UTC (rev 98)
@@ -37,9 +37,12 @@
return(m_actions);
}
+ public void setCategory(String cat) {
+ m_category = cat;
+ }
+
public String getCategory() {
- // TODO Auto-generated method stub
- return null;
+ return(m_category);
}
public String getConversationType() {
@@ -47,10 +50,17 @@
return null;
}
+ public void setName(String name) {
+ m_name = name;
+ }
+
public String getName() {
- // TODO Auto-generated method stub
- return null;
+ return(m_name);
}
+
+ public void setModel(ESBLanguageModel model) {
+ m_model = model;
+ }
public ESBLanguageModel getModel() {
return(m_model);
@@ -107,9 +117,12 @@
return(m_root);
}
+ public void setSessionBased(boolean bool) {
+ m_sessionBased = bool;
+ }
+
public boolean isSessionBased() {
- // TODO Auto-generated method stub
- return false;
+ return(m_sessionBased);
}
public void validate(ModelListener l) {
@@ -117,8 +130,11 @@
}
+ private String m_category=null;
+ private String m_name=null;
private ESBLanguageModel m_model=null;
private List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
private boolean m_root=false;
+ private boolean m_sessionBased=false;
private Class<?> m_sessionClass=null;
}
15 years, 10 months
Overlord SVN: r97 - in cdl/trunk: runtime/jbossesb and 7 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-07-02 07:28:53 -0400 (Wed, 02 Jul 2008)
New Revision: 97
Added:
cdl/trunk/runtime/jbossesb/src/test/java/org/jboss/soa/overlord/jbossesb/util/MVELUsageTest.java
Modified:
cdl/trunk/pom.xml
cdl/trunk/runtime/jbossesb/pom.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageProperties.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
cdl/trunk/samples/jbossesb/broker/pom.xml
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/BrokerMain.java
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/CompleteTransactionMain.java
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Confirmation.java
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Quote.java
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java
cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Supplier.java
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/broker/src/main/resources/hibernate.cfg.xml
cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml
Log:
* Using MVEL library.
Modified: cdl/trunk/pom.xml
===================================================================
--- cdl/trunk/pom.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/pom.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -28,7 +28,7 @@
</developers>
<modules>
<module>runtime</module>
- <module>samples</module>
+ <!--module>samples</module-->
</modules>
<properties>
@@ -197,6 +197,12 @@
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
</repository>
+ <repository>
+ <id>codehaus</id>
+ <name>codehaus repository</name>
+ <url>http://repo1.maven.org/maven2</url>
+ </repository>
+
</repositories>
<distributionManagement>
Modified: cdl/trunk/runtime/jbossesb/pom.xml
===================================================================
--- cdl/trunk/runtime/jbossesb/pom.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/pom.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -58,6 +58,11 @@
<version>0.9.1</version>
</dependency>
<dependency>
+ <groupId>org.mvel</groupId>
+ <artifactId>mvel</artifactId>
+ <version>1.3.4-java1.5</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -94,8 +94,8 @@
transaction = hibernateSession.beginTransaction();
//TODO: set variable here.
- String bindExpression = (String) message.getProperties().getProperty(MessageProperties.BIND_VARIABLE);
- Object value = message.getProperties().getProperty(MessageProperties.BIND_OBJECT);
+ //String bindExpression = (String) message.getProperties().getProperty(MessageProperties.BIND_VARIABLE);
+ //Object value = message.getProperties().getProperty(MessageProperties.BIND_OBJECT);
hibernateSession.save(businessState);
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -207,6 +207,10 @@
session.unschedule(serviceCategory, serviceName);
}
+ protected String getMvelMethodName(String method) {
+ return method + "()";
+ }
+
/**
* This is the method that deals with business logic for derived conversation actions.
* @param message
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -19,11 +19,10 @@
*/
package org.jboss.soa.overlord.jbossesb.actions;
-import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.ClassLoaderUtil;
import org.jboss.soa.overlord.conversation.Session;
+import org.mvel.MVEL;
/**
* This action represents a choice between a set of specified paths
@@ -53,31 +52,18 @@
String method=children[i].getAttribute("decision-method");
if (method != null) {
- // Try to invoke method on business object, to obtain a decision
try {
- Class cls= ClassLoaderUtil.loadClass(session.getPojoClass());
-
- Class[] clsParam = null;
- java.lang.reflect.Method m=cls.getMethod(method, clsParam);
-
- if (m != null) {
- Object[] objs = null;
- Object res= m.invoke(session.getBusinessObject(), objs);
+ Object res = MVEL.eval(getMvelMethodName(method), session.getBusinessObject());
+ if (res instanceof Boolean) {
- if (res instanceof Boolean) {
-
- f_register = ((Boolean)res).booleanValue();
-
- } else {
- logger.error("Result of method '"+method+
- "' on session '"+session+"' should be boolean," +
- " but got: "+res);
- }
+ f_register = ((Boolean)res).booleanValue();
+
} else {
- logger.error("Failed to find method '"+method+
- "' on session '"+session+"'");
+ logger.error("Result of method '"+method+
+ "' on session '"+session+"' should be boolean," +
+ " but got: "+res);
}
-
+
} catch(Exception e) {
logger.error("Failed to invoke decision method '"+
method+"' on session '"+session+"'", e);
@@ -95,8 +81,7 @@
return(message);
}
-
- private static Logger logger = Logger.getLogger(IfAction.class);
+
}
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageProperties.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageProperties.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageProperties.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -27,7 +27,6 @@
public static final String OPERATION="operation";
public static final String MESSAGE_TYPE="messageType";
- public static final String BIND_VARIABLE = "bind_variable";
- public static final String BIND_OBJECT = "bind_object";
+ public static final String BOUND_VARIABLE_KEY = "bound_variable_key";
}
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -19,9 +19,14 @@
*/
package org.jboss.soa.overlord.jbossesb.actions;
+import java.util.HashMap;
+import java.util.Map;
+
import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.conversation.Session;
+import org.mvel.MVEL;
/**
* @author jeffyu
@@ -39,24 +44,26 @@
public Message handle(Message message) throws Exception {
String serviceCategory = getConfig().getAttribute(ActionProperties.SERVICE_CATEGORY_PROPERTY);
String serviceName = getConfig().getAttribute(ActionProperties.SERVICE_NAME_PROPERTY);
+ Session session = getSession(message);
ConfigTree[] configs = getConfig().getAllChildren();
+ Map<String, Object> bindingVal = new HashMap<String, Object>();
+
for(ConfigTree ct : configs) {
if ("bind".equals(ct.getName())) {
String fromExpression = ct.getAttribute("from-expression");
String toVariable = ct.getAttribute("to-variable");
- //TODO: Object retrieving from the "fromExpression".
- Object o = new Object();
- message.getProperties().setProperty(MessageProperties.BIND_VARIABLE, toVariable);
- message.getProperties().setProperty(MessageProperties.BIND_OBJECT, o);
-
- ServiceInvoker serviceInvoker = new ServiceInvoker(serviceCategory, serviceName);
- serviceInvoker.deliverAsync(message);
+ Object o = MVEL.eval(fromExpression, session.getBusinessObject());
+ bindingVal.put(toVariable, o);
}
}
+ message.getProperties().setProperty(MessageProperties.BOUND_VARIABLE_KEY, bindingVal);
+ ServiceInvoker serviceInvoker = new ServiceInvoker(serviceCategory, serviceName);
+ serviceInvoker.deliverAsync(message);
+
return message;
}
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -19,12 +19,10 @@
*/
package org.jboss.soa.overlord.jbossesb.actions;
-import java.lang.reflect.Method;
-
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.ClassLoaderUtil;
import org.jboss.soa.overlord.conversation.Session;
+import org.mvel.MVEL;
/**
* @author jeffyu
@@ -69,12 +67,8 @@
String category = ct.getAttribute(ActionProperties.SERVICE_CATEGORY);
String name = ct.getAttribute(ActionProperties.SERVICE_NAME);
try {
- Class<?> cls= ClassLoaderUtil.loadClass(session.getPojoClass());
- Class<?>[] clsParam = null;
- Method m=cls.getMethod(decision, clsParam);
- if (m != null) {
- Object[] params = null;
- Object res = m.invoke(session.getBusinessObject(), params);
+ if (decision != null) {
+ Object res = MVEL.eval(getMvelMethodName(decision), session.getBusinessObject());
if (res instanceof Boolean) {
Boolean ret = (Boolean)res;
if (ret.booleanValue()) {
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -21,8 +21,8 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.ClassLoaderUtil;
import org.jboss.soa.overlord.conversation.Session;
+import org.mvel.MVEL;
/**
* @author jeffyu
@@ -56,12 +56,8 @@
//TODO: Need to think about the expression.
String decisionMethod = whileConfig.getAttribute("decision-method");
- Class<?> cls= ClassLoaderUtil.loadClass(session.getPojoClass());
- Class<?>[] clsParam = null;
- java.lang.reflect.Method m=cls.getMethod(decisionMethod, clsParam);
- if (m != null) {
- Object[] params = null;
- Object response = m.invoke(session.getBusinessObject(), params);
+ if (decisionMethod != null) {
+ Object response = MVEL.eval(getMvelMethodName(decisionMethod), session.getBusinessObject());
if (response instanceof Integer) {
Integer value = (Integer) response;
if (counter < value) {
Added: cdl/trunk/runtime/jbossesb/src/test/java/org/jboss/soa/overlord/jbossesb/util/MVELUsageTest.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/test/java/org/jboss/soa/overlord/jbossesb/util/MVELUsageTest.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/test/java/org/jboss/soa/overlord/jbossesb/util/MVELUsageTest.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb.util;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mvel.MVEL;
+
+import junit.framework.Assert;
+
+/**
+ * @author jeffyu
+ *
+ */
+public class MVELUsageTest extends Assert {
+
+ private Example example;
+
+ @Before
+ public void setUp() {
+ example = new Example();
+ example.setProperty("exampleProperty");
+ }
+
+ @Test
+ public void testPropertyAssessor() throws Exception {
+ String expression = "property";
+ String value = (String)MVEL.eval(expression, example);
+
+ assertEquals("exampleProperty", value);
+ }
+
+ @Test
+ public void testInvokeMethod() throws Exception {
+ String expression = "isInvoked()";
+ boolean result = (Boolean)MVEL.eval(expression, example);
+ assertEquals(true, result);
+ }
+
+ @Test
+ public void testPropertyInjection() throws Exception {
+ String expression="property";
+ MVEL.setProperty(example, expression, "AnotherValue");
+ assertEquals("AnotherValue", MVEL.eval(expression, example));
+ }
+
+ @Test
+ public void testGetProperty() throws Exception {
+ String property = "property";
+ assertEquals("exampleProperty", MVEL.getProperty(property, example));
+ }
+
+
+ public class Example {
+
+ private String property;
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public boolean isInvoked() {
+ return true;
+ }
+
+ }
+
+}
Modified: cdl/trunk/samples/jbossesb/broker/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/pom.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/pom.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -55,7 +55,7 @@
</dependencies>
<build>
- <finalName>purchasing</finalName>
+ <finalName>broker</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -78,7 +78,7 @@
create="true"
drop="true"
export="true"
- outputfilename="purchasing-ddl.sql"
+ outputfilename="broker-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
@@ -96,7 +96,7 @@
<configuration>
<tasks>
<property name="deploy.dir" value="/var/local/jboss-4.2.2.GA/server/default/deploy" />
- <copy file="target/purchasing.esb" todir="${deploy.dir}" overwrite="true" />
+ <copy file="target/broker.esb" todir="${deploy.dir}" overwrite="true" />
</tasks>
</configuration>
<goals>
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/BrokerMain.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/BrokerMain.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/BrokerMain.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -44,8 +44,8 @@
@Column(name="ID")
private long id;
- @Column(name="TRANSACTION_ID")
- @OneToOne(mappedBy="TRANSACTION_ID")
+ @OneToOne
+ @JoinColumn(name="transaction_ID")
private CompleteTransactionMain transaction;
@OneToMany
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/CompleteTransactionMain.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/CompleteTransactionMain.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/CompleteTransactionMain.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -23,6 +23,7 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -38,10 +39,14 @@
@Column(name="ID")
private long id;
- @OneToOne(mappedBy="quote")
- @Column(name="quote")
- private Quote confirmedQuote;
+ @OneToOne
+ @JoinColumn(name="Confirmation_ID")
+ private Confirmation confirmation;
+ @OneToOne
+ @JoinColumn(name="ID")
+ private Supplier supplier;
+
public long getId() {
return this.id;
}
@@ -50,13 +55,20 @@
this.id = id;
}
- public Quote getConfirmedQuote() {
- return confirmedQuote;
+ public Supplier getSupplier() {
+ return supplier;
}
- public void setConfirmedQuote(Quote confirmedQuote) {
- this.confirmedQuote = confirmedQuote;
+ public void setSupplier(Supplier supplier) {
+ this.supplier = supplier;
}
-
-
+
+ public Confirmation getConfirmation() {
+ return confirmation;
+ }
+
+ public void setConfirmation(Confirmation confirmation) {
+ this.confirmation = confirmation;
+ }
+
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Confirmation.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Confirmation.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Confirmation.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -19,7 +19,10 @@
*/
package org.jboss.soa.overlord.samples.jbossesb.loan.broker;
+import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
import javax.persistence.Table;
import org.jboss.soa.overlord.conversation.HibernateObject;
@@ -35,8 +38,13 @@
private static final long serialVersionUID = 115L;
+ @Id @GeneratedValue
+ @Column(name="ID")
private long id;
+ @Column(name="DETAIL")
+ private String detail;
+
public long getId() {
return this.id;
}
@@ -45,4 +53,14 @@
this.id = id;
}
+ public String getDetail() {
+ return detail;
+ }
+
+ public void setDetail(String detail) {
+ this.detail = detail;
+ }
+
+
+
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Quote.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Quote.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Quote.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -19,8 +19,42 @@
*/
package org.jboss.soa.overlord.samples.jbossesb.loan.broker;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.jboss.soa.overlord.conversation.HibernateObject;
-public class Quote {
+@Entity
+@Table(name="T_QUOTE")
+public class Quote implements HibernateObject {
+
+ private static final long serialVersionUID = 12333L;
+ @Id @GeneratedValue
+ @Column(name="ID")
+ private long id;
+
+ @Column(name="VALUE")
+ private int value;
+
+ public long getId() {
+ return this.id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -23,6 +23,7 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -42,10 +43,14 @@
@Column(name="ID")
private long id;
- @Column(name="SUPPLIER")
- @OneToOne(mappedBy="SUPPLIER")
+ @OneToOne
+ @JoinColumn(name="supplier_ID")
private Supplier supplier;
+ @OneToOne
+ @JoinColumn(name="quote_ID")
+ private Quote quote;
+
public long getId() {
return id;
}
@@ -61,6 +66,14 @@
public void setSupplier(Supplier supplier) {
this.supplier = supplier;
}
+
+ public Quote getQuote() {
+ return quote;
+ }
+
+ public void setQuote(Quote quote) {
+ this.quote = quote;
+ }
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Supplier.java
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Supplier.java 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Supplier.java 2008-07-02 11:28:53 UTC (rev 97)
@@ -23,6 +23,8 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.jboss.soa.overlord.conversation.HibernateObject;
@@ -47,6 +49,10 @@
@Column(name="SERVICE_NAME")
private String serviceName;
+ @ManyToOne
+ @JoinColumn(name="BROKER_ID")
+ private BrokerMain broker;
+
public long getId() {
return this.id;
}
@@ -70,6 +76,15 @@
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
+
+ public BrokerMain getBroker() {
+ return broker;
+ }
+
+ public void setBroker(BrokerMain broker) {
+ this.broker = broker;
+ }
+
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -1,14 +1,19 @@
<jbossesb-deployment>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker_reply</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker1</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker2</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker3</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker4</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker5</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker6</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-broker7</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency1</depends>
- <depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency2</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker1</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker2</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker3</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker4</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker5</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker6</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker7</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker8</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker9</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker10</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker11</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker12</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker13</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker14</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker15</depends>
+ <depends>jboss.esb.gen.destination:service=Queue,name=esb-loan-broker16</depends>
</jbossesb-deployment>
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/hibernate.cfg.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/hibernate.cfg.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/hibernate.cfg.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -54,6 +54,13 @@
<mapping class="org.jboss.soa.overlord.conversation.EPRWrapper"/>
<!-- List of Business State class -->
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.Supplier" />
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.BrokerMain" />
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.CompleteTransactionMain" />
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.Confirmation" />
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.Quote" />
+ <mapping class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.Request4QuoteMain" />
+
</session-factory>
</hibernate-configuration>
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml 2008-07-01 15:41:40 UTC (rev 96)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml 2008-07-02 11:28:53 UTC (rev 97)
@@ -2,76 +2,108 @@
<server>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker_reply">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker1">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker1">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker2">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
+
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker2">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker3">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker3">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker4">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker4">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker5">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker5">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker6">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker6">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker7">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-broker7">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker8">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-creditAgency">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker9">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-creditAgency1">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker10">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.esb.gen.destination:service=Queue,name=esb-creditAgency2">
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker11">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</depends>
</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker12">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker13">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker14">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker15">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.gen.destination:service=Queue,name=esb-loan-broker16">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+
</server>
15 years, 10 months
Overlord SVN: r96 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: test/org/jboss/tools/overlord/jbossesb/model/actions and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-01 11:41:40 -0400 (Tue, 01 Jul 2008)
New Revision: 96
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableActionTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
Log:
Unit tests for get/set variable actions - validation only at the moment.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01 15:14:17 UTC (rev 95)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -65,13 +65,7 @@
String variable=getPropertyValue(VARIABLE);
- if (variable == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_NOT_SPECIFIED_VARIABLE",
- new String[]{}), null);
- } else {
+ if (variable != null) {
// Check that variable defined on session class
Class<?> cls=getService().getSessionClass();
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-01 15:14:17 UTC (rev 95)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-07-01 15:41:40 UTC (rev 96)
@@ -23,5 +23,4 @@
_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor that starts with a CreateSessionAction
_NOT_SPECIFIED_CONVERSATION_TYPE=Conversation type must be specified on root service descriptor
_NOT_SPECIFIED_REQ_RESP_EPR=Send does not contain request service category/name or response client EPR
-_NOT_SPECIFIED_VARIABLE=Variable name has not been specified
_MUST_BE_FIRST_ACTION='{0}' action must be first in the service descriptor
\ No newline at end of file
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01 15:14:17 UTC (rev 95)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -65,13 +65,7 @@
String variable=getPropertyValue(VARIABLE);
- if (variable == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_NOT_SPECIFIED_VARIABLE",
- new String[]{}), null);
- } else {
+ if (variable != null) {
// Check that variable defined on session class
Class<?> cls=getService().getSessionClass();
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java 2008-07-01 15:14:17 UTC (rev 95)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -69,8 +69,10 @@
TestESBService service=new TestESBService();
service.setRoot(true);
- org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, null);
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
CreateSessionAction action=new CreateSessionAction(service, elem);
service.getActions().add(action);
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableActionTest.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class GetVariableActionTest extends TestCase {
+
+ public void testValidateNoVariable() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ GetVariableAction action=new GetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"variable"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateVariableNotClassProperty() {
+ String varName="classX";
+ Class<?> cls=java.lang.Object.class;
+
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+ service.setSessionClass(cls);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("variable", varName);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null,
+ props, null);
+
+ GetVariableAction action=new GetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_NOT_FOUND_VARIABLE",
+ new String[]{varName, cls.getName()}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateVariableIsClassProperty() {
+ String varName="class";
+ Class<?> cls=java.lang.Object.class;
+
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+ service.setSessionClass(cls);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("variable", varName);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null,
+ props, null);
+
+ GetVariableAction action=new GetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableActionTest.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class SetVariableActionTest extends TestCase {
+
+ public void testValidateNoVariable() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ SetVariableAction action=new SetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{"variable"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateVariableNotClassProperty() {
+ String varName="classX";
+ Class<?> cls=java.lang.Object.class;
+
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+ service.setSessionClass(cls);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("variable", varName);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null,
+ props, null);
+
+ SetVariableAction action=new SetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_NOT_FOUND_VARIABLE",
+ new String[]{varName, cls.getName()}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateVariableIsClassProperty() {
+ String varName="class";
+ Class<?> cls=java.lang.Object.class;
+
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+ service.setSessionClass(cls);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("variable", varName);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null,
+ props, null);
+
+ SetVariableAction action=new SetVariableAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-01 15:14:17 UTC (rev 95)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-01 15:41:40 UTC (rev 96)
@@ -76,9 +76,12 @@
return 0;
}
+ public void setSessionClass(Class<?> cls) {
+ m_sessionClass = cls;
+ }
+
public Class<?> getSessionClass() {
- // TODO Auto-generated method stub
- return null;
+ return(m_sessionClass);
}
public String getSessionName() {
@@ -117,4 +120,5 @@
private ESBLanguageModel m_model=null;
private List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
private boolean m_root=false;
+ private Class<?> m_sessionClass=null;
}
15 years, 10 months
Overlord SVN: r95 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb: src/java/org/jboss/tools/overlord/jbossesb/model and 10 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-07-01 11:14:17 -0400 (Tue, 01 Jul 2008)
New Revision: 95
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java
Log:
First unit test for CreateSessionAction - refactored top level action, service and language model components to be interfaces, to make unit testing easier.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath 2008-07-01 15:14:17 UTC (rev 95)
@@ -4,5 +4,6 @@
<classpathentry kind="src" path="src/test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,339 @@
+/*
+ * 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.jbossesb.model;
+
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+
+/**
+ * This class represents an ESB model.
+ *
+ * @author gary
+ */
+public class DefaultESBLanguageModel extends org.scribble.lang.model.LanguageModel
+ implements ESBLanguageModel {
+
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String SERVICES_ELEMENT = "services";
+
+ public static final String JBOSSESB_NOTATION = "jboss-esb.xml";
+
+ /**
+ * This constructor is initialized with the ESB configuration.
+ *
+ * @param source The model reference for the JBossESB configuration source
+ * @param elem The ESB configuration
+ * @param contents The textual contents
+ */
+ public DefaultESBLanguageModel(ModelReference source, org.w3c.dom.Element elem,
+ String contents) {
+ m_source = source;
+ m_esbConfig = elem;
+ m_contents = contents;
+
+ // Extract service action pipelines
+ initialize();
+ }
+
+ /**
+ * This method initializes the ESB Model.
+ */
+ protected void initialize() {
+ org.w3c.dom.NodeList services=
+ m_esbConfig.getElementsByTagName(SERVICES_ELEMENT);
+
+ org.scribble.model.DependencyManager dm=
+ (org.scribble.model.DependencyManager)
+ org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+ org.scribble.model.DependencyManager.class, null);
+
+ ModelName mname=new ModelName();
+ mname.setName(m_source.getLocalpart());
+
+ setModelName(mname);
+
+ Namespace ns=new Namespace();
+ ns.setName(m_source.getNamespace());
+ setNamespace(ns);
+
+ if (services != null && services.getLength() == 1 &&
+ services.item(0) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
+ services.item(0)).getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(SERVICE_ELEMENT)) {
+
+ ESBService service=new DefaultESBService(this,
+ (org.w3c.dom.Element)nl.item(i));
+ String key=getKey(service.getCategory(),
+ service.getName());
+
+ m_services.put(key, service);
+ }
+ }
+
+ java.util.Iterator<ESBService> iter=m_services.values().iterator();
+
+ while (iter.hasNext()) {
+ iter.next().initializeLinks();
+ }
+
+ // Initialize the conversations
+ java.util.Iterator<ESBService> serviter=getServices().iterator();
+
+ while (serviter.hasNext()) {
+ ESBService service=serviter.next();
+
+ if (service.isRoot()) {
+ Conversation conv=new Conversation();
+
+ ModelName modelName=new ModelName();
+ modelName.setName(service.getServiceName());
+
+ conv.setModelName(modelName);
+
+ String convType=service.getConversationType();
+ if (convType != null) {
+ int index=convType.indexOf('@');
+
+ if (index != -1) {
+ // TODO: Need to think whether this should be
+ // 'implements' reference. If so, then need to change
+ // Java Lang Model parser and also Lang Model conformance
+ // rule.
+ ImplementsReference iref=
+ new ImplementsReference(ConversationModel.CONVERSATION);
+ //ConformanceReference iref=
+ // new ConformanceReference(ConversationModel.CONVERSATION);
+
+ iref.setLocatedRole(convType.substring(index+1));
+
+ // Need to locate the model name
+ modelName.setLocatedRole(new Role(iref.getLocatedRole()));
+
+ String mainpart=convType.substring(0, index);
+
+ index = mainpart.lastIndexOf(".");
+
+ if (index == -1) {
+ iref.setNamespace("");
+ iref.setLocalpart(mainpart);
+ } else {
+ iref.setNamespace(mainpart.substring(0, index));
+ iref.setLocalpart(mainpart.substring(index+1));
+ }
+
+ conv.getImplements().add(iref);
+ //conv.getConformsTo().add(iref);
+
+ dm.recordDependency(m_source, iref,
+ DependencyType.Implements);
+
+ } else {
+ logger.warning("Conversation type does not " +
+ "contain '@' located role separator");
+ }
+ } else {
+ logger.warning("No conversation type specified");
+ }
+
+ // TODO: Associate a conformance reference for the
+ // conversation type - when using Scribble dependency
+ // management, this will ensure appropriate validation
+ // when either the dependent conversation is changed, or
+ // the ESB config file changed.
+ //ConformanceReference confRef=new ConformanceReference();
+
+ //conv.getConformsTo().add(confRef);
+
+ conv.setBlock(new Block());
+
+ service.convert(conv.getBlock().getContents(),
+ new DefaultConversionContext());
+
+ getConversations().add(conv);
+ }
+ }
+ }
+
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+
+ org.scribble.export.Exporter exporter=
+ (org.scribble.export.Exporter)
+ RegistryFactory.getRegistry().getExtension(
+ org.scribble.export.Exporter.class, null);
+
+ try {
+ for (int i=0; i < getConversations().size(); i++) {
+ ConversationModel model=new ConversationModel();
+
+ model.setConversation(getConversations().get(i));
+
+ org.scribble.export.text.TextFormatter formatter=
+ new org.scribble.export.text.TextFormatter();
+
+ java.io.ByteArrayOutputStream os=
+ new java.io.ByteArrayOutputStream();
+
+ formatter.setOutputStream(os);
+
+ exporter.export(model, formatter);
+
+ String str=new String(os.toByteArray());
+
+ System.out.println("EXPORTED JBOSS-ESB TEXT:");
+ System.out.println(str);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public String getNotation() {
+ return(JBOSSESB_NOTATION);
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference() {
+ return(m_source);
+ }
+
+ /**
+ * Generate a key for use in accessing the service related to
+ * the supplied category and name.
+ *
+ * @param category The category
+ * @param name The service name
+ * @return The key
+ */
+ protected String getKey(String category, String name) {
+ return(category+"/"+name);
+ }
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ java.util.Iterator<ESBService> iter=m_services.values().iterator();
+
+ while (iter.hasNext()) {
+ ESBService service=iter.next();
+
+ service.validate(l);
+ }
+ }
+
+ /**
+ * This method returns the ESB service for the supplied
+ * category and name.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @return The ESB service, or null if not found
+ */
+ public ESBService getService(String category, String name) {
+ return(m_services.get(getKey(category, name)));
+ }
+
+ /**
+ * This method returns the collection of ESB services associated
+ * with the model.
+ *
+ * @return The collection of ESB services
+ */
+ public java.util.Collection<ESBService> getServices() {
+ return(m_services.values());
+ }
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getContents() {
+ return(m_contents);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ModelReference m_source=null;
+ private org.w3c.dom.Element m_esbConfig=null;
+ private String m_contents=null;
+ private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
+
+ public class InnerModelListener implements ModelListener {
+
+ public InnerModelListener(ModelListener l) {
+ m_listener = l;
+ }
+
+ public void error(ModelObject src, String mesg, Properties props) {
+
+ if (props == null) {
+ props = new Properties();
+ }
+
+ props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ props.put(ModelListener.REFERENCE_MODEL, m_source);
+ props.put(ModelListener.REFERENCE_MODEL_START_POSITION, src.getSource().getStartPosition());
+ props.put(ModelListener.REFERENCE_MODEL_END_POSITION, src.getSource().getEndPosition());
+ if (src.getSource().getComponent() != null) {
+ props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ src.getSource().getComponent());
+ }
+
+ m_listener.error(src, mesg, props);
+ }
+
+ public void warning(ModelObject src, String mesg, Properties props) {
+ if (props == null) {
+ props = new Properties();
+ }
+
+ props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ props.put(ModelListener.REFERENCE_MODEL, m_source);
+ props.put(ModelListener.REFERENCE_MODEL_START_POSITION, src.getSource().getStartPosition());
+ props.put(ModelListener.REFERENCE_MODEL_END_POSITION, src.getSource().getEndPosition());
+ if (src.getSource().getComponent() != null) {
+ props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ src.getSource().getComponent());
+ }
+
+ m_listener.warning(src, mesg, props);
+ }
+
+ private ModelListener m_listener=null;
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,604 @@
+/*
+ * 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.jbossesb.model;
+
+import java.util.logging.Logger;
+
+import org.eclipse.jdt.core.*;
+import org.eclipse.core.resources.*;
+
+// TODO: Need to find alternative to JavaModel
+import org.eclipse.jdt.internal.core.*;
+
+import org.scribble.model.*;
+import org.scribble.osgi.model.*;
+
+/**
+ * This class represents an ESB service.
+ *
+ * @author gary
+ */
+public class DefaultESBService extends ModelObject implements ESBService {
+
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String SERVICE_NAME_PROPERTY = "serviceName";
+ private static final String ROOT_PROPERTY = "root";
+ private static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
+ private static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
+ private static final String ACTION_PACKAGE = "org.jboss.soa.overlord.jbossesb.actions.";
+ private static final String CREATE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.CreateSessionAction";
+ private static final String RETRIEVE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
+ private static final String ACTION_ELEMENT = "action";
+ private static final String ACTIONS_ELEMENT = "actions";
+
+ /**
+ * This is the constructor for the ESB service.
+ *
+ * @param model The ESB model in which the service has been defined
+ * @param service The XML configuration of the service
+ */
+ public DefaultESBService(ESBLanguageModel model, org.w3c.dom.Element service) {
+ m_model = model;
+ m_service = service;
+
+ if (m_model != null && m_service != null) {
+ initialize();
+ }
+ }
+
+ /**
+ * This method initializes the service.
+ */
+ protected void initialize() {
+ // Check if relevant action
+ org.w3c.dom.NodeList actions=m_service.getElementsByTagName(ACTIONS_ELEMENT);
+
+ if (actions != null && actions.getLength() == 1 &&
+ actions.item(0) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
+ actions.item(0)).getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(ACTION_ELEMENT)) {
+ m_actions.add(ESBActionFactory.createAction(this,
+ ((org.w3c.dom.Element)nl.item(i))));
+ }
+ }
+ }
+
+ // Find positional information
+ int servCount=getServicePosition();
+
+ String str=getModel().getContents();
+
+ int startPosition=str.indexOf("<service ");
+ int endPosition=-1;
+
+ while (startPosition != -1 && servCount > 0) {
+ servCount--;
+
+ endPosition = str.indexOf("</service>", startPosition);
+
+ if (servCount > 0) {
+ startPosition=str.indexOf("<service ", endPosition);
+ }
+ }
+
+ if (startPosition != -1) {
+ endPosition = str.indexOf("</service>", startPosition);
+
+ getSource().setStartPosition(startPosition);
+ getSource().setEndPosition(endPosition);
+ }
+ }
+
+ /**
+ * This method initializes the links.
+ */
+ public void initializeLinks() {
+
+ // Work through actions requesting them to
+ // establish their links
+ for (int i=0; i < m_actions.size(); i++) {
+ m_actions.get(i).initializeLinks();
+ }
+ }
+
+ /**
+ * This method validates the ESB service and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ // Check that the service specifies a session
+ if (isSessionBased() && getSessionClass() == null) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_SESSION_CLASS",
+ new String[]{}), null);
+ }
+
+ for (int i=0; i < m_actions.size(); i++) {
+ m_actions.get(i).validate(l);
+ }
+ }
+
+ /**
+ * This method returns the ESB model.
+ *
+ * @return The ESB model
+ */
+ public ESBLanguageModel getModel() {
+ return(m_model);
+ }
+
+ /**
+ * This method returns the category associated with the service
+ * descriptor.
+ *
+ * @return The service category
+ */
+ public String getCategory() {
+ return(m_service.getAttribute("category"));
+ }
+
+ /**
+ * This method returns the name associated with the service
+ * descriptor.
+ *
+ * @return The service name
+ */
+ public String getName() {
+ return(m_service.getAttribute("name"));
+ }
+
+ /**
+ * This method returns the XML configuration representation of the service.
+ *
+ * @return The XML configuration for the service
+ */
+ public org.w3c.dom.Element getService() {
+ return(m_service);
+ }
+
+ /**
+ * This method returns the list of ESB actions.
+ *
+ * @return The ESB actions
+ */
+ public java.util.List<ESBAction> getActions() {
+ return(m_actions);
+ }
+
+ protected java.lang.annotation.Annotation getServiceAnnotation(String session) {
+ java.lang.annotation.Annotation ret=null;
+
+ try {
+ ClassLoader cl=getServiceClassLoader();
+
+ Class<?> cls=Class.forName(session, true, cl);
+
+ // TODO: This should be replaced by direct lookup
+ // of Service annotation - but library not available
+ // at the moment
+ java.lang.annotation.Annotation[] annotations=
+ cls.getAnnotations();
+ for (int i=0; ret == null &&
+ i < annotations.length; i++) {
+ try {
+ if (annotations[i].annotationType().getName().equals(
+ "org.jboss.soa.overlord.jbossesb.actions.Service")) {
+ ret = annotations[i];
+ }
+ } catch(Throwable ex) {
+ // Ignore
+ System.err.println("ANNOTATION: "+annotations[i].annotationType());
+ ex.printStackTrace();
+ }
+ }
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get session class '"+session+"'", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the ESB service represents a
+ * loop construct.
+ *
+ * @return Whether the service represents a loop
+ */
+ public boolean isLoop() {
+ boolean ret=false;
+
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ ret = action.isLoop();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the ESB service descriptor represents
+ * a 'root' conversation.
+ *
+ * @return Whether the ESB service is associated with a root conversation
+ */
+ public boolean isRoot() {
+ boolean ret=false;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null && action.getActionClass() != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
+ String bool=action.getPropertyValue(ROOT_PROPERTY);
+ if (bool != null) {
+ ret = bool.equalsIgnoreCase("true");
+ } else {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("root", (Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof Boolean) {
+ ret = ((Boolean)val).booleanValue();
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'root' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service description name associated with the
+ * ESB service.
+ *
+ * @return The service description name
+ */
+ public String getServiceName() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS) ||
+ action.getActionClass().equals(RETRIEVE_SESSION_ACTION_CLASS)) {
+ ret = action.getPropertyValue(SERVICE_NAME_PROPERTY);
+
+ if (ret == null) {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("name", (Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof String) {
+ ret = (String)val;
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'name' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the conversation type associated with the
+ * ESB service.
+ *
+ * @return The conversation type
+ */
+ public String getConversationType() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
+ ret = action.getPropertyValue(CONVERSATION_TYPE_PROPERTY);
+
+ if (ret == null) {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("conversationType", (Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof String) {
+ ret = (String)val;
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'name' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the session name associated with the service
+ * descriptor.
+ *
+ * @return The session name
+ */
+ public String getSessionName() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null &&
+ action.getActionClass().startsWith(ACTION_PACKAGE)) {
+ ret = action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the session class associated with the service
+ * descriptor.
+ *
+ * @return The session class
+ */
+ public Class<?> getSessionClass() {
+ Class<?> ret=null;
+ String session=getSessionName();
+
+ if (session != null) {
+ try {
+ ClassLoader cl=getServiceClassLoader();
+
+ ret = Class.forName(session, true, cl);
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get session class '"+session+"'", e);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the service is related to a behavioural
+ * session.
+ *
+ * @return Whether the service is session based
+ */
+ public boolean isSessionBased() {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < m_actions.size(); i++) {
+ ret = m_actions.get(i).isSessionBased();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method converts the actions associated with the ESB service into
+ * activities that can be checked for conformance against a conversation
+ * type.
+ *
+ * @param activities The target list of activities associated with the
+ * ESB actions being converted
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+
+ context.processing(this);
+
+ for (int i=0; i < m_actions.size(); i++) {
+ ((ESBAction)m_actions.get(i)).convert(activities, context);
+ }
+
+ context.processed(this);
+ }
+
+ /**
+ * This method returns the position of the service node within the
+ * ESB configuration.
+ *
+ * @return The service node position
+ */
+ public int getServicePosition() {
+ org.w3c.dom.Node services=m_service.getParentNode();
+ int servCount=0;
+ boolean f_end=false;
+
+ for (int i=0; f_end == false &&
+ i < services.getChildNodes().getLength(); i++) {
+ org.w3c.dom.Node serv=services.getChildNodes().item(i);
+
+ if (serv.getNodeName().equals(SERVICE_ELEMENT)) {
+ servCount++;
+ if (serv == m_service) {
+ f_end = true;
+ }
+ }
+ }
+
+ return(servCount);
+ }
+
+ /**
+ * This method returns a custom classloader that uses the project's
+ * classpath to locate classes referenced by the ESB config file.
+ *
+ * @see http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg17769.html
+ *
+ * @return The classloader
+ * @throws Exception Failed to obtain the classloader
+ */
+ public ClassLoader getServiceClassLoader() throws Exception {
+ java.net.URLClassLoader classLoader=null;
+ IFile file=OSGIModelRepository.getFile(getModel().getModelReference());
+
+ if (file != null) {
+ IJavaProject javaProject=JavaCore.create(file.getProject());
+ IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
+ String wsPath = javaProject.getProject().getLocation().toPortableString();
+ String firstEntryLocation = javaProject.getPath().toPortableString();
+ int idx = wsPath.indexOf(firstEntryLocation);
+ wsPath = wsPath.substring(0,idx);
+
+ String fullPath = null;
+
+ java.net.URL[] urls = new java.net.URL[entries.length+1];
+ int i = 0;
+ urls[i++] = new java.io.File(wsPath +
+ javaProject.getOutputLocation().toPortableString()).toURL();
+
+ for (IClasspathEntry entry : entries) {
+ if(entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IResource project =
+ ResourcesPlugin.getWorkspace().getRoot().findMember(entry.getPath());
+ String projectPath =
+ JavaCore.create(project.getProject()).getOutputLocation().toPortableString();
+ fullPath = wsPath + projectPath;
+ } else {
+ // TODO: Need to find alternative to this internal class (JavaModel)
+ Object resource =
+ JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(),entry.getPath(),true);
+
+ if (resource instanceof IResource) {
+ IResource iFile = (IResource) resource;
+ fullPath = iFile.getLocation().toPortableString();
+ } else if (resource instanceof java.io.File) {
+ java.io.File resfile = (java.io.File) resource;
+ fullPath = resfile.getAbsolutePath();
+ }
+ }
+
+ urls[i++] = new java.io.File(fullPath).toURL();
+ }
+
+ classLoader = new java.net.URLClassLoader(urls,String.class.getClassLoader());
+ }
+
+ return(classLoader);
+ }
+
+ public int hashCode() {
+ return(m_service.hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof DefaultESBService) {
+ DefaultESBService other=(DefaultESBService)obj;
+
+ if (m_service == other.m_service) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("ESBService: "+getCategory()+"/"+getName()+"["+getSource()+"]");
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ESBLanguageModel m_model=null;
+ private org.w3c.dom.Element m_service=null;
+ private java.util.List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
+}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -1,343 +0,0 @@
-/*
- * 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.jbossesb.model;
-
-import java.util.logging.Logger;
-
-import org.scribble.model.*;
-
-/**
- * This is the generic ESB action class.
- *
- * @author gary
- */
-public abstract class ESBAction extends ModelObject {
-
- private static final String ACTION_ELEMENT = "action";
- //private static final String SERVICE_ELEMENT = "service";
- private static final String VALUE_ATTR = "value";
- private static final String NAME_ATTR = "name";
- private static final String PROPERTY_ELEMENT = "property";
- private static final String CLASS_PROPERTY = "class";
-
- protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
-
- /**
- * The default constructor.
- */
- protected ESBAction() {
- }
-
- /**
- * This method initializes the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param action The XML configuration details for the action
- */
- protected void init(ESBService service,
- org.w3c.dom.Element action) {
- m_service = service;
- m_action = action;
-
- // Find positional information
- int servCount=m_service.getServicePosition();
- int actionCount=getActionPosition();
-
- String str=m_service.getModel().getContents();
-
- int startPosition=str.indexOf("<service ");
- int endPosition=-1;
-
- while (startPosition != -1 && servCount > 0) {
- servCount--;
-
- endPosition = str.indexOf("</service>", startPosition);
-
- if (servCount > 0) {
- startPosition=str.indexOf("<service ", endPosition);
- }
- }
-
- if (actionCount > 0 &&
- startPosition != -1 && endPosition != -1) {
- startPosition=str.indexOf("<action ", startPosition);
- endPosition=-1;
-
- while (startPosition != -1 && actionCount > 0) {
- actionCount--;
-
- endPosition = str.indexOf("</action>", startPosition);
-
- if (actionCount > 0) {
- startPosition=str.indexOf("<action ", endPosition);
- }
- }
- }
-
- getSource().setStartPosition(startPosition);
- getSource().setEndPosition(endPosition);
- }
-
- /**
- * This method initializes the links with the ESB service descriptors
- * identified in each path of the action.
- */
- protected void initializeLinks() {
- }
-
- /**
- * 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) {
-
- String[] mandatory=getMandatoryProperties();
-
- for (int i=0; i < mandatory.length; i++) {
- if (getPropertyValue(mandatory[i]) == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_SPECIFIED_PROPERTY",
- new String[]{mandatory[i]}), null);
- }
- }
-
- String session=getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- if (session != null) {
- // Validate that the business object type exists
- try {
- ClassLoader cl=getService().getProjectLoader();
-
- try {
- Class.forName(session, true, cl);
- } catch(ClassNotFoundException cfne) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_FOUND_BUSINESS_OBJECT_TYPE",
- new String[]{session}), null);
- }
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to load business class '"+session+"'", e);
- }
- }
-
- // Validate links
- for (int i=0; i < m_links.size(); i++) {
- ESBLink link=(ESBLink)m_links.get(i);
-
- if (link.getService() == null) {
- // If target service not found, then report error
- // unless it is a remote service, so defined in a
- // different file
- if (link.isRemote() == false) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_FOUND_SERVICE_DESCRIPTOR",
- new String[]{link.getCategory(),link.getName()}), null);
- }
- } else if (getService().getSessionName() != null &&
- isPerform() == false &&
- getService().getSessionName().equals(
- link.getService().getSessionName()) == false) {
-
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_MISMATCH_SESSION_CLASS",
- new String[]{link.getCategory(),link.getName()}), null);
- }
- }
- }
-
- /**
- * This method determines if the action represents a loop construct.
- *
- * @return Whether the action represents a loop construct
- */
- public boolean isLoop() {
- return(false);
- }
-
- /**
- * This method determines whether the action is related to a behavioural
- * session.
- *
- * @return Whether the action is session based
- */
- public boolean isSessionBased() {
- return(true);
- }
-
- /**
- * This method indicates whether this action performs another
- * sub-conversation.
- *
- * @return Whether the action is a 'perform'
- */
- public boolean isPerform() {
- return(false);
- }
-
- /**
- * This method returns the mandatory property names.
- *
- * @return The mandatory property names
- */
- protected String[] getMandatoryProperties() {
- return(new String[0]);
- }
-
- /**
- * This method returns the action's class name.
- *
- * @return The action's class name
- */
- public String getActionClass() {
- return(m_action.getAttribute(CLASS_PROPERTY));
- }
-
- /**
- * This method returns the property value associated
- * with the supplied name.
- *
- * @param property The property name
- * @return The property value, or null if not found
- */
- public String getPropertyValue(String property) {
- String ret=null;
-
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getAttribute(VALUE_ATTR);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the 'property' child nodes, associated with the
- * supplied property name, within the action configuration.
- *
- * @param property The property name
- * @return The list of child nodes
- */
- public org.w3c.dom.NodeList getPropertyChildNodes(String property) {
- org.w3c.dom.NodeList ret=null;
-
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getChildNodes();
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the reference to the service that contains the
- * action.
- *
- * @return The service
- */
- protected ESBService getService() {
- return(m_service);
- }
-
- /**
- * This method returns the XML configuration representation of the action.
- *
- * @return The XML configuration for the action
- */
- public org.w3c.dom.Element getAction() {
- return(m_action);
- }
-
- /**
- * This method returns the list of links established by this action.
- *
- * @return The list of links
- */
- protected java.util.List<ESBLink> getLinks() {
- return(m_links);
- }
-
- /**
- * This method converts the ESB action 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);
-
- /**
- * This method returns the node position of the action configuration
- * within the service descriptor.
- *
- * @return The action position
- */
- protected int getActionPosition() {
- org.w3c.dom.Element service=(org.w3c.dom.Element)
- getAction().getParentNode().getParentNode();
-
- int actionCount=0;
- boolean f_end=false;
-
- org.w3c.dom.NodeList acts=service.getElementsByTagName(ACTION_ELEMENT);
-
- for (int i=0; f_end == false &&
- i < acts.getLength(); i++) {
- org.w3c.dom.Node act=acts.item(i);
-
- actionCount++;
- if (act == getAction()) {
- f_end = true;
- }
- }
-
- return(actionCount);
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ESBService m_service=null;
- private org.w3c.dom.Element m_action=null;
- private java.util.List<ESBLink> m_links=new java.util.Vector<ESBLink>();
-}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,100 @@
+/*
+ * 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.jbossesb.model;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the generic ESB action class.
+ *
+ * @author gary
+ */
+public interface ESBAction {
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ public void initializeLinks();
+
+ /**
+ * 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 determines if the action represents a loop construct.
+ *
+ * @return Whether the action represents a loop construct
+ */
+ public boolean isLoop();
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased();
+
+ /**
+ * This method indicates whether this action performs another
+ * sub-conversation.
+ *
+ * @return Whether the action is a 'perform'
+ */
+ public boolean isPerform();
+
+ /**
+ * This method returns the action's class name.
+ *
+ * @return The action's class name
+ */
+ public String getActionClass();
+
+ /**
+ * This method returns the property value associated
+ * with the supplied name.
+ *
+ * @param property The property name
+ * @return The property value, or null if not found
+ */
+ public String getPropertyValue(String property);
+
+ /**
+ * This method returns the XML configuration representation of the action.
+ *
+ * @return The XML configuration for the action
+ */
+ public org.w3c.dom.Element getAction();
+
+ /**
+ * This method converts the ESB action 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);
+
+}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -1,81 +0,0 @@
-/*
- * 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.jbossesb.model;
-
-import java.util.logging.Logger;
-
-/**
- * This class provides a factory for ESBAction instances.
- *
- * @author gary
- */
-public class ESBActionFactory {
-
- private static final String MODEL_ACTION_PACKAGE =
- "org.jboss.tools.overlord.jbossesb.model.actions";
- private static final String CLASS_ATTR = "class";
- private static final String CONVERSATION_ACTION_PACKAGE =
- "org.jboss.soa.overlord.jbossesb.actions";
-
- /**
- * This method creates an ESBAction instance relevant to the
- * supplied JBossESB action, associated with the supplied
- * service.
- *
- * @param service The service
- * @param action The XML configuration of the action
- * @return The ESBAction instance
- */
- public static ESBAction createAction(ESBService service,
- org.w3c.dom.Element action) {
- ESBAction ret=null;
- String actionType=action.getAttribute(CLASS_ATTR);
-
- // Check that it is a conversation based ESB action
- if (actionType.startsWith(CONVERSATION_ACTION_PACKAGE)) {
- int index=actionType.lastIndexOf('.');
- if (index != -1) {
- String actionName=actionType.substring(index+1);
-
- try {
- Class<?> cls=(Class<?>)
- Class.forName(MODEL_ACTION_PACKAGE+"."+actionName);
-
- ret = (ESBAction)cls.newInstance();
-
- ret.init(service, action);
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Unable to find action class '"+
- MODEL_ACTION_PACKAGE+"."+actionName+"'", e);
- }
- }
- }
-
- if (ret == null) {
- // Unrecognised or unsupported action
- ret = new UnsupportedAction();
- ret.init(service, action);
- }
-
- return(ret);
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.actions.UnsupportedAction;
+
+/**
+ * This class provides a factory for ESBAction instances.
+ *
+ * @author gary
+ */
+public class ESBActionFactory {
+
+ private static final String MODEL_ACTION_PACKAGE =
+ "org.jboss.tools.overlord.jbossesb.model.actions";
+ private static final String CLASS_ATTR = "class";
+ private static final String CONVERSATION_ACTION_PACKAGE =
+ "org.jboss.soa.overlord.jbossesb.actions";
+
+ /**
+ * This method creates an ESBAction instance relevant to the
+ * supplied JBossESB action, associated with the supplied
+ * service.
+ *
+ * @param service The service
+ * @param action The XML configuration of the action
+ * @return The ESBAction instance
+ */
+ public static ESBAction createAction(ESBService service,
+ org.w3c.dom.Element action) {
+ ESBAction ret=null;
+ String actionType=action.getAttribute(CLASS_ATTR);
+
+ // Check that it is a conversation based ESB action
+ if (actionType.startsWith(CONVERSATION_ACTION_PACKAGE)) {
+ int index=actionType.lastIndexOf('.');
+ if (index != -1) {
+ String actionName=actionType.substring(index+1);
+
+ try {
+ Class<?> cls=(Class<?>)
+ Class.forName(MODEL_ACTION_PACKAGE+"."+actionName);
+
+ java.lang.reflect.Constructor<?> con=
+ cls.getConstructor(new Class<?>[]{ESBService.class,
+ org.w3c.dom.Element.class});
+
+ ret = (ESBAction)con.newInstance(new Object[]{service, action});
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Unable to find action class '"+
+ MODEL_ACTION_PACKAGE+"."+actionName+"'", e);
+ }
+ }
+ }
+
+ if (ret == null) {
+ // Unrecognised or unsupported action
+ ret = new UnsupportedAction(service, action);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,11 +17,6 @@
*/
package org.jboss.tools.overlord.jbossesb.model;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryFactory;
import org.scribble.model.*;
/**
@@ -29,232 +24,26 @@
*
* @author gary
*/
-public class ESBLanguageModel extends org.scribble.lang.model.LanguageModel {
+public interface ESBLanguageModel {
- private static final String SERVICE_ELEMENT = "service";
- private static final String SERVICES_ELEMENT = "services";
-
public static final String JBOSSESB_NOTATION = "jboss-esb.xml";
/**
- * This constructor is initialized with the ESB configuration.
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
*
- * @param source The model reference for the JBossESB configuration source
- * @param elem The ESB configuration
- * @param contents The textual contents
+ * @param l The model listener
*/
- public ESBLanguageModel(ModelReference source, org.w3c.dom.Element elem,
- String contents) {
- m_source = source;
- m_esbConfig = elem;
- m_contents = contents;
-
- // Extract service action pipelines
- initialize();
- }
+ public void validate(ModelListener l);
/**
- * This method initializes the ESB Model.
- */
- protected void initialize() {
- org.w3c.dom.NodeList services=
- m_esbConfig.getElementsByTagName(SERVICES_ELEMENT);
-
- org.scribble.model.DependencyManager dm=
- (org.scribble.model.DependencyManager)
- org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
- org.scribble.model.DependencyManager.class, null);
-
- ModelName mname=new ModelName();
- mname.setName(m_source.getLocalpart());
-
- setModelName(mname);
-
- Namespace ns=new Namespace();
- ns.setName(m_source.getNamespace());
- setNamespace(ns);
-
- if (services != null && services.getLength() == 1 &&
- services.item(0) instanceof org.w3c.dom.Element) {
- org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
- services.item(0)).getChildNodes();
-
- for (int i=0; i < nl.getLength(); i++) {
-
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(SERVICE_ELEMENT)) {
-
- ESBService service=new ESBService(this,
- (org.w3c.dom.Element)nl.item(i));
- String key=getKey(service.getCategory(),
- service.getName());
-
- m_services.put(key, service);
- }
- }
-
- java.util.Iterator<ESBService> iter=m_services.values().iterator();
-
- while (iter.hasNext()) {
- iter.next().initializeLinks();
- }
-
- // Initialize the conversations
- java.util.Iterator<ESBService> serviter=getServices().iterator();
-
- while (serviter.hasNext()) {
- ESBService service=serviter.next();
-
- if (service.isRoot()) {
- Conversation conv=new Conversation();
-
- ModelName modelName=new ModelName();
- modelName.setName(service.getServiceName());
-
- conv.setModelName(modelName);
-
- String convType=service.getConversationType();
- if (convType != null) {
- int index=convType.indexOf('@');
-
- if (index != -1) {
- // TODO: Need to think whether this should be
- // 'implements' reference. If so, then need to change
- // Java Lang Model parser and also Lang Model conformance
- // rule.
- ImplementsReference iref=
- new ImplementsReference(ConversationModel.CONVERSATION);
- //ConformanceReference iref=
- // new ConformanceReference(ConversationModel.CONVERSATION);
-
- iref.setLocatedRole(convType.substring(index+1));
-
- // Need to locate the model name
- modelName.setLocatedRole(new Role(iref.getLocatedRole()));
-
- String mainpart=convType.substring(0, index);
-
- index = mainpart.lastIndexOf(".");
-
- if (index == -1) {
- iref.setNamespace("");
- iref.setLocalpart(mainpart);
- } else {
- iref.setNamespace(mainpart.substring(0, index));
- iref.setLocalpart(mainpart.substring(index+1));
- }
-
- conv.getImplements().add(iref);
- //conv.getConformsTo().add(iref);
-
- dm.recordDependency(m_source, iref,
- DependencyType.Implements);
-
- } else {
- logger.warning("Conversation type does not " +
- "contain '@' located role separator");
- }
- } else {
- logger.warning("No conversation type specified");
- }
-
- // TODO: Associate a conformance reference for the
- // conversation type - when using Scribble dependency
- // management, this will ensure appropriate validation
- // when either the dependent conversation is changed, or
- // the ESB config file changed.
- //ConformanceReference confRef=new ConformanceReference();
-
- //conv.getConformsTo().add(confRef);
-
- conv.setBlock(new Block());
-
- service.convert(conv.getBlock().getContents(),
- new DefaultConversionContext());
-
- getConversations().add(conv);
- }
- }
- }
-
- if (logger.isLoggable(java.util.logging.Level.FINEST)) {
-
- org.scribble.export.Exporter exporter=
- (org.scribble.export.Exporter)
- RegistryFactory.getRegistry().getExtension(
- org.scribble.export.Exporter.class, null);
-
- try {
- for (int i=0; i < getConversations().size(); i++) {
- ConversationModel model=new ConversationModel();
-
- model.setConversation(getConversations().get(i));
-
- org.scribble.export.text.TextFormatter formatter=
- new org.scribble.export.text.TextFormatter();
-
- java.io.ByteArrayOutputStream os=
- new java.io.ByteArrayOutputStream();
-
- formatter.setOutputStream(os);
-
- exporter.export(model, formatter);
-
- String str=new String(os.toByteArray());
-
- System.out.println("EXPORTED JBOSS-ESB TEXT:");
- System.out.println(str);
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public String getNotation() {
- return(JBOSSESB_NOTATION);
- }
-
- /**
* This method returns the source model reference.
*
* @return The source model reference
*/
- public ModelReference getModelReference() {
- return(m_source);
- }
+ public ModelReference getModelReference();
/**
- * Generate a key for use in accessing the service related to
- * the supplied category and name.
- *
- * @param category The category
- * @param name The service name
- * @return The key
- */
- protected String getKey(String category, String name) {
- return(category+"/"+name);
- }
-
- /**
- * This method validates the ESB model and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- public void validate(ModelListener l) {
-
- java.util.Iterator<ESBService> iter=m_services.values().iterator();
-
- while (iter.hasNext()) {
- ESBService service=iter.next();
-
- service.validate(l);
- }
- }
-
- /**
* This method returns the ESB service for the supplied
* category and name.
*
@@ -262,9 +51,7 @@
* @param name The service name
* @return The ESB service, or null if not found
*/
- public ESBService getService(String category, String name) {
- return(m_services.get(getKey(category, name)));
- }
+ public ESBService getService(String category, String name);
/**
* This method returns the collection of ESB services associated
@@ -272,67 +59,13 @@
*
* @return The collection of ESB services
*/
- public java.util.Collection<ESBService> getServices() {
- return(m_services.values());
- }
+ public java.util.Collection<ESBService> getServices();
/**
* This textual contents of the model.
*
* @return The textual contents
*/
- protected String getContents() {
- return(m_contents);
- }
+ public String getContents();
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ModelReference m_source=null;
- private org.w3c.dom.Element m_esbConfig=null;
- private String m_contents=null;
- private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
-
- public class InnerModelListener implements ModelListener {
-
- public InnerModelListener(ModelListener l) {
- m_listener = l;
- }
-
- public void error(ModelObject src, String mesg, Properties props) {
-
- if (props == null) {
- props = new Properties();
- }
-
- props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
- props.put(ModelListener.REFERENCE_MODEL, m_source);
- props.put(ModelListener.REFERENCE_MODEL_START_POSITION, src.getSource().getStartPosition());
- props.put(ModelListener.REFERENCE_MODEL_END_POSITION, src.getSource().getEndPosition());
- if (src.getSource().getComponent() != null) {
- props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
- src.getSource().getComponent());
- }
-
- m_listener.error(src, mesg, props);
- }
-
- public void warning(ModelObject src, String mesg, Properties props) {
- if (props == null) {
- props = new Properties();
- }
-
- props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
- props.put(ModelListener.REFERENCE_MODEL, m_source);
- props.put(ModelListener.REFERENCE_MODEL_START_POSITION, src.getSource().getStartPosition());
- props.put(ModelListener.REFERENCE_MODEL_END_POSITION, src.getSource().getEndPosition());
- if (src.getSource().getComponent() != null) {
- props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
- src.getSource().getComponent());
- }
-
- m_listener.warning(src, mesg, props);
- }
-
- private ModelListener m_listener=null;
- }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,109 +17,19 @@
*/
package org.jboss.tools.overlord.jbossesb.model;
-//import org.eclipse.jdt.core.IJavaElement;
-//import org.eclipse.jdt.core.dom.*;
-import java.util.logging.Logger;
-
-import org.eclipse.jdt.core.*;
-import org.eclipse.core.resources.*;
-
-// TODO: Need to find alternative to JavaModel
-import org.eclipse.jdt.internal.core.*;
-
-
import org.scribble.model.*;
-import org.scribble.osgi.model.*;
/**
- * This class represents an ESB service.
+ * This interface represents an ESB service.
*
* @author gary
*/
-public class ESBService extends ModelObject {
+public interface ESBService {
- private static final String SERVICE_ELEMENT = "service";
- private static final String SERVICE_NAME_PROPERTY = "serviceName";
- private static final String ROOT_PROPERTY = "root";
- private static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
- private static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
- private static final String ACTION_PACKAGE = "org.jboss.soa.overlord.jbossesb.actions.";
- private static final String CREATE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.CreateSessionAction";
- private static final String RETRIEVE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
- private static final String ACTION_ELEMENT = "action";
- private static final String ACTIONS_ELEMENT = "actions";
-
/**
- * This is the constructor for the ESB service.
- *
- * @param model The ESB model in which the service has been defined
- * @param service The XML configuration of the service
- */
- protected ESBService(ESBLanguageModel model, org.w3c.dom.Element service) {
- m_model = model;
- m_service = service;
-
- initialize();
- }
-
- /**
- * This method initializes the service.
- */
- protected void initialize() {
- // Check if relevant action
- org.w3c.dom.NodeList actions=m_service.getElementsByTagName(ACTIONS_ELEMENT);
-
- if (actions != null && actions.getLength() == 1 &&
- actions.item(0) instanceof org.w3c.dom.Element) {
- org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
- actions.item(0)).getChildNodes();
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(ACTION_ELEMENT)) {
- m_actions.add(ESBActionFactory.createAction(this,
- ((org.w3c.dom.Element)nl.item(i))));
- }
- }
- }
-
- // Find positional information
- int servCount=getServicePosition();
-
- String str=getModel().getContents();
-
- int startPosition=str.indexOf("<service ");
- int endPosition=-1;
-
- while (startPosition != -1 && servCount > 0) {
- servCount--;
-
- endPosition = str.indexOf("</service>", startPosition);
-
- if (servCount > 0) {
- startPosition=str.indexOf("<service ", endPosition);
- }
- }
-
- if (startPosition != -1) {
- endPosition = str.indexOf("</service>", startPosition);
-
- getSource().setStartPosition(startPosition);
- getSource().setEndPosition(endPosition);
- }
- }
-
- /**
* This method initializes the links.
*/
- protected void initializeLinks() {
-
- // Work through actions requesting them to
- // establish their links
- for (int i=0; i < m_actions.size(); i++) {
- m_actions.get(i).initializeLinks();
- }
- }
+ public void initializeLinks();
/**
* This method validates the ESB service and reports warnings or
@@ -127,40 +37,15 @@
*
* @param l The model listener
*/
- public void validate(ModelListener l) {
-
- // Check that the service specifies a session
- if (isSessionBased() && getSessionClass() == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_SPECIFIED_SESSION_CLASS",
- new String[]{}), null);
- }
-
- for (int i=0; i < m_actions.size(); i++) {
- m_actions.get(i).validate(l);
- }
- }
+ public void validate(ModelListener l);
/**
- * This method returns the ESB model.
- *
- * @return The ESB model
- */
- public ESBLanguageModel getModel() {
- return(m_model);
- }
-
- /**
* This method returns the category associated with the service
* descriptor.
*
* @return The service category
*/
- public String getCategory() {
- return(m_service.getAttribute("category"));
- }
+ public String getCategory();
/**
* This method returns the name associated with the service
@@ -168,88 +53,36 @@
*
* @return The service name
*/
- public String getName() {
- return(m_service.getAttribute("name"));
- }
+ public String getName();
/**
+ * This method returns the ESB model.
+ *
+ * @return The ESB model
+ */
+ public ESBLanguageModel getModel();
+
+ /**
* This method returns the XML configuration representation of the service.
*
* @return The XML configuration for the service
*/
- public org.w3c.dom.Element getService() {
- return(m_service);
- }
+ public org.w3c.dom.Element getService();
/**
* This method returns the list of ESB actions.
*
* @return The ESB actions
*/
- public java.util.List<ESBAction> getActions() {
- return(m_actions);
- }
+ public java.util.List<ESBAction> getActions();
- protected java.lang.annotation.Annotation getServiceAnnotation(String session) {
- java.lang.annotation.Annotation ret=null;
-
- try {
- ClassLoader cl=getProjectLoader();
-
- Class<?> cls=Class.forName(session, true, cl);
-
- // TODO: This should be replaced by direct lookup
- // of Service annotation - but library not available
- // at the moment
- java.lang.annotation.Annotation[] annotations=
- cls.getAnnotations();
- for (int i=0; ret == null &&
- i < annotations.length; i++) {
- try {
- if (annotations[i].annotationType().getName().equals(
- "org.jboss.soa.overlord.jbossesb.actions.Service")) {
- ret = annotations[i];
- }
- } catch(Throwable ex) {
- // Ignore
- System.err.println("ANNOTATION: "+annotations[i].annotationType());
- ex.printStackTrace();
- }
- }
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get session class '"+session+"'", e);
- }
-
- return(ret);
- }
-
/**
* This method determines whether the ESB service represents a
* loop construct.
*
* @return Whether the service represents a loop
*/
- public boolean isLoop() {
- boolean ret=false;
-
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- ret = action.isLoop();
- }
-
- return(ret);
- }
+ public boolean isLoop();
/**
* This method determines whether the ESB service descriptor represents
@@ -257,50 +90,7 @@
*
* @return Whether the ESB service is associated with a root conversation
*/
- public boolean isRoot() {
- boolean ret=false;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
- String bool=action.getPropertyValue(ROOT_PROPERTY);
- if (bool != null) {
- ret = bool.equalsIgnoreCase("true");
- } else {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("root", (Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof Boolean) {
- ret = ((Boolean)val).booleanValue();
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'root' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public boolean isRoot();
/**
* This method returns the service description name associated with the
@@ -308,50 +98,7 @@
*
* @return The service description name
*/
- public String getServiceName() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS) ||
- action.getActionClass().equals(RETRIEVE_SESSION_ACTION_CLASS)) {
- ret = action.getPropertyValue(SERVICE_NAME_PROPERTY);
-
- if (ret == null) {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("name", (Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof String) {
- ret = (String)val;
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'name' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public String getServiceName();
/**
* This method returns the conversation type associated with the
@@ -359,49 +106,7 @@
*
* @return The conversation type
*/
- public String getConversationType() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
- ret = action.getPropertyValue(CONVERSATION_TYPE_PROPERTY);
-
- if (ret == null) {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("conversationType", (Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof String) {
- ret = (String)val;
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'name' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public String getConversationType();
/**
* This method returns the session name associated with the service
@@ -409,25 +114,7 @@
*
* @return The session name
*/
- public String getSessionName() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null &&
- action.getActionClass().startsWith(ACTION_PACKAGE)) {
- ret = action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
- }
-
- return(ret);
- }
+ public String getSessionName();
/**
* This method returns the session class associated with the service
@@ -435,40 +122,15 @@
*
* @return The session class
*/
- public Class<?> getSessionClass() {
- Class<?> ret=null;
- String session=getSessionName();
-
- if (session != null) {
- try {
- ClassLoader cl=getProjectLoader();
-
- ret = Class.forName(session, true, cl);
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get session class '"+session+"'", e);
- }
- }
-
- return(ret);
- }
-
+ public Class<?> getSessionClass();
+
/**
* This method determines whether the service is related to a behavioural
* session.
*
* @return Whether the service is session based
*/
- public boolean isSessionBased() {
- boolean ret=false;
-
- for (int i=0; ret == false && i < m_actions.size(); i++) {
- ret = m_actions.get(i).isSessionBased();
- }
-
- return(ret);
- }
+ public boolean isSessionBased();
/**
* This method converts the actions associated with the ESB service into
@@ -480,16 +142,7 @@
* @param context The conversion context
*/
public void convert(java.util.List<Activity> activities,
- ConversionContext context) {
-
- context.processing(this);
-
- for (int i=0; i < m_actions.size(); i++) {
- ((ESBAction)m_actions.get(i)).convert(activities, context);
- }
-
- context.processed(this);
- }
+ ConversionContext context);
/**
* This method returns the position of the service node within the
@@ -497,26 +150,8 @@
*
* @return The service node position
*/
- protected int getServicePosition() {
- org.w3c.dom.Node services=m_service.getParentNode();
- int servCount=0;
- boolean f_end=false;
+ public int getServicePosition();
- for (int i=0; f_end == false &&
- i < services.getChildNodes().getLength(); i++) {
- org.w3c.dom.Node serv=services.getChildNodes().item(i);
-
- if (serv.getNodeName().equals(SERVICE_ELEMENT)) {
- servCount++;
- if (serv == m_service) {
- f_end = true;
- }
- }
- }
-
- return(servCount);
- }
-
/**
* This method returns a custom classloader that uses the project's
* classpath to locate classes referenced by the ESB config file.
@@ -526,80 +161,6 @@
* @return The classloader
* @throws Exception Failed to obtain the classloader
*/
- protected ClassLoader getProjectLoader() throws Exception {
- java.net.URLClassLoader classLoader=null;
- IFile file=OSGIModelRepository.getFile(getModel().getModelReference());
-
- if (file != null) {
- IJavaProject javaProject=JavaCore.create(file.getProject());
- IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
- String wsPath = javaProject.getProject().getLocation().toPortableString();
- String firstEntryLocation = javaProject.getPath().toPortableString();
- int idx = wsPath.indexOf(firstEntryLocation);
- wsPath = wsPath.substring(0,idx);
-
- String fullPath = null;
-
- java.net.URL[] urls = new java.net.URL[entries.length+1];
- int i = 0;
- urls[i++] = new java.io.File(wsPath +
- javaProject.getOutputLocation().toPortableString()).toURL();
+ public ClassLoader getServiceClassLoader() throws Exception;
- for (IClasspathEntry entry : entries) {
- if(entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IResource project =
- ResourcesPlugin.getWorkspace().getRoot().findMember(entry.getPath());
- String projectPath =
- JavaCore.create(project.getProject()).getOutputLocation().toPortableString();
- fullPath = wsPath + projectPath;
- } else {
- // TODO: Need to find alternative to this internal class (JavaModel)
- Object resource =
- JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(),entry.getPath(),true);
-
- if (resource instanceof IResource) {
- IResource iFile = (IResource) resource;
- fullPath = iFile.getLocation().toPortableString();
- } else if (resource instanceof java.io.File) {
- java.io.File resfile = (java.io.File) resource;
- fullPath = resfile.getAbsolutePath();
- }
- }
-
- urls[i++] = new java.io.File(fullPath).toURL();
- }
-
- classLoader = new java.net.URLClassLoader(urls,String.class.getClassLoader());
- }
-
- return(classLoader);
- }
-
- public int hashCode() {
- return(m_service.hashCode());
- }
-
- public boolean equals(Object obj) {
- boolean ret=false;
-
- if (obj instanceof ESBService) {
- ESBService other=(ESBService)obj;
-
- if (m_service == other.m_service) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- public String toString() {
- return("ESBService: "+getCategory()+"/"+getName()+"["+getSource()+"]");
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ESBLanguageModel m_model=null;
- private org.w3c.dom.Element m_service=null;
- private java.util.List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -1,52 +0,0 @@
-/*
- * 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.jbossesb.model;
-
-import org.scribble.model.*;
-
-/**
- * This class represents an unsupported (or custom) action within
- * the conversation based ESB service descriptor.
- *
- * @author gary
- */
-public class UnsupportedAction extends ESBAction {
-
- /**
- * This method determines whether the action is related to a behavioural
- * session.
- *
- * @return Whether the action is session based
- */
- public boolean isSessionBased() {
- return(false);
- }
-
- /**
- * This method converts the ESB action 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.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,359 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.jboss.tools.overlord.jbossesb.model.*;
+
+/**
+ * This is the generic ESB action class.
+ *
+ * @author gary
+ */
+public abstract class AbstractESBAction extends ModelObject
+ implements ESBAction {
+
+ private static final String ACTION_ELEMENT = "action";
+ //private static final String SERVICE_ELEMENT = "service";
+ private static final String VALUE_ATTR = "value";
+ private static final String NAME_ATTR = "name";
+ private static final String PROPERTY_ELEMENT = "property";
+ private static final String CLASS_PROPERTY = "class";
+
+ protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
+
+ /**
+ * The default constructor.
+ */
+ protected AbstractESBAction(ESBService service,
+ org.w3c.dom.Element action) {
+ init(service, action);
+ }
+
+ /**
+ * This method initializes the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ protected void init(ESBService service,
+ org.w3c.dom.Element action) {
+ m_service = service;
+ m_action = action;
+
+ if (m_service.getModel() != null &&
+ m_service.getModel().getContents() != null) {
+
+ // Find positional information
+ int servCount=m_service.getServicePosition();
+ int actionCount=getActionPosition();
+
+ String str=m_service.getModel().getContents();
+
+ int startPosition=str.indexOf("<service ");
+ int endPosition=-1;
+
+ while (startPosition != -1 && servCount > 0) {
+ servCount--;
+
+ endPosition = str.indexOf("</service>", startPosition);
+
+ if (servCount > 0) {
+ startPosition=str.indexOf("<service ", endPosition);
+ }
+ }
+
+ if (actionCount > 0 &&
+ startPosition != -1 && endPosition != -1) {
+ startPosition=str.indexOf("<action ", startPosition);
+ endPosition=-1;
+
+ while (startPosition != -1 && actionCount > 0) {
+ actionCount--;
+
+ endPosition = str.indexOf("</action>", startPosition);
+
+ if (actionCount > 0) {
+ startPosition=str.indexOf("<action ", endPosition);
+ }
+ }
+ }
+
+ getSource().setStartPosition(startPosition);
+ getSource().setEndPosition(endPosition);
+ }
+ }
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ public void initializeLinks() {
+ }
+
+ /**
+ * 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) {
+
+ String[] mandatory=getMandatoryProperties();
+
+ for (int i=0; i < mandatory.length; i++) {
+ if (getPropertyValue(mandatory[i]) == null) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{mandatory[i]}), null);
+ }
+ }
+
+ String session=getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ if (session != null) {
+ // Validate that the business object type exists
+ try {
+ ClassLoader cl=getService().getServiceClassLoader();
+
+ try {
+ Class.forName(session, true, cl);
+ } catch(ClassNotFoundException cfne) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_BUSINESS_OBJECT_TYPE",
+ new String[]{session}), null);
+ }
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to load business class '"+session+"'", e);
+ }
+ }
+
+ // Validate links
+ for (int i=0; i < m_links.size(); i++) {
+ ESBLink link=(ESBLink)m_links.get(i);
+
+ if (link.getService() == null) {
+ // If target service not found, then report error
+ // unless it is a remote service, so defined in a
+ // different file
+ if (link.isRemote() == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{link.getCategory(),link.getName()}), null);
+ }
+ } else if (getService().getSessionName() != null &&
+ isPerform() == false &&
+ getService().getSessionName().equals(
+ link.getService().getSessionName()) == false) {
+
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_MISMATCH_SESSION_CLASS",
+ new String[]{link.getCategory(),link.getName()}), null);
+ }
+ }
+ }
+
+ /**
+ * This method determines if the action represents a loop construct.
+ *
+ * @return Whether the action represents a loop construct
+ */
+ public boolean isLoop() {
+ return(false);
+ }
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased() {
+ return(true);
+ }
+
+ /**
+ * This method indicates whether this action performs another
+ * sub-conversation.
+ *
+ * @return Whether the action is a 'perform'
+ */
+ public boolean isPerform() {
+ return(false);
+ }
+
+ /**
+ * This method returns the mandatory property names.
+ *
+ * @return The mandatory property names
+ */
+ protected String[] getMandatoryProperties() {
+ return(new String[0]);
+ }
+
+ /**
+ * This method returns the action's class name.
+ *
+ * @return The action's class name
+ */
+ public String getActionClass() {
+ String ret=null;
+
+ if (m_action != null) {
+ ret = m_action.getAttribute(CLASS_PROPERTY);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the property value associated
+ * with the supplied name.
+ *
+ * @param property The property name
+ * @return The property value, or null if not found
+ */
+ public String getPropertyValue(String property) {
+ String ret=null;
+
+ if (m_action != null) {
+ org.w3c.dom.NodeList nl=m_action.getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
+ ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
+ equals(property)) {
+ ret = ((org.w3c.dom.Element)nl.item(i)).getAttribute(VALUE_ATTR);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the 'property' child nodes, associated with the
+ * supplied property name, within the action configuration.
+ *
+ * @param property The property name
+ * @return The list of child nodes
+ */
+ public org.w3c.dom.NodeList getPropertyChildNodes(String property) {
+ org.w3c.dom.NodeList ret=null;
+
+ org.w3c.dom.NodeList nl=m_action.getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
+ ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
+ equals(property)) {
+ ret = ((org.w3c.dom.Element)nl.item(i)).getChildNodes();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the reference to the service that contains the
+ * action.
+ *
+ * @return The service
+ */
+ protected ESBService getService() {
+ return(m_service);
+ }
+
+ /**
+ * This method returns the XML configuration representation of the action.
+ *
+ * @return The XML configuration for the action
+ */
+ public org.w3c.dom.Element getAction() {
+ return(m_action);
+ }
+
+ /**
+ * This method returns the list of links established by this action.
+ *
+ * @return The list of links
+ */
+ protected java.util.List<ESBLink> getLinks() {
+ return(m_links);
+ }
+
+ /**
+ * This method converts the ESB action 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);
+
+ /**
+ * This method returns the node position of the action configuration
+ * within the service descriptor.
+ *
+ * @return The action position
+ */
+ protected int getActionPosition() {
+ org.w3c.dom.Element service=(org.w3c.dom.Element)
+ getAction().getParentNode().getParentNode();
+
+ int actionCount=0;
+ boolean f_end=false;
+
+ org.w3c.dom.NodeList acts=service.getElementsByTagName(ACTION_ELEMENT);
+
+ for (int i=0; f_end == false &&
+ i < acts.getLength(); i++) {
+ org.w3c.dom.Node act=acts.item(i);
+
+ actionCount++;
+ if (act == getAction()) {
+ f_end = true;
+ }
+ }
+
+ return(actionCount);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ESBService m_service=null;
+ private org.w3c.dom.Element m_action=null;
+ private java.util.List<ESBLink> m_links=new java.util.Vector<ESBLink>();
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -19,6 +19,7 @@
import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.ESBService;
import org.scribble.model.*;
/**
@@ -26,9 +27,21 @@
*
* @author gary
*/
-public class CreateSessionAction extends ESBAction {
+public class CreateSessionAction extends AbstractESBAction {
private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public CreateSessionAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
/**
* This method validates the ESB action and reports warnings or
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -19,8 +19,7 @@
import java.util.logging.Logger;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -28,11 +27,23 @@
*
* @author gary
*/
-public class GetVariableAction extends ESBAction {
+public class GetVariableAction extends AbstractESBAction {
private static final String VARIABLE = "variable";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public GetVariableAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class IfAction extends ESBAction {
+public class IfAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -39,11 +36,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public IfAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -35,7 +32,7 @@
*
* @author gary
*/
-public class MessageRouterAction extends ESBAction {
+public class MessageRouterAction extends AbstractESBAction {
private static final String INITIATE = "initiate";
private static final String SERVICE_NAME = "service-name";
@@ -44,11 +41,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public MessageRouterAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class ParallelAction extends ESBAction {
+public class ParallelAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -38,11 +35,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ParallelAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class PerformAction extends ESBAction {
+public class PerformAction extends AbstractESBAction {
private static final String SERVICE_NAME = "serviceName";
private static final String SERVICE_CATEGORY = "serviceCategory";
@@ -37,11 +34,23 @@
private static final String JOIN_SERVICE_CATEGORY = "joinServiceCategory";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public PerformAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
m_category=getPropertyValue(SERVICE_CATEGORY);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.conversation.model.*;
import org.scribble.model.*;
@@ -27,13 +26,25 @@
*
* @author gary
*/
-public class ReceiveMessageAction extends ESBAction {
+public class ReceiveMessageAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
private static final String MESSAGE_TYPE = "messageType";
private static final String OPERATION = "operation";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ReceiveMessageAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -26,11 +25,23 @@
*
* @author gary
*/
-public class RetrieveSessionAction extends ESBAction {
+public class RetrieveSessionAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public RetrieveSessionAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,9 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.jboss.tools.overlord.jbossesb.model.ESBService;
@@ -28,18 +26,30 @@
*
* @author gary
*/
-public class ScheduleStateAction extends ESBAction {
+public class ScheduleStateAction extends AbstractESBAction {
private static final String IMMEDIATE = "immediate";
private static final String SERVICE_NAME = "serviceName";
private static final String SERVICE_CATEGORY = "serviceCategory";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ScheduleStateAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
String serviceCategory=getPropertyValue(SERVICE_CATEGORY);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.conversation.model.*;
import org.scribble.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class SendMessageAction extends ESBAction {
+public class SendMessageAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
private static final String CLIENT_EPR = "clientEPR";
@@ -41,11 +38,23 @@
private static final String OPERATION = "operation";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SendMessageAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
String serviceCategory=getPropertyValue(SERVICE_CATEGORY);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -19,8 +19,7 @@
import java.util.logging.Logger;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -28,11 +27,23 @@
*
* @author gary
*/
-public class SetVariableAction extends ESBAction {
+public class SetVariableAction extends AbstractESBAction {
private static final String VARIABLE = "variable";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SetVariableAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class SwitchAction extends ESBAction {
+public class SwitchAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -37,11 +34,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SwitchAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java (from rev 92, cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,65 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.scribble.model.*;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class UnsupportedAction extends AbstractESBAction {
+
+ /**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public UnsupportedAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased() {
+ return(false);
+ }
+
+ /**
+ * This method converts the ESB action 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.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class WhenAction extends ESBAction {
+public class WhenAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -38,11 +35,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public WhenAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class WhileAction extends ESBAction {
+public class WhileAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -39,11 +36,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public WhileAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java 2008-07-01 11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -50,7 +50,7 @@
*/
public Model parse(ModelReference ref, InputStream is,
ModelListener l) {
- ESBLanguageModel ret=null;
+ DefaultESBLanguageModel ret=null;
org.scribble.model.DependencyManager dm=
(org.scribble.model.DependencyManager)
@@ -86,7 +86,7 @@
// Identify the model associated with the
// changed resource
- ret = new ESBLanguageModel(ref, doc.getDocumentElement(),
+ ret = new DefaultESBLanguageModel(ref, doc.getDocumentElement(),
new String(b));
} catch(Exception e) {
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,114 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+public class CreateSessionActionTest extends TestCase {
+
+ public void testValidateFirstAction() {
+ TestESBService service=new TestESBService();
+
+ UnsupportedAction unsupported=new UnsupportedAction(service, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, null);
+
+ service.getActions().add(action);
+ service.getActions().add(unsupported);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNotFirstAction() {
+ TestESBService service=new TestESBService();
+
+ UnsupportedAction unsupported=new UnsupportedAction(service, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, null);
+
+ service.getActions().add(unsupported);
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_MUST_BE_FIRST_ACTION",
+ new String[]{"CreateSession"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateRootNoConversationType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ l.addExpectedError(org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
+ "_NOT_SPECIFIED_CONVERSATION_TYPE",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateRootWithConversationType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+ props.put("conversationType", "test.Type");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.actions;
+
+public class ESBActionTestUtil {
+
+ public static org.w3c.dom.Element getAction(String actionClass,
+ java.util.Map<String,String> simpleProps,
+ java.util.Map<String,org.w3c.dom.Element> customProps) {
+
+ org.w3c.dom.Element ret=null;
+
+ // Create an empty document
+ try {
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.
+ newInstance().newDocumentBuilder().newDocument();
+
+ if (doc != null) {
+ ret = doc.createElement("action");
+
+ if (actionClass != null) {
+ ret.setAttribute("class", actionClass);
+ }
+
+ if (simpleProps != null) {
+ java.util.Iterator<String> props=simpleProps.keySet().iterator();
+
+ while (props.hasNext()) {
+ String key=props.next();
+ String value=simpleProps.get(key);
+
+ org.w3c.dom.Element property=ret.getOwnerDocument().createElement("property");
+ ret.appendChild(property);
+
+ property.setAttribute("name", key);
+ property.setAttribute("value", value);
+ }
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,120 @@
+/*
+ * 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.jbossesb.model.actions;
+
+import java.util.List;
+
+import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
+import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.scribble.model.Activity;
+import org.scribble.model.ModelListener;
+import org.w3c.dom.Element;
+
+public class TestESBService implements org.jboss.tools.overlord.jbossesb.model.ESBService {
+
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<ESBAction> getActions() {
+ return(m_actions);
+ }
+
+ public String getCategory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getConversationType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ESBLanguageModel getModel() {
+ return(m_model);
+ }
+
+ public Element getService() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ClassLoader getServiceClassLoader() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getServiceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getServicePosition() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Class<?> getSessionClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getSessionName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void initializeLinks() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isLoop() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setRoot(boolean bool) {
+ m_root = bool;
+ }
+
+ public boolean isRoot() {
+ return(m_root);
+ }
+
+ public boolean isSessionBased() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void validate(ModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private ESBLanguageModel m_model=null;
+ private List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
+ private boolean m_root=false;
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java 2008-07-01 15:14:17 UTC (rev 95)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.actions;
+
+import java.util.Properties;
+
+import org.scribble.model.ModelObject;
+
+public class TestModelListener implements org.scribble.model.ModelListener {
+
+ public void error(ModelObject modelObject, String mesg, Properties props) {
+ reported(mesg);
+ }
+
+ public void warning(ModelObject modelObject, String mesg, Properties props) {
+ reported(mesg);
+ }
+
+ protected void reported(String mesg) {
+ if (mesg != null) {
+
+ // Check if in the list of messages to be
+ // detected
+ if (m_errorsToDetect.contains(mesg)) {
+ m_errorsToDetect.remove(mesg);
+ } else {
+ m_unexpectedErrors.add(mesg);
+ }
+ }
+ }
+
+ public void addExpectedError(String mesg) {
+ m_errorsToDetect.add(mesg);
+ }
+
+ public boolean isValid() {
+ // If there are no more errors to detect, and no
+ // unexpected errors have been reported, then
+ // the expression has been validated as expected
+ return(m_errorsToDetect.size() == 0 &&
+ m_unexpectedErrors.size() == 0);
+ }
+
+ public String invalidMessage() {
+ String ret="\r\n";
+
+ if (m_errorsToDetect.size() > 0) {
+ ret += "Errors not detected:\r\n";
+
+ for (int i=0; i < m_errorsToDetect.size(); i++) {
+ ret += m_errorsToDetect.get(i)+"\r\n";
+ }
+ }
+
+ if (m_unexpectedErrors.size() > 0) {
+ ret += "Unexpected Errors:\r\n";
+
+ for (int i=0; i < m_unexpectedErrors.size(); i++) {
+ ret += m_unexpectedErrors.get(i)+"\r\n";
+ }
+ }
+
+ return(ret);
+ }
+
+ private java.util.List<String> m_errorsToDetect=new java.util.Vector<String>();
+ private java.util.List<String> m_unexpectedErrors=new java.util.Vector<String>();
+ private java.util.List<String> m_messages=new java.util.Vector<String>();
+}
15 years, 10 months