camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1365013 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/mock/MockEndpoint.java test/java/org/apache/camel/component/mock/MockEndpointTest.java
Date Tue, 24 Jul 2012 12:44:57 GMT
Author: bvahdat
Date: Tue Jul 24 12:44:56 2012
New Revision: 1365013

URL: http://svn.apache.org/viewvc?rev=1365013&view=rev
Log:
CAMEL-5460: MockEndpoint.expectedBodiesReceivedInAnyOrder() should allow asserting on the
multiple arrival for the SAME body.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.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=1365013&r1=1365012&r2=1365013&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
Tue Jul 24 12:44:56 2012
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -693,15 +692,13 @@ public class MockEndpoint extends Defaul
 
         expects(new Runnable() {
             public void run() {
-                Set<Object> actualBodyValuesSet = new HashSet<Object>(actualBodyValues);
+                List<Object> actualBodyValuesSet = new ArrayList<Object>(actualBodyValues);
                 for (int i = 0; i < expectedBodyValues.size(); i++) {
                     Exchange exchange = getReceivedExchange(i);
                     assertTrue("No exchange received for counter: " + i, exchange != null);
 
                     Object expectedBody = expectedBodyValues.get(i);
-                    assertTrue("Message with body " + expectedBody
-                            + " was expected but not found in " + actualBodyValuesSet,
-                            actualBodyValuesSet.remove(expectedBody));
+                    assertTrue("Message with body " + expectedBody + " was expected but not
found in " + actualBodyValuesSet, actualBodyValuesSet.remove(expectedBody));
                 }
             }
         });
@@ -1156,7 +1153,7 @@ public class MockEndpoint extends Defaul
             }
             performAssertions(exchange, copy);
         } catch (Throwable e) {
-            // must catch java.lang.Throwable as AssertionException extends java.lang.Error
+            // must catch java.lang.Throwable as AssertionError extends java.lang.Error
             failures.add(e);
         } finally {
             // make sure latch is counted down to avoid test hanging forever

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java?rev=1365013&r1=1365012&r2=1365013&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
Tue Jul 24 12:44:56 2012
@@ -92,7 +92,16 @@ public class MockEndpointTest extends Co
 
         resultEndpoint.assertIsSatisfied();
     }       
-    
+
+    public void testExpectsBodiesInAnyOrderWithDuplicates() throws Exception {
+        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+        resultEndpoint.expectedBodiesReceivedInAnyOrder(listOfMessages(11, 15, 12, 12, 13,
14, 15, 15));
+
+        sendMessages(15, 15, 12, 14, 13, 12, 15, 11);
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
     public void testExpectsHeadersInAnyOrder() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedHeaderValuesReceivedInAnyOrder("counter", 11, 12, 13, 14,
15);



Mime
View raw message