[ 
https://issues.apache.org/jira/browse/CAMEL-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13057065#comment-13057065
 ] 

Søren Markert commented on CAMEL-4159:
--------------------------------------

You're quick =)

> MockEndpoint.expectedHeaderReceived checks only one header
> ----------------------------------------------------------
>
>                 Key: CAMEL-4159
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4159
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Søren Markert
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.0
>
>
> The method MockEndpoint.expectedHeaderReceived sets one header key and one 
> header value to check. Subsequent calls to the same method overwrites the key 
> and value. As a (non-expert) user of the MockEndpoint, I would expect this 
> method to work somewhat along the lines of Map.put, so that multiple headers 
> can be expected. Alternatively, replace it with 
> MockEndpoint.expectedHeadersReceived(Map<String, Object> headers) or 
> something like that.
> MockEndpoint.expectedPropertyReceived has the same issue.
> The unit test below demonstrates the bug. Have fun :)
> {code}
> import java.util.HashMap;
> import org.apache.camel.Produce;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.CamelTestSupport;
> public class MockEndpointTest extends CamelTestSupport {
>       @Produce(uri = "direct:input")
>       protected ProducerTemplate input;
>       protected MockEndpoint resultEndpoint;
>       @Override
>       protected RouteBuilder createRouteBuilder() throws Exception {
>           return new RouteBuilder() {
>             public void configure() {
>               resultEndpoint = new MockEndpoint("mock:result");
>               resultEndpoint.setCamelContext(getContext());
>               
>               from("direct:input")
>                       .inOnly("log:output?showHeaders=true")
>                       .to(resultEndpoint);
>             }
>         };
>       }
>       
>       public void testStuff() throws Exception {
>               HashMap<String, Object> headers = new HashMap<String, Object>();
> //            headers.put("h1", "hello");
>               headers.put("h2", "world");
>               resultEndpoint.expectedHeaderReceived("h1", "hello");
>               resultEndpoint.expectedHeaderReceived("h2", "world");
>               
>               input.sendBodyAndHeaders(null, headers);
>               
>               resultEndpoint.expectedMessageCount(1);
>               resultEndpoint.assertIsNotSatisfied();
>       }
> }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to