[jboss-svn-commits] JBL Code SVN: r16051 - in labs/jbossesb/trunk: product/rosetta/src/org/jboss/internal/soa/esb/assertion and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 24 10:48:33 EDT 2007


Author: tfennelly
Date: 2007-10-24 10:48:32 -0400 (Wed, 24 Oct 2007)
New Revision: 16051

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/LogicalEPR.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/LogicalEPRUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/TestUtils.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/LogicalEPRUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service2Action.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action1.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action2.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/ServiceInvokerAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/deployment.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jms-service.xml
Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/mock/MockAction.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipelineUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
   labs/jbossesb/trunk/qa/build.xml
Log:
http://jira.jboss.com/jira/browse/JBESB-1161

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -21,35 +21,26 @@
  * @author mark.little at jboss.com
  */
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
 import org.jboss.internal.soa.esb.assertion.AssertArgument;
 import org.jboss.soa.esb.MarshalException;
 import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.XMLUtil;
-import org.jboss.soa.esb.addressing.eprs.EmailEpr;
-import org.jboss.soa.esb.addressing.eprs.FTPEpr;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
-import org.jboss.soa.esb.addressing.eprs.HibernateEpr;
-import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.jboss.soa.esb.addressing.eprs.*;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
 
 public class EPRHelper
 {
@@ -312,8 +303,11 @@
 			eprType = FTPEpr.type().toString();
 		else if (epr instanceof FileEpr)
 			eprType = FileEpr.type().toString();
+        else if (epr instanceof LogicalEPR) {
+            eprType = LogicalEPR.type().toString();
+        }
 
-		if (eprType != null)
+        if (eprType != null)
 		{
 			if (epr.getAddr().getExtensionValue(EPR_TYPE) == null) {
 				epr.getAddr().addExtension(EPR_TYPE, eprType);
@@ -347,6 +341,8 @@
 				return new FTPEpr(epr);
 			else if (eprType.equals(FileEpr.type().toString()))
 				return new FileEpr(epr);
+            else if (eprType.equals(LogicalEPR.type().toString()))
+                return new LogicalEPR(epr.getAddr());
 			else
 				return epr;
 		} else {
@@ -405,6 +401,8 @@
 				return new FTPEpr(epr, header);
 			else if (eprType.equals(FileEpr.type().toString()))
 				return new FileEpr(epr, header);
+            else if (eprType.equals(LogicalEPR.type().toString()))
+                return new LogicalEPR(epr.getAddr());
 			else
 				return epr;
 		} else {

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -32,18 +32,19 @@
  */
 public abstract class AssertArgument {
 
-	/**
-	 * Assert that the argument is not null.
-	 * @param arg Argument.
-	 * @param argName Argument name.
-	 * @throws IllegalArgumentException Argument is null.
-	 */
-	public static void isNotNull(Object arg, String argName) throws IllegalArgumentException {
-		if (arg == null) {
-			throw new IllegalArgumentException("null '" + argName
-					+ "' arg in method call.");
-		}
-	}
+    /**
+     * Assert that the argument is not null.
+     * @param arg Argument.
+     * @param argName Argument name.
+     * @throws IllegalArgumentException Argument is null.
+     */
+    public static Object isNotNull(Object arg, String argName) throws IllegalArgumentException {
+        if (arg == null) {
+            throw new IllegalArgumentException("null '" + argName
+                    + "' arg in method call.");
+        }
+        return arg;
+    }
 
 	/**
 	 * Assert that the argument is not empty.
@@ -51,12 +52,13 @@
 	 * @param argName Argument name.
 	 * @throws IllegalArgumentException Argument is not null, but is empty.
 	 */
-	public static void isNotEmpty(String arg, String argName) throws IllegalArgumentException {
+	public static String isNotEmpty(String arg, String argName) throws IllegalArgumentException {
 		if (arg != null && arg.trim().equals("")) {
 			throw new IllegalArgumentException("Not null, but empty '"
 					+ argName + "' arg in method call.");
 		}
-	}
+        return arg;
+    }
 
 	/**
 	 * Assert that the argument is neither null nor empty.
@@ -64,11 +66,12 @@
 	 * @param argName Argument name.
 	 * @throws IllegalArgumentException Argument is null or empty.
 	 */
-	public static void isNotNullAndNotEmpty(String arg, String argName) throws IllegalArgumentException {
+	public static String isNotNullAndNotEmpty(String arg, String argName) throws IllegalArgumentException {
 		if (arg == null || arg.trim().equals("")) {
 			throw new IllegalArgumentException("null or empty '" + argName
 					+ "' arg in method call.");
 		}
+        return arg;
 	}
 
     /**
@@ -77,11 +80,12 @@
      * @param argName Argument name.
      * @throws IllegalArgumentException Argument is null or empty.
      */
-    public static void isNotNullAndNotEmpty(Collection arg, String argName) throws IllegalArgumentException {
+    public static Collection isNotNullAndNotEmpty(Collection arg, String argName) throws IllegalArgumentException {
         if (arg == null || arg.isEmpty()) {
             throw new IllegalArgumentException("null or empty '" + argName
                     + "' arg in method call.");
         }
+        return arg;
     }
 
     /**
@@ -90,11 +94,12 @@
      * @param argName Argument name.
      * @throws IllegalArgumentException Argument is null or empty.
      */
-    public static void isNotNullAndNotEmpty(Object[] arg, String argName) throws IllegalArgumentException {
+    public static Object[] isNotNullAndNotEmpty(Object[] arg, String argName) throws IllegalArgumentException {
         if (arg == null || arg.length == 0) {
             throw new IllegalArgumentException("null or empty '" + argName
                     + "' arg in method call.");
         }
+        return arg;
     }
 
     /**
@@ -103,10 +108,11 @@
      * @param argName Argument name.
      * @throws IllegalArgumentException Argument is null or empty.
      */
-    public static void isNotNullAndNotEmpty(Map arg, String argName) throws IllegalArgumentException {
+    public static Map isNotNullAndNotEmpty(Map arg, String argName) throws IllegalArgumentException {
         if (arg == null || arg.isEmpty()) {
             throw new IllegalArgumentException("null or empty '" + argName
                     + "' arg in method call.");
         }
+        return arg;
     }
 }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/LogicalEPR.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/LogicalEPR.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/LogicalEPR.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.addressing.eprs;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.client.ServiceInvoker;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Logical EPR.
+ * <p/>
+ * Logical EPRs allow services to be addressed by their "logical" (Vs physical)
+ * name.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LogicalEPR extends EPR {
+
+    private static final String PROTOCOL = "logical";
+    private ServiceInvoker serviceInvoker;
+
+    public LogicalEPR() {
+        super();
+    }
+
+    public LogicalEPR(PortReference addr) {
+        this(URI.create(((PortReference)AssertArgument.isNotNull(addr, "addr")).getAddress()));
+    }
+
+    public LogicalEPR(URI uri) {
+        super((URI)AssertArgument.isNotNull(uri, "uri"));
+        assertValidLogicalURI(uri);
+    }
+
+    public LogicalEPR(String serviceCategory, String serviceName) {
+        super(toLogicalURI(serviceCategory, serviceName));
+    }
+
+    public void setAddr(PortReference addr) {
+        AssertArgument.isNotNull(addr, "addr");
+        assertValidLogicalURI(URI.create(addr.getAddress()));
+        super.setAddr(addr);
+    }
+
+    public Service toService() {
+        PortReference portRef = getAddr();
+
+        if(portRef == null) {
+            throw new IllegalStateException("Invalid Logical EPR state.  No PortReference set on EPR.");
+        }
+
+        URI uri;
+        try {
+            uri = new URI(portRef.getAddress());
+        } catch (URISyntaxException e) {
+            throw new IllegalStateException("Invalid Logical EPR state.  '" + portRef.getAddress() + "' is not a valid URI.", e);
+        }
+
+        assertValidLogicalURI(uri);
+
+        return new Service(uri.getSchemeSpecificPart(), uri.getFragment());
+    }
+
+    public ServiceInvoker getServiceInvoker() throws MessageDeliverException {
+        if(serviceInvoker == null) {
+            serviceInvoker = new ServiceInvoker(toService());
+        }
+        return serviceInvoker;
+    }
+
+    private static URI toLogicalURI(String serviceCategory, String serviceName) {
+        AssertArgument.isNotNullAndNotEmpty(serviceCategory, "serviceCategory");
+        AssertArgument.isNotNullAndNotEmpty(serviceName, "serviceName");
+
+        try {
+            // Using this URI constructor because it encodes the
+            // scheme specific part and fragment - the cat and name
+            // may have illegal URI characters...
+            return new URI(PROTOCOL, serviceCategory, serviceName);
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    private void assertValidLogicalURI(URI uri) {
+        if(!PROTOCOL.equalsIgnoreCase(uri.getScheme())) {
+            throw new IllegalArgumentException("'" + uri + "' is not a valid URI for a Logical EPR - URI scheme must be '" + PROTOCOL + "'.");
+        }
+        if(!uri.isOpaque()) {
+            throw new IllegalArgumentException("'" + uri + "' is not a valid URI for a Logical EPR - URI must be opaque.");
+        }
+
+        String category = uri.getSchemeSpecificPart();
+        String name = uri.getFragment();
+
+        if(category == null) {
+            throw new IllegalArgumentException("'" + uri + "' is not a valid URI for a Logical EPR - no URI scheme specific part (service category).");
+        }
+        if(name == null) {
+            throw new IllegalArgumentException("'" + uri + "' is not a valid URI for a Logical EPR - no URI fragment (service name) part.");
+        }
+    }
+
+    public static URI type() {
+        return _type;
+    }
+
+    private static URI _type;
+
+    static {
+        try {
+            _type = new URI("urn:jboss/esb/epr/type/logical");
+        }
+        catch (Exception ex) {
+            ex.printStackTrace();
+
+            throw new ExceptionInInitializerError(ex.toString());
+        }
+    }
+
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/LogicalEPR.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -22,9 +22,6 @@
 
 package org.jboss.soa.esb.listeners.message;
 
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.ActionLifecycle;
@@ -34,8 +31,10 @@
 import org.jboss.soa.esb.addressing.Call;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
 import org.jboss.soa.esb.addressing.util.DefaultFaultTo;
 import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
+import org.jboss.soa.esb.client.ServiceInvoker;
 import org.jboss.soa.esb.couriers.Courier;
 import org.jboss.soa.esb.couriers.CourierException;
 import org.jboss.soa.esb.couriers.CourierFactory;
@@ -44,8 +43,12 @@
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.message.errors.Factory;
 import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageType;
 import org.jboss.soa.esb.util.ClassUtil;
 
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  * Action Processing Pipeline. <p/> Runs a list of action classes on a message
  * 
@@ -368,7 +371,7 @@
 	    return transactional ;
 	}
 
-	/**
+    /**
 	 * Send the reply.
 	 * 
          * @param fromAddress
@@ -381,53 +384,28 @@
 
 	private void replyTo(EPR fromAddress, EPR replyToAddress, Message message)
 	{
-		Courier courier = null;
 		EPR replyToEPR = DefaultReplyTo.getReplyToAddress(message);
 
-		if (replyToEPR != null)
-			replyToAddress = replyToEPR;
+        if (replyToEPR != null) {
+            replyToAddress = replyToEPR;
+        }
 
-		if (replyToAddress == null)
+        if (replyToAddress == null)
 		{
-			LOGGER.warn("No reply to address defined for reply message! "+message.getHeader());
-		}
+            LOGGER.warn("No reply to address defined for reply message! "+message.getHeader());
+        }
 		else
 		{
-			final Call call = message.getHeader().getCall() ;
-			call.setFrom(fromAddress) ;
-			call.setReplyTo(null) ;
-			call.setFaultTo(null) ;
-			try
-			{
-				courier = CourierFactory.getCourier(replyToAddress);
-				courier.deliver(message);
-			}
-			catch (final CourierException e)
-			{
-				LOGGER.error("Failed to reply to address " + replyToAddress + " for message "+message.getHeader(),
-						e);
-			}
-			catch (final MalformedEPRException e)
-			{
-				LOGGER.error("Failed to reply to address " + replyToAddress + " for message "+message.getHeader(),
-						e);
-			}
-			catch (final Throwable e)
-			{
-				LOGGER.error("Failed to reply to address " + replyToAddress + " for message "+message.getHeader(),
-						e);
-			}
-			finally
-			{
-				if (courier != null)
-				{
-					CourierUtil.cleanCourier(courier);
-				}
-			}
+            final Call call = message.getHeader().getCall() ;
+            call.setFrom(fromAddress) ;
+            call.setReplyTo(null) ;
+            call.setFaultTo(null) ;
+
+            messageTo(replyToAddress, message, MessageType.reply);
 		}
 	}
 
-	/**
+    /**
 	 * Send the fault message to the EPR.
 	 * 
          * @param fromAddress
@@ -440,53 +418,65 @@
 
 	private void faultTo(EPR fromAddress, EPR faultToAddress, Message message)
 	{
-		Courier courier = null;
 		EPR faultToEPR = DefaultFaultTo.getFaultToAddress(message);
 
-		if (faultToEPR != null)
-			faultToAddress = faultToEPR;
+        if (faultToEPR != null) {
+            faultToAddress = faultToEPR;
+        }
 
-		if (faultToAddress == null)
+        if (faultToAddress == null)
 		{
-			LOGGER.warn("No fault address defined for fault message! "+message.getHeader());
-		}
+            LOGGER.warn("No fault address defined for fault message! "+message.getHeader());
+        }
 		else
 		{
-			final Call call = message.getHeader().getCall() ;
-			call.setFrom(fromAddress) ;
-			call.setReplyTo(null) ;
-			call.setFaultTo(null) ;
-			try
-			{
-				courier = CourierFactory.getCourier(faultToAddress);
-				courier.deliver(message);
-			}
-			catch (final CourierException e)
-			{
-				LOGGER.error("Failed to send error to address " + faultToAddress
-						+ " for message "+message.getHeader(), e);
-			}
-			catch (final MalformedEPRException e)
-			{
-				LOGGER.error("Failed to send error to address " + faultToAddress
-						+ " for message "+message.getHeader(), e);
-			}
-			catch (final Throwable e)
-			{
-				LOGGER.error("Failed to send error to address " + faultToAddress
-						+ " for message "+message.getHeader(), e);
-			}
-			finally
-			{
-				if (courier != null)
-				{
-					CourierUtil.cleanCourier(courier);
-				}
-			}
-		}
+            final Call call = message.getHeader().getCall() ;
+            call.setFrom(fromAddress) ;
+            call.setReplyTo(null) ;
+            call.setFaultTo(null) ;
+
+            messageTo(faultToAddress, message, MessageType.fault);
+        }
 	}
 
-	/**
+    private static enum MessageType {
+        reply,
+        fault,
+    }
+
+    private void messageTo(EPR epr, Message message, MessageType messageType) {
+        if(epr instanceof LogicalEPR) {
+            try {
+                ServiceInvoker invoker = ((LogicalEPR)epr).getServiceInvoker();
+                invoker.deliverAsync(message);
+            } catch (MessageDeliverException e) {
+                LOGGER.error("Failed to send " + messageType + " to address " + epr
+                        + " for message "+message.getHeader(), e);
+            }
+        } else {
+            Courier courier = null;
+
+            try {
+                courier = CourierFactory.getCourier(epr);
+                courier.deliver(message);
+            } catch (final CourierException e) {
+                LOGGER.error("Failed to send " + messageType + " to address " + epr
+                        + " for message " + message.getHeader(), e);
+            } catch (final MalformedEPRException e) {
+                LOGGER.error("Failed to send " + messageType + " to address " + epr
+                        + " for message " + message.getHeader(), e);
+            } catch (final Throwable e) {
+                LOGGER.error("Failed to send " + messageType + " to address " + epr
+                        + " for message " + message.getHeader(), e);
+            } finally {
+                if (courier != null) {
+                    CourierUtil.cleanCourier(courier);
+                }
+            }
+        }
+    }
+
+    /**
 	 * Handle the destruction of the pipeline from the specified position.
 	 * 
 	 * @param initialPosition

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/mock/MockAction.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/mock/MockAction.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/mock/MockAction.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -32,12 +32,20 @@
 public class MockAction extends AbstractActionPipelineProcessor {
 
     public static Message message;
+    public static ActionProcessingException exception;
 
     public MockAction(ConfigTree config) {
     }
 
     public Message process(final Message message) throws ActionProcessingException {
         MockAction.message = message;
+
+        if(exception != null) {
+            ActionProcessingException e = exception;
+            exception = null;
+            throw e;
+        }
+
         return message;
     }
 }

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/LogicalEPRUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/LogicalEPRUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/LogicalEPRUnitTest.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.addressing.eprs;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.ActionProcessingPipeline;
+import org.jboss.soa.esb.listeners.message.ActionProcessingPipelineUnitTest;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.message.tests.XMLMessageUnitTest;
+import org.jboss.soa.esb.mock.MockAction;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LogicalEPRUnitTest extends TestCase {
+
+    public void test_valid_uri() {
+        LogicalEPR epr;
+
+        epr = new LogicalEPR("a", "b");
+        assertEquals("logical:a#b", epr.getAddr().getAddress());
+        assertEquals("a", epr.toService().getCategory());
+        assertEquals("b", epr.toService().getName());
+
+        // Make sure the parts are properly encoded/decoded - cat and name with spaces, slashes etc...
+        epr = new LogicalEPR("My / Category", "My / Name");
+        assertEquals("logical:My%20/%20Category#My%20/%20Name", epr.getAddr().getAddress());
+        assertEquals("My / Category", epr.toService().getCategory());
+        assertEquals("My / Name", epr.toService().getName());
+
+        epr = new LogicalEPR(URI.create("logical:My%20/%20Category#My%20/%20Name"));
+        assertEquals("logical:My%20/%20Category#My%20/%20Name", epr.getAddr().getAddress());
+        assertEquals("My / Category", epr.toService().getCategory());
+        assertEquals("My / Name", epr.toService().getName());
+
+        epr = new LogicalEPR(new PortReference("logical:My%20/%20Category#My%20/%20Name"));
+        assertEquals("logical:My%20/%20Category#My%20/%20Name", epr.getAddr().getAddress());
+        assertEquals("My / Category", epr.toService().getCategory());
+        assertEquals("My / Name", epr.toService().getName());
+
+        epr = new LogicalEPR();
+        epr.setAddr(new PortReference("logical:My%20/%20Category#My%20/%20Name"));
+        assertEquals("logical:My%20/%20Category#My%20/%20Name", epr.getAddr().getAddress());
+        assertEquals("My / Category", epr.toService().getCategory());
+        assertEquals("My / Name", epr.toService().getName());
+
+        epr = new LogicalEPR("1234567890 -=`!\"£$%^&*()_+\\|,./;'#[]<>?:@~{}", "1234567890 -=`!\"£$%^&*()_+\\|,./;'#[]<>?:@~{}");
+        assertEquals("logical:1234567890%20-=%60!%22£$%25%5E&*()_+%5C%7C,./;'%23[]%3C%3E?:@~%7B%7D#1234567890%20-=%60!%22£$%25%5E&*()_+%5C%7C,./;'%23[]%3C%3E?:@~%7B%7D", epr.getAddr().getAddress());
+        assertEquals("1234567890 -=`!\"£$%^&*()_+\\|,./;'#[]<>?:@~{}", epr.toService().getCategory());
+        assertEquals("1234567890 -=`!\"£$%^&*()_+\\|,./;'#[]<>?:@~{}", epr.toService().getName());
+
+    }
+
+    public void test_invalid_uri() {
+        try {
+            new LogicalEPR(URI.create("xxxx:a#b"));
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertEquals("'xxxx:a#b' is not a valid URI for a Logical EPR - URI scheme must be 'logical'.", e.getMessage());
+        }
+
+        try {
+            new LogicalEPR(new PortReference("logical://a#b"));
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertEquals("'logical://a#b' is not a valid URI for a Logical EPR - URI must be opaque.", e.getMessage());
+        }
+
+        try {
+            LogicalEPR epr = new LogicalEPR();
+            epr.setAddr(new PortReference("logical:a"));
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertEquals("'logical:a' is not a valid URI for a Logical EPR - no URI fragment (service name) part.", e.getMessage());
+        }
+
+        try {
+            LogicalEPR epr = new LogicalEPR();
+            epr.setAddr(new PortReference("logical:#b"));
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Expected scheme-specific part at index 8: logical:#b", e.getCause().getMessage());
+        }
+    }
+
+    public void test_Serialize_Deserialize()
+    {
+        Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+        try
+        {
+            EPR epr = new LogicalEPR(new PortReference("logical:a#b"));
+
+            msg.getHeader().getCall().setTo(epr);
+
+            final String xmlRepresentation = XMLMessageUnitTest.msgToXML((MessageImpl)msg) ;
+
+            final MessageImpl nImpl = XMLMessageUnitTest.msgFromXML(xmlRepresentation) ;
+
+            EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+            assertTrue("Expected a Logical EPR", theEpr instanceof LogicalEPR);
+
+            assertEquals("logical:a#b", theEpr.getAddr().getAddress());
+        }
+        catch (Exception ex)
+        {
+            fail(ex.toString());
+        }
+    }
+
+    private MockCourier courier1;
+    private MockCourier courier2;
+
+    public void setUp() throws Exception {
+        MockCourierFactory.install();
+        MockRegistry.install();
+
+        courier1 = new MockCourier(true);
+        courier2 = new MockCourier(true);
+        MockRegistry.register("cat", "servicex", courier1);
+        MockRegistry.register("cat", "servicey", courier2);
+     }
+
+    public void tearDown() throws Exception {
+        MockRegistry.uninstall();
+        MockCourierFactory.uninstall();
+    }
+
+    public void test_replyTo() throws ConfigurationException {
+        ActionProcessingPipeline pipeline = createTestPipeline();
+        Message message;
+
+        message = MessageFactory.getInstance().getMessage();
+        message.getHeader().getCall().setReplyTo(new LogicalEPR("cat", "servicex"));
+        message.getHeader().getCall().setFaultTo(new LogicalEPR("cat", "servicey"));
+        assertTrue(!courier1.deliveryAttempted);
+        assertTrue(!courier2.deliveryAttempted);
+        pipeline.process(message);
+        assertTrue(courier1.deliveryAttempted);
+        assertTrue(!courier2.deliveryAttempted);
+    }
+
+    public void test_faultTo() throws ConfigurationException {
+        ActionProcessingPipeline pipeline = createTestPipeline();
+        Message message;
+
+        message = MessageFactory.getInstance().getMessage();
+        message.getHeader().getCall().setReplyTo(new LogicalEPR("cat", "servicex"));
+        message.getHeader().getCall().setFaultTo(new LogicalEPR("cat", "servicey"));
+        assertTrue(!courier1.deliveryAttempted);
+        assertTrue(!courier2.deliveryAttempted);
+        MockAction.exception = new ActionProcessingException("blah");
+        pipeline.process(message);
+        assertTrue(!courier1.deliveryAttempted);
+        assertTrue(courier2.deliveryAttempted);
+    }
+
+    private ActionProcessingPipeline createTestPipeline() throws ConfigurationException {
+        ConfigTree pipelineConfig = new ConfigTree("pipline");
+
+        ActionProcessingPipelineUnitTest.addAction(pipelineConfig, MockAction.class.getName());
+
+        ActionProcessingPipeline pipeline = new ActionProcessingPipeline(pipelineConfig);
+        pipeline.initialise();
+
+        return pipeline;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/LogicalEPRUnitTest.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipelineUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipelineUnitTest.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipelineUnitTest.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -379,8 +379,11 @@
             
         }
     }
-    
-    private void addAction(final ConfigTree configTree, final String actionName,
+
+    public static void addAction(final ConfigTree configTree, final String actionName) {
+        addAction(configTree, actionName, null, null, null);
+    }
+    public static void addAction(final ConfigTree configTree, final String actionName,
         final String processOverride, final String successOverride,
         final String exceptionOverride)
     {

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -35,13 +35,8 @@
 import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
 import org.jboss.soa.esb.addressing.Call;
 import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.EmailEpr;
-import org.jboss.soa.esb.addressing.eprs.FTPEpr;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
-import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.eprs.*;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.body.content.BytesBody;
 import org.jboss.soa.esb.message.format.MessageFactory;
@@ -410,7 +405,7 @@
 			fail(ex.toString());
 		}
 	}
-	
+
 	public void testEmailEPRType ()
 	{
 		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
@@ -552,7 +547,7 @@
 		}
 	}
 	
-	private String msgToXML(final MessageImpl msg)
+	public static String msgToXML(final MessageImpl msg)
 		throws Exception
 	{
 		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
@@ -576,7 +571,7 @@
 		return sWriter.toString() ;
 	}
 	
-	private MessageImpl msgFromXML(final String xmlRepresentation)
+	public static MessageImpl msgFromXML(final String xmlRepresentation)
 		throws Exception
 	{
 		final StringReader stringReader = new StringReader(xmlRepresentation) ;

Modified: labs/jbossesb/trunk/qa/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/build.xml	2007-10-24 14:41:19 UTC (rev 16050)
+++ labs/jbossesb/trunk/qa/build.xml	2007-10-24 14:48:32 UTC (rev 16051)
@@ -55,7 +55,11 @@
 		</condition>
 		<fail if="integration.qa.tests.failed" message="QA Unit Test failure"/>
 	</target>
-	
+
+    <target name="junit" depends="esb.init" description="Run JUnit based QA tests.">
+        <ant dir="junit" target="test" />
+    </target>
+
 	<target name="test.junit" depends="esb.init" description="Run JUnit based QA tests.">
 		<ant dir="junit" target="test" />
 		<ant dir="quickstarts" target="all-test" />

Copied: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/TestUtils.java (from rev 15979, labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java)
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/TestUtils.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/TestUtils.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Helper class for tests.
+ * <p/>
+ * Just a few methods lifted from the quickstart "Helper" class.
+ */
+public class TestUtils {
+
+	/* Determine if the event file has been written */
+	public static boolean waitForFile(String fileName) throws Exception {
+		final File file = new File(fileName) ;
+
+        long startTime = System.currentTimeMillis();
+        while(System.currentTimeMillis() < startTime + 10000) {
+            if(file.exists()) {
+                return true;
+            }
+            Thread.sleep(500);
+        }
+
+        return false;
+    }
+
+    public static String getTempDir(String filename)
+    {
+        String tmpDir="";
+        if (!filename.startsWith(File.separator)) {
+            tmpDir = System.getProperty("java.io.tmpdir") + File.separator;
+        }
+        return tmpDir;
+    }
+
+    public static String getQuickstartLocation(final String location)
+        throws IOException
+    {
+        final File quickstartDir = new File(System.getProperty("org.jboss.esb.test.quickstarts.dir"), location) ;
+        return quickstartDir.getCanonicalPath() ;
+    }
+
+    public static boolean assertEquals(final String content1, final String content2, final boolean trimLines) throws IOException {
+        List<String> content1Lines = getLines(content1, trimLines);
+        List<String> content2Lines = getLines(content2, trimLines);
+
+        return content1Lines.equals(content2Lines);
+    }
+
+    private static List<String> getLines(final String string, final boolean trimLines) throws IOException {
+        BufferedReader reader = new BufferedReader(new StringReader(string));
+        List<String> lines = new ArrayList<String>();
+        String line;
+
+        while((line = reader.readLine()) != null) {
+            if(trimLines) {
+                lines.add(line.trim());
+            } else {
+                lines.add(line);
+            }
+        }
+
+        return lines;
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/LogicalEPRUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/LogicalEPRUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/LogicalEPRUnitTest.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.epr;
+
+import junit.framework.Test;
+import org.jboss.soa.esb.TestUtils;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.testutils.JMSUtil;
+import org.jboss.soa.esb.util.DeploymentArchive;
+import org.jboss.test.JBossTestCase;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LogicalEPRUnitTest extends JBossTestCase {
+
+    private static final String FILE_NAME = "LogicalEPRUnitTest.log";
+    private static final File TEST_OUTPUT_FILE = new File(TestUtils.getTempDir(FILE_NAME) + FILE_NAME);
+
+    public LogicalEPRUnitTest(String s) {
+        super(s);
+    }
+
+    protected void setUp() throws Exception {
+        TEST_OUTPUT_FILE.delete();
+    }
+
+    public void test_replyto() throws Exception {
+        // Send the message and wait for the drop...
+        JMSUtil.sendMessageToQueue("reply-To", "queue/LogicalEPRUnitTest_service1_gtw", null);
+        assertTrue("Test output file '" + TEST_OUTPUT_FILE + "' not dropped.", TestUtils.waitForFile(TEST_OUTPUT_FILE.getAbsolutePath()));
+
+        String actualOutput = FileUtil.readStream(new FileInputStream(TEST_OUTPUT_FILE));
+        assertEquals("Reply-To Service3", actualOutput);
+    }
+
+    public void test_faultto() throws Exception {
+        // Send the message and wait for the drop...
+        JMSUtil.sendMessageToQueue("fault-To", "queue/LogicalEPRUnitTest_service1_gtw", null);
+        assertTrue("Test output file '" + TEST_OUTPUT_FILE + "' not dropped.", TestUtils.waitForFile(TEST_OUTPUT_FILE.getAbsolutePath()));
+
+        String actualOutput = FileUtil.readStream(new FileInputStream(TEST_OUTPUT_FILE));
+        assertEquals("org.jboss.soa.esb.actions.ActionProcessingException: Service2Action fault", actualOutput);
+    }
+
+    public static Test suite() throws Exception {
+        DeploymentArchive deployment = new DeploymentArchive("LogicalEPRUnitTest.esb");
+
+        deployment.addEntry("META-INF/jboss-esb.xml", LogicalEPRUnitTest.class.getResourceAsStream("jboss-esb.xml"));
+        deployment.addEntry("META-INF/deployment.xml", LogicalEPRUnitTest.class.getResourceAsStream("deployment.xml"));
+        deployment.addEntry("jms-service.xml", LogicalEPRUnitTest.class.getResourceAsStream("jms-service.xml"));
+        deployment.addEntry(ServiceInvokerAction.class);
+        deployment.addEntry(Service2Action.class);
+        deployment.addEntry(Service3Action1.class);
+        deployment.addEntry(Service3Action2.class);
+
+        deployment.create();
+
+        return getDeploySetup(LogicalEPRUnitTest.class, "LogicalEPRUnitTest.esb");
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/LogicalEPRUnitTest.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service2Action.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service2Action.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service2Action.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.epr;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Service2Action extends AbstractActionPipelineProcessor {
+
+    public Service2Action(ConfigTree config) throws MessageDeliverException {
+    }
+
+    public Message process(Message message) throws ActionProcessingException {
+
+        if(message.getHeader().getCall().getFaultTo() != null) {
+            message.getBody().add("Fault-To Service3");
+            throw new ActionProcessingException("Service2Action fault");
+        } else {
+            message.getBody().add("Reply-To Service3");
+        }
+
+        return message;
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service2Action.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action1.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action1.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action1.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.epr;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Service3Action1 extends AbstractActionPipelineProcessor {
+
+    public Service3Action1(ConfigTree config) throws MessageDeliverException {
+    }
+
+    public Message process(Message message) throws ActionProcessingException {
+
+        if(message.getFault().getReason() != null) {
+            message.getBody().add(message.getFault().getReason());
+        }
+
+        return message;
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action1.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action2.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action2.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action2.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.epr;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Service3Action2 extends AbstractActionPipelineProcessor {
+
+    public Service3Action2(ConfigTree config) throws MessageDeliverException {
+    }
+
+    public Message process(Message message) throws ActionProcessingException {
+        // "Terminate" the pipeline by returning null, otherwise we might try sending
+        // a reply to the caller.  Nuts :-)
+        return null;
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/Service3Action2.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/ServiceInvokerAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/ServiceInvokerAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/ServiceInvokerAction.java	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.epr;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ServiceInvokerAction extends AbstractActionPipelineProcessor {
+    
+    private ServiceInvoker invoker;
+
+    public ServiceInvokerAction(ConfigTree config) throws MessageDeliverException {
+        invoker = new ServiceInvoker("MyServiceCategory", "MyService2");
+    }
+
+    public Message process(Message message) throws ActionProcessingException {
+        String instruction = (String) message.getBody().get();
+
+        if(instruction.equalsIgnoreCase("reply-To")) {
+            message.getHeader().getCall().setReplyTo(new LogicalEPR("MyServiceCategory", "MyService3"));
+            message.getHeader().getCall().setFaultTo(null);
+        } else {
+            message.getHeader().getCall().setReplyTo(null);
+            message.getHeader().getCall().setFaultTo(new LogicalEPR("MyServiceCategory", "MyService3"));
+        }
+
+        try {
+            invoker.deliverAsync(message);
+        } catch (MessageDeliverException e) {
+            throw new ActionProcessingException(e);
+        }
+
+        return message;
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/ServiceInvokerAction.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/deployment.xml (from rev 15979, labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml)
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/deployment.xml	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,6 @@
+<jbossesb-deployment>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1_gtw</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service2</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service3</depends>
+</jbossesb-deployment>

Copied: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jboss-esb.xml (from rev 15979, labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml)
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jboss-esb.xml	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,76 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
+        xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+        parameterReloadSecs="5">
+
+    <providers>
+        <jms-provider name="JMS" connection-factory="ConnectionFactory"
+                      jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+                      jndi-URL="localhost">
+
+            <jms-bus busid="service1_gtw">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/LogicalEPRUnitTest_service1_gtw"/>
+            </jms-bus>
+            <jms-bus busid="service1">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/LogicalEPRUnitTest_service1"/>
+            </jms-bus>
+            <jms-bus busid="service2">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/LogicalEPRUnitTest_service2"/>
+            </jms-bus>
+            <jms-bus busid="service3">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/LogicalEPRUnitTest_service3"/>
+            </jms-bus>
+        </jms-provider>
+    </providers>
+
+    <services>
+
+        <service category="MyServiceCategory" name="MyService1" description="Service 1">
+            <listeners>
+                <jms-listener name="JMS-Gateway" busidref="service1_gtw" is-gateway="true"/>
+                <jms-listener name="JMS-ESBListener" busidref="service1"/>
+            </listeners>
+            <actions>
+                <action name="invoke-service2" class="org.jboss.soa.esb.epr.ServiceInvokerAction" />
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService2" description="Service 2">
+            <listeners>
+                <jms-listener name="JMS-ESBListener" busidref="service2"/>
+            </listeners>
+            <actions>
+                <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
+                    <property name="message" value="Reply/Fault going to Service 3" />
+                </action>
+                <action name="Service2Action" class="org.jboss.soa.esb.epr.Service2Action" />
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService3" description="Service 3">
+            <listeners>
+                <jms-listener name="JMS-ESBListener" busidref="service3"/>
+            </listeners>
+            <actions>
+                <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
+                    <property name="message" value="Reply/Fault received at Service 3" />
+                </action>
+
+                <action name="Service3Action1" class="org.jboss.soa.esb.epr.Service3Action1" />
+                
+                <action name="testStore" class="org.jboss.soa.esb.actions.StoreMessageToFile">
+                    <property name="filename" value="LogicalEPRUnitTest.log" />
+                    <property name="raw" value="true"/>
+                </action>
+
+                <!--
+                    Just a noddy action to return a null message out of the pipeline
+                    in order to avoid an exception...
+                -->
+                <action name="Service3Action2" class="org.jboss.soa.esb.epr.Service3Action2" />
+            </actions>
+        </service>
+
+    </services>
+
+</jbossesb>

Copied: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jms-service.xml (from rev 15979, labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml)
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jms-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/jms-service.xml	2007-10-24 14:48:32 UTC (rev 16051)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1_gtw"
+           xmbean-dd="xmdesc/Queue-xmbean.xml">
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1"
+           xmbean-dd="xmdesc/Queue-xmbean.xml">
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service2"
+           xmbean-dd="xmdesc/Queue-xmbean.xml">
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service3"
+           xmbean-dd="xmdesc/Queue-xmbean.xml">
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+
+</server>
\ No newline at end of file




More information about the jboss-svn-commits mailing list