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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 2 09:11:48 EDT 2007


Author: tfennelly
Date: 2007-10-02 09:11:47 -0400 (Tue, 02 Oct 2007)
New Revision: 15512

Added:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/MessageAugmentor.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/TargetServiceAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DeploymentArchive.java
Removed:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java
Modified:
   labs/jbossesb/trunk/product/esb-config.xml
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
   labs/jbossesb/trunk/qa/build.xml
Log:
QA Test for JMS:
1. Listeners (ESB Aware + Gateway) - Queue and Topic
2. Couriers - Queue and Topic

Modified: labs/jbossesb/trunk/product/esb-config.xml
===================================================================
--- labs/jbossesb/trunk/product/esb-config.xml	2007-10-02 12:54:41 UTC (rev 15511)
+++ labs/jbossesb/trunk/product/esb-config.xml	2007-10-02 13:11:47 UTC (rev 15512)
@@ -8,6 +8,7 @@
     <property name="esb.ftp.location" location="${esb.config.location}/ftp"/>
     <property name="esb.ftp.server.location" location="${esb.ftp.location}/build"/>
     <property name="esb.ftp.server.name" value="ftp-server.sar"/>
+    <property name="build.location" location="./build" /> <!-- The "build" dir in product or qa, depending on which is running. -->
 
     <property name="agent.jvmarg" value=""/>
     <property name="org.jboss.esb.server.config" value="default"/>
@@ -50,6 +51,7 @@
                 dir="@{serverHome}/bin">
                 <classpath refid="server.classpath"/>
                 <jvmarg line="${agent.jvmarg}"/>
+                <sysproperty key="build.dir" value="${build.location}" />
                 <arg value="-c"/>
                 <arg value="@{serverConfig}"/>
             </java>

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-10-02 12:54:41 UTC (rev 15511)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -116,7 +116,9 @@
         synchronized(this) {
             if (jmsSession != null) {
                 try {
-                    _pool.closeSession(jmsSession);
+                    getConnectionPool().closeSession(jmsSession);
+                } catch (ConnectionException e) {
+                    _logger.error("Unable to get Connection Poll for closing of JMS Session.", e);
                 } finally {
                     jmsSession = null;
                 }
@@ -138,9 +140,9 @@
 
                     try {
                         if (JMSEpr.QUEUE_TYPE.equals(sType)) {
-                            jmsSession = _pool.getQueueSession();
+                            jmsSession = getConnectionPool().getQueueSession();
                         } else {
-                            jmsSession = _pool.getTopicSession();
+                            jmsSession = getConnectionPool().getTopicSession();
                         }
                     } catch (NamingException e) {
                         throw new CourierException("Failed to get JMS Session from pool.", e);
@@ -296,13 +298,7 @@
                     try {
                         oJndiCtx = NamingContext.getServerContext(_epr.getJndiEnvironment());
 
-                        String sFactoryClass = _epr.getConnectionFactory();
-                        if (Util.isNullString(sFactoryClass))
-                            sFactoryClass = "ConnectionFactory";
-
                         String sType = _epr.getDestinationType();
-                        _pool = JmsConnectionPoolContainer.getPool(_epr.getJndiEnvironment(), sFactoryClass, sType);
-
                         if (JMSEpr.QUEUE_TYPE.equals(sType)) {
                             QueueSession qSess = (QueueSession) getJmsSession();
                             javax.jms.Queue queue = null;
@@ -335,9 +331,6 @@
                             throw new CourierException("Unknown destination type");
                         }
                     }
-                    catch (ConnectionException vex) {
-                        throw new CourierException(vex);
-                    }
                     catch (JMSException ex) {
                         _logger.debug("Error from JMS system.", ex);
 
@@ -351,6 +344,34 @@
         }
     } // ________________________________
 
+    private JmsConnectionPool getConnectionPool() throws ConnectionException {
+        if(jmsConnectionPool == null) {
+            synchronized(this) {
+                if(jmsConnectionPool == null) {
+                    String sFactoryClass;
+                    String sType;
+                    Properties properties;
+
+                    try {
+                        sFactoryClass = _epr.getConnectionFactory();
+                        sType = _epr.getDestinationType();
+                        properties = _epr.getJndiEnvironment();
+                    } catch (URISyntaxException e) {
+                        throw new ConnectionException("Unexpected exception while getting JMS connection pool.", e);
+                    }
+
+                    if (Util.isNullString(sFactoryClass)) {
+                        sFactoryClass = "ConnectionFactory";
+                    }
+
+                    jmsConnectionPool = JmsConnectionPoolContainer.getPool(properties, sFactoryClass, sType);
+                }
+            }
+        }
+
+        return jmsConnectionPool;
+    }
+
     public Message pickup(long millis) throws CourierException, CourierTimeoutException {
         javax.jms.Message jmsMessage = pickupPayload(millis);
 
@@ -490,13 +511,7 @@
                             throw new ConfigurationException(
                                     "Unable fo obtain jndi context");
 
-                        String sFactoryClass = _epr.getConnectionFactory();
-                        if (Util.isNullString(sFactoryClass))
-                            sFactoryClass = "ConnectionFactory";
-
                         String sType = _epr.getDestinationType();
-                        _pool = JmsConnectionPoolContainer.getPool(environment, sFactoryClass, sType);
-
                         if (JMSEpr.QUEUE_TYPE.equals(sType)) {
                             QueueSession qSess = (QueueSession) getJmsSession();
                             javax.jms.Queue queue = null;
@@ -524,9 +539,6 @@
                         }
                         success = true;
                     }
-                    catch (ConnectionException cex) {
-                        throw new CourierException(cex);
-                    }
                     catch (JMSException ex) {
                         _logger.debug("Error from JMS system.", ex);
 
@@ -564,7 +576,7 @@
 
     protected List<KeyValuePair> _messageProperties;
 
-    protected JmsConnectionPool _pool;
+    protected volatile JmsConnectionPool jmsConnectionPool;
 
     /**
      * Strategy for setting JMSProperties

Modified: labs/jbossesb/trunk/qa/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/build.xml	2007-10-02 12:54:41 UTC (rev 15511)
+++ labs/jbossesb/trunk/qa/build.xml	2007-10-02 13:11:47 UTC (rev 15512)
@@ -60,7 +60,7 @@
 	</target>
 
 	<target name="ci-test.junit" depends="esb.init" description="Run JUnit based QA tests.">
-		<ant dir="junit" target="ci-test" />
+        <ant dir="junit" target="ci-test" />
 	</target>
 
 	<target name="clean" description="Clean the QA env">
@@ -76,7 +76,7 @@
 	
 	<target name="start-server" depends="esb.setup-esb">
 		<echo>server ${org.jboss.esb.server.home} ${org.jboss.esb.test.server.config}</echo>
-		<start-server serverHome="${org.jboss.esb.server.home}"
+        <start-server serverHome="${org.jboss.esb.server.home}"
 			serverConfig="${org.jboss.esb.test.server.config}"/>
 		<wait-on-server/>
 	</target>

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+    
+    <mbean code="org.jboss.jms.server.destination.TopicService"
+           name="jboss.esb.qa.junit.destination:service=Topic,name=JmsGatewayListenerUnitTest_topic"
+           xmbean-dd="xmdesc/Topic-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=JmsGatewayListenerUnitTest_queue_s1"
+           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=JmsGatewayListenerUnitTest_queue_s2"
+           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=JmsGatewayListenerUnitTest_queue_response_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=JmsGatewayListenerUnitTest_queue_response_srv"
+           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


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/JmsGatewayListenerUnitTest.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,77 @@
+/*
+ * 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.jms;
+
+import junit.framework.Test;
+import org.jboss.soa.esb.util.DeploymentArchive;
+import org.jboss.soa.esb.testutils.JMSUtil;
+import org.jboss.test.JBossTestCase;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JmsGatewayListenerUnitTest extends JBossTestCase {
+
+    DeploymentArchive deployment;
+
+    public JmsGatewayListenerUnitTest(String name) {
+        super(name);
+    }
+
+    public void test() throws Exception {
+        File file1 = new File("build/" + TargetServiceAction.FILE_PREFIX + "Service1-Received");
+        File file2 = new File("build/" + TargetServiceAction.FILE_PREFIX + "Service2-Received");
+
+        file1.delete();
+        file2.delete();
+        JMSUtil.sendMessageToTopic("Howya", "topic/JmsGatewayListenerUnitTest_topic", null);
+
+        long start = System.currentTimeMillis();
+        while(System.currentTimeMillis() < (start + 10000)) {
+            if(file1.exists() && file2.exists()) {
+                // Test passed...
+                return;
+            }
+            Thread.sleep(500);
+        }
+
+        fail("Test failed to deliver files to build dir: " + file1.getAbsolutePath() + ", " + file2.getAbsolutePath());
+    }
+
+    public static Test suite() throws Exception {
+        createEsbDeployment();
+
+        return getDeploySetup(JmsGatewayListenerUnitTest.class, "JmsGatewayListenerUnitTest.esb");
+    }
+
+    private static void createEsbDeployment() {
+        DeploymentArchive deployment = new DeploymentArchive("JmsGatewayListenerUnitTest.esb");
+
+        deployment.addEntry("META-INF/jboss-esb.xml", JmsGatewayListenerUnitTest.class.getResourceAsStream("jboss-esb.xml"));
+        deployment.addEntry("META-INF/deployment.xml", JmsGatewayListenerUnitTest.class.getResourceAsStream("deployment.xml"));
+        deployment.addEntry("jms-service.xml", JmsGatewayListenerUnitTest.class.getResourceAsStream("JmsGatewayListenerUnitTest-service.xml"));
+        deployment.addEntry(MessageAugmentor.class);
+        deployment.addEntry(TargetServiceAction.class);
+
+        deployment.create();
+    }
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/MessageAugmentor.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/MessageAugmentor.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/MessageAugmentor.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,67 @@
+/*
+ * 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.jms;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import junit.framework.TestCase;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class MessageAugmentor extends AbstractActionPipelineProcessor {
+
+    public static List<String> messages = new ArrayList<String>();
+    private String addition;
+    private String target;
+
+    public MessageAugmentor(ConfigTree config) throws ConfigurationException {
+        addition = config.getRequiredAttribute("addition");
+        target = config.getRequiredAttribute("target");
+    }
+
+    public Message process(final Message message) throws ActionProcessingException {
+        message.getProperties().setProperty("addition", addition);
+
+        String[] targetTokens = target.split(":");
+        if(targetTokens.length != 2) {
+            TestCase.fail("Action not configured properly - 'target' service property must be in format 'category:name'.");
+        }
+
+        try {
+            ServiceInvoker invoker = new ServiceInvoker(targetTokens[0], targetTokens[1]);
+            invoker.deliverAsync(message);
+        } catch (MessageDeliverException e) {
+            TestCase.fail("Failed to create ServiceInvoker: " + e.getMessage());
+        }
+
+        messages.add(addition);
+
+        return message;
+    }
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/TargetServiceAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/TargetServiceAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/TargetServiceAction.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,61 @@
+/*
+ * 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.jms;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class TargetServiceAction extends AbstractActionPipelineProcessor {
+
+    public static final String FILE_PREFIX = "TargetServiceAction-";
+    private static Logger logger = Logger.getLogger(TargetServiceAction.class);
+    private static String buildDir = System.getProperty("build.dir");
+
+    public TargetServiceAction(ConfigTree config) {
+    }
+
+    public Message process(final Message message) throws ActionProcessingException {
+        String addition = (String) message.getProperties().getProperty("addition");
+        File buildDirFile = new File(buildDir);
+
+        if(!buildDirFile.exists()) {
+            throw new ActionProcessingException("Invalid 'build.dir' dir '" + buildDirFile.getAbsolutePath() + "'.");
+        }
+
+        File file = new File(buildDirFile, FILE_PREFIX + addition);
+        try {
+            logger.info("Creating file " + file.getAbsolutePath());
+            file.createNewFile();
+        } catch (IOException e) {
+            throw new ActionProcessingException("Failed to create file '" + file.getAbsolutePath() + "'.");
+        }
+
+        return message;
+    }
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,7 @@
+<jbossesb-deployment>
+    <depends>jboss.esb.qa.junit.destination:service=Topic,name=JmsGatewayListenerUnitTest_topic</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=JmsGatewayListenerUnitTest_queue_s1</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=JmsGatewayListenerUnitTest_queue_s2</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=JmsGatewayListenerUnitTest_queue_response_gtw</depends>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=JmsGatewayListenerUnitTest_queue_response_srv</depends>
+</jbossesb-deployment>


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/deployment.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,83 @@
+<?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">
+
+    <!--
+                                - -> MyService1 -> - MyService3 - - -|
+                                |                                    |
+    UnitTest -> - "test-topic" -|                                    |- - - "queue_testnotify" - UnitTest  
+                                |                                    |
+                                - -> MyService2 -> - MyService3 - - -|
+    -->
+
+
+    <providers>
+        <jms-provider name="JMS" connection-factory="ConnectionFactory"
+                      jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+                      jndi-URL="localhost">
+
+            <jms-bus busid="test-topic">
+                <jms-message-filter dest-type="TOPIC" dest-name="topic/JmsGatewayListenerUnitTest_topic"/>
+            </jms-bus>
+
+            <jms-bus busid="test-queue-s1">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/JmsGatewayListenerUnitTest_queue_s1"/>
+            </jms-bus>
+            <jms-bus busid="test-queue-s2">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/JmsGatewayListenerUnitTest_queue_s2"/>
+            </jms-bus>
+
+            <jms-bus busid="test-queue-response-gtw">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/JmsGatewayListenerUnitTest_queue_response_gtw"/>
+            </jms-bus>
+            <jms-bus busid="test-queue-response-srv">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/JmsGatewayListenerUnitTest_queue_response_srv"/>
+            </jms-bus>
+        </jms-provider>
+    </providers>
+
+    <services>
+
+        <service category="MyServiceCategory" name="MyService1" description="Topic receiver 1">
+            <listeners>
+                <jms-listener name="JMS-Gateway" busidref="test-topic" is-gateway="true"/>
+                <jms-listener name="JMS-ESBListener" busidref="test-queue-s1"/>
+            </listeners>
+            <actions>
+                <action name="augmentor" class="org.jboss.soa.esb.jms.MessageAugmentor">
+                    <property name="addition" value="Service1-Received"/>
+                    <property name="target" value="MyServiceCategory:MyService3"/>
+                </action>
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService2" description="Topic receiver 2">
+            <listeners>
+                <jms-listener name="JMS-Gateway" busidref="test-topic" is-gateway="true"/>
+                <jms-listener name="JMS-ESBListener" busidref="test-queue-s2"/>
+            </listeners>
+            <actions>
+                <action name="augmentor" class="org.jboss.soa.esb.jms.MessageAugmentor">
+                    <property name="addition" value="Service2-Received"/>
+                    <property name="target" value="MyServiceCategory:MyService3"/>
+                </action>
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService3" description="Target Service">
+            <listeners>
+                <jms-listener name="JMS-Gateway" busidref="test-queue-response-gtw" is-gateway="true"/>
+                <jms-listener name="JMS-ESBListener" busidref="test-queue-response-srv"/>
+            </listeners>
+            <actions>
+                <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
+                    <property name="message" value="Hi" />
+                </action>
+                <action name="target" class="org.jboss.soa.esb.jms.TargetServiceAction" />
+            </actions>
+        </service>
+
+    </services>
+
+</jbossesb>


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/jms/jboss-esb.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DeploymentArchive.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DeploymentArchive.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DeploymentArchive.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -0,0 +1,160 @@
+/*
+ * 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.util;
+
+import junit.framework.TestCase;
+
+import java.util.zip.ZipOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import java.io.*;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.apache.log4j.Logger;
+
+/**
+ * Deployment archive creator.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DeploymentArchive {
+
+    private static Logger logger = Logger.getLogger(DeploymentArchive.class);
+    private static final String PROP_ORG_JBOSS_ESB_DEPLOY_DIR = "jbosstest.deploy.dir";
+
+    private File archiveFile;
+    private LinkedHashMap<String, byte[]> entries = new LinkedHashMap<String, byte[]>();
+
+    /**
+     * Create the named archive in the folder denoted by the "jbosstest.deploy.dir"
+     * System property.
+     *
+     * @param name Archive name.
+     */
+    public DeploymentArchive(String name) {
+        this(getParentFolder(name), name);
+    }
+
+    /**
+     * Create the named archive in the folder specified by the parentFolder arg.
+     *
+     * @param parentFolder Archive parent folder.
+     * @param name Archive name.
+     */
+    public DeploymentArchive(File parentFolder, String name) {
+        AssertArgument.isNotNull(parentFolder, "parentFolder");
+        AssertArgument.isNotNullAndNotEmpty(name, "name");
+
+        if(!parentFolder.exists()) {
+            TestCase.fail("Cannot create archive '" + name + "'.  Parent folder '" + parentFolder.getAbsolutePath() + "' does not exist.");
+        }
+        archiveFile = new File(parentFolder, name);
+    }
+
+    private static File getParentFolder(String name) {
+        String deployTargetFolder = System.getProperty(PROP_ORG_JBOSS_ESB_DEPLOY_DIR);
+        if(deployTargetFolder == null) {
+            TestCase.fail("Cannot create archive '" + name + "'.  Parent folder must be specified in System property '" + PROP_ORG_JBOSS_ESB_DEPLOY_DIR + "'.");
+        }
+        return new File(deployTargetFolder);
+    }
+
+    public void addEntry(String path, InputStream data) {
+        AssertArgument.isNotNullAndNotEmpty(path, "path");
+        AssertArgument.isNotNull(data, "data");
+        
+        try {
+            entries.put(path, StreamUtils.readStream(data));
+        } finally {
+            try {
+                data.close();
+            } catch (IOException e) {
+                TestCase.fail("Unable to close input stream for archive entry '" + path + "'.");
+            }
+        }
+    }
+
+    public void addEntry(String path, String resClasspathLocation) {
+        InputStream resource = getClass().getResourceAsStream(resClasspathLocation);
+        if(resource == null) {
+            TestCase.fail("Unable to close input stream for archive entry '" + path + "'.");
+        } else {
+            addEntry(path, resource);
+        }
+    }
+
+    public void addEntry(Class clazz) {
+        String className = clazz.getName();
+
+        className = className.replace('.', '/') + ".class";
+        addEntry(className, "/" + className);
+    }
+
+    /**
+     * Create an archive of the specified name and containing entries
+     * for the data contained in the streams supplied entries arg. 
+     * specifying the entry name and the value is a InputStream containing
+     * the entry data. 
+     */
+    public void create() {
+        ZipOutputStream archiveStream = null;
+        try {
+            archiveStream = new ZipOutputStream(new FileOutputStream(archiveFile));
+        } catch (FileNotFoundException e) {
+            TestCase.fail("Unable to open output stream to archive file '" + archiveFile.getAbsolutePath() + "'.");
+        }
+
+        try {
+            writeEntriesToArchive(archiveStream);
+            logger.info("Deployment archive '" + archiveFile.getAbsolutePath() + "' created.");
+        } finally {
+            try {
+                archiveStream.close();
+            } catch (IOException e) {
+                TestCase.fail("Unable to close output stream to archive file '" + archiveFile.getAbsolutePath() + "'.");
+            }
+        }
+    }
+
+    /**
+     * Remove the archive.
+     */
+    public void remove() {
+        if(archiveFile.exists()) {
+            archiveFile.delete();
+        }
+    }
+
+    private void writeEntriesToArchive(ZipOutputStream archiveStream) {
+        Set<Map.Entry<String, byte[]>> entrySet = entries.entrySet();
+        for (Map.Entry<String, byte[]> entry : entrySet) {
+            try {
+                archiveStream.putNextEntry(new ZipEntry(entry.getKey()));
+                archiveStream.write(entry.getValue());
+                archiveStream.closeEntry();
+            } catch (IOException e) {
+                TestCase.fail("Unable to create archive entry for '" + archiveFile.getAbsolutePath() + "': " + e.getMessage());
+            }
+        }
+    }
+}


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

Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java	2007-10-02 12:54:41 UTC (rev 15511)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/JMSClientUtil.java	2007-10-02 13:11:47 UTC (rev 15512)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.util;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.helpers.NamingContext;
-
-/**
- * JMS Client utilities.
- * @author Esteban
- */
-public class JMSClientUtil {
-	
-	private static Logger logger = Logger.getLogger(JMSClientUtil.class); 
-	
-	/**
-	 * Test queues - correspond to the default queue set e.g. "queue/A", "queue/B" etc.
-	 */
-	public enum QUEUE {
-		A, B, C, D, ex
-	};
-
-	/**
-	 * Send a message to the specified queue.
-	 * @param message The message to be sent (String or other Object).
-	 * @param queue The {@link QUEUE} to send the message to.
-	 * @param properties The String properties to be set on the message.
-	 * @throws Exception
-	 */
-	public static void sendMessageToQueue(Serializable message, QUEUE queue, KeyValuePair[] properties) {
-		JMSSendQueueSetup queueSetup = null;
-		
-		if(message == null || queue == null) {
-			TestCase.fail("Invalid call to sendMessageToQueue: neither 'message' or 'queue' params can be null.");
-		}
-		
-		try {
-			queueSetup = new JMSSendQueueSetup(queue);
-			logger.info("Queue Setup for sending: " + queueSetup.queueName);
-	
-			// Send a Text message to the queue...
-			if (message instanceof String) {
-				TextMessage oMsg = queueSetup.jmsSession.createTextMessage();
-	
-				logger.info("Sending Text message: [" + message + "]");
-				oMsg.setText((String)message);
-				setStringProperties(oMsg, properties);
-				queueSetup.jmsProducer.send(oMsg);
-			} else {
-				ObjectMessage oMsg = queueSetup.jmsSession.createObjectMessage();
-				
-				logger.info("Sending Object message: [" + message + "]");
-				oMsg.setObject(message);
-				setStringProperties(oMsg, properties);
-				queueSetup.jmsProducer.send(oMsg);
-			}
-			logger.info("Message sent: [" + message + "]");
-		} catch(Exception e) {
-			String errorMessage = "Exception while sending message [" + message + "] to queue [" + queue + "].";
-			logger.error(errorMessage, e);
-			TestCase.fail(errorMessage + ": " + e.getMessage());
-		} finally {
-			if(queueSetup != null) {
-				logger.info("Closing Queue Setup: " + queueSetup.queueName);
-				queueSetup.close();
-			}
-		}
-	}
-
-	private static void setStringProperties(Message msg, KeyValuePair[] properties) throws JMSException {
-		if(properties == null) {
-			return;
-		}
-		
-		for(KeyValuePair property : properties) {
-			msg.setStringProperty(property.getKey(), property.getValue());
-		}
-	}
-
-	
-	private static class JMSSendQueueSetup {
-		QueueSession jmsSession;
-		Queue jmsQueue;
-		MessageProducer jmsProducer;
-		String queueName;
-
-		private JMSSendQueueSetup(QUEUE queue) throws Exception {
-            Properties environment = new Properties();
-            environment.setProperty(Context.PROVIDER_URL, Configuration.getJndiServerURL());
-            environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, Configuration.getJndiServerContextFactory());
-            environment.setProperty(Context.URL_PKG_PREFIXES, Configuration.getJndiServerPkgPrefix());
-			Context oCtx = NamingContext.getServerContext(environment);
-			QueueConnectionFactory qcf = (QueueConnectionFactory) oCtx.lookup("ConnectionFactory");
-			QueueConnection oQconn = qcf.createQueueConnection();
-
-			queueName = "queue/" + queue.name();
-			
-			jmsSession = oQconn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-			jmsQueue = (Queue) oCtx.lookup(queueName);
-			jmsProducer = jmsSession.createSender(jmsQueue);
-            oCtx.close();
-		}
-		
-		private void close() {
-			try {
-				jmsProducer.close();
-				jmsSession.close();
-			} catch (Exception e) {
-				logger.error("Unable to close JMS Queue Setup.", e);
-				TestCase.fail("Unable to close JMS Queue Setup: " + e.getMessage());
-			}
-		}
-	}
-}




More information about the jboss-svn-commits mailing list