[jboss-svn-commits] JBL Code SVN: r34071 - in labs/jbossesb/trunk/qa/junit: resources/server and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 20 13:04:29 EDT 2010


Author: tcunning
Date: 2010-07-20 13:04:27 -0400 (Tue, 20 Jul 2010)
New Revision: 34071

Added:
   labs/jbossesb/trunk/qa/junit/resources/server/epr/
   labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/
   labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/deployment.xml
   labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/resources/server/epr/jbm-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/epr/jbmq-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/epr/test-service.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorage.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorageMBean.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/LogicalEPRUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/MyAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service2Action.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action1.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action2.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service4Action.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/ServiceInvokerAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/StoreToJMXAction.java
Removed:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/epr/
Modified:
   labs/jbossesb/trunk/qa/junit/build.xml
Log:
JBESB-2110
Convert LogicalEPRUnitTest so that it no longer uses a file for output,
but uses an MBean like FTPUnitTest.


Modified: labs/jbossesb/trunk/qa/junit/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/build.xml	2010-07-20 16:07:00 UTC (rev 34070)
+++ labs/jbossesb/trunk/qa/junit/build.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -97,6 +97,20 @@
          </fileset>
          <fileset dir="${qa.build.ftp}" includes="META-INF/*.xml"/>
       </jar>
+      <jar jarfile="${qa.build.lib}/epr-test.esb">
+         <fileset dir="${qa.junit.classes}">
+            <include name="org/jboss/soa/esb/server/EPRStorage.class"/>
+            <include name="org/jboss/soa/esb/server/EPRStorageMBean.class"/>
+	    <include name="org/jboss/soa/esb/server/epr/*.class"/>
+         </fileset>
+         <fileset dir="${qa.junit.resources}/server/epr">
+            <include name="test-service.xml"/>
+         </fileset>
+         <fileset dir="${qa.junit.resources}/server/epr">
+            <include name="${org.jboss.soa.esb.qa.jmsprovider}-service.xml"/>
+            <include name="META-INF/*.xml"/>
+         </fileset>
+      </jar>
       <jar jarfile="${qa.build.lib}/jca-test.esb">
          <fileset dir="${qa.junit.classes}">
             <include name="org/jboss/soa/esb/server/*.class"/>

Added: labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/deployment.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/deployment.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,8 @@
+<jbossesb-deployment>
+    <depends>jboss.esb:test=EPRStorage</depends>
+    <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>
+    <depends>jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service4</depends>
+</jbossesb-deployment>

Added: labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/epr/META-INF/jboss-esb.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,105 @@
+<?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-bus busid="service4">
+                <jms-message-filter dest-type="QUEUE" dest-name="queue/LogicalEPRUnitTest_service4"/>
+            </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.server.epr.ServiceInvokerAction" />
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService2" description="Service 2">
+            <listeners>
+                <jms-listener name="JMS-ESBListener" busidref="service2"/>
+            </listeners>
+            <actions>
+            	<action name="displayAction" 
+            		class="org.jboss.soa.esb.server.epr.MyAction"
+            		process="process"/>
+
+                <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.server.epr.Service2Action" />
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService3" description="Service 3">
+            <listeners>
+                <jms-listener name="JMS-ESBListener" busidref="service3"/>
+            </listeners>
+            <actions>
+                <action name="displayAction"
+			class="org.jboss.soa.esb.server.epr.MyAction"
+			process="process">
+		</action>
+                <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.server.epr.Service3Action1" />
+		<action name="storeJMX" class="org.jboss.soa.esb.server.epr.StoreToJMXAction"/>
+                <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.server.epr.Service3Action2" />
+            </actions>
+        </service>
+
+        <service category="MyServiceCategory" name="MyService4" description="Service 4">
+            <listeners>
+                <jms-listener name="JMS-ESBListener" busidref="service4"/>
+            </listeners>
+            <actions>
+		<action name="displayAction"
+			class="org.jboss.soa.esb.server.epr.MyAction"
+			process="process">
+		</action>
+                <action name="Service4Action" class="org.jboss.soa.esb.server.epr.Service4Action" />
+		<action name="storeJMX" class="org.jboss.soa.esb.server.epr.StoreToJMXAction"/>
+                <action name="testStore" class="org.jboss.soa.esb.actions.StoreMessageToFile">
+                    <property name="filename" value="LogicalEPRUnitTest.log" />
+                    <property name="raw" value="true"/>
+                </action>
+            </actions>
+        </service>
+    </services>
+
+</jbossesb>

Added: labs/jbossesb/trunk/qa/junit/resources/server/epr/jbm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/epr/jbm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/epr/jbm-service.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,39 @@
+<?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>
+
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service4"
+           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

Added: labs/jbossesb/trunk/qa/junit/resources/server/epr/jbmq-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/epr/jbmq-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/epr/jbmq-service.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1_gtw">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+    </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service1">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+    </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service2">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+    </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service3">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+    </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.qa.junit.destination:service=Queue,name=LogicalEPRUnitTest_service4">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+    </mbean>
+</server>

Added: labs/jbossesb/trunk/qa/junit/resources/server/epr/test-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/epr/test-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/epr/test-service.xml	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.esb:test=EPRStorage" code="org.jboss.soa.esb.server.EPRStorage"/>
+</server>

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorage.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorage.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorage.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,22 @@
+package org.jboss.soa.esb.server;
+
+/**
+ * Storage MBean for the LogicalEPRUnitTest
+ * 
+ * @author <a href="tcunning at redhat.com">Tom Cunningham</a>
+ */
+public class EPRStorage implements EPRStorageMBean {
+	   private String storage = null;
+	
+	   public void clearMessage() {
+		   this.storage = null;
+	   }
+	   
+	   public void setMessage(final String message) {
+		   this.storage = message;
+	   }
+	   
+	   public String getMessage() {
+		   return storage;
+	   }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorageMBean.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorageMBean.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/EPRStorageMBean.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,38 @@
+/*
+* 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.server;
+
+/**
+ * MBean to monitor redelivery of transaction based messages.
+ *
+ * @author <a href="tcunning at redhat.com">Tom Cunningham</a>
+ */
+public interface EPRStorageMBean
+{
+   public static final String objectName = "jboss.esb:test=EPRStorage";
+
+   public void clearMessage();
+   
+   public void setMessage(final String message) ;
+   
+   public String getMessage();
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/LogicalEPRUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/LogicalEPRUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/LogicalEPRUnitTest.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,125 @@
+/*
+* 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.server.epr;
+
+import junit.framework.Test;
+import org.jboss.soa.esb.TestUtils;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+
+import javax.management.Attribute;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+import org.jboss.soa.esb.testutils.JMSUtil;
+
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.server.EPRStorage;
+import org.jboss.soa.esb.server.EPRStorageMBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Id: BlobUnitTestCase.java 58110 2006-11-04 08:34:21Z scott.stark at jboss.org $
+ */
+
+public class LogicalEPRUnitTest
+        extends JBossTestCase
+{
+   public LogicalEPRUnitTest(String name)
+   {
+      super(name);
+   }
+
+   public void testJMX() throws Exception
+   {
+      //Thread.sleep(10000); // wait for message to post.
+      Attribute attr = new Attribute("Message", "foo");
+      getServer().setAttribute(new ObjectName(EPRStorageMBean.objectName), attr);
+      String version = (String)getServer().getAttribute(new ObjectName(EPRStorageMBean.objectName), "Message");
+      assertEquals("foo", version);      
+   }
+
+    public void test_replyto() throws Exception {
+	ObjectName on = new ObjectName(EPRStorageMBean.objectName);
+	getServer().invoke(on, "clearMessage", null, null);
+
+        // Send the message and wait for the drop...
+        JMSUtil.sendMessageToQueue("reply-To", "queue/LogicalEPRUnitTest_service1_gtw", null);
+	Thread.sleep(10000);
+      	String messageOutput = (String) getServer().getAttribute(on, "Message");
+        System.out.println("value from JMX = " + messageOutput);
+
+        assertEquals("Reply-To Service3", messageOutput);
+    }
+
+    public void test_faultto() throws Exception {
+	ObjectName on = new ObjectName(EPRStorageMBean.objectName);
+	getServer().invoke(on, "clearMessage", null, null);
+
+        // Send the message and wait for the drop...
+        JMSUtil.sendMessageToQueue("fault-To", "queue/LogicalEPRUnitTest_service1_gtw", null);
+	Thread.sleep(10000);
+	String messageOutput = (String) getServer().getAttribute(on, "Message");
+	System.out.println("value from JMX = " + messageOutput);
+        assertEquals("org.jboss.soa.esb.actions.ActionProcessingException: Service2Action fault", messageOutput);
+    }
+
+    public void test_logical_extension() throws Exception {
+	ObjectName on = new ObjectName(EPRStorageMBean.objectName);
+	getServer().invoke(on, "clearMessage", null, null);
+
+        final LogicalEPR logicalEPR = new LogicalEPR("MyServiceCategory", "MyService4") ;
+        final String tag = "TestTag" ;
+        final String prefix = "TestPrefix" ;
+        final String value = "TestValue" ;
+        
+        logicalEPR.getAddr().addExtension(tag, prefix, Service4Action.TEST_URI, value) ;
+        
+        final Message message = MessageFactory.getInstance().getMessage() ;
+        message.getBody().add("Incoming Test Payload") ;
+        logicalEPR.getServiceInvoker().deliverAsync(message) ;
+	Thread.sleep(10000);
+        String messageOutput = (String) getServer().getAttribute(on, "Message"); 
+        System.out.println("value from JMX = " + messageOutput);
+ 
+        final String expectedOutput = "Prefix " + prefix + " Tag " + tag + " value " + value ;
+        assertEquals(expectedOutput, messageOutput);
+    }
+
+
+
+   public static Test suite() throws Exception
+   {
+       return getDeploySetup(LogicalEPRUnitTest.class, "epr-test.esb");
+   }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/MyAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/MyAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/MyAction.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,80 @@
+/*
+* 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.server.epr;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.server.EPRStorageMBean;
+
+public class MyAction extends AbstractActionPipelineProcessor
+{
+   protected ConfigTree _config;
+
+   public MyAction(ConfigTree config)
+   {
+      _config = config;
+   }
+
+   public Message noOperation(Message message)
+   {
+      return message;
+   }
+
+   public Message process(Message message) throws ActionProcessingException
+   {
+      logHeader();
+      System.out.println("Body: " + message.getBody().get());
+      logFooter();
+      MBeanServer server = MBeanServerLocator.locateJBoss();
+      EPRStorageMBean storage;
+      try
+      {
+          storage = (EPRStorageMBean)MBeanProxyExt.create(EPRStorageMBean.class, EPRStorageMBean.objectName, server);
+      }
+      catch (final MalformedObjectNameException mone)
+      {
+          throw new ActionProcessingException("Error creating MBean proxy", mone) ;
+      }
+      return message;
+   }
+
+   // This makes it easier to read on the console
+   private void logHeader()
+   {
+      System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+   }
+
+   private void logFooter()
+   {
+      System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+   }
+
+
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service2Action.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service2Action.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service2Action.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -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.server.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;
+    }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action1.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action1.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action1.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -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.server.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;
+    }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action2.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action2.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service3Action2.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -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.server.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;
+    }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service4Action.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service4Action.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/Service4Action.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,70 @@
+/*
+ * 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.server.epr;
+
+import java.util.Iterator;
+
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference.Extension;
+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:Kevin.Conner at jboss.com">Kevin Conner</a>
+ */
+public class Service4Action extends AbstractActionPipelineProcessor
+{
+    public static final String TEST_URI = "http://labs.jboss.org/jbossesb/testing/test-uri" ;
+    
+    public Service4Action(final ConfigTree config)
+        throws MessageDeliverException
+    {
+    }
+
+    public Message process(final Message message)
+        throws ActionProcessingException
+    {
+        final Call call = message.getHeader().getCall() ;
+        final EPR toEPR = call.getTo() ;
+        final Iterator<Extension> extensions = toEPR.getAddr().getExtensions() ;
+        if (extensions.hasNext())
+        {
+            final StringBuilder sb = new StringBuilder() ;
+            do
+            {
+                final Extension extension = extensions.next() ;
+                if (TEST_URI.equals(extension.getURI()))
+                {
+                    sb.append("Prefix " + extension.getPrefix()) ;
+                    sb.append(" Tag " + extension.getTag()) ;
+                    sb.append(" value " + extension.getValue()) ;
+                }
+            }
+            while(extensions.hasNext()) ;
+            message.getBody().add(sb.toString()) ;
+        }
+
+        return message;
+    }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/ServiceInvokerAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/ServiceInvokerAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/ServiceInvokerAction.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -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.server.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;
+    }
+}

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/StoreToJMXAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/StoreToJMXAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/epr/StoreToJMXAction.java	2010-07-20 17:04:27 UTC (rev 34071)
@@ -0,0 +1,97 @@
+/*
+* 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.server.epr;
+
+import javax.management.ObjectName;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.Attribute;
+import javax.management.InstanceNotFoundException;
+import javax.management.AttributeNotFoundException;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.server.EPRStorageMBean;
+import org.jboss.soa.esb.server.EPRStorage;
+
+
+public class StoreToJMXAction extends AbstractActionPipelineProcessor
+{
+   protected ConfigTree _config;
+
+   public StoreToJMXAction(ConfigTree config)
+   {
+      _config = config;
+   }
+
+   public Message noOperation(Message message)
+   {
+      return message;
+   }
+
+   public Message process(Message message) throws ActionProcessingException
+   {
+      logHeader();
+      System.out.println("Body: " + message.getBody().get());
+      logFooter();
+      MBeanServer server = MBeanServerLocator.locateJBoss();
+      try
+      {
+	  ObjectName on = new ObjectName(EPRStorageMBean.objectName);
+	  String value = (String) message.getBody().get();
+	  Attribute attribute = new Attribute("Message", value); 	
+	  server.setAttribute(on, attribute);
+	  System.out.println((String)message.getBody().get());
+      }
+      catch (final MalformedObjectNameException mone)
+      {
+          throw new ActionProcessingException("Error creating MBean proxy", mone) ;
+      } catch (InstanceNotFoundException infe) 
+      {
+	  throw new ActionProcessingException("Instance not found", infe);
+      } catch (AttributeNotFoundException anfe)
+      {
+	  throw new ActionProcessingException("Message attribute not found", anfe);
+      } catch (Exception e) {
+     	  throw new ActionProcessingException("Exception caught", e); 
+      }
+      return message;
+   }
+
+   // This makes it easier to read on the console
+   private void logHeader()
+   {
+      System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+   }
+
+   private void logFooter()
+   {
+      System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+   }
+
+
+}



More information about the jboss-svn-commits mailing list