camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Markert (JIRA) <>
Subject [jira] [Created] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header
Date Tue, 28 Jun 2011 14:31:17 GMT
MockEndpoint.expectedHeaderReceived checks only one header

                 Key: CAMEL-4159
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.7.0
            Reporter: Søren Markert

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 :)

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;

	protected RouteBuilder createRouteBuilder() throws Exception {
	    return new RouteBuilder() {
            public void configure() {
            	resultEndpoint = new MockEndpoint("mock:result");
	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);

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message