servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r726642 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src: main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java
Date Mon, 15 Dec 2008 08:04:52 GMT
Author: gnodet
Date: Mon Dec 15 00:04:52 2008
New Revision: 726642

URL: http://svn.apache.org/viewvc?rev=726642&view=rev
Log:
SM-1667: TransformBeanSupport fails to handle InOut exchanges

Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java?rev=726642&r1=726641&r2=726642&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/support/TransformBeanSupport.java
Mon Dec 15 00:04:52 2008
@@ -123,7 +123,7 @@
         if (exchange.getRole() == MessageExchange.Role.CONSUMER
                 || exchange.getProperty(correlation) != null) {
             processOngoingExchange(exchange);
-        } else {
+        } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
             processFirstExchange(exchange);
         }
     }

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java?rev=726642&r1=726641&r2=726642&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/TransformBeanSupportTest.java
Mon Dec 15 00:04:52 2008
@@ -31,6 +31,7 @@
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.components.util.ComponentSupport;
 import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.util.MessageUtil;
 import org.apache.servicemix.tck.ExchangeCompletedListener;
@@ -51,24 +52,42 @@
         configureContainer();
         listener = new ExchangeCompletedListener();
         container.addListener(listener);
-
+        
         container.init();
         container.start();
 
         component = new BeanComponent();
         container.activateComponent(component, "servicemix-bean");
-
+        
         client = new DefaultServiceMixClient(container);
     }
 
     protected void tearDown() throws Exception {
-        container.shutDown();
         listener.assertExchangeCompleted();
+        container.shutDown();
     }
 
     protected void configureContainer() throws Exception {
         container.setFlowName("st");
     }
+    
+    public void testInOut() throws Exception {
+        TransformBeanSupport transformer = new MyTransformer();
+        BeanEndpoint transformEndpoint = createBeanEndpoint(transformer);
+        component.addEndpoint(transformEndpoint);
+
+        MessageExchange io = client.createInOutExchange();
+        io.setService(new QName("transform"));
+        io.getMessage("in").setContent(new StringSource("<hello/>"));
+        client.send(io);
+        
+        io = client.receive();
+        assertEquals(ExchangeStatus.ACTIVE, io.getStatus());
+        assertEquals("<hello/>", new SourceTransformer().contentToString(io.getMessage("out")));
+        
+        client.done(io);
+        assertEquals(ExchangeStatus.DONE, io.getStatus());
+    }
 
     public void testInOnly() throws Exception {
         TransformBeanSupport transformer = createTransformer("receiver");
@@ -77,31 +96,30 @@
 
         ReceiverComponent receiver = new ReceiverComponent();
         activateComponent(receiver, "receiver");
-
+        
         MessageExchange io = client.createInOnlyExchange();
         io.setService(new QName("transform"));
         io.getMessage("in").setContent(new StringSource("<hello/>"));
         client.send(io);
-
+        
         io = client.receive();
         assertEquals(ExchangeStatus.DONE, io.getStatus());
-
+        
         receiver.getMessageList().assertMessagesReceived(1);
     }
 
-
     public void testInOnlyWithError() throws Exception {
         TransformBeanSupport transformer = createTransformer("error");
         BeanEndpoint transformEndpoint = createBeanEndpoint(transformer);
         component.addEndpoint(transformEndpoint);
 
         activateComponent(new ReturnErrorComponent(), "error");
-
+        
         MessageExchange io = client.createInOnlyExchange();
         io.setService(new QName("transform"));
         io.getMessage("in").setContent(new StringSource("<hello/>"));
         client.send(io);
-
+        
         io = client.receive();
         assertEquals(ExchangeStatus.ERROR, io.getStatus());
     }
@@ -113,18 +131,36 @@
 
         ReceiverComponent receiver = new ReceiverComponent();
         activateComponent(receiver, "receiver");
-
+        
         MessageExchange io = client.createRobustInOnlyExchange();
         io.setService(new QName("transform"));
         io.getMessage("in").setContent(new StringSource("<hello/>"));
         client.send(io);
-
+        
         io = client.receive();
         assertEquals(ExchangeStatus.DONE, io.getStatus());
-
+        
         receiver.getMessageList().assertMessagesReceived(1);
     }
 
+    public void testRobustInOnlyWithFault() throws Exception {
+        TransformBeanSupport transformer = createTransformer("fault");
+        BeanEndpoint transformEndpoint = createBeanEndpoint(transformer);
+        component.addEndpoint(transformEndpoint);
+
+        activateComponent(new ReturnFaultComponent(), "fault");
+
+        MessageExchange io = client.createRobustInOnlyExchange();
+        io.setService(new QName("transform"));
+        io.getMessage("in").setContent(new StringSource("<hello/>"));
+        client.send(io);
+
+        io = client.receive();
+        assertEquals(ExchangeStatus.ACTIVE, io.getStatus());
+        assertNotNull(io.getFault());
+        client.done(io);
+    }
+
     public void testRobustInOnlyWithFaultAndError() throws Exception {
         TransformBeanSupport transformer = createTransformer("fault");
         BeanEndpoint transformEndpoint = createBeanEndpoint(transformer);
@@ -158,13 +194,13 @@
         transformEndpoint.setEndpoint("endpoint");
         return transformEndpoint;
     }
-
-    protected void activateComponent(ComponentSupport cmp, String name) throws Exception
{
-        cmp.setService(new QName(name));
-        cmp.setEndpoint("endpoint");
-        container.activateComponent(cmp, name);
+    
+    protected void activateComponent(ComponentSupport comp, String name) throws Exception
{
+        comp.setService(new QName(name));
+        comp.setEndpoint("endpoint");
+        container.activateComponent(comp, name);
     }
-
+    
     public static class MyTransformer extends TransformBeanSupport {
         protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage
out) throws Exception {
             MessageUtil.transfer(in, out);
@@ -182,7 +218,7 @@
     }
 
     public static class ReturnFaultComponent extends ComponentSupport implements MessageExchangeListener
{
-
+        
         public void onMessageExchange(MessageExchange exchange) throws MessagingException
{
             if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                 Fault fault = exchange.createFault();
@@ -191,5 +227,5 @@
             }
         }
     }
-
+    
 }



Mime
View raw message