Author: objectiser
Date: 2009-11-06 13:21:59 -0500 (Fri, 06 Nov 2009)
New Revision: 249
Added:
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartESBBPELLoanFaultTestCase.java
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/build.xml
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/deployment.xml
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jbm-queue-service.xml
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jboss-esb.xml
Modified:
trunk/integration-tests/build.xml
trunk/integration-tests/pom.xml
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/BPELInvoke.java
Log:
Added integration test example for faults - although currently the test is restricted to
just checking the fault message body, due to a class version conflict with QName.
Modified: trunk/integration-tests/build.xml
===================================================================
--- trunk/integration-tests/build.xml 2009-11-06 14:40:45 UTC (rev 248)
+++ trunk/integration-tests/build.xml 2009-11-06 18:21:59 UTC (rev 249)
@@ -104,5 +104,6 @@
<ant antfile="src/test/resources/samples/Quickstart_bpel_atm/build.xml"
/>
<ant
antfile="src/test/resources/samples/Quickstart_esb_bpel_hello_world/build.xml"
/>
+ <ant
antfile="src/test/resources/samples/Quickstart_esb_bpel_loan_fault/build.xml"
/>
</target>
</project>
Modified: trunk/integration-tests/pom.xml
===================================================================
--- trunk/integration-tests/pom.xml 2009-11-06 14:40:45 UTC (rev 248)
+++ trunk/integration-tests/pom.xml 2009-11-06 18:21:59 UTC (rev 249)
@@ -184,7 +184,7 @@
<!-- Cleanup test environment in case of previous failure -->
<!--
- <ant antfile="${basedir}/build.xml">
+ <ant antfile="${basedir}/build.xml">
<target name="undeploy-riftsaw" />
</ant>
-->
Added:
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartESBBPELLoanFaultTestCase.java
===================================================================
---
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartESBBPELLoanFaultTestCase.java
(rev 0)
+++
trunk/integration-tests/src/test/java/org/jboss/soa/bpel/tests/samples/QuickstartESBBPELLoanFaultTestCase.java 2009-11-06
18:21:59 UTC (rev 249)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.bpel.tests.samples;
+
+import org.jboss.soa.bpel.tests.RiftSawTest;
+import org.jboss.soa.bpel.tests.RiftSawTestSetup;
+
+import junit.framework.Test;
+
+/**
+ * Test case for running the Quickstart_bpel_loan_fault sample.
+ */
+public class QuickstartESBBPELLoanFaultTestCase extends RiftSawTest {
+
+ private static final String TEST_NAME = "Quickstart_esb_bpel_loan_fault";
+ protected static final String BODY_FAULT_CODE =
"org.jboss.soa.esb.message.fault.detail.code";
+ protected static final String BODY_FAULT_MESSAGE =
"org.jboss.soa.esb.message.fault.detail.detail";
+
+ public QuickstartESBBPELLoanFaultTestCase() {
+ super(TEST_NAME);
+ }
+
+ public static Test suite() {
+ return(new RiftSawTestSetup(QuickstartESBBPELLoanFaultTestCase.class,
+ TEST_NAME,
"Quickstart_esb_bpel_loan_fault.esb,../Quickstart_bpel_loan_approval/Quickstart_bpel_loan_approval-1.jar,../Quickstart_bpel_loan_approval/Quickstart_bpel_loan_approval.war"));
+ }
+
+ public void testSendLoanRequestZeroAmountException() throws Exception {
+ try {
+ String
result=sendESBMessage("<request><firstName>Jane</firstName><name>Bloggs</name><amount>0</amount></request>",
+ "LoanFaultBPELESB", "LoanFailException");
+
+ fail("Test should have failed with FaultMessageException");
+
+ } catch(org.jboss.soa.esb.couriers.FaultMessageException fme) {
+
+ assertMessage((String)fme.getReturnedMessage().getBody().get(BODY_FAULT_MESSAGE),
+ "<message><errorCode><integer
xmlns=\"http://example.com/loan-approval/xsd/error-messages/\"&...);
+
+ //System.out.println("FAULT:
"+fme.getReturnedMessage().getBody().get(BODY_FAULT_CODE));
+
+ } catch(Exception e) {
+ fail("Test failed with exception: "+e);
+ }
+ }
+
+ public void testSendLoanRequestZeroAmountFaultMessage() throws Exception {
+ try {
+ String
result=sendESBMessage("<request><firstName>Jane</firstName><name>Bloggs</name><amount>0</amount></request>",
+ "LoanFaultBPELESB", "LoanFailMessage");
+
+ fail("Test should have failed with FaultMessageException");
+
+ } catch(org.jboss.soa.esb.couriers.FaultMessageException fme) {
+
+ assertMessage((String)fme.getReturnedMessage().getBody().get(BODY_FAULT_MESSAGE),
+ "<message><errorCode><integer
xmlns=\"http://example.com/loan-approval/xsd/error-messages/\"&...);
+
+ //System.out.println("FAULT:
"+fme.getReturnedMessage().getBody().get(BODY_FAULT_CODE));
+
+ } catch(Exception e) {
+ fail("Test failed with exception: "+e);
+ }
+ }
+}
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/build.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/build.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/build.xml 2009-11-06
18:21:59 UTC (rev 249)
@@ -0,0 +1,28 @@
+<project name="Quickstart_esb_bpel_loan_fault" default="deploy"
basedir=".">
+
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <property name="deploy.dir" value="${basedir}/target/tests"/>
+ <property name="test.dir"
value="${basedir}/src/test/resources/samples/${ant.project.name}" />
+
+ <property name="sample.esb.name" value="${ant.project.name}.esb"
/>
+
+ <target name="deploy">
+ <echo>Deploy ${ant.project.name}</echo>
+ <mkdir dir="${deploy.dir}/${ant.project.name}" />
+ <zip destfile="${deploy.dir}/${ant.project.name}/${sample.esb.name}">
+ <zipfileset dir="${test.dir}" includes="deployment.xml"
fullpath="META-INF/deployment.xml"/>
+ <zipfileset dir="${test.dir}" includes="jboss-esb.xml"
fullpath="META-INF/jboss-esb.xml"/>
+ <zipfileset dir="${test.dir}" includes="jbm-queue-service.xml"
fullpath="jbm-queue-service.xml"/>
+ </zip>
+ </target>
+
+ <target name="undeploy">
+ <echo>Undeploy ${ant.project.name}</echo>
+ <delete file="${deploy.dir}/${sample.jar.name}" />
+ </target>
+
+</project>
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/deployment.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/deployment.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/deployment.xml 2009-11-06
18:21:59 UTC (rev 249)
@@ -0,0 +1,6 @@
+<jbossesb-deployment>
+ <depends>jboss.bpel:service=BPELEngine</depends>
+
<depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_esb</depends>
+
<depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_esb_reply</depends>
+
<depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_gw</depends>
+</jbossesb-deployment>
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jbm-queue-service.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jbm-queue-service.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jbm-queue-service.xml 2009-11-06
18:21:59 UTC (rev 249)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+
name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_esb"
+ 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.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_esb_reply"
+ 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.quickstart.destination:service=Queue,name=quickstart_bpel_loan_fault_Request_gw"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added:
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jboss-esb.xml
===================================================================
---
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jboss-esb.xml
(rev 0)
+++
trunk/integration-tests/src/test/resources/samples/Quickstart_esb_bpel_loan_fault/jboss-esb.xml 2009-11-06
18:21:59 UTC (rev 249)
@@ -0,0 +1,79 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc...
parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMQ"
connection-factory="ConnectionFactory">
+ <jms-bus busid="quickstartGwChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_bpel_loan_fault_Request_gw"
+ />
+ </jms-bus>
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_bpel_loan_fault_Request_esb"
+ />
+ </jms-bus>
+
+ </jms-provider>
+ </providers>
+
+ <services>
+ <service
+ category="LoanFaultBPELESB"
+ name="LoanFailException"
+ description="Fail to get loan approved, fault returned as an exception
aborting the pipeline">
+ <listeners>
+ <jms-listener name="JMS-Gateway"
+ busidref="quickstartGwChannel"
+ is-gateway="true" />
+ <jms-listener name="loanFault"
+ busidref="quickstartEsbChannel" />
+ </listeners>
+ <actions>
+ <action name="action1"
class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull"
value="true"/>
+ </action>
+ <action name="action2"
class="org.jboss.soa.esb.actions.bpel.BPELInvoke">
+ <property name="service"
value="{http://example.com/loan-approval/wsdl/}loanService"/>
+ <property name="operation" value="request"
/>
+ <property name="abortOnFault" value="true" />
+ </action>
+ <action name="action3"
class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull"
value="true"/>
+ </action>
+ <!-- The next action is for Continuous Integration testing -->
+ <action name="testStore"
class="org.jboss.soa.esb.actions.TestMessageStore"/>
+ </actions>
+ </service>
+ <service
+ category="LoanFaultBPELESB"
+ name="LoanFailMessage"
+ description="Fail to get loan approved, fault returned as a
message">
+ <listeners>
+ <jms-listener name="JMS-Gateway"
+ busidref="quickstartGwChannel"
+ is-gateway="true" />
+ <jms-listener name="loanFault"
+ busidref="quickstartEsbChannel" />
+ </listeners>
+ <actions>
+ <action name="action1"
class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull"
value="true"/>
+ </action>
+ <action name="action2"
class="org.jboss.soa.esb.actions.bpel.BPELInvoke">
+ <property name="service"
value="{http://example.com/loan-approval/wsdl/}loanService"/>
+ <property name="operation" value="request"
/>
+ <property name="abortOnFault" value="false" />
+ </action>
+ <action name="action3"
class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull"
value="true"/>
+ </action>
+ <!-- The next action is for Continuous Integration testing -->
+ <action name="testStore"
class="org.jboss.soa.esb.actions.TestMessageStore"/>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Modified:
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/BPELInvoke.java
===================================================================
---
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/BPELInvoke.java 2009-11-06
14:40:45 UTC (rev 248)
+++
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/soa/esb/actions/bpel/BPELInvoke.java 2009-11-06
18:21:59 UTC (rev 249)
@@ -137,6 +137,8 @@
throw new RuntimeException("Failed to obtain DOM representation of message
value");
}
+ logger.debug("Node type is: "+node.getNodeType()+"
requestPartName="+requestPartName);
+
// If value is an element, and no request part name has been provided,
// then pass the DOM element through as is.
if (node.getNodeType() == Node.ELEMENT_NODE &&
@@ -235,10 +237,15 @@
if (faultName != null) {
logger.debug("Fault '"+faultName+"' detected, throwing
exception");
- //ret.getFault().setReason(faultName.toString());
- throw new
org.jboss.soa.esb.actions.ActionProcessingDetailFaultException(faultName,
+ org.jboss.soa.esb.actions.ActionProcessingDetailFaultException faultException=
+ new org.jboss.soa.esb.actions.ActionProcessingDetailFaultException(faultName,
"Fault '"+faultName+"' occurred when calling service
'"+serviceName+"'",
respValue.toString());
+
+ // In case we wanted to return the fault message as the message body
+ //faultException.getFaultMessage().getBody().add(respValue.toString());
+
+ throw faultException;
}
}
} catch(org.jboss.soa.esb.actions.ActionProcessingDetailFaultException fault) {