[jboss-svn-commits] JBL Code SVN: r23079 - in labs/jbossesb/workspace/skeagh/runtime/src: main/java/org/jboss/esb/routing and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 25 12:05:29 EDT 2008


Author: tfennelly
Date: 2008-09-25 12:05:29 -0400 (Thu, 25 Sep 2008)
New Revision: 23079

Added:
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/01-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/02-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/03-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/RoutingTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/01-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/02-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/RoutingTest.java
Modified:
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/TestInboundRouter.java
Log:
More replyTo tests.

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-09-25 15:37:22 UTC (rev 23078)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-09-25 16:05:29 UTC (rev 23079)
@@ -206,7 +206,9 @@
                 // If we need to send a reply, send it now...
                 if(outMessage != null && replyTo != null)
                 {
-                    serviceInvoker.send(outMessage, replyTo);
+                    // We make a shallow clone in case it's a local service
+                    // invocation...
+                    serviceInvoker.send((Message) outMessage.clone(), replyTo);
                 }
 
                 return outMessage;

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java	2008-09-25 15:37:22 UTC (rev 23078)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java	2008-09-25 16:05:29 UTC (rev 23079)
@@ -154,10 +154,7 @@
 
                 if(eventLog.propagate())
                 {
-                    ProcessingEventLog newEventLog = new ProcessingEventLog(true);
-
-                    newEventLog.getProcessingEvents().addAll(eventLog.getProcessingEvents());
-                    ProcessingEventLog.setEventLog(newEventLog, dispatchInvocationContext);
+                    ProcessingEventLog.setEventLog(eventLog, dispatchInvocationContext);
                 }
 
                 // And dispatch the message...

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/TestInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/TestInboundRouter.java	2008-09-25 15:37:22 UTC (rev 23078)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/TestInboundRouter.java	2008-09-25 16:05:29 UTC (rev 23079)
@@ -31,6 +31,7 @@
 public class TestInboundRouter implements InboundRouter
 {
     private MessageDispatcher dispatcher;
+    private ProcessingEventLog eventLog;
 
     public void setDispatcher(MessageDispatcher dispatcher)
     {
@@ -46,7 +47,8 @@
     {
         Message esbMessage = new Message();
         InvocationContext invocationContext = new InvocationContext();
-        ProcessingEventLog eventLog = new ProcessingEventLog(propagateEventLog);
+
+        eventLog = new ProcessingEventLog(propagateEventLog);
         ProcessingEventLog.setEventLog(eventLog, invocationContext);
 
         esbMessage.setPayload(message);
@@ -54,4 +56,9 @@
 
         return invocationContext;
     }
+
+    public ProcessingEventLog getEventLog()
+    {
+        return eventLog;
+    }
 }
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/01-deployment.xml (from rev 23078, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_008/01-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/01-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/01-deployment.xml	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,15 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="Service" serviceName="A" serviceDescription="A Service" class="org.jboss.esb.TestService" />
+    </services>
+
+    <routing>
+        <inRouters serviceCategory="Service" serviceName="A">
+            <inRouter name="inrouter" class="org.jboss.esb.TestInboundRouter">
+                <replyTo serviceCategory="Service" serviceName="B" />
+            </inRouter>
+        </inRouters>
+    </routing>
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/02-deployment.xml (from rev 23078, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_008/02-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/02-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/02-deployment.xml	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,12 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <routing>
+        <outRouters serviceCategory="Service" serviceName="A">
+            <!--
+                And route it out altogether...
+            -->
+            <outRouter name="outrouter" class="org.jboss.esb.TestOutboundRouter" />
+        </outRouters>
+    </routing>
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/03-deployment.xml (from rev 23078, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_008/03-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/03-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/03-deployment.xml	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,7 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.TestService" />
+    </services>
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/RoutingTest.java (from rev 23078, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_008/RoutingTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/RoutingTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_009/RoutingTest.java	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.routing.scenario_009;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.jms.JMSTestRunner;
+import org.jboss.esb.TestInboundRouter;
+import org.jboss.esb.TestService;
+import org.jboss.esb.TestOutboundRouter;
+import org.jboss.esb.service.ServiceName;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class RoutingTest extends TestCase
+{
+
+    /*
+     * The message should go (across the 3 deployments):
+     *      [inrouter_ServiceA -> ServiceA] -|
+     *                                       |--------------------------> [replyTo{ServiceB}]
+     *                                       |-> [outrouter_ServiceA]
+     */
+    public void test() throws Exception
+    {
+        new JMSTestRunner() {
+            public void test() throws Exception
+            {
+                ServiceName serviceNameA = new ServiceName("Service", "A");
+                ServiceName serviceNameB = new ServiceName("Service", "B");
+                DeploymentRuntime deployment1 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-deployment.xml"));
+
+                deployment1.setDeploymentName("deployment1");
+                deployment1.setDeploymentId("deployment1-Id");
+                deployment1.deploy();
+                try
+                {
+                    DeploymentRuntime deployment2 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-deployment.xml"));
+
+                    deployment2.setDeploymentName("deployment2");
+                    deployment2.setDeploymentId("deployment2-Id");
+                    deployment2.deploy();
+                    try
+                    {
+                        DeploymentRuntime deployment3 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-deployment.xml"));
+
+                        deployment3.setDeploymentName("deployment3");
+                        deployment3.setDeploymentId("deployment3-Id");
+                        deployment3.deploy();
+                        Thread.sleep(300); // Allow the deployments to exchange deployment details
+                        try
+                        {
+                            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceNameA, "inrouter", deployment1).getRouter();
+                            TestService serviceA = (TestService) DeploymentUtil.getService(serviceNameA, deployment1).getService();
+                            TestService serviceB = (TestService) DeploymentUtil.getService(serviceNameB, deployment3).getService();
+                            TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceNameA, "outrouter", deployment2).getRouter();
+
+                            inrouter.sendMessage("Hi there!!", true);
+                            Thread.sleep(300); // Allow the message to be delivered
+
+                            // Check that the message has been routed across deployments, from the inrouter
+                            // to the service instance and then to the outrouter...
+                            assertEquals("Hi there!!", serviceA.getMessage());
+                            assertEquals("Hi there!!", serviceB.getMessage());
+                            assertEquals("Hi there!!", outrouter.getMessage());
+
+                            assertEquals("Message Processing Event Log:\n" +
+                                    "\t1.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:A'\n" +
+                                    "\t2.   [deployment1-Id:deployment1] BusRouterProcessingEvent: to='Service:B', targetDeploymentId='deployment3-Id:deployment3', busType='JMSBus'\n" +
+                                    "\t3.   [deployment3-Id:deployment3] ServiceProcessingEvent: service='Service:B'",
+                                    serviceB.getEventLog().toString().trim());
+
+                            assertEquals("Message Processing Event Log:\n" +
+                                    "\t1.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:A'\n" +
+                                    "\t2.   [deployment1-Id:deployment1] BusRouterProcessingEvent: to='Service:B', targetDeploymentId='deployment3-Id:deployment3', busType='JMSBus'\n" +
+                                    "\t3.   [deployment1-Id:deployment1] BusRouterProcessingEvent: to='Service:A', targetDeploymentId='deployment2-Id:deployment2', busType='JMSBus'\n" +
+                                    "\t4.   [deployment2-Id:deployment2] OutboundRouterProcessingEvent: config='outrouter'",
+                                    outrouter.getEventLog().toString().trim());
+                        }
+                        finally
+                        {
+                            deployment3.undeploy();
+                        }
+                    }
+                    finally
+                    {
+                        deployment2.undeploy();
+                    }
+                }
+                finally
+                {
+                    deployment1.undeploy();
+                }
+            }
+        }.run();
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/01-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/01-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/01-deployment.xml	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,16 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="Service" serviceName="A" serviceDescription="A Service" class="org.jboss.esb.TestService" />
+        <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.TestService" />
+    </services>
+
+    <routing>
+        <inRouters serviceCategory="Service" serviceName="A">
+            <inRouter name="inrouter" class="org.jboss.esb.TestInboundRouter">
+                <replyTo serviceCategory="Service" serviceName="B" />
+            </inRouter>
+        </inRouters>
+    </routing>
+
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/01-deployment.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/02-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/02-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/02-deployment.xml	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,12 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <routing>
+        <outRouters serviceCategory="Service" serviceName="A">
+            <!--
+                And route it out altogether...
+            -->
+            <outRouter name="outrouter" class="org.jboss.esb.TestOutboundRouter" />
+        </outRouters>
+    </routing>
+
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/02-deployment.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/RoutingTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/RoutingTest.java	2008-09-25 16:05:29 UTC (rev 23079)
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.routing.scenario_010;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.jms.JMSTestRunner;
+import org.jboss.esb.TestInboundRouter;
+import org.jboss.esb.TestService;
+import org.jboss.esb.TestOutboundRouter;
+import org.jboss.esb.service.ServiceName;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class RoutingTest extends TestCase
+{
+
+    /*
+     * The message should go (across the 3 deployments):
+     *      [inrouter_ServiceA -> ServiceA] -|
+     *                 [replyTo{ServiceB}] <-|-> [outrouter_ServiceA]
+     */
+    public void test() throws Exception
+    {
+        new JMSTestRunner() {
+            public void test() throws Exception
+            {
+                ServiceName serviceNameA = new ServiceName("Service", "A");
+                ServiceName serviceNameB = new ServiceName("Service", "B");
+                DeploymentRuntime deployment1 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-deployment.xml"));
+
+                deployment1.setDeploymentName("deployment1");
+                deployment1.setDeploymentId("deployment1-Id");
+                deployment1.deploy();
+                try
+                {
+                    DeploymentRuntime deployment2 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-deployment.xml"));
+
+                    deployment2.setDeploymentName("deployment2");
+                    deployment2.setDeploymentId("deployment2-Id");
+                    deployment2.deploy();
+                    Thread.sleep(300); // Allow the deployments to exchange deployment details
+                    try
+                    {
+                        TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceNameA, "inrouter", deployment1).getRouter();
+                        TestService serviceA = (TestService) DeploymentUtil.getService(serviceNameA, deployment1).getService();
+                        TestService serviceB = (TestService) DeploymentUtil.getService(serviceNameB, deployment1).getService();
+                        TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceNameA, "outrouter", deployment2).getRouter();
+
+                        inrouter.sendMessage("Hi there!!", true);
+                        Thread.sleep(300); // Allow the message to be delivered
+
+                        // Check that the message has been routed across deployments, from the inrouter
+                        // to the service instance and then to the outrouter...
+                        assertEquals("Hi there!!", serviceA.getMessage());
+                        assertEquals("Hi there!!", serviceB.getMessage());
+                        assertEquals("Hi there!!", outrouter.getMessage());
+
+                        assertEquals("Message Processing Event Log:\n" +
+                                "\t1.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:A'\n" +
+                                "\t2.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:B'\n" +
+                                "\t3.   [deployment1-Id:deployment1] BusRouterProcessingEvent: to='Service:A', targetDeploymentId='deployment2-Id:deployment2', busType='JMSBus'",
+                                serviceB.getEventLog().toString().trim());
+
+                        assertEquals("Message Processing Event Log:\n" +
+                                "\t1.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:A'\n" +
+                                "\t2.   [deployment1-Id:deployment1] ServiceProcessingEvent: service='Service:B'\n" +
+                                "\t3.   [deployment1-Id:deployment1] BusRouterProcessingEvent: to='Service:A', targetDeploymentId='deployment2-Id:deployment2', busType='JMSBus'\n" +
+                                "\t4.   [deployment2-Id:deployment2] OutboundRouterProcessingEvent: config='outrouter'",
+                                outrouter.getEventLog().toString().trim());
+                    }
+                    finally
+                    {
+                        deployment2.undeploy();
+                    }
+                }
+                finally
+                {
+                    deployment1.undeploy();
+                }
+            }
+        }.run();
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_010/RoutingTest.java
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list