Author: davsclaus
Date: Wed Nov 25 11:27:53 2009
New Revision: 884056

URL: http://svn.apache.org/viewvc?rev=884056&view=rev
Log:
CAMEL-2227: Fixed mock component expectedBodies with a List parameter. Bad bad 
java generics.

Added:
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.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=884056&r1=884055&r2=884056&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
 Wed Nov 25 11:27:53 2009
@@ -363,7 +363,8 @@
      * Adds an expectation that the given body values are received by this
      * endpoint in the specified order
      */
-    public void expectedBodiesReceived(final List<Object> bodies) {
+    @SuppressWarnings("unchecked")
+    public void expectedBodiesReceived(final List bodies) {
         expectedMessageCount(bodies.size());
         this.expectedBodyValues = bodies;
         this.actualBodyValues = new ArrayList<Object>();
@@ -423,7 +424,8 @@
      * Adds an expectation that the given body values are received by this
      * endpoint in any order
      */
-    public void expectedBodiesReceivedInAnyOrder(final List<Object> bodies) {
+    @SuppressWarnings("unchecked")
+    public void expectedBodiesReceivedInAnyOrder(final List bodies) {
         expectedMessageCount(bodies.size());
         this.expectedBodyValues = bodies;
         this.actualBodyValues = new ArrayList<Object>();

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java?rev=884056&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java
 Wed Nov 25 11:27:53 2009
@@ -0,0 +1,77 @@
+/**
+ * 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.component.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class MockExpectedBodiesAsListTest extends ContextTestSupport {
+
+    public void testUsingVarargs() throws Exception {
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived("Hello World", "Bye World");
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testUsingListString() throws Exception {
+        List<String> data = new ArrayList<String>();
+        data.add("Hello World");
+        data.add("Bye World");
+
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived(data);
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testUsingList() throws Exception {
+        List data = new ArrayList();
+        data.add("Hello World");
+        data.add(123);
+
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived(data);
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", 123);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+}

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockExpectedBodiesAsListTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to