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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 22 03:31:31 EDT 2008


Author: tfennelly
Date: 2008-09-22 03:31:30 -0400 (Mon, 22 Sep 2008)
New Revision: 22972

Added:
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/
   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/ServiceRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/package.html
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestInboundRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestOutboundRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestService.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/01-inrouter-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/02-service-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/03-outrouter-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/RoutingTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/01-inrouter-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/03-outrouter-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/RoutingTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/01-inrouter-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/03-serviceB-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/RoutingTest.java
Removed:
   labs/jbossesb/workspace/skeagh/routing/esb/
Modified:
   labs/jbossesb/workspace/skeagh/routing/pom.xml
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
Log:
moved the routing/esb stuff back into the runtime module

Modified: labs/jbossesb/workspace/skeagh/routing/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/pom.xml	2008-09-22 05:20:13 UTC (rev 22971)
+++ labs/jbossesb/workspace/skeagh/routing/pom.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -15,7 +15,6 @@
     <url>http://www.jboss.org/jbossesb/</url>
 
     <modules>
-        <module>esb</module>
         <!-- module>file</module -->
         <module>jms</module>
     </modules>

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-22 05:20:13 UTC (rev 22971)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -30,6 +30,7 @@
 import org.jboss.esb.routing.RoutingException;
 import org.jboss.esb.service.Service;
 import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.service.ServiceException;
 
 import java.util.List;
 
@@ -75,6 +76,7 @@
     public AbstractDispatcher(final DeploymentContext deploymentContext)
     {
         this.deploymentContext = deploymentContext;
+        //serviceInvoker = new ServiceInvoker(deploymentContext);
     }
 
     /**
@@ -153,6 +155,10 @@
                 AddressingContext.getContext().setFrom(getServiceName());
                 return outMessage;
             }
+            catch (ServiceException e)
+            {
+                
+            }
             catch (Throwable t)
             {
                 throw new RoutingException("Error processing message.", t);

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java (from rev 22939, labs/jbossesb/workspace/skeagh/routing/esb/src/main/java/org/jboss/esb/ServiceInvoker.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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;
+
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.federate.DeploymentCoordinator;
+import org.jboss.esb.federate.DeploymentMonitor;
+import org.jboss.esb.federate.bus.BusInboundRouter;
+import org.jboss.esb.federate.bus.BusMessage;
+import org.jboss.esb.federate.bus.BusRoutingContext;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.routing.RoutingException;
+import org.jboss.esb.util.AssertArgument;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Service Invoker.
+ *
+ * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
+ * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ * @author <a href="mailto:tom.fennelly at jboss.com">Tom Fennelly</a>
+ */
+public class ServiceInvoker
+{
+    /**
+     * Deployment context.
+     */
+    private DeploymentContext deploymentContext;
+    /**
+     * Deployment runtime.
+     */
+    private DeploymentRuntime deploymentRuntime;
+
+    /**
+     * Public constructor.
+     * @param deploymentContext The deployment context associated with this invoker instance.
+     */
+    public ServiceInvoker(final DeploymentContext deploymentContext)
+    {
+        AssertArgument.isNotNull(deploymentContext, "deploymentContext");
+        this.deploymentContext = deploymentContext;
+        deploymentRuntime = DeploymentRuntime.getRuntime(deploymentContext);
+    }
+
+    /**
+     * Send the supplied message to the specified Service.
+     *
+     * @param message The message to be sent.
+     * @param addressingContext
+     * @throws org.jboss.esb.routing.RoutingException
+     */
+    public void send(Message message, AddressingContext addressingContext) throws RoutingException
+    {
+        if(addressingContext.getTo() == null)
+        {
+            throw new RoutingException("Invalid AddressingContext configuration.  The 'to' service name must be specified.");
+        }
+
+        // The "to" service name should not be this service...
+        if(addressingContext.getTo().equals(addressingContext.getFrom()))
+        {
+            throw new RoutingException("Invalid AddressingContext configuration.  The 'to' and 'from' service names (" + addressingContext.getTo() + ") cannot be the same.");
+        }
+
+        // Work out whether or not the target service is local,
+        // or on another deployment...
+        boolean isLocalService = false;
+        if(DeploymentUtil.getService(addressingContext.getTo(), deploymentRuntime) != null)
+        {
+            isLocalService = true;
+        }
+
+        if(isLocalService)
+        {
+            routeLocal(message, addressingContext);
+        }
+        else
+        {
+            routeByBus(message, addressingContext);
+        }
+    }
+
+
+    /**
+     * Route the message to a local Service.
+     * @param message The message.
+     * @param invokeAddressingContext The {@link AddressingContext} for the invocation.
+     * @throws RoutingException Exception during invocation.
+     */
+    private void routeLocal(final Message message, final AddressingContext invokeAddressingContext) throws RoutingException
+    {
+        InvocationContext thisInvocationContext = InvocationContext.getContext();
+        AddressingContext thisAddressingContext = AddressingContext.getContext();
+
+        // Set the Addressing context for the new Service Invocation...
+        AddressingContext.setContext(invokeAddressingContext);
+        try
+        {
+            try
+            {
+                BusRoutingContext routingContext = BusRoutingContext.getContext(deploymentContext);
+                BusInboundRouter inRouter = routingContext.getBusInRouters().get(invokeAddressingContext.getTo());
+
+                // Going to use the same InvocationContext...
+                inRouter.dispatch(message, thisInvocationContext);
+            }
+            finally
+            {
+                // Make sure the invocation context is still set on the
+                // local thread...
+                InvocationContext.setContext(thisInvocationContext);
+            }
+        }
+        finally
+        {
+            // Reset the addressing context...
+            AddressingContext.setContext(thisAddressingContext);
+        }
+    }
+
+    /**
+     * Route the message to a Service by a Bus.
+     * @param message The message.
+     * @param invokeAddressingContext The {@link AddressingContext} for the invocation.
+     * @throws RoutingException Exception during invocation.
+     */
+    private void routeByBus(final Message message, final AddressingContext invokeAddressingContext) throws RoutingException
+    {
+        InvocationContext thisInvocationContext = InvocationContext.getContext();
+        List<DeploymentCoordinator.BusDeployment> busDeployments = deploymentRuntime.getDeploymentCoordinator().getBusDeployments();
+
+        // Iterate over all the Bus deployments looking for a deployment that
+        // is online and is hosting the target service...
+        for (DeploymentCoordinator.BusDeployment busDeployment : busDeployments)
+        {
+            Set<Map.Entry<String, DeploymentMonitor>> monitors = busDeployment.getDeploymentMonitors().entrySet();
+            for (Map.Entry<String, DeploymentMonitor> entry : monitors)
+            {
+                String deploymentId = entry.getKey();
+                DeploymentMonitor monitor = entry.getValue();
+
+                // Is the deployment online and does it host the target service...
+                if(monitor.isOnline() && monitor.hasService(invokeAddressingContext.getTo()))
+                {
+                    BusMessage busMessage = new BusMessage();
+
+                    busMessage.setMessage(message);
+                    busMessage.setInvocationParameters(thisInvocationContext.getInvocationParameters());
+                    busMessage.setAddressingContext(invokeAddressingContext);
+
+                    monitor.getBus().send(busMessage, deploymentId);
+
+                    return;
+                }
+            }
+        }
+
+        throw new RoutingException("Failed to route message from service '" + invokeAddressingContext.getFrom() + "' to service '" + invokeAddressingContext.getTo() + "'.  Target service is not available.");
+    }
+}


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

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceRouter.java (from rev 22939, labs/jbossesb/workspace/skeagh/routing/esb/src/main/java/org/jboss/esb/ServiceRouter.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceRouter.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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;
+
+import org.jboss.esb.annotations.Initialize;
+import org.jboss.esb.annotations.Property;
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.routing.OutboundRouter;
+import org.jboss.esb.routing.RoutingException;
+import org.jboss.esb.service.ServiceName;
+
+/**
+ * Service Message {@link OutboundRouter}.
+ * <p/>
+ * Allows routing of an ESB message to another Service instance.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ServiceRouter implements OutboundRouter
+{
+    /**
+     * The service name i.e. the "from" service. Injected by the framework.
+     */
+    private ServiceName serviceName;
+    /**
+     * Deployment context.
+     */
+    private DeploymentContext deploymentContext;
+    /**
+     * The Category name of the "to" service.
+     */
+    @Property
+    private String toCategory;
+    /**
+     * The name of the "to" service.
+     */
+    @Property
+    private String toService;
+    /**
+     * The qualified "to" service name.
+     */
+    private ServiceName toServiceName;
+    /**
+     * The Category name of the "fault" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String faultToCategory;
+    /**
+     * The name of the "fault" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String faultToService;
+    /**
+     * The qualified "fault" service name.
+     */
+    private ServiceName faultToServiceName;
+    /**
+     * The Category name of the "replyTo" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String replyToCategory;
+    /**
+     * The name of the "replyTo" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String replyToService;
+    /**
+     * The qualified "replyTo" service name.
+     */
+    private ServiceName replyToServiceName;
+    /**
+     * Service Invoker.
+     */
+    private ServiceInvoker serviceInvoker;
+
+    /**
+     * Initialize the router.
+     */
+    @Initialize
+    public void initialize() throws DeploymentException
+    {
+        serviceInvoker = new ServiceInvoker(deploymentContext);
+
+        toServiceName = new ServiceName(toCategory, toService);
+        if(faultToCategory != null && faultToService != null)
+        {
+            faultToServiceName = new ServiceName(faultToCategory, faultToService);
+        }
+        if(replyToCategory != null && replyToService != null)
+        {
+            replyToServiceName = new ServiceName(replyToCategory, replyToService);
+        }
+    }
+
+    /**
+     * Route the message.
+     *
+     * @param message The message to be routed.
+     * @throws RoutingException An exception occured while routing the message.
+     */
+    public final void route(final Message message) throws RoutingException
+    {
+        AddressingContext addressingContext = new AddressingContext();
+
+        addressingContext.setTo(toServiceName);
+        addressingContext.setFrom(serviceName);
+        addressingContext.setReplyTo(replyToServiceName);
+        addressingContext.setFaultTo(faultToServiceName);
+
+        serviceInvoker.send(message, addressingContext);
+    }
+}


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

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/package.html (from rev 22938, labs/jbossesb/workspace/skeagh/routing/esb/src/main/java/org/jboss/esb/package.html)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/package.html	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+ESB Message Aware Routing.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestInboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestInboundRouter.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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;
+
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class TestInboundRouter implements InboundRouter
+{
+    private MessageDispatcher dispatcher;
+
+    public void setDispatcher(MessageDispatcher dispatcher)
+    {
+        this.dispatcher = dispatcher;
+    }
+
+    public void sendMessage(String message) throws RoutingException
+    {
+        Message esbMessage = new Message();
+        esbMessage.setPayload(message);
+        dispatcher.dispatch(esbMessage, new InvocationContext());
+    }
+}
\ No newline at end of file


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestOutboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestOutboundRouter.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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;
+
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.routing.OutboundRouter;
+import org.jboss.esb.routing.RoutingException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class TestOutboundRouter implements OutboundRouter
+{
+    private String message;
+    public static InvocationContext invocationContext;
+    public static AddressingContext addressingContext;
+    public static DeploymentContext deploymentContext;
+
+    public void route(Message message) throws RoutingException
+    {
+        this.message = (String) message.getPayload();
+        invocationContext = InvocationContext.getContext();
+        addressingContext = AddressingContext.getContext();
+        deploymentContext = DeploymentContext.getContext();
+    }
+
+    public String getMessage()
+    {
+        return message;
+    }
+}
\ No newline at end of file


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestService.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/TestService.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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;
+
+import org.jboss.esb.service.Service;
+import org.jboss.esb.service.ServiceException;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class TestService implements Service
+{
+    private String message;
+    public static InvocationContext invocationContext;
+    public static AddressingContext addressingContext;
+    public static DeploymentContext deploymentContext;
+
+    public Message process(Message message) throws ServiceException
+    {
+        this.message = (String) message.getPayload();
+        invocationContext = InvocationContext.getContext();
+        addressingContext = AddressingContext.getContext();
+        deploymentContext = DeploymentContext.getContext();
+        return message;
+    }
+
+    public String getMessage()
+    {
+        return message;
+    }
+}
\ No newline at end of file


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/01-inrouter-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/01-inrouter-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/01-inrouter-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <routing>
+        <inRouters serviceCategory="Service" serviceName="A">
+            <inRouter name="inrouter" class="org.jboss.esb.routing.TestInboundRouter" />
+        </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_001/01-inrouter-config.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_001/02-service-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/02-service-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/02-service-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,7 @@
+<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.routing.TestService" />
+    </services>
+
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/02-service-config.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_001/03-outrouter-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/03-outrouter-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/03-outrouter-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <routing>
+        <outRouters serviceCategory="Service" serviceName="A">
+            <outRouter name="outrouter" class="org.jboss.esb.routing.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_001/03-outrouter-config.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_001/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/RoutingTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_001/RoutingTest.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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_001;
+
+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.routing.TestInboundRouter;
+import org.jboss.esb.routing.TestOutboundRouter;
+import org.jboss.esb.routing.TestService;
+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
+{
+
+    /*
+     * This is a simple scenario where there are 3 deployments all connected into the same bus:
+     * 1. "inrouterDeployment" defines an inrouter for "Service:A".
+     * 2. "serviceDeployment" defines the service instance for "Service:A".
+     * 3. "outrouterDeployment" defines an outrouter for "Service:A".
+     *
+     * The message should get routed from the inrouter onto the bus, get picked
+     * up by "serviceDeployment", run through "Service:A", sent back onto the bus
+     * for "outrouterDeployment", picked up by "outrouterDeployment" and sent to
+     * outrouter for "Service:A".
+     */
+    public void test() throws Exception
+    {
+        new JMSTestRunner() {
+            public void test() throws Exception
+            {
+                ServiceName serviceA = new ServiceName("Service", "A");
+                DeploymentRuntime outrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-outrouter-config.xml"));
+
+                outrouterDeployment.setDeploymentName("outrouter");
+                outrouterDeployment.deploy();
+                try
+                {
+                    DeploymentRuntime serviceDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-service-config.xml"));
+
+                    serviceDeployment.setDeploymentName("service");
+                    serviceDeployment.deploy();
+                    try
+                    {
+                        DeploymentRuntime inrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-inrouter-config.xml"));
+
+                        inrouterDeployment.setDeploymentName("inrouter");
+                        inrouterDeployment.deploy();
+                        Thread.sleep(300); // Allow the deployments to exchange deployment details
+                        try
+                        {
+                            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceA, "inrouter", inrouterDeployment).getRouter();
+                            TestService service = (TestService) DeploymentUtil.getService(serviceA, serviceDeployment).getService();
+                            TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceA, "outrouter", outrouterDeployment).getRouter();
+
+                            inrouter.sendMessage("Hi there!!");
+                            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!!", service.getMessage());
+                            assertEquals("Hi there!!", outrouter.getMessage());
+                        }
+                        finally
+                        {
+                            inrouterDeployment.undeploy();
+                        }
+                    }
+                    finally
+                    {
+                        serviceDeployment.undeploy();
+                    }
+                }
+                finally
+                {
+                    outrouterDeployment.undeploy();
+                }
+            }
+        }.run();
+    }
+
+    // Reversing the deployment startup order should be ok... should still work...
+    public void test_reverse_startup_order() throws Exception
+    {
+        new JMSTestRunner() {
+            public void test() throws Exception
+            {
+                ServiceName serviceA = new ServiceName("Service", "A");
+                DeploymentRuntime inrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-inrouter-config.xml"));
+
+                inrouterDeployment.setDeploymentName("inrouter");
+                inrouterDeployment.deploy();
+                try
+                {
+                    DeploymentRuntime serviceDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-service-config.xml"));
+
+                    serviceDeployment.setDeploymentName("service");
+                    serviceDeployment.deploy();
+                    try
+                    {
+                        DeploymentRuntime outrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-outrouter-config.xml"));
+
+                        outrouterDeployment.setDeploymentName("outrouter");
+                        outrouterDeployment.deploy();
+
+                        Thread.sleep(300); // Allow the deployments to exchange deployment details
+                        try
+                        {
+                            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceA, "inrouter", inrouterDeployment).getRouter();
+                            TestService service = (TestService) DeploymentUtil.getService(serviceA, serviceDeployment).getService();
+                            TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceA, "outrouter", outrouterDeployment).getRouter();
+
+                            inrouter.sendMessage("Hi there!!");
+                            Thread.sleep(300); // Allow the message to be delivered
+
+                            // Check that the message has been routed across deployments via the bus... from the inrouter
+                            // to the service instance and then to the outrouter...
+                            assertEquals("Hi there!!", service.getMessage());
+                            assertEquals("Hi there!!", outrouter.getMessage());
+                        }
+                        finally
+                        {
+                            outrouterDeployment.undeploy();
+                        }
+                    }
+                    finally
+                    {
+                        serviceDeployment.undeploy();
+                    }
+                }
+                finally
+                {
+                    inrouterDeployment.undeploy();
+                }
+            }
+        }.run();
+    }
+}


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/01-inrouter-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/01-inrouter-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/01-inrouter-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <routing>
+        <inRouters serviceCategory="Service" serviceName="A">
+            <inRouter name="inrouter" class="org.jboss.esb.routing.TestInboundRouter" />
+        </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_002/01-inrouter-config.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_002/02-service-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,20 @@
+<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.routing.TestService" />
+        <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.routing.TestService" />
+    </services>
+
+    <routing>
+        <!--
+            Route the message from A to B....
+        -->
+        <outRouters serviceCategory="Service" serviceName="A">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+                <property name="toCategory">Service</property>
+                <property name="toService">B</property>
+            </outRouter>
+        </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_002/02-service-config.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_002/03-outrouter-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/03-outrouter-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/03-outrouter-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <routing>
+        <outRouters serviceCategory="Service" serviceName="B">
+            <outRouter name="outrouter" class="org.jboss.esb.routing.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_002/03-outrouter-config.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_002/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/RoutingTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/RoutingTest.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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_002;
+
+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.routing.TestInboundRouter;
+import org.jboss.esb.routing.TestOutboundRouter;
+import org.jboss.esb.routing.TestService;
+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
+{
+
+    /*
+     * This is a simple scenario where there are 3 deployments all connected into the same bus:
+     * 1. "inrouterDeployment" defines an inrouter for "Service:A".
+     * 2. "serviceDeployment" defines service instances for "Service:A" and "Service:B". It
+     *    also defines a router from "Service:A" to "Service:B".
+     * 3. "outrouterDeployment" defines an outrouter for "Service:B".
+     *
+     * So the message should go (across the 3 deployments):
+     *    [inrouter_ServiceA] -> [ServiceA -> ServiceB] -> [outrouter_ServiceB] 
+     *
+     */
+    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 outrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-outrouter-config.xml"));
+
+                outrouterDeployment.setDeploymentName("outrouter");
+                outrouterDeployment.deploy();
+                try
+                {
+                    DeploymentRuntime serviceDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-service-config.xml"));
+
+                    serviceDeployment.setDeploymentName("service");
+                    serviceDeployment.deploy();
+                    try
+                    {
+                        DeploymentRuntime inrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-inrouter-config.xml"));
+
+                        inrouterDeployment.setDeploymentName("inrouter");
+                        inrouterDeployment.deploy();
+                        Thread.sleep(300); // Allow the deployments to exchange deployment details
+                        try
+                        {
+                            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceNameA, "inrouter", inrouterDeployment).getRouter();
+                            TestService serviceA = (TestService) DeploymentUtil.getService(serviceNameA, serviceDeployment).getService();
+                            TestService serviceB = (TestService) DeploymentUtil.getService(serviceNameB, serviceDeployment).getService();
+                            TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceNameB, "outrouter", outrouterDeployment).getRouter();
+
+                            inrouter.sendMessage("Hi there!!");
+                            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());
+                        }
+                        finally
+                        {
+                            inrouterDeployment.undeploy();
+                        }
+                    }
+                    finally
+                    {
+                        serviceDeployment.undeploy();
+                    }
+                }
+                finally
+                {
+                    outrouterDeployment.undeploy();
+                }
+            }
+        }.run();
+    }
+}
\ No newline at end of file


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/01-inrouter-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/01-inrouter-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/01-inrouter-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <routing>
+        <inRouters serviceCategory="Service" serviceName="A">
+            <inRouter name="inrouter" class="org.jboss.esb.routing.TestInboundRouter" />
+        </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_003/01-inrouter-config.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_003/02-serviceA-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,19 @@
+<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.routing.TestService" />
+    </services>
+
+    <routing>
+        <!--
+            Route the message from A to B....
+        -->
+        <outRouters serviceCategory="Service" serviceName="A">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+                <property name="toCategory">Service</property>
+                <property name="toService">B</property>
+            </outRouter>
+        </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_003/02-serviceA-config.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_003/03-serviceB-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/03-serviceB-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/03-serviceB-config.xml	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,13 @@
+<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.routing.TestService" />
+    </services>
+
+    <routing>
+        <outRouters serviceCategory="Service" serviceName="B">
+            <outRouter name="outrouter" class="org.jboss.esb.routing.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_003/03-serviceB-config.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_003/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/RoutingTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/RoutingTest.java	2008-09-22 07:31:30 UTC (rev 22972)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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_003;
+
+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.routing.TestInboundRouter;
+import org.jboss.esb.routing.TestOutboundRouter;
+import org.jboss.esb.routing.TestService;
+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
+{
+
+    /*
+     * This is a simple scenario where there are 3 deployments all connected into the same bus:
+     * 1. "inrouterDeployment" defines an inrouter for "Service:A".
+     * 2. "serviceADeployment" defines a service instance for "Service:A". It
+     *    also defines a router from "Service:A" to "Service:B".
+     * 3. "serviceBDeployment" defines a service instance for "Service:B". It also
+     *    defines an outrouter for "Service:B".
+     *
+     * So the message should go (across the 3 deployments):
+     *    [inrouter_ServiceA] -> [ServiceA] -> [ServiceB -> outrouter_ServiceB]
+     *
+     */
+    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 serviceBDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-serviceB-config.xml"));
+
+                serviceBDeployment.setDeploymentName("outrouter");
+                serviceBDeployment.deploy();
+                try
+                {
+                    DeploymentRuntime serviceADeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-serviceA-config.xml"));
+
+                    serviceADeployment.setDeploymentName("service");
+                    serviceADeployment.deploy();
+                    try
+                    {
+                        DeploymentRuntime inrouterDeployment = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-inrouter-config.xml"));
+
+                        inrouterDeployment.setDeploymentName("inrouter");
+                        inrouterDeployment.deploy();
+                        Thread.sleep(300); // Allow the deployments to exchange deployment details
+                        try
+                        {
+                            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter(serviceNameA, "inrouter", inrouterDeployment).getRouter();
+                            TestService serviceA = (TestService) DeploymentUtil.getService(serviceNameA, serviceADeployment).getService();
+                            TestService serviceB = (TestService) DeploymentUtil.getService(serviceNameB, serviceBDeployment).getService();
+                            TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceNameB, "outrouter", serviceBDeployment).getRouter();
+
+                            inrouter.sendMessage("Hi there!!");
+                            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());
+                        }
+                        finally
+                        {
+                            inrouterDeployment.undeploy();
+                        }
+                    }
+                    finally
+                    {
+                        serviceADeployment.undeploy();
+                    }
+                }
+                finally
+                {
+                    serviceBDeployment.undeploy();
+                }
+            }
+        }.run();
+    }
+}
\ No newline at end of file


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




More information about the jboss-svn-commits mailing list