Author: davsclaus
Date: Thu Sep  3 16:38:15 2009
New Revision: 811018

URL: http://svn.apache.org/viewvc?rev=811018&view=rev
Log:
Fixed mock endpoint and expected headers javadoc being wrong as it does not add 
but set instead

Added:
    
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MockExepctedHeadersIssueTest.java
   (with props)
Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=811018&r1=811017&r2=811018&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
 Thu Sep  3 16:38:15 2009
@@ -299,7 +299,7 @@
     }
 
     /**
-     * Adds an expectation that the given header name & value are received by 
this endpoint
+     * Sets an expectation that the given header name & value are received by 
this endpoint
      */
     public void expectedHeaderReceived(final String name, final Object value) {
         this.headerName = name;
@@ -331,7 +331,7 @@
     }
     
     /**
-     * Adds an expectation that the given property name & value are received 
by this endpoint
+     * Sets an expectation that the given property name & value are received 
by this endpoint
      */
     public void expectedPropertyReceived(final String name, final Object 
value) {
         this.propertyName = name;
@@ -375,7 +375,7 @@
     }
 
     /**
-     * Adds an expectation that the given body values are received by this 
endpoint
+     * Sets an expectation that the given body values are received by this 
endpoint
      */
     public void expectedBodiesReceived(Object... bodies) {
         List bodyList = new ArrayList();

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MockExepctedHeadersIssueTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MockExepctedHeadersIssueTest.java?rev=811018&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MockExepctedHeadersIssueTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MockExepctedHeadersIssueTest.java
 Thu Sep  3 16:38:15 2009
@@ -0,0 +1,61 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class MockExepctedHeadersIssueTest extends ContextTestSupport {
+
+    public void testHeaders() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+
+        // this one does NOT add by only SET so what happens is that header1 
value1 is the only tested
+        resultEndpoint.expectedHeaderReceived("header2", "value2");
+        resultEndpoint.expectedHeaderReceived("header1", "value1");
+
+        template.sendBody("direct:test", null);
+
+        resultEndpoint.assertIsNotSatisfied();
+    }
+
+    public void testHeadersAdded() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+        resultEndpoint.message(0).header("header1").isNull();
+        resultEndpoint.message(0).header("header2").isEqualTo("value2");
+
+        template.sendBody("direct:test", null);
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:test")
+                    .setHeader("header2", constant("value2"))
+                    .to("mock:result");
+            }
+        };
+    }
+}

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

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


Reply via email to