You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/10/26 08:34:06 UTC

svn commit: r1027378 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/camel/component/seda/ camel-core/src/test/java/org/apache/camel/component/vm/ camel-core/src/test/java/org/apache/camel/impl/ ca...

Author: davsclaus
Date: Tue Oct 26 06:34:05 2010
New Revision: 1027378

URL: http://svn.apache.org/viewvc?rev=1027378&view=rev
Log:
CAMEL-3276: Fixed setting result message on Exchange when pipeline copy result back to exchange.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MulticastPipelineAggregateIssueTest.java
Removed:
    camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcPreserveHeadersTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
    camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
    camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTests.java
    camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java
    camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/HMACAccumulatorTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java Tue Oct 26 06:34:05 2010
@@ -208,11 +208,15 @@ public final class ExchangeHelper {
                 // have created any OUT; such as a mock:endpoint
                 // so lets assume the last IN is the OUT
                 if (result.getPattern().isOutCapable()) {
-                    // only set OUT if its OUT capable
+                    // only set OUT if its OUT capable or already has OUT
                     result.getOut().copyFrom(source.getIn());
                 } else {
                     // if not replace IN instead to keep the MEP
                     result.getIn().copyFrom(source.getIn());
+                    // clear any existing OUT as the result is on the IN
+                    if (result.hasOut()) {
+                        result.setOut(null);
+                    }
                 }
             }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteTest.java Tue Oct 26 06:34:05 2010
@@ -47,7 +47,7 @@ public class SedaWaitForTaskCompleteTest
                 exchange.setPattern(ExchangePattern.InOnly);
             }
         });
-        assertEquals("Bye World", out.getOut().getBody());
+        assertEquals("Bye World", out.getIn().getBody());
 
         assertMockEndpointsSatisfied();
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java Tue Oct 26 06:34:05 2010
@@ -47,7 +47,7 @@ public class VmWaitForTaskCompleteTest e
                 exchange.setPattern(ExchangePattern.InOnly);
             }
         });
-        assertEquals("Bye World", out.getOut().getBody());
+        assertEquals("Bye World", out.getIn().getBody());
 
         assertMockEndpointsSatisfied();
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java Tue Oct 26 06:34:05 2010
@@ -58,7 +58,7 @@ public class DefaultProducerTemplateAsyn
         Exchange result = future.get();
 
         long delta = System.currentTimeMillis() - start;
-        assertEquals("Hello World", result.getOut().getBody());
+        assertEquals("Hello World", result.getIn().getBody());
         assertTrue("Should take longer than: " + delta, delta > 250);
 
         assertMockEndpointsSatisfied();
@@ -79,7 +79,7 @@ public class DefaultProducerTemplateAsyn
         Exchange result = future.get();
 
         long delta = System.currentTimeMillis() - start;
-        assertEquals("Hello World", result.getOut().getBody());
+        assertEquals("Hello World", result.getIn().getBody());
         assertTrue("Should take longer than: " + delta, delta > 250);
     }
 

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MulticastPipelineAggregateIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MulticastPipelineAggregateIssueTest.java?rev=1027378&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MulticastPipelineAggregateIssueTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MulticastPipelineAggregateIssueTest.java Tue Oct 26 06:34:05 2010
@@ -0,0 +1,96 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+
+/**
+ * @version $Revision$
+ */
+public class MulticastPipelineAggregateIssueTest extends ContextTestSupport {
+
+    public void testMulticastPipelineAggregateIssue() throws Exception {
+        getMockEndpoint("mock:a").expectedBodiesReceived(8);
+        getMockEndpoint("mock:b").expectedBodiesReceived(8);
+        getMockEndpoint("mock:c").expectedBodiesReceived(8);
+
+        template.sendBody("direct:a", 1);
+        template.sendBody("direct:b", 1);
+        template.sendBody("direct:c", 1);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:a").multicast(new SumAggregateBean())
+                    .pipeline().bean(IncreaseOne.class).bean(new IncreaseTwo()).end()
+                    .pipeline().bean(IncreaseOne.class).bean(new IncreaseTwo()).end()
+                .end()
+                .to("mock:a");
+
+                from("direct:b").multicast(new SumAggregateBean())
+                    .pipeline().transform(bean(IncreaseOne.class)).bean(new IncreaseTwo()).end()
+                    .pipeline().transform(bean(IncreaseOne.class)).bean(new IncreaseTwo()).end()
+                .end()
+                .to("mock:b");
+
+                from("direct:c").multicast(new SumAggregateBean())
+                    .pipeline().transform(bean(IncreaseOne.class)).transform(bean(new IncreaseTwo())).end()
+                    .pipeline().transform(bean(IncreaseOne.class)).transform(bean(new IncreaseTwo())).end()
+                .end()
+                .to("mock:c");
+            }
+        };
+    }
+
+    public static class IncreaseOne {
+
+        public int addOne(int num) {
+            return num + 1;
+        }
+    }
+
+    public static class IncreaseTwo {
+
+        public int addTwo(int num) {
+            return num + 2;
+        }
+    }
+
+    public static class SumAggregateBean implements AggregationStrategy {
+
+        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+            if (oldExchange == null) {
+                return newExchange;
+            }
+
+            int num1 = oldExchange.getIn().getBody(int.class);
+            int num2 = newExchange.getIn().getBody(int.class);
+
+            newExchange.getIn().setBody(num1 + num2);
+            return newExchange;
+        }
+    }
+
+}

Modified: camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java (original)
+++ camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java Tue Oct 26 06:34:05 2010
@@ -33,6 +33,7 @@ import static org.apache.camel.component
 /**
  * @version $Revision$
  */
+@Ignore("AMQP testing is a bit unstable")
 public class AMQPRouteTest extends CamelTestSupport {
     protected MockEndpoint resultEndpoint;
     
@@ -54,7 +55,6 @@ public class AMQPRouteTest extends Camel
     
 
     @Test
-    @Ignore("AMQP testing is a bit unstable")
     public void testJmsRouteWithTextMessage() throws Exception {
         String expectedBody = "Hello there!";
 
@@ -80,7 +80,6 @@ public class AMQPRouteTest extends Camel
     }
 
     @Test
-    @Ignore("AMQP testing is a bit unstable")
     public void testJmsRouteWithObjectMessage() throws Exception {
         PurchaseOrder expectedBody = new PurchaseOrder("Beer", 10);
 
@@ -93,7 +92,6 @@ public class AMQPRouteTest extends Camel
     }
 
     @Test
-    @Ignore("AMQP testing is a bit unstable")
     public void testJmsRouteWithByteArrayMessage() throws Exception {
         PurchaseOrder aPO = new PurchaseOrder("Beer", 10);
         byte[] expectedBody = SerializationUtils.serialize(aPO);

Modified: camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTests.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTests.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTests.java (original)
+++ camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTests.java Tue Oct 26 06:34:05 2010
@@ -27,7 +27,6 @@ import java.security.SecureRandom;
 import java.security.cert.Certificate;
 import java.util.Collections;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
@@ -37,9 +36,6 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
 
 import static org.apache.camel.component.crypto.DigitalSignatureConstants.KEYSTORE_ALIAS;
 import static org.apache.camel.component.crypto.DigitalSignatureConstants.SIGNATURE_PRIVATE_KEY;
@@ -52,7 +48,6 @@ public class SignatureTests extends Cont
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
-        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%c - %m%n")));
         JndiRegistry registry = super.createRegistry();
         KeyStore keystore = loadKeystore();
         Certificate cert = keystore.getCertificate("bob");
@@ -144,25 +139,25 @@ public class SignatureTests extends Cont
     public void testBasicSignatureRoute() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:keypair", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetAlgorithmInRouteDefinition() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:algorithm", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetBufferInRouteDefinition() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:buffersize", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetRandomInRouteDefinition() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:random", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetProviderInRouteDefinition() throws Exception {
@@ -172,19 +167,19 @@ public class SignatureTests extends Cont
         // can only be run on SUN JDK
         MockEndpoint mock = setupMock();
         sendBody("direct:provider", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetCertificateInRouteDefinition() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:certificate", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSetKeystoreInRouteDefinition() throws Exception {
         MockEndpoint mock = setupMock();
         sendBody("direct:keystore", payload);
-        verify(mock);
+        assertMockEndpointsSatisfied();
     }
 
     public void testSignatureHeaderInRouteDefinition() throws Exception {
@@ -192,12 +187,14 @@ public class SignatureTests extends Cont
         Exchange signed = getMandatoryEndpoint("direct:signature-header").createExchange();
         signed.getIn().setBody(payload);
         template.send("direct:signature-header", signed);
-        assertNotNull(signed.getOut().getHeader("AnotherDigitalSignature"));
-        verify(mock);
+        assertNotNull(signed.getIn().getHeader("AnotherDigitalSignature"));
+
+        assertMockEndpointsSatisfied();
     }
 
     public void testProvideAliasInHeader() throws Exception {
         MockEndpoint mock = setupMock();
+
         // START SNIPPET: alias-send
         Exchange unsigned = getMandatoryEndpoint("direct:alias-sign").createExchange();
         unsigned.getIn().setBody(payload);
@@ -211,8 +208,7 @@ public class SignatureTests extends Cont
         template.send("direct:alias-verify", signed);
         // START SNIPPET: alias-send
 
-        verify(mock);
-
+        assertMockEndpointsSatisfied();
     }
 
     public void testProvideKeysInHeader() throws Exception {
@@ -232,7 +228,8 @@ public class SignatureTests extends Cont
         signed.getIn().copyFrom(unsigned.getOut());
         signed.getIn().setHeader(SIGNATURE_PUBLIC_KEY_OR_CERT, pair.getPublic());
         template.send("direct:headerkey-verify", signed);
-        verify(mock);
+
+        assertMockEndpointsSatisfied();
     }
 
     public void testProvideCertificateInHeader() throws Exception {
@@ -254,11 +251,8 @@ public class SignatureTests extends Cont
         signed.getIn().copyFrom(unsigned.getOut());
         signed.getIn().setHeader(SIGNATURE_PUBLIC_KEY_OR_CERT, certificate);
         template.send("direct:headerkey-verify", signed);
-        verify(mock);
-    }
 
-    private void verify(MockEndpoint mock) throws InterruptedException {
-        MockEndpoint.assertIsSatisfied(10, TimeUnit.SECONDS, mock);
+        assertMockEndpointsSatisfied();
     }
 
     private MockEndpoint setupMock() {
@@ -287,7 +281,7 @@ public class SignatureTests extends Cont
             } else {
                 template.sendBodyAndHeaders("direct:in", payload, headers);
             }
-            verify(mock);
+            assertMockEndpointsSatisfied();
             return mock.getReceivedExchanges().get(0);
         } finally {
             context.stop();

Modified: camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java (original)
+++ camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java Tue Oct 26 06:34:05 2010
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
 import java.security.Key;
 import java.util.Collections;
 import java.util.Map;
-
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
 
@@ -67,14 +66,14 @@ public class CryptoDataFormatTest extend
 
         MockEndpoint mock = setupExpectations(context, 1, "mock:unencrypted");
         Exchange encrypted = getMandatoryEndpoint("direct:key-in-header-decrypt").createExchange();
-        encrypted.getIn().copyFrom(unecrypted.getOut());
+        encrypted.getIn().copyFrom(unecrypted.getIn());
         encrypted.getIn().setHeader(CryptoDataFormat.KEY, key);
         template.send("direct:key-in-header-decrypt", encrypted);
-        awaitAndAssert(mock);
+
+        assertMockEndpointsSatisfied();
 
         Exchange received = mock.getReceivedExchanges().get(0);
         validateHeaderIsCleared(received);
-
     }
 
     private void validateHeaderIsCleared(Exchange ex) {
@@ -88,13 +87,14 @@ public class CryptoDataFormatTest extend
     }
 
     private void doRoundTripEncryptionTests(String endpoint, Map<String, Object> headers) throws Exception, InterruptedException, InvalidPayloadException {
-
         MockEndpoint encrypted = setupExpectations(context, 3, "mock:encrypted");
         MockEndpoint unencrypted = setupExpectations(context, 3, "mock:unencrypted");
+
         String payload = "Hi Alice, Be careful Eve is listening, signed Bob";
         template.sendBodyAndHeaders(endpoint, payload, headers);
         template.sendBodyAndHeaders(endpoint, payload.getBytes(), headers);
         template.sendBodyAndHeaders(endpoint, new ByteArrayInputStream(payload.getBytes()), headers);
+
         assertMocksSatisfied(encrypted, unencrypted, payload);
     }
 
@@ -112,63 +112,87 @@ public class CryptoDataFormatTest extend
 
     protected RouteBuilder[] createRouteBuilders() throws Exception {
         return new RouteBuilder[] {new RouteBuilder() {
-            @Override
             public void configure() throws Exception {
                 // START SNIPPET: basic
                 KeyGenerator generator = KeyGenerator.getInstance("DES");
+
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
-                from("direct:basic-encryption").marshal(cryptoFormat).to("mock:encrypted").unmarshal(cryptoFormat).to("mock:unencrypted");
+
+                from("direct:basic-encryption")
+                    .marshal(cryptoFormat)
+                    .to("mock:encrypted")
+                    .unmarshal(cryptoFormat)
+                    .to("mock:unencrypted");
                 // END SNIPPET: basic
             }
         }, new RouteBuilder() {
-            @Override
             public void configure() throws Exception {
                 // START SNIPPET: init-vector
                 KeyGenerator generator = KeyGenerator.getInstance("DES");
                 byte[] initializationVector = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", generator.generateKey());
                 cryptoFormat.setInitializationVector(initializationVector);
-                from("direct:init-vector").marshal(cryptoFormat).to("mock:encrypted").unmarshal(cryptoFormat).to("mock:unencrypted");
+
+                from("direct:init-vector")
+                    .marshal(cryptoFormat)
+                    .to("mock:encrypted")
+                    .unmarshal(cryptoFormat)
+                    .to("mock:unencrypted");
                 // END SNIPPET: init-vector
             }
         }, new RouteBuilder() {
-
             public void configure() throws Exception {
                 // START SNIPPET: inline-init-vector
                 KeyGenerator generator = KeyGenerator.getInstance("DES");
                 byte[] initializationVector = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
                 SecretKey key = generator.generateKey();
+
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key);
                 cryptoFormat.setInitializationVector(initializationVector);
                 cryptoFormat.setShouldInlineInitializationVector(true);
                 CryptoDataFormat decryptFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key);
                 decryptFormat.setShouldInlineInitializationVector(true);
-                from("direct:inline").marshal(cryptoFormat).to("mock:encrypted").unmarshal(decryptFormat).to("mock:unencrypted");
+
+                from("direct:inline")
+                    .marshal(cryptoFormat)
+                    .to("mock:encrypted")
+                    .unmarshal(decryptFormat)
+                    .to("mock:unencrypted");
                 // END SNIPPET: inline-init-vector
             }
         }, new RouteBuilder() {
-
             public void configure() throws Exception {
                 // START SNIPPET: hmac
                 KeyGenerator generator = KeyGenerator.getInstance("DES");
+
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
                 cryptoFormat.setShouldAppendHMAC(true);
-                from("direct:hmac").marshal(cryptoFormat).to("mock:encrypted").unmarshal(cryptoFormat).to("mock:unencrypted");
+
+                from("direct:hmac")
+                    .marshal(cryptoFormat)
+                    .to("mock:encrypted")
+                    .unmarshal(cryptoFormat)
+                    .to("mock:unencrypted");
                 // END SNIPPET: hmac
             }
         }, new RouteBuilder() {
-
             public void configure() throws Exception {
                 // START SNIPPET: hmac-algorithm
                 KeyGenerator generator = KeyGenerator.getInstance("DES");
+
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
                 cryptoFormat.setShouldAppendHMAC(true);
                 cryptoFormat.setMacAlgorithm("HmacMD5");
-                from("direct:hmac-algorithm").marshal(cryptoFormat).to("mock:encrypted").unmarshal(cryptoFormat).to("mock:unencrypted");
+
+                from("direct:hmac-algorithm")
+                    .marshal(cryptoFormat)
+                    .to("mock:encrypted")
+                    .unmarshal(cryptoFormat)
+                    .to("mock:unencrypted");
                 // END SNIPPET: hmac-algorithm
             }
         }, new RouteBuilder() {
-
             public void configure() throws Exception {
                 // START SNIPPET: key-in-header
                 CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", null);
@@ -179,11 +203,12 @@ public class CryptoDataFormatTest extend
                  * arguably better as the key is left in the header when you use
                  * the DSL leaks the fact that camel encryption was used.
                  */
-                from("direct:key-in-header-encrypt").marshal(cryptoFormat).setHeader(CryptoDataFormat.KEY, constant(null)).setOutHeader(CryptoDataFormat.KEY, constant(null))
+                from("direct:key-in-header-encrypt")
+                    .marshal(cryptoFormat)
+                    .removeHeader(CryptoDataFormat.KEY)
                     .to("mock:encrypted");
 
                 from("direct:key-in-header-decrypt").unmarshal(cryptoFormat).process(new Processor() {
-
                     public void process(Exchange exchange) throws Exception {
                         exchange.getIn().getHeaders().remove(CryptoDataFormat.KEY);
                         exchange.getOut().copyFrom(exchange.getIn());
@@ -195,7 +220,6 @@ public class CryptoDataFormatTest extend
     }
 
     private void awaitAndAssert(MockEndpoint mock) throws InterruptedException {
-        mock.await();
         mock.assertIsSatisfied();
     }
 
@@ -204,4 +228,5 @@ public class CryptoDataFormatTest extend
         mockEp.expectedMessageCount(expected);
         return mockEp;
     }
+
 }

Modified: camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/HMACAccumulatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/HMACAccumulatorTest.java?rev=1027378&r1=1027377&r2=1027378&view=diff
==============================================================================
--- camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/HMACAccumulatorTest.java (original)
+++ camel/trunk/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/HMACAccumulatorTest.java Tue Oct 26 06:34:05 2010
@@ -135,7 +135,6 @@ public class HMACAccumulatorTest {
 
     private void assertMacs(byte[] expected, byte[] actual) {
         assertEquals(HexUtils.byteArrayToHexString(expected), HexUtils.byteArrayToHexString(actual));
-
     }
 
     @Test