Repository: camel
Updated Branches:
  refs/heads/master c260ef39a -> ae8fc5505


CAMEL-11589: Fixing issue with MockEndpoint.expectedPropertyReceived


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c80ccfe2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c80ccfe2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c80ccfe2

Branch: refs/heads/master
Commit: c80ccfe22d163c2f080fdfe734acbd26beb52fbb
Parents: c260ef3
Author: Saravanakumar Selvaraj <saravanakumar.j...@gmail.com>
Authored: Mon Jul 24 13:11:15 2017 +0530
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Jul 25 14:04:22 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/component/mock/MockEndpoint.java    | 10 +++-------
 .../camel/component/mock/MockEndpointTest.java       | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c80ccfe2/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
index 1dbf173..ff5b19e 100644
--- a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.CountDownLatch;
@@ -609,12 +608,9 @@ public class MockEndpoint extends DefaultEndpoint 
implements BrowsableEndpoint {
      */
     public void expectedPropertyReceived(final String name, final Object 
value) {
         if (expectedPropertyValues == null) {
-            expectedPropertyValues = new ConcurrentHashMap<String, Object>();
-        }
-        if (value != null) {
-            // ConcurrentHashMap cannot store null values
-            expectedPropertyValues.put(name, value);
+            expectedPropertyValues = new HashMap<String, Object>();
         }
+        expectedPropertyValues.put(name, value);
 
         expects(new Runnable() {
             public void run() {
@@ -624,7 +620,7 @@ public class MockEndpoint extends DefaultEndpoint 
implements BrowsableEndpoint {
                         String key = entry.getKey();
                         Object expectedValue = entry.getValue();
 
-                        // we accept that an expectedValue of null also means 
that the header may be absent
+                        // we accept that an expectedValue of null also means 
that the property may be absent
                         if (expectedValue != null) {
                             assertTrue("Exchange " + i + " has no properties", 
!exchange.getProperties().isEmpty());
                             boolean hasKey = 
exchange.getProperties().containsKey(key);

http://git-wip-us.apache.org/repos/asf/camel/blob/c80ccfe2/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
index b471820..104059a 100644
--- 
a/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
@@ -521,6 +521,21 @@ public class MockEndpointTest extends ContextTestSupport {
             assertEquals("mock://result No property with name bar found for 
message: 0", e.getMessage());
         }
     }
+    
+    public void testPropertyNotReceived() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedPropertyReceived("foo", null);
+
+        template.send("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.setProperty("foo", 123);
+            }
+        });
+
+        mock.assertIsNotSatisfied();
+    }
+
 
     public void testPropertyInvalidValue() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");

Reply via email to