servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r383902 - in /incubator/servicemix/trunk: servicemix-bpe/src/main/java/org/apache/servicemix/bpe/ servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/ servicemix-bpe/src/test/java/org/apache/servicemix/bpe/ servicemix-common/src...
Date Tue, 07 Mar 2006 15:08:36 GMT
Author: gnodet
Date: Tue Mar  7 07:08:31 2006
New Revision: 383902

URL: http://svn.apache.org/viewcvs?rev=383902&view=rev
Log:
SM-306: fix message exchange meps

Modified:
    incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
    incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java
    incubator/servicemix/trunk/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/PojoSupport.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/TransformComponentSupport.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOnlyImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOptionalOutImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOutImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/RobustInOnlyImpl.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/JmsFlowTransactionTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MEPExchangeTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MessageExchangeTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/flow/jms/SimpleClusterSendSyncTest.java
    incubator/servicemix/trunk/servicemix-gbean/src/main/java/org/apache/servicemix/gbean/ServiceMixConfigBuilder.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
    incubator/servicemix/trunk/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java
    incubator/servicemix/trunk/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexPojoTest.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java

Modified: incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java Tue Mar  7 07:08:31 2006
@@ -76,8 +76,6 @@
         if (exchange.getStatus() == ExchangeStatus.DONE) {
             return;
         } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
-            exchange.setStatus(ExchangeStatus.DONE);
-            channel.send(exchange);
             return;
         }
 		BPELStaticKey bsk = new BPELStaticKey();
@@ -145,7 +143,6 @@
             } else {
                 exchange.setError(e);
             }
-            exchange.setStatus(ExchangeStatus.ERROR);
             channel.send(exchange);
         }
 	}

Modified: incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java (original)
+++ incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java Tue Mar  7 07:08:31 2006
@@ -167,29 +167,17 @@
                 throw new ActionSystemException("Timeout on sending message");
             }
             if (me.getStatus() == ExchangeStatus.ACTIVE) {
-                nm = me.getMessage("out");
-                if (nm != null) {
-                    try {
-                        XMLInteractionObject result = new XMLInteractionObject();
-                        result.setDocument((Document) transformer.toDOMNode(nm));
-                        output.put(BPEComponent.PART_PAYLOAD, result);
-                    } catch (Exception e) {
-                        throw new ActionSystemException(e);
-                    }
-                }
-                me.setStatus(ExchangeStatus.DONE);
-                channel.send(me);
-            } else if (me.getStatus() == ExchangeStatus.ERROR) {
-                // Extract fault or error
                 if (me.getFault() != null) {
                     Document fault;
                     try {
                         fault = (Document) transformer.toDOMNode(me.getFault());
+                        me.setStatus(ExchangeStatus.DONE);
                     } catch (Exception e) {
+                        me.setError(e);
                         throw new ActionSystemException(e);
+                    } finally {
+                        channel.send(me);
                     }
-                    me.setStatus(ExchangeStatus.DONE);
-                    channel.send(me);
                     Element e = fault.getDocumentElement();
                     BPRuntimeException bpre = new BPRuntimeException(e.getLocalName(), "");
                     bpre.setNameSpace(e.getNamespaceURI());
@@ -197,23 +185,26 @@
                     interaction.setDocument(fault);
                     bpre.addPartMessage("payload", interaction);
                     throw bpre;
-                    /*
+                } else {
                     try {
-                        XMLInteractionObject result = new XMLInteractionObject();
-                        result.setDocument((Document) transformer.toDOMNode(me.getFault()));
-                        output.put(BPEComponent.PART_PAYLOAD, result);
+                        nm = me.getMessage("out");
+                        if (nm != null) {
+                            XMLInteractionObject result = new XMLInteractionObject();
+                            result.setDocument((Document) transformer.toDOMNode(nm));
+                            output.put(BPEComponent.PART_PAYLOAD, result);
+                        }
+                        me.setStatus(ExchangeStatus.DONE);
                     } catch (Exception e) {
+                        me.setError(e);
                         throw new ActionSystemException(e);
+                    } finally {
+                        channel.send(me);
                     }
-                    me.setStatus(ExchangeStatus.DONE);
-                    channel.send(me);
-                    */
-                } else {
-                    Exception error = me.getError();
-                    me.setStatus(ExchangeStatus.DONE);
-                    channel.send(me);
-                    throw new BPRuntimeException("Unknown", error);
                 }
+            } else if (me.getStatus() == ExchangeStatus.ERROR) {
+                // Extract error
+                Exception error = me.getError();
+                throw new BPRuntimeException("Unknown", error);
             }
         } catch (MessagingException e) {
             throw new ActionSystemException(e);

Modified: incubator/servicemix/trunk/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java (original)
+++ incubator/servicemix/trunk/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java Tue Mar  7 07:08:31 2006
@@ -220,7 +220,7 @@
         me.setOperation(new QName("getLoanQuote"));
         me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>234341</ssn></getLoanQuoteRequest>"));
         client.sendSync(me);
-        assertEquals(ExchangeStatus.ERROR, me.getStatus());
+        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
         assertNotNull(me.getFault());
         client.done(me);
     }
@@ -242,7 +242,6 @@
         client.sendSync(me);
         assertEquals(ExchangeStatus.ERROR, me.getStatus());
         assertNotNull(me.getError());
-        client.done(me);
     }
     
     public static class Bank extends ComponentSupport implements MessageExchangeListener {

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java Tue Mar  7 07:08:31 2006
@@ -23,7 +23,6 @@
 import javax.jbi.component.ComponentLifeCycle;
 import javax.jbi.messaging.DeliveryChannel;
 import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.MessageExchange.Role;
@@ -242,14 +241,10 @@
                                 logger.error("Error processing exchange " + exchange, t);
                                 // Set an error on message
                                 try {
-                                    if (exchange instanceof InOnly) {
-                                        exchange.setStatus(ExchangeStatus.DONE);
+                                    if (t instanceof Exception) {
+                                        exchange.setError((Exception) t);
                                     } else {
-                                        if (t instanceof Exception) {
-                                            exchange.setError((Exception) t);
-                                        } else {
-                                            exchange.setError(new Exception("Throwable", t));
-                                        }
+                                        exchange.setError(new Exception("Throwable", t));
                                     }
                                     channel.send(exchange);
                                 } catch (Exception inner) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/PojoSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/PojoSupport.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/PojoSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/PojoSupport.java Tue Mar  7 07:08:31 2006
@@ -15,15 +15,6 @@
  */
 package org.apache.servicemix.components.util;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.JavaSource;
-import org.apache.servicemix.jbi.FaultException;
-import org.apache.servicemix.jbi.NotInitialisedYetException;
-import org.apache.servicemix.jbi.management.BaseLifeCycle;
-import org.apache.servicemix.jbi.messaging.NormalizedMessageImpl;
-import org.apache.servicemix.jbi.messaging.PojoMarshaler;
-
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.component.ComponentLifeCycle;
@@ -42,6 +33,13 @@
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
+import org.apache.servicemix.JavaSource;
+import org.apache.servicemix.jbi.FaultException;
+import org.apache.servicemix.jbi.NotInitialisedYetException;
+import org.apache.servicemix.jbi.management.BaseLifeCycle;
+import org.apache.servicemix.jbi.messaging.NormalizedMessageImpl;
+import org.apache.servicemix.jbi.messaging.PojoMarshaler;
+
 /**
  * A useful base class for a POJO based JBI component which contains most of the basic plumbing
  *
@@ -57,8 +55,6 @@
     private String description = "POJO Component";
     private ServiceEndpoint serviceEndpoint;
     
-    private static final Log log = LogFactory.getLog(PojoSupport.class);
-    
     protected PojoSupport() {
     }
 
@@ -249,10 +245,11 @@
      * A helper method which fails and completes the given exchange with the specified fault
      */
     public void fail(MessageExchange exchange, Fault fault) throws MessagingException {
-        if (fault != null) {
+        if (exchange instanceof InOnly || fault == null) {
+            exchange.setError(new FaultException("Fault occured for in-only exchange", exchange, fault));
+        } else {
             exchange.setFault(fault);
         }
-        exchange.setStatus(ExchangeStatus.ERROR);
         getDeliveryChannel().send(exchange);
     }
 
@@ -261,15 +258,11 @@
      * @throws MessagingException 
      */
     public void fail(MessageExchange exchange, Exception error) throws MessagingException {
-        if (exchange instanceof InOnly) {
-            log.error("Error processing exchange", error);
-            exchange.setStatus(ExchangeStatus.DONE);
-        } else {
+        if (exchange instanceof InOnly || error instanceof FaultException == false) {
             exchange.setError(error);
-            if (error instanceof FaultException) {
-                FaultException faultException = (FaultException) error;
-                exchange.setFault(faultException.getFault());
-            }
+        } else {
+            FaultException faultException = (FaultException) error;
+            exchange.setFault(faultException.getFault());
         }
         getDeliveryChannel().send(exchange);
     }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/TransformComponentSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/TransformComponentSupport.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/TransformComponentSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/components/util/TransformComponentSupport.java Tue Mar  7 07:08:31 2006
@@ -39,7 +39,6 @@
             return;
         // Handle error exchanges
         } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
-            done(exchange);
             return;
         }
         NormalizedMessage in = getInMessage(exchange);
@@ -58,9 +57,6 @@
                 }
             } else {
                 exchange.setStatus(ExchangeStatus.DONE);
-            }
-            if (exchange.getFault() != null) {
-                exchange.setStatus(ExchangeStatus.ERROR);
             }
             getDeliveryChannel().send(exchange);
         }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOnlyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOnlyImpl.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOnlyImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOnlyImpl.java Tue Mar  7 07:08:31 2006
@@ -30,14 +30,14 @@
     private static final long serialVersionUID = -4851111881482457905L;
     
     private static int[][] STATES_CONSUMER = {
-        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE, 1, -1, -1 },
-        { CAN_CONSUMER, -1, -1, 2 },
-        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, 1, -1, -1, -1 },
+        { CAN_CONSUMER, -1, -1, 2, 2 },
+        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 },
     };
     private static int[][] STATES_PROVIDER = {
-        { CAN_PROVIDER, 1, -1, -1 },
-        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE, -1, -1, 2 },
-        { CAN_PROVIDER, -1, -1, -1 },
+        { CAN_PROVIDER, 1, -1, -1, -1 },
+        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE + CAN_STATUS_ERROR, -1, -1, 2, 2 },
+        { CAN_PROVIDER, -1, -1, -1, -1 },
     };
     
     public InOnlyImpl() {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOptionalOutImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOptionalOutImpl.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOptionalOutImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOptionalOutImpl.java Tue Mar  7 07:08:31 2006
@@ -30,21 +30,25 @@
     private static final long serialVersionUID = -3145649037372074912L;
 
     private static int[][] STATES_CONSUMER = {
-        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE, 1, -1, -1},
-        { CAN_CONSUMER, 2, 2, 4 },
-        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_SET_FAULT_MSG + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, 5, 3},
-        { CAN_CONSUMER, -1, -1, -1 },
-        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1 },
-        { CAN_CONSUMER + CAN_OWNER, -1, -1, 3 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, 1, -1, -1, -1},
+        { CAN_CONSUMER, 2, 3, 4, 4 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_SET_FAULT_MSG + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, 5, 6, 6},
+        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, -1, 6, 6},
+        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 },
+        { CAN_CONSUMER, -1, -1, 7, 7 },
+        { CAN_CONSUMER, -1, -1, -1, -1 },
+        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 },
     };
     
     private static int[][] STATES_PROVIDER = {
         { CAN_PROVIDER, 1, -1, -1 },
-        { CAN_PROVIDER + CAN_OWNER + CAN_SET_OUT_MSG + CAN_SET_FAULT_MSG + CAN_SEND + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, 2, 2, 4 },
-        { CAN_PROVIDER, -1, 5, 3 },
-        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1 },
-        { CAN_PROVIDER, -1, -1, -1 },
-        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE, -1, -1, 4 },
+        { CAN_PROVIDER + CAN_OWNER + CAN_SET_OUT_MSG + CAN_SET_FAULT_MSG + CAN_SEND + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, 2, 3, 4, 4 },
+        { CAN_PROVIDER, -1, 5, 6, 6 },
+        { CAN_PROVIDER, -1, -1, 6, 6 },
+        { CAN_PROVIDER, -1, -1, -1, -1 },
+        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, -1, 7, 7 },
+        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1, -1 },
+        { CAN_PROVIDER, -1, -1, -1, -1 },
     };
 
     public InOptionalOutImpl() {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOutImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOutImpl.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOutImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/InOutImpl.java Tue Mar  7 07:08:31 2006
@@ -30,17 +30,19 @@
     private static final long serialVersionUID = -1639492357707831113L;
 
     private static int[][] STATES_CONSUMER = {
-        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE, 1, -1, -1},
-        { CAN_CONSUMER, 2, 2, -1 },
-        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE, -1, -1, 3},
-        { CAN_CONSUMER, -1, -1, -1 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, 1, -1, -1, -1},
+        { CAN_CONSUMER, 2, 2, 3, 3 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, -1, 4, 4},
+        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 },
+        { CAN_CONSUMER, -1, -1, -1, -1 },
     };
     
     private static int[][] STATES_PROVIDER = {
         { CAN_PROVIDER, 1, -1, -1 },
-        { CAN_PROVIDER + CAN_OWNER + CAN_SET_OUT_MSG + CAN_SET_FAULT_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR, 2, 2, -1 },
-        { CAN_PROVIDER, -1, -1, 3 },
-        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1 },
+        { CAN_PROVIDER + CAN_OWNER + CAN_SET_OUT_MSG + CAN_SET_FAULT_MSG + CAN_SEND + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR, 2, 2, 3, -1 },
+        { CAN_PROVIDER, -1, -1, 4, 4 },
+        { CAN_PROVIDER, -1, -1, -1, -1 },
+        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1, -1 },
     };
     
     public InOutImpl() {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java Tue Mar  7 07:08:31 2006
@@ -54,16 +54,16 @@
     protected static final int CAN_PROVIDER                 = 0x00000008;
     protected static final int CAN_CONSUMER                 = 0x00000000;
     protected static final int CAN_SEND                     = 0x00000010;
-    protected static final int CAN_SEND_SYNC                = 0x00000020;
     protected static final int CAN_STATUS_ACTIVE            = 0x00000040;
     protected static final int CAN_STATUS_DONE              = 0x00000080;
     protected static final int CAN_STATUS_ERROR             = 0x00000100;
     protected static final int CAN_OWNER                    = 0x00000200;
 
     protected static final int STATES_CANS       = 0;
-    protected static final int STATES_NEXT_MSG   = 1;
-    protected static final int STATES_NEXT_ERROR = 2;
-    protected static final int STATES_NEXT_DONE  = 3;
+    protected static final int STATES_NEXT_OUT   = 1;
+    protected static final int STATES_NEXT_FAULT = 2;
+    protected static final int STATES_NEXT_ERROR = 3;
+    protected static final int STATES_NEXT_DONE  = 4;
     
     public static final String FAULT = "fault";
     public static final String IN = "in";
@@ -475,7 +475,6 @@
      */
     public  void setOutMessage(NormalizedMessage message) throws MessagingException {
         setMessage(message, OUT);
-        
     }
     
     /**
@@ -535,14 +534,11 @@
     
     public void handleSend(boolean sync) throws MessagingException {
         // Check if send / sendSync is legal
-        if (sync) {
-            if (!can(CAN_SEND_SYNC)) {
-                throw new MessagingException("illegal call to sendSync");
-            }
-        } else {
-            if (!can(CAN_SEND)) {
-                throw new MessagingException("illegal call to send");
-            }
+        if (!can(CAN_SEND)) {
+            throw new MessagingException("illegal call to send / sendSync");
+        }
+        if (sync && getStatus() != ExchangeStatus.ACTIVE) {
+            throw new MessagingException("illegal call to sendSync");
         }
         this.syncState = sync ? SYNC_STATE_SYNC_SENT : SYNC_STATE_ASYNC;
         // Check status
@@ -558,8 +554,10 @@
         }
         // Check message
         // Change state
-        if (status == ExchangeStatus.ACTIVE) {
-            this.state = this.states[this.state][STATES_NEXT_MSG];
+        if (status == ExchangeStatus.ACTIVE && packet.getFault() == null) {
+            this.state = this.states[this.state][STATES_NEXT_OUT];
+        } else if (status == ExchangeStatus.ACTIVE && packet.getFault() != null) {
+            this.state = this.states[this.state][STATES_NEXT_FAULT];
         } else if (status == ExchangeStatus.ERROR) {
             this.state = this.states[this.state][STATES_NEXT_ERROR];
         } else if (status == ExchangeStatus.DONE) {
@@ -576,8 +574,10 @@
         // Change state
         ExchangeStatus status = getStatus();
         int nextState;
-        if (status == ExchangeStatus.ACTIVE) {
-            nextState = this.states[this.state][STATES_NEXT_MSG];
+        if (status == ExchangeStatus.ACTIVE && packet.getFault() == null) {
+            nextState = this.states[this.state][STATES_NEXT_OUT];
+        } else if (status == ExchangeStatus.ACTIVE && packet.getFault() != null) {
+            nextState = this.states[this.state][STATES_NEXT_FAULT];
         } else if (status == ExchangeStatus.ERROR) {
             nextState = this.states[this.state][STATES_NEXT_ERROR];
         } else if (status == ExchangeStatus.DONE) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/RobustInOnlyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/RobustInOnlyImpl.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/RobustInOnlyImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/RobustInOnlyImpl.java Tue Mar  7 07:08:31 2006
@@ -30,19 +30,19 @@
     private static final long serialVersionUID = -1606399168587959356L;
 
     private static int[][] STATES_CONSUMER = {
-        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE, 1, -1, -1},
-        { CAN_CONSUMER, -1, 2, 4 },
-        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE, -1, -1, 3},
-        { CAN_CONSUMER, -1, -1, -1 },
-        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, 1, -1, -1, -1},
+        { CAN_CONSUMER, -1, 2, 3, 3 },
+        { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_DONE + CAN_STATUS_ERROR, -1, -1, 4, 4 },
+        { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 },
+        { CAN_CONSUMER, -1, -1, -1, -1 },
     };
     
     private static int[][] STATES_PROVIDER = {
-        { CAN_PROVIDER, 1, -1, -1 },
-        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_SET_FAULT_MSG + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, 2, 4 },
-        { CAN_PROVIDER, -1, -1, 3 },
-        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1 },
-        { CAN_PROVIDER, -1, -1, -1 },
+        { CAN_PROVIDER, 1, -1, -1, -1 },
+        { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_SET_FAULT_MSG + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, 2, 4, 4 },
+        { CAN_PROVIDER, -1, -1, 3, 3 },
+        { CAN_PROVIDER + CAN_OWNER, -1, -1, -1, -1 },
+        { CAN_PROVIDER, -1, -1, -1, -1 },
     };
     
     public RobustInOnlyImpl() {

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/JmsFlowTransactionTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/JmsFlowTransactionTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/JmsFlowTransactionTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/JmsFlowTransactionTest.java Tue Mar  7 07:08:31 2006
@@ -29,19 +29,37 @@
 
     public void testSyncSendSyncReceive() throws Exception {
         try {
-            runSimpleTest(true, true);
-            fail("sendSync can not be used");
+            super.testSyncSendSyncReceive();
+            fail("JMS flow does not handle transactions");
         } catch (Exception e) {
-            // sendSync can not be used
+            // JMS flow does not handle transactions
         }
     }
 
     public void testSyncSendAsyncReceive() throws Exception {
         try {
-            runSimpleTest(true, false);
-            fail("sendSync can not be used");
+            super.testSyncSendAsyncReceive();
+            fail("JMS flow does not handle transactions");
         } catch (Exception e) {
-            // sendSync can not be used
+            // JMS flow does not handle transactions
+        }
+    }
+
+    public void testAsyncSendAsyncReceive() throws Exception {
+        try {
+            super.testAsyncSendAsyncReceive();
+            fail("JMS flow does not handle transactions");
+        } catch (Exception e) {
+            // JMS flow does not handle transactions
+        }
+    }
+
+    public void testAsyncSendSyncReceive() throws Exception {
+        try {
+            super.testAsyncSendSyncReceive();
+            fail("JMS flow does not handle transactions");
+        } catch (Exception e) {
+            // JMS flow does not handle transactions
         }
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MEPExchangeTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MEPExchangeTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MEPExchangeTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MEPExchangeTest.java Tue Mar  7 07:08:31 2006
@@ -23,6 +23,7 @@
 
 import javax.jbi.messaging.DeliveryChannel;
 import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.Fault;
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.InOptionalOut;
 import javax.jbi.messaging.InOut;
@@ -100,6 +101,12 @@
         } catch (Exception e) {
             // ok
         }
+        try {
+            mec.setMessage(mec.createFault(), "fault");
+            fail("Fault not supported");
+        } catch (Exception e) {
+            // ok
+        }
 		consumer.getChannel().send(mec);
         try {
             mec.setProperty("myprop", "myvalue");
@@ -122,6 +129,38 @@
 		assertNull(consumer.getChannel().accept(100L)); // receive in
 		assertNull(provider.getChannel().accept(100L)); // receive in
 	}
+    
+    public void testInOnlyWithError() throws Exception {
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOnly mec = mef.createInOnlyExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        assertEquals(Role.CONSUMER, mec.getRole());
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOnly mep = (InOnly) provider.getChannel().accept(1000L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        assertEquals(Role.PROVIDER, mep.getRole());
+        mep.setError(new Exception());
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(1000L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        assertEquals(Role.CONSUMER, mec.getRole());
+        // Check we can not send the exchange anymore
+        try {
+            mec.setStatus(ExchangeStatus.DONE);
+            consumer.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
 	
 	public void testInOnlySync() throws Exception {
 		// Create thread to answer
@@ -311,35 +350,131 @@
 		assertNull(provider.getChannel().accept(100L)); // receive in
 	}
 	
-	public void testInOutWithFault() throws Exception {
-		// Send message exchange
-		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
-		InOut mec = mef.createInOutExchange();
-		NormalizedMessage m = mec.createMessage();
-		m.setContent(new StringSource(PAYLOAD));
-		mec.setInMessage(m);
-		consumer.getChannel().send(mec);
-		// Provider side
-		InOut mep = (InOut) provider.getChannel().accept(100L);
-		assertNotNull(mep);
-		assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
-		m = mep.createMessage();
-		m.setContent(new StringSource(RESPONSE));
-		mep.setStatus(ExchangeStatus.ERROR);
-		provider.getChannel().send(mep);
-		// Consumer side
-		assertSame(mec, consumer.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.ERROR, mec.getStatus());
-		mec.setStatus(ExchangeStatus.DONE);
-		consumer.getChannel().send(mec);
-		// Provider site
-		assertSame(mep, provider.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.DONE, mec.getStatus());
-		// Nothing left
-		assertNull(consumer.getChannel().accept(100L)); // receive in
-		assertNull(provider.getChannel().accept(100L)); // receive in
-	}
-	
+    public void testInOutWithFault() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOut mec = mef.createInOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOut mep = (InOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        Fault f = mep.createFault();
+        f.setContent(new StringSource(RESPONSE));
+        mep.setFault(f);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        assertNotNull(mec.getFault());
+        mec.setStatus(ExchangeStatus.DONE);
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.DONE, mec.getStatus());
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOutWithFaultAndError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOut mec = mef.createInOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOut mep = (InOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        Fault f = mep.createFault();
+        f.setContent(new StringSource(RESPONSE));
+        mep.setFault(f);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        assertNotNull(mec.getFault());
+        mec.setStatus(ExchangeStatus.ERROR);
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        try {
+            consumer.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOutWithError1() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOut mec = mef.createInOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOut mep = (InOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        m = mep.createMessage();
+        m.setContent(new StringSource(RESPONSE));
+        mep.setStatus(ExchangeStatus.ERROR);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        try {
+            mec.setStatus(ExchangeStatus.DONE);
+            consumer.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOutWithError2() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOut mec = mef.createInOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOut mep = (InOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        m = mep.createMessage();
+        m.setContent(new StringSource(RESPONSE));
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        mec.setStatus(ExchangeStatus.ERROR);
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
 	public void testInOptOutWithRep() throws Exception {
 		// Send message exchange
 		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
@@ -391,67 +526,176 @@
 		assertNull(provider.getChannel().accept(100L)); // receive in
 	}
 	
-	public void testInOptOutWithProviderFault() throws Exception {
-		// Send message exchange
-		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
-		InOptionalOut mec = mef.createInOptionalOutExchange();
-		NormalizedMessage m = mec.createMessage();
-		m.setContent(new StringSource(PAYLOAD));
-		mec.setInMessage(m);
-		consumer.getChannel().send(mec);
-		// Provider side
-		InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
-		assertNotNull(mep);
-		assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
-		mep.setStatus(ExchangeStatus.ERROR);
-		provider.getChannel().send(mep);
-		// Consumer side
-		assertSame(mec, consumer.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.ERROR, mec.getStatus());
-		mec.setStatus(ExchangeStatus.DONE);
-		consumer.getChannel().send(mec);
-		// Provider site
-		assertSame(mep, provider.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.DONE, mec.getStatus());
-		// Nothing left
-		assertNull(consumer.getChannel().accept(100L)); // receive in
-		assertNull(provider.getChannel().accept(100L)); // receive in
-	}
-	
-	public void testInOptOutWithRepAndConsumerFault() throws Exception {
-		// Send message exchange
-		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
-		InOptionalOut mec = mef.createInOptionalOutExchange();
-		NormalizedMessage m = mec.createMessage();
-		m.setContent(new StringSource(PAYLOAD));
-		mec.setInMessage(m);
-		consumer.getChannel().send(mec);
-		// Provider side
-		InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
-		assertNotNull(mep);
-		assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
-		m = mep.createMessage();
-		m.setContent(new StringSource(RESPONSE));
-		mep.setOutMessage(m);
-		provider.getChannel().send(mep);
-		// Consumer side
-		assertSame(mec, consumer.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
-		mec.setStatus(ExchangeStatus.ERROR);
-		consumer.getChannel().send(mec);
-		// Provider site
-		assertSame(mep, provider.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.ERROR, mep.getStatus());
-		mep.setStatus(ExchangeStatus.DONE);
-		provider.getChannel().send(mep);
-		// Consumer side
-		assertSame(mec, consumer.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.DONE, mec.getStatus());
-		// Nothing left
-		assertNull(consumer.getChannel().accept(100L)); // receive in
-		assertNull(provider.getChannel().accept(100L)); // receive in
-	}
-	
+    public void testInOptOutWithProviderFault() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOptionalOut mec = mef.createInOptionalOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        mep.setFault(mep.createFault());
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        assertNotNull(mec.getFault());
+        mec.setStatus(ExchangeStatus.DONE);
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.DONE, mec.getStatus());
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOptOutWithProviderError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOptionalOut mec = mef.createInOptionalOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        mep.setStatus(ExchangeStatus.ERROR);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        try {
+            mec.setStatus(ExchangeStatus.DONE);
+            consumer.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOptOutWithRepAndConsumerFault() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOptionalOut mec = mef.createInOptionalOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        m = mep.createMessage();
+        m.setContent(new StringSource(RESPONSE));
+        mep.setOutMessage(m);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        mec.setFault(mec.createFault());
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        assertNotNull(mep.getFault());
+        mep.setStatus(ExchangeStatus.DONE);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.DONE, mec.getStatus());
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOptOutWithRepAndConsumerError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOptionalOut mec = mef.createInOptionalOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        m = mep.createMessage();
+        m.setContent(new StringSource(RESPONSE));
+        mep.setOutMessage(m);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        mec.setStatus(ExchangeStatus.ERROR);
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mep.getStatus());
+        try {
+            mep.setStatus(ExchangeStatus.DONE);
+            provider.getChannel().send(mep);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testInOptOutWithRepFaultAndError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        InOptionalOut mec = mef.createInOptionalOutExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        InOptionalOut mep = (InOptionalOut) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        m = mep.createMessage();
+        m.setContent(new StringSource(RESPONSE));
+        mep.setOutMessage(m);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        mec.setFault(mec.createFault());
+        consumer.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        assertNotNull(mep.getFault());
+        mep.setStatus(ExchangeStatus.ERROR);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        try {
+            mec.setStatus(ExchangeStatus.DONE);
+            consumer.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
 	public void testRobustInOnly() throws Exception {
 		// Send message exchange
 		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
@@ -474,31 +718,96 @@
 		assertNull(provider.getChannel().accept(100L)); // receive in
 	}
 	
-	public void testRobustInOnlyWithFault() throws Exception {
-		// Send message exchange
-		MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
-		RobustInOnly mec = mef.createRobustInOnlyExchange();
-		NormalizedMessage m = mec.createMessage();
-		m.setContent(new StringSource(PAYLOAD));
-		mec.setInMessage(m);
-		consumer.getChannel().send(mec);
-		// Provider side
-		RobustInOnly mep = (RobustInOnly) provider.getChannel().accept(100L);
-		assertNotNull(mep);
-		assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
-		mep.setStatus(ExchangeStatus.ERROR);
-		provider.getChannel().send(mep);
-		// Consumer side
-		assertSame(mec, consumer.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.ERROR, mec.getStatus());
-		mec.setStatus(ExchangeStatus.DONE);
-		provider.getChannel().send(mec);
-		// Provider site
-		assertSame(mep, provider.getChannel().accept(100L));
-		assertEquals(ExchangeStatus.DONE, mep.getStatus());
-		// Nothing left
-		assertNull(consumer.getChannel().accept(100L)); // receive in
-		assertNull(provider.getChannel().accept(100L)); // receive in
-	}
-	
+    public void testRobustInOnlyWithFault() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        RobustInOnly mec = mef.createRobustInOnlyExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        RobustInOnly mep = (RobustInOnly) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        mep.setFault(mep.createFault());
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        assertNotNull(mec.getFault());
+        mec.setStatus(ExchangeStatus.DONE);
+        provider.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.DONE, mep.getStatus());
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testRobustInOnlyWithError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        RobustInOnly mec = mef.createRobustInOnlyExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        RobustInOnly mep = (RobustInOnly) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        mep.setStatus(ExchangeStatus.ERROR);
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
+        try {
+            mec.setStatus(ExchangeStatus.DONE);
+            provider.getChannel().send(mec);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
+    public void testRobustInOnlyWithFaultAndError() throws Exception {
+        // Send message exchange
+        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
+        RobustInOnly mec = mef.createRobustInOnlyExchange();
+        NormalizedMessage m = mec.createMessage();
+        m.setContent(new StringSource(PAYLOAD));
+        mec.setInMessage(m);
+        consumer.getChannel().send(mec);
+        // Provider side
+        RobustInOnly mep = (RobustInOnly) provider.getChannel().accept(100L);
+        assertNotNull(mep);
+        assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+        mep.setFault(mep.createFault());
+        provider.getChannel().send(mep);
+        // Consumer side
+        assertSame(mec, consumer.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ACTIVE, mec.getStatus());
+        assertNotNull(mec.getFault());
+        mec.setError(new Exception());
+        provider.getChannel().send(mec);
+        // Provider site
+        assertSame(mep, provider.getChannel().accept(100L));
+        assertEquals(ExchangeStatus.ERROR, mep.getStatus());
+        try {
+            mep.setStatus(ExchangeStatus.DONE);
+            provider.getChannel().send(mep);
+            fail("Exchange status is ERROR");
+        } catch (Exception e) {
+            // ok
+        }
+        // Nothing left
+        assertNull(consumer.getChannel().accept(100L)); // receive in
+        assertNull(provider.getChannel().accept(100L)); // receive in
+    }
+    
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MessageExchangeTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MessageExchangeTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MessageExchangeTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/MessageExchangeTest.java Tue Mar  7 07:08:31 2006
@@ -29,13 +29,14 @@
 public class MessageExchangeTest extends TestCase {
 
     public static class TestMessageExchange extends MessageExchangeImpl {
+        private static final long serialVersionUID = 5572313276570983400L;
         public TestMessageExchange() {
             super(new ExchangePacket(), STATES);
         }
         public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         }
         private static int[][] STATES = {
-            { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_SEND_SYNC + CAN_STATUS_ACTIVE, -1, -1, -1 },
+            { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, -1, -1, -1 },
         };
     }
     

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/flow/jms/SimpleClusterSendSyncTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/flow/jms/SimpleClusterSendSyncTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/flow/jms/SimpleClusterSendSyncTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/flow/jms/SimpleClusterSendSyncTest.java Tue Mar  7 07:08:31 2006
@@ -63,6 +63,8 @@
             assertNotNull(exchange.getOutMessage());
             System.out.println("GOT RESPONSE; exchange.out=" + new SourceTransformer().toString(exchange.getOutMessage().getContent()));
             client.done(exchange);
+            // Wait for done to be delivered
+            Thread.sleep(50);
         } finally {
             ctx.close();
         }

Modified: incubator/servicemix/trunk/servicemix-gbean/src/main/java/org/apache/servicemix/gbean/ServiceMixConfigBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-gbean/src/main/java/org/apache/servicemix/gbean/ServiceMixConfigBuilder.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-gbean/src/main/java/org/apache/servicemix/gbean/ServiceMixConfigBuilder.java (original)
+++ incubator/servicemix/trunk/servicemix-gbean/src/main/java/org/apache/servicemix/gbean/ServiceMixConfigBuilder.java Tue Mar  7 07:08:31 2006
@@ -174,7 +174,7 @@
             context.addGBean(gbeanData);
 
             try {
-                servicemix.getContainer().getInstallationService().install(module.getName());
+                servicemix.getContainer().getAdminCommandsService().installArchive(module.getName());
             } catch (javax.jbi.management.DeploymentException e) {
                 throw new DeploymentException("Could not deploy jbi package", e);
             }

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Tue Mar  7 07:08:31 2006
@@ -27,7 +27,6 @@
 import javax.jbi.messaging.NormalizedMessage;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
 
 import org.apache.servicemix.JbiConstants;
 import org.apache.servicemix.common.BaseLifeCycle;
@@ -42,7 +41,6 @@
 import org.apache.servicemix.soap.marshalers.JBIMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMessage;
-import org.mortbay.jetty.RetryRequest;
 import org.mortbay.jetty.handler.ContextHandler;
 import org.mortbay.util.ajax.Continuation;
 import org.mortbay.util.ajax.ContinuationSupport;
@@ -76,7 +74,6 @@
     public void process(MessageExchange exchange) throws Exception {
         Continuation cont = (Continuation) locks.remove(exchange.getExchangeId());
         if (cont != null) {
-            //System.err.println("Notifying: " + exchange.getExchangeId());
             cont.resume();
         } else {
             throw new IllegalStateException("Exchange not found");
@@ -101,77 +98,81 @@
         if (!"POST".equals(request.getMethod())) {
             throw new UnsupportedOperationException(request.getMethod() + " not supported");
         }
-        QName envelopeName = null;
-        try {
-            // Not giving a specific mutex will synchronize on the contination itself
-            Continuation cont = ContinuationSupport.getContinuation(request, null);
-            MessageExchange exchange;
-            // If the continuation is not a retry
-            if (!cont.isPending()) {
+        // Not giving a specific mutex will synchronize on the contination itself
+        Continuation cont = ContinuationSupport.getContinuation(request, null);
+        MessageExchange exchange;
+        // If the continuation is not a retry
+        if (!cont.isPending()) {
+            try {
                 SoapMessage message = soapMarshaler.createReader().read(request.getInputStream(), 
                                                                         request.getHeader("Content-Type"));
                 exchange = soapHelper.createExchange(message);
-                //System.err.println("Handling: " + exchange.getExchangeId());
                 NormalizedMessage inMessage = exchange.getMessage("in");
                 inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(request));
                 locks.put(exchange.getExchangeId(), cont);
+                request.setAttribute(SoapMessage.class.getName(), message);
                 request.setAttribute(MessageExchange.class.getName(), exchange);
-                //System.err.println("Sending: " + exchange.getExchangeId());
                 ((BaseLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle()).sendConsumerExchange(exchange, this);
                 // TODO: make this timeout configurable
                 boolean result = cont.suspend(1000 * 60); // 60 s
                 if (!result) {
                     throw new Exception("Error sending exchange: aborted");
                 }
-                //System.err.println("Continuing: " + exchange.getExchangeId());
+            } catch (SoapFault fault) {
+                sendFault(fault, request, response);
+                return;
+            }
+        } else {
+            exchange = (MessageExchange) request.getAttribute(MessageExchange.class.getName());
+            request.removeAttribute(MessageExchange.class.getName());
+            boolean result = cont.suspend(0); 
+            // Check if this is a timeout
+            if (exchange == null) {
+                throw new IllegalStateException("Exchange not found");
+            }
+            if (!result) {
+                throw new Exception("Timeout");
+            }
+        }
+        if (exchange.getStatus() == ExchangeStatus.ERROR) {
+            if (exchange.getError() != null) {
+                throw new Exception(exchange.getError());
             } else {
-                exchange = (MessageExchange) request.getAttribute(MessageExchange.class.getName());
-                request.removeAttribute(MessageExchange.class.getName());
-                boolean result = cont.suspend(0); 
-                // Check if this is a timeout
-                if (exchange == null) {
-                    throw new IllegalStateException("Exchange not found");
-                }
-                //System.err.println("Processing: " + exchange.getExchangeId());
-                if (!result) {
-                    throw new Exception("Timeout");
-                }
+                throw new Exception("Unknown Error");
             }
-            if (exchange.getStatus() == ExchangeStatus.ERROR) {
-                exchange.setStatus(ExchangeStatus.DONE);
-                channel.send(exchange);
-                if (exchange.getError() != null) {
-                    throw new Exception(exchange.getError());
-                } else if (exchange.getFault() != null) {
-                    throw new SoapFault(SoapFault.RECEIVER, null, null, null, exchange.getFault().getContent());
+        } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+            try {
+                if (exchange.getFault() != null) {
+                    SoapFault fault = new SoapFault(SoapFault.RECEIVER, null, null, null, exchange.getFault().getContent());
+                    sendFault(fault, request, response);
                 } else {
-                    throw new Exception("Unkown Error");
-                }
-            } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
-                NormalizedMessage outMsg = exchange.getMessage("out");
-                if (outMsg != null) {
-                    SoapMessage out = new SoapMessage();
-                    jbiMarshaler.fromNMS(out, outMsg);
-                    soapMarshaler.createWriter(out).write(response.getOutputStream());
+                    NormalizedMessage outMsg = exchange.getMessage("out");
+                    if (outMsg != null) {
+                        SoapMessage out = new SoapMessage();
+                        jbiMarshaler.fromNMS(out, outMsg);
+                        soapMarshaler.createWriter(out).write(response.getOutputStream());
+                    }
                 }
+            } finally {
                 exchange.setStatus(ExchangeStatus.DONE);
                 channel.send(exchange);
             }
-        } catch (SoapFault fault) {
-            if (SoapFault.SENDER.equals(fault.getCode())) {
-                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-            } else {
-                response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            }
-            SoapMessage soapFault = new SoapMessage();
-            soapFault.setFault(fault);
-            soapFault.setEnvelopeName(envelopeName);
-            soapMarshaler.createWriter(soapFault).write(response.getOutputStream());
-        } catch (RetryRequest e) {
-            throw e;
-        } catch (Exception e) {
-            throw e;
         }
+    }
+    
+    protected void sendFault(SoapFault fault, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        if (SoapFault.SENDER.equals(fault.getCode())) {
+            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+        } else {
+            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        }
+        SoapMessage in = (SoapMessage) request.getAttribute(SoapMessage.class.getName());
+        SoapMessage soapFault = new SoapMessage();
+        soapFault.setFault(fault);
+        if (in != null) {
+            soapFault.setEnvelopeName(in.getEnvelopeName());
+        }
+        soapMarshaler.createWriter(soapFault).write(response.getOutputStream());
     }
     
     protected Map getHeaders(HttpServletRequest request) {

Modified: incubator/servicemix/trunk/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java Tue Mar  7 07:08:31 2006
@@ -17,18 +17,27 @@
 
 import java.net.URI;
 
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
 import javax.xml.transform.stream.StreamSource;
 
 import junit.framework.TestCase;
 
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.client.ServiceMixClient;
 import org.apache.servicemix.components.util.EchoComponent;
+import org.apache.servicemix.components.util.TransformComponentSupport;
+import org.apache.servicemix.jbi.FaultException;
 import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
 import org.apache.servicemix.jbi.util.FileUtil;
 
@@ -50,59 +59,94 @@
         }
     }
     
-    public void testFault() throws Exception {
-    	HttpSpringComponent http = new HttpSpringComponent();
-    	HttpEndpoint ep = new HttpEndpoint();
-    	ep.setService(new QName("urn:test", "echo"));
-    	ep.setEndpoint("echo");
-    	ep.setLocationURI("http://localhost:8192/ep1/");
-    	ep.setRoleAsString("consumer");
-    	ep.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
-    	ep.setSoap(true);
-    	http.setEndpoints(new HttpEndpoint[] { ep });
-    	container.activateComponent(http, "http");
-    	container.start();
-    	
+    public void testFaultOnParse() throws Exception {
+        HttpSpringComponent http = new HttpSpringComponent();
+        HttpEndpoint ep = new HttpEndpoint();
+        ep.setService(new QName("urn:test", "echo"));
+        ep.setEndpoint("echo");
+        ep.setLocationURI("http://localhost:8192/ep1/");
+        ep.setRoleAsString("consumer");
+        ep.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
+        ep.setSoap(true);
+        http.setEndpoints(new HttpEndpoint[] { ep });
+        container.activateComponent(http, "http");
+        container.start();
+        
         PostMethod method = new PostMethod("http://localhost:8192/ep1/");
         method.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
         int state = new HttpClient().executeMethod(method);
-        assertEquals(400, state);
+        assertEquals(HttpServletResponse.SC_BAD_REQUEST, state);
         FileUtil.copyInputStream(method.getResponseBodyAsStream(), System.out);
     }
 
     public void testSoap() throws Exception {
-    	EchoComponent echo = new EchoComponent();
-    	echo.setService(new QName("urn:test", "echo"));
-    	echo.setEndpoint("echo");
-    	container.activateComponent(echo, "echo");
-    	
-    	HttpSpringComponent http = new HttpSpringComponent();
-    	
-    	HttpEndpoint ep1 = new HttpEndpoint();
-    	ep1.setService(new QName("urn:test", "echo"));
-    	ep1.setEndpoint("echo");
-    	ep1.setLocationURI("http://localhost:8192/ep1/");
-    	ep1.setRoleAsString("consumer");
-    	ep1.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
-    	ep1.setSoap(true);
-    	
-    	HttpEndpoint ep2 = new HttpEndpoint();
-    	ep2.setService(new QName("urn:test", "s2"));
-    	ep2.setEndpoint("ep2");
-    	ep2.setLocationURI("http://localhost:8192/ep1/");
-    	ep2.setRoleAsString("provider");
-    	ep2.setSoap(true);
-    	
-    	http.setEndpoints(new HttpEndpoint[] { ep1, ep2 });
-    	
-    	container.activateComponent(http, "http");
-    	
-    	container.start();
-    	
-    	ServiceMixClient client = new DefaultServiceMixClient(container);
-    	client.request(new ServiceNameEndpointResolver(new QName("urn:test", "s2")), null, null, 
-    				   new StreamSource(getClass().getResourceAsStream("soap-request.xml")));
-    	
+        EchoComponent echo = new EchoComponent();
+        echo.setService(new QName("urn:test", "echo"));
+        echo.setEndpoint("echo");
+        container.activateComponent(echo, "echo");
+        
+        HttpSpringComponent http = new HttpSpringComponent();
+        
+        HttpEndpoint ep1 = new HttpEndpoint();
+        ep1.setService(new QName("urn:test", "echo"));
+        ep1.setEndpoint("echo");
+        ep1.setLocationURI("http://localhost:8192/ep1/");
+        ep1.setRoleAsString("consumer");
+        ep1.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
+        ep1.setSoap(true);
+        
+        HttpEndpoint ep2 = new HttpEndpoint();
+        ep2.setService(new QName("urn:test", "s2"));
+        ep2.setEndpoint("ep2");
+        ep2.setLocationURI("http://localhost:8192/ep1/");
+        ep2.setRoleAsString("provider");
+        ep2.setSoap(true);
+        
+        http.setEndpoints(new HttpEndpoint[] { ep1, ep2 });
+        
+        container.activateComponent(http, "http");
+        
+        container.start();
+        
+        ServiceMixClient client = new DefaultServiceMixClient(container);
+        client.request(new ServiceNameEndpointResolver(new QName("urn:test", "s2")), null, null, 
+                       new StreamSource(getClass().getResourceAsStream("soap-request.xml")));
+        
+    }
+
+    public void testSoapFault() throws Exception {
+        TransformComponentSupport echo = new TransformComponentSupport() {
+            protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
+                Fault f = exchange.createFault();
+                f.setContent(new StringSource("<hello>this is a fault</hello>"));
+                throw new FaultException(null, exchange, f);
+            }
+        };
+        echo.setService(new QName("urn:test", "echo"));
+        echo.setEndpoint("echo");
+        container.activateComponent(echo, "echo");
+        
+        HttpSpringComponent http = new HttpSpringComponent();
+        
+        HttpEndpoint ep1 = new HttpEndpoint();
+        ep1.setService(new QName("urn:test", "echo"));
+        ep1.setEndpoint("echo");
+        ep1.setLocationURI("http://localhost:8192/ep1/");
+        ep1.setRoleAsString("consumer");
+        ep1.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
+        ep1.setSoap(true);
+        
+        http.setEndpoints(new HttpEndpoint[] { ep1 });
+        
+        container.activateComponent(http, "http");
+        
+        container.start();
+        
+        PostMethod method = new PostMethod("http://localhost:8192/ep1/");
+        method.setRequestEntity(new InputStreamRequestEntity(getClass().getResourceAsStream("soap-request.xml")));
+        int state = new HttpClient().executeMethod(method);
+        assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, state);
+        FileUtil.copyInputStream(method.getResponseBodyAsStream(), System.out);
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexPojoTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexPojoTest.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexPojoTest.java (original)
+++ incubator/servicemix/trunk/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexPojoTest.java Tue Mar  7 07:08:31 2006
@@ -144,10 +144,8 @@
         assertNotNull(me.getFault());
         Node n = transformer.toDOMNode(me.getFault());
         System.err.println(transformer.toString(n));
-        String xpath;
-        assertNotNull(xpath = textValueOfXPath(n, "//message"));
-        assertNull(xpath = textValueOfXPath(n, "//stack"));
-        client.done(me);
+        assertNotNull(textValueOfXPath(n, "//message"));
+        assertNull(textValueOfXPath(n, "//stack"));
         
         ((Jsr181LifeCycle) component.getLifeCycle()).getConfiguration().setPrintStackTraceInFaults(true);
         
@@ -159,9 +157,8 @@
         assertNotNull(me.getFault());
         n = transformer.toDOMNode(me.getFault());
         System.err.println(transformer.toString(n));
-        assertNotNull(xpath = textValueOfXPath(n, "//message"));
-        assertNotNull(xpath = textValueOfXPath(n, "//stack"));
-        client.done(me);
+        assertNotNull(textValueOfXPath(n, "//message"));
+        assertNotNull(textValueOfXPath(n, "//stack"));
         
         // Wait all acks being processed
         Thread.sleep(100);

Modified: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java?rev=383902&r1=383901&r2=383902&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java (original)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java Tue Mar  7 07:08:31 2006
@@ -27,7 +27,9 @@
  */
 public class SoapFault extends Exception {
 	
-	public static final String SENDER = "Sender";
+    private static final long serialVersionUID = 984561453557136677L;
+    
+    public static final String SENDER = "Sender";
 	public static final String RECEIVER = "Receiver";
 	
     private String code;



Mime
View raw message