svn commit: r935469 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/spr...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r935469 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/spr...

davsclaus-2
Author: davsclaus
Date: Mon Apr 19 07:58:58 2010
New Revision: 935469

URL: http://svn.apache.org/viewvc?rev=935469&view=rev
Log:
CAMEL-2555: WireTap when sending new Exchange uses a copy of the original Exchange as input to the Expression or Processor. You can use the new copy option to change the behavior.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java
      - copied, changed from r935446, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.java
      - copied, changed from r935446, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml
      - copied, changed from r935446, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/WireTapProcessor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=935469&r1=935468&r2=935469&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Mon Apr 19 07:58:58 2010
@@ -1684,6 +1684,9 @@ public abstract class ProcessorDefinitio
      * <a href="http://camel.apache.org/wiretap.html">WireTap EIP:</a>
      * Sends a new {@link org.apache.camel.Exchange} to the destination
      * using {@link ExchangePattern#InOnly}.
+     * <p/>
+     * Will use a copy of the original Exchange which is passed in as argument
+     * to the given expression
      *
      * @param uri  the destination
      * @param body expression that creates the body to send
@@ -1691,8 +1694,24 @@ public abstract class ProcessorDefinitio
      */
     @SuppressWarnings("unchecked")
     public Type wireTap(String uri, Expression body) {
+        return wireTap(uri, true, body);
+    }
+
+    /**
+     * <a href="http://camel.apache.org/wiretap.html">WireTap EIP:</a>
+     * Sends a new {@link org.apache.camel.Exchange} to the destination
+     * using {@link ExchangePattern#InOnly}.
+     *
+     * @param uri  the destination
+     * @param copy whether or not use a copy of the original exchange or a new empty exchange
+     * @param body expression that creates the body to send
+     * @return the builder
+     */
+    @SuppressWarnings("unchecked")
+    public Type wireTap(String uri, boolean copy, Expression body) {
         WireTapDefinition answer = new WireTapDefinition();
         answer.setUri(uri);
+        answer.setCopy(copy);
         answer.setNewExchangeExpression(body);
         addOutput(answer);
         return (Type) this;
@@ -1702,15 +1721,33 @@ public abstract class ProcessorDefinitio
      * <a href="http://camel.apache.org/wiretap.html">WireTap EIP:</a>
      * Sends a new {@link org.apache.camel.Exchange} to the destination
      * using {@link ExchangePattern#InOnly}.
+     * <p/>
+     * Will use a copy of the original Exchange which is passed in as argument
+     * to the given processor
      *
      * @param uri  the destination
      * @param processor  processor preparing the new exchange to send
      * @return the builder
      */
-    @SuppressWarnings("unchecked")
     public Type wireTap(String uri, Processor processor) {
+        return wireTap(uri, true, processor);
+    }
+
+    /**
+     * <a href="http://camel.apache.org/wiretap.html">WireTap EIP:</a>
+     * Sends a new {@link org.apache.camel.Exchange} to the destination
+     * using {@link ExchangePattern#InOnly}.
+     *
+     * @param uri  the destination
+     * @param copy whether or not use a copy of the original exchange or a new empty exchange
+     * @param processor  processor preparing the new exchange to send
+     * @return the builder
+     */
+    @SuppressWarnings("unchecked")
+    public Type wireTap(String uri, boolean copy, Processor processor) {
         WireTapDefinition answer = new WireTapDefinition();
         answer.setUri(uri);
+        answer.setCopy(copy);
         answer.setNewExchangeProcessor(processor);
         addOutput(answer);
         return (Type) this;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java?rev=935469&r1=935468&r2=935469&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java Mon Apr 19 07:58:58 2010
@@ -43,14 +43,16 @@ public class WireTapDefinition extends S
 
     @XmlTransient
     private Processor newExchangeProcessor;
-    @XmlAttribute(name = "processorRef", required = false)
+    @XmlAttribute(name = "processorRef")
     private String newExchangeProcessorRef;
-    @XmlElement(name = "body", required = false)
+    @XmlElement(name = "body")
     private ExpressionSubElementDefinition newExchangeExpression;
     @XmlTransient
     private ExecutorService executorService;
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String executorServiceRef;
+    @XmlAttribute
+    private Boolean copy = Boolean.TRUE;
 
     public WireTapDefinition() {
     }
@@ -72,6 +74,7 @@ public class WireTapDefinition extends S
             executorService = routeContext.getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this, "WireTap");
         }
         WireTapProcessor answer = new WireTapProcessor(endpoint, getPattern(), executorService);
+        answer.setCopy(isCopy());
 
         if (newExchangeProcessorRef != null) {
             newExchangeProcessor = routeContext.lookup(newExchangeProcessorRef, Processor.class);
@@ -81,7 +84,6 @@ public class WireTapDefinition extends S
             answer.setNewExchangeExpression(newExchangeExpression.createExpression(routeContext));
         }
 
-
         return answer;
     }
 
@@ -156,4 +158,12 @@ public class WireTapDefinition extends S
     public void setExecutorServiceRef(String executorServiceRef) {
         this.executorServiceRef = executorServiceRef;
     }
+
+    public Boolean isCopy() {
+        return copy != null && copy;
+    }
+
+    public void setCopy(Boolean copy) {
+        this.copy = copy;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/WireTapProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/WireTapProcessor.java?rev=935469&r1=935468&r2=935469&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/WireTapProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/WireTapProcessor.java Mon Apr 19 07:58:58 2010
@@ -42,6 +42,7 @@ public class WireTapProcessor extends Se
     // as opposed to traditional wiretap that sends a copy of the original exchange
     private Expression newExchangeExpression;
     private Processor newExchangeProcessor;
+    private boolean copy;
 
     public WireTapProcessor(Endpoint destination, ExecutorService executorService) {
         super(destination);
@@ -99,30 +100,16 @@ public class WireTapProcessor extends Se
     @Override
     protected Exchange configureExchange(Exchange exchange, ExchangePattern pattern) {
         Exchange answer;
-        if (newExchangeProcessor == null && newExchangeExpression == null) {
+        if (copy) {
             // use a copy of the original exchange
             answer = configureCopyExchange(exchange);
         } else {
             // use a new exchange
             answer = configureNewExchange(exchange);
         }
+
         // set property which endpoint we send to
         answer.setProperty(Exchange.TO_ENDPOINT, destination.getEndpointUri());
-        return answer;
-    }
-
-    private Exchange configureCopyExchange(Exchange exchange) {
-        // must use a copy as we dont want it to cause side effects of the original exchange
-        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
-        // set MEP to InOnly as this wire tap is a fire and forget
-        copy.setPattern(ExchangePattern.InOnly);
-        return copy;
-    }
-
-    private Exchange configureNewExchange(Exchange exchange) {
-        Exchange answer = new DefaultExchange(exchange.getContext(), ExchangePattern.InOnly);
-        // use destination os origin of this new exchange
-        answer.setFromEndpoint(getDestination());
 
         // prepare the exchange
         if (newExchangeProcessor != null) {
@@ -131,7 +118,7 @@ public class WireTapProcessor extends Se
             } catch (Exception e) {
                 throw ObjectHelper.wrapRuntimeCamelException(e);
             }
-        } else {
+        } else if (newExchangeExpression != null) {
             Object body = newExchangeExpression.evaluate(answer, Object.class);
             if (body != null) {
                 answer.getIn().setBody(body);
@@ -141,6 +128,18 @@ public class WireTapProcessor extends Se
         return answer;
     }
 
+    private Exchange configureCopyExchange(Exchange exchange) {
+        // must use a copy as we dont want it to cause side effects of the original exchange
+        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
+        // set MEP to InOnly as this wire tap is a fire and forget
+        copy.setPattern(ExchangePattern.InOnly);
+        return copy;
+    }
+
+    private Exchange configureNewExchange(Exchange exchange) {
+        return new DefaultExchange(exchange.getFromEndpoint(), ExchangePattern.InOnly);
+    }
+
     public Processor getNewExchangeProcessor() {
         return newExchangeProcessor;
     }
@@ -156,4 +155,12 @@ public class WireTapProcessor extends Se
     public void setNewExchangeExpression(Expression newExchangeExpression) {
         this.newExchangeExpression = newExchangeExpression;
     }
+
+    public boolean isCopy() {
+        return copy;
+    }
+
+    public void setCopy(boolean copy) {
+        this.copy = copy;
+    }
 }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java?rev=935469&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java Mon Apr 19 07:58:58 2010
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static org.apache.camel.language.simple.SimpleLanguage.simple;
+
+/**
+ * @version $Revision$
+ */
+public class WireTapUsingFireAndForgetCopyAsDefaultTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testFireAndForgetUsingProcessor() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // START SNIPPET: e1
+                from("direct:start")
+                    .wireTap("direct:foo", new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String body = exchange.getIn().getBody(String.class);
+                            exchange.getIn().setBody("Bye " + body);
+                            exchange.getIn().setHeader("foo", "bar");
+                        }
+                    }).to("mock:result");
+
+
+                from("direct:foo").to("mock:foo");
+                // END SNIPPET: e1
+            }
+        });
+        context.start();
+
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived("World");
+
+        MockEndpoint foo = getMockEndpoint("mock:foo");
+        foo.expectedBodiesReceived("Bye World");
+        foo.expectedHeaderReceived("foo", "bar");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+
+        // should be different exchange instances
+        Exchange e1 = result.getReceivedExchanges().get(0);
+        Exchange e2 = foo.getReceivedExchanges().get(0);
+        assertNotSame("Should not be same Exchange", e1, e2);
+
+        // should have same from endpoint
+        assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
+    }
+
+    public void testFireAndForgetUsingExpression() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // START SNIPPET: e2
+                from("direct:start")
+                    .wireTap("direct:foo", simple("Bye ${body}"))
+                    .to("mock:result");
+
+                from("direct:foo").to("mock:foo");
+                // END SNIPPET: e2
+            }
+        });
+        context.start();
+
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived("World");
+
+        MockEndpoint foo = getMockEndpoint("mock:foo");
+        foo.expectedBodiesReceived("Bye World");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+
+        // should be different exchange instances
+        Exchange e1 = result.getReceivedExchanges().get(0);
+        Exchange e2 = foo.getReceivedExchanges().get(0);
+        assertNotSame("Should not be same Exchange", e1, e2);
+
+        // should have same from endpoint
+        assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyAsDefaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java (from r935446, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java&r1=935446&r2=935469&rev=935469&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetCopyTest.java Mon Apr 19 07:58:58 2010
@@ -22,10 +22,12 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
+import static org.apache.camel.language.simple.SimpleLanguage.simple;
+
 /**
  * @version $Revision$
  */
-public class WireTapUsingFireAndForgetTest extends ContextTestSupport {
+public class WireTapUsingFireAndForgetCopyTest extends ContextTestSupport {
 
     @Override
     public boolean isUseRouteBuilder() {
@@ -38,9 +40,10 @@ public class WireTapUsingFireAndForgetTe
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 from("direct:start")
-                    .wireTap("direct:foo", new Processor() {
+                    .wireTap("direct:foo", true, new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            exchange.getIn().setBody("Bye World");
+                            String body = exchange.getIn().getBody(String.class);
+                            exchange.getIn().setBody("Bye " + body);
                             exchange.getIn().setHeader("foo", "bar");
                         }
                     }).to("mock:result");
@@ -53,13 +56,13 @@ public class WireTapUsingFireAndForgetTe
         context.start();
 
         MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived("Hello World");
+        result.expectedBodiesReceived("World");
 
         MockEndpoint foo = getMockEndpoint("mock:foo");
         foo.expectedBodiesReceived("Bye World");
         foo.expectedHeaderReceived("foo", "bar");
 
-        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "World");
 
         assertMockEndpointsSatisfied();
 
@@ -68,9 +71,9 @@ public class WireTapUsingFireAndForgetTe
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
     public void testFireAndForgetUsingExpression() throws Exception {
@@ -79,7 +82,7 @@ public class WireTapUsingFireAndForgetTe
             public void configure() throws Exception {
                 // START SNIPPET: e2
                 from("direct:start")
-                    .wireTap("direct:foo", constant("Bye World"))
+                    .wireTap("direct:foo", true, simple("Bye ${body}"))
                     .to("mock:result");
 
                 from("direct:foo").to("mock:foo");
@@ -89,12 +92,12 @@ public class WireTapUsingFireAndForgetTe
         context.start();
 
         MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived("Hello World");
+        result.expectedBodiesReceived("World");
 
         MockEndpoint foo = getMockEndpoint("mock:foo");
         foo.expectedBodiesReceived("Bye World");
 
-        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "World");
 
         assertMockEndpointsSatisfied();
 
@@ -103,9 +106,9 @@ public class WireTapUsingFireAndForgetTe
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
-}
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java?rev=935469&r1=935468&r2=935469&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/WireTapUsingFireAndForgetTest.java Mon Apr 19 07:58:58 2010
@@ -38,7 +38,7 @@ public class WireTapUsingFireAndForgetTe
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 from("direct:start")
-                    .wireTap("direct:foo", new Processor() {
+                    .wireTap("direct:foo", false, new Processor() {
                         public void process(Exchange exchange) throws Exception {
                             exchange.getIn().setBody("Bye World");
                             exchange.getIn().setHeader("foo", "bar");
@@ -68,9 +68,9 @@ public class WireTapUsingFireAndForgetTe
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
     public void testFireAndForgetUsingExpression() throws Exception {
@@ -79,7 +79,7 @@ public class WireTapUsingFireAndForgetTe
             public void configure() throws Exception {
                 // START SNIPPET: e2
                 from("direct:start")
-                    .wireTap("direct:foo", constant("Bye World"))
+                    .wireTap("direct:foo", false, constant("Bye World"))
                     .to("mock:result");
 
                 from("direct:foo").to("mock:foo");
@@ -103,9 +103,9 @@ public class WireTapUsingFireAndForgetTe
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
 }

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.java (from r935446, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java&r1=935446&r2=935469&rev=935469&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.java Mon Apr 19 07:58:58 2010
@@ -21,22 +21,23 @@ import org.apache.camel.ContextTestSuppo
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.mock.MockEndpoint;
+
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringWireTapUsingFireAndForgetTest extends ContextTestSupport {
+public class SpringWireTapUsingFireAndForgetCopyTest extends ContextTestSupport {
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml");
     }
 
     public void testFireAndForgetUsingExpression() throws Exception {
         MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived("Hello World");
+        result.expectedBodiesReceived("World");
 
         MockEndpoint foo = getMockEndpoint("mock:foo");
         foo.expectedBodiesReceived("Bye World");
 
-        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "World");
 
         assertMockEndpointsSatisfied();
 
@@ -45,20 +46,20 @@ public class SpringWireTapUsingFireAndFo
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
     public void testFireAndForgetUsingProcessor() throws Exception {
         MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived("Hello World");
+        result.expectedBodiesReceived("World");
 
         MockEndpoint foo = getMockEndpoint("mock:foo");
         foo.expectedBodiesReceived("Bye World");
         foo.expectedHeaderReceived("foo", "bar");
 
-        template.sendBody("direct:start2", "Hello World");
+        template.sendBody("direct:start2", "World");
 
         assertMockEndpointsSatisfied();
 
@@ -67,18 +68,19 @@ public class SpringWireTapUsingFireAndFo
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start2", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start2", e2.getFromEndpoint().getEndpointUri());
     }
 
     // START SNIPPET: e1
     public static class MyProcessor implements Processor {
 
         public void process(Exchange exchange) throws Exception {
+            String body = exchange.getIn().getBody(String.class);
             // here we prepare the new exchange by setting the payload on the exchange
-            // on the IN messege.
-            exchange.getIn().setBody("Bye World");
+            // on the IN message.
+            exchange.getIn().setBody("Bye " + body);
             exchange.getIn().setHeader("foo", "bar");
         }
     }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java?rev=935469&r1=935468&r2=935469&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.java Mon Apr 19 07:58:58 2010
@@ -45,9 +45,9 @@ public class SpringWireTapUsingFireAndFo
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start", e2.getFromEndpoint().getEndpointUri());
     }
 
     public void testFireAndForgetUsingProcessor() throws Exception {
@@ -67,9 +67,9 @@ public class SpringWireTapUsingFireAndFo
         Exchange e2 = foo.getReceivedExchanges().get(0);
         assertNotSame("Should not be same Exchange", e1, e2);
 
-        // should have different from endpoint
+        // should have same from endpoint
         assertEquals("direct://start2", e1.getFromEndpoint().getEndpointUri());
-        assertEquals("direct://foo", e2.getFromEndpoint().getEndpointUri());
+        assertEquals("direct://start2", e2.getFromEndpoint().getEndpointUri());
     }
 
     // START SNIPPET: e1
@@ -77,7 +77,7 @@ public class SpringWireTapUsingFireAndFo
 
         public void process(Exchange exchange) throws Exception {
             // here we prepare the new exchange by setting the payload on the exchange
-            // on the IN messege.
+            // on the IN message.
             exchange.getIn().setBody("Bye World");
             exchange.getIn().setHeader("foo", "bar");
         }

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml (from r935446, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml&r1=935446&r2=935469&rev=935469&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml Mon Apr 19 07:58:58 2010
@@ -28,7 +28,7 @@
         <route>
             <from uri="direct:start"/>
             <wireTap uri="direct:foo">
-                <body><constant>Bye World</constant></body>
+                <body><simple>Bye ${body}</simple></body>
             </wireTap>
             <to uri="mock:result"/>
         </route>
@@ -49,6 +49,6 @@
 
     </camelContext>
 
-    <bean id="myProcessor" class="org.apache.camel.spring.processor.SpringWireTapUsingFireAndForgetTest$MyProcessor"/>
+    <bean id="myProcessor" class="org.apache.camel.spring.processor.SpringWireTapUsingFireAndForgetCopyTest$MyProcessor"/>
 
 </beans>