[jboss-svn-commits] JBL Code SVN: r24678 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta: tests/src/org/jboss/soa/esb/message and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 13 12:31:58 EST 2009
Author: tfennelly
Date: 2009-01-13 12:31:57 -0500 (Tue, 13 Jan 2009)
New Revision: 24678
Added:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/FaultProcessorAction.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB-2227-config-01.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB_2227_UnitTest.java
Modified:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2227: ServiceInvoker not properly handling acync delivery of fault messages.
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2009-01-13 17:18:06 UTC (rev 24677)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2009-01-13 17:31:57 UTC (rev 24678)
@@ -345,17 +345,23 @@
{
replyMessage = eprInvoker.attemptDelivery(message, epr);
if (replyMessage != null) {
- // remove the security context so that it is not exposed to the action pipeline.
- replyMessage.getContext().removeContext(SecurityService.CONTEXT);
- replyMessage.getContext().removeContext(SecurityService.AUTH_REQUEST);
+ if(eprInvoker.synchronous) {
+ // remove the security context so that it is not exposed to the action pipeline.
+ replyMessage.getContext().removeContext(SecurityService.CONTEXT);
+ replyMessage.getContext().removeContext(SecurityService.AUTH_REQUEST);
- if (Type.isFaultMessage(replyMessage)) {
- Factory.createExceptionFromFault(replyMessage) ;
+ if (Type.isFaultMessage(replyMessage)) {
+ Factory.createExceptionFromFault(replyMessage) ;
+ }
+
+ // We've delivered it, we're done!
+ return replyMessage;
+ } else {
+ // It was an async delivery. The replyMessage was just an indicator that
+ // the delivery succeeded. Return null...
+ return null;
}
-
- // We've delivered it, we're done!
- return replyMessage;
- } else {
+ } else {
logger.info("Unresponsive EPR: " + epr+" for message: "+message.getHeader());
serviceClusterInfo.removeDeadEPR(epr);
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/FaultProcessorAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/FaultProcessorAction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/FaultProcessorAction.java 2009-01-13 17:31:57 UTC (rev 24678)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.message.fault;
+
+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 java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class FaultProcessorAction extends AbstractActionPipelineProcessor {
+
+ public static List<Message> faultMessages = new ArrayList<Message>();
+
+ public FaultProcessorAction(ConfigTree config) {
+ }
+
+ public Message process(Message message) throws ActionProcessingException {
+ faultMessages.add(message);
+ return message;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/FaultProcessorAction.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB-2227-config-01.xml (from rev 24650, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-01.xml)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB-2227-config-01.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB-2227-config-01.xml 2009-01-13 17:31:57 UTC (rev 24678)
@@ -0,0 +1,18 @@
+<?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">
+
+ <services>
+ <service category="ServiceCat" name="CallService" description="The Service">
+ <actions mep="OneWay">
+ <action name="action" class="org.jboss.soa.esb.mock.MockAction" />
+ </actions>
+ </service>
+
+ <service category="ServiceCat" name="FaultService" description="The Fault Service">
+ <actions mep="OneWay">
+ <action name="action" class="org.jboss.soa.esb.message.fault.FaultProcessorAction" />
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB-2227-config-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB_2227_UnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB_2227_UnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB_2227_UnitTest.java 2009-01-13 17:31:57 UTC (rev 24678)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.message.fault;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.mock.MockAction;
+import org.jboss.soa.esb.testutils.AbstractTestRunner;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.util.Type;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBESB_2227_UnitTest extends TestCase {
+
+
+ protected void setUp() throws Exception {
+ System.setProperty(Environment.DEFAULT_INVM_SCOPE, "GLOBAL");
+ MockAction.exception = null;
+ }
+
+ protected void tearDown() throws Exception {
+ System.setProperty(Environment.DEFAULT_INVM_SCOPE, "NONE");
+ MockAction.exception = null;
+ }
+
+ public void test_async() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
+ ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "CallService");
+ Message message = MessageFactory.getInstance().getMessage();
+
+ FaultProcessorAction.faultMessages.clear();
+ MockAction.exception = new ActionProcessingException("Exception in Service Action!!!");
+
+ message.getBody().add("Hi there!");
+ message.getHeader().getCall().setFaultTo(new LogicalEPR("ServiceCat", "FaultService"));
+ invoker.deliverAsync(message);
+
+ waitForFault(message);
+
+ Message faultMessage = FaultProcessorAction.faultMessages.get(0);
+ assertTrue(Type.isFaultMessage(faultMessage));
+ assertEquals("org.jboss.soa.esb.actions.ActionProcessingException: Exception in Service Action!!!", faultMessage.getFault().getReason());
+ }
+ }.setServiceConfig("JBESB-2227-config-01.xml");
+
+ testRunner.run();
+ }
+
+ private void waitForFault(Message message) {
+ long start = System.currentTimeMillis();
+
+ while(System.currentTimeMillis() - start < 5000) {
+ if(!FaultProcessorAction.faultMessages.isEmpty()) {
+ return;
+ }
+ sleep(50);
+ }
+
+ fail("Timed out waiting on fault message!!");
+ }
+
+ private static void sleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ fail("Unexpected InterruptedException exception.");
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/fault/JBESB_2227_UnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list