You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Søren Markert (JIRA)" <ji...@apache.org> on 2011/06/28 16:31:17 UTC

[jira] [Created] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

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


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

       

[jira] [Commented] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056608#comment-13056608 ] 

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

Running full tests. Will get the last pieces polished later today / tomorrow morning.

> 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

       

[jira] [Commented] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056593#comment-13056593 ] 

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

Okay I have this working now. Will polish it a bit as I noticed we should try to type coerce the expected bodies.

> 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

       

[jira] [Commented] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ 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

       

[jira] [Resolved] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-4159.
--------------------------------

    Resolution: Fixed

Yep we are fast in the Camel community. Its a kick-ass community.

> 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

       

[jira] [Commented] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Søren Markert (JIRA)" <ji...@apache.org>.
    [ 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

       

[jira] [Updated] (CAMEL-4159) MockEndpoint.expectedHeaderReceived checks only one header

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-4159:
-------------------------------

         Priority: Minor  (was: Major)
    Fix Version/s: 2.8.0
         Assignee: Claus Ibsen
       Issue Type: Improvement  (was: Bug)

> 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