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 2017/07/25 12:18:15 UTC

[1/2] camel git commit: CAMEL-11589: Fixing issue with MockEndpoint.expectedPropertyReceived

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 <sa...@gmail.com>
Authored: Mon Jul 24 13:11:15 2017 +0530
Committer: Claus Ibsen <da...@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");


[2/2] camel git commit: CAMEL-11589: Fixing issue with MockEndpoint.expectedPropertyReceived. This closes #1842.

Posted by da...@apache.org.
CAMEL-11589: Fixing issue with MockEndpoint.expectedPropertyReceived. This closes #1842.


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

Branch: refs/heads/master
Commit: ae8fc55053abbdfdcbcc033660542a4d90329592
Parents: c80ccfe
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 25 14:07:47 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 25 14:07:47 2017 +0200

----------------------------------------------------------------------
 .../camel/component/mock/MockEndpointTest.java  | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ae8fc550/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 104059a..e6074f6 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
@@ -522,7 +522,7 @@ public class MockEndpointTest extends ContextTestSupport {
         }
     }
     
-    public void testPropertyNotReceived() throws Exception {
+    public void testPropertyExpectedNull() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedPropertyReceived("foo", null);
@@ -534,8 +534,27 @@ public class MockEndpointTest extends ContextTestSupport {
         });
 
         mock.assertIsNotSatisfied();
-    }
 
+        resetMocks();
+
+        template.send("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.setProperty("foo", null);
+            }
+        });
+
+        mock.assertIsSatisfied();
+
+        resetMocks();
+
+        template.send("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                // no foo property
+            }
+        });
+
+        mock.assertIsSatisfied();
+    }
 
     public void testPropertyInvalidValue() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");