camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header
Date Tue, 28 Jun 2011 14:43:17 GMT

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

Claus Ibsen commented on CAMEL-4159:
------------------------------------

Well that was how it was intended as it was like the expectedBodyXXX etc. But I guess since
headers/properties are in maps, we could make that work that way so you can specify multiple.

You can always do something like:
{code}
mock.message(0).header("xxx").isEqualTo("blah");
mock.message(0).header("yyy").isEqualTo(123);
{code}


> MockEndpoint.expectedHeaderReceived checks only one header
> ----------------------------------------------------------
>
>                 Key: CAMEL-4159
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4159
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Søren Markert
>             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

       

Mime
View raw message