Package org.apache.camel.component.mock

Examples of org.apache.camel.component.mock.MockEndpoint.expectedHeaderReceived()


    public void testNPE() throws Exception {
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm a NPE");

        try {
            template.sendBody("direct:a", "Hello NPE");
            fail("Should have thrown a NullPointerException");
        } catch (RuntimeCamelException e) {
View Full Code Here


    public void testIOException() throws Exception {
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm somekind of IO exception");

        try {
            template.sendBody("direct:a", "Hello IO");
            fail("Should have thrown a IOException");
        } catch (RuntimeCamelException e) {
View Full Code Here

    public void testException() throws Exception {
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm just exception");

        try {
            template.sendBody("direct:a", "Hello Exception");
            fail("Should have thrown a Exception");
        } catch (RuntimeCamelException e) {
View Full Code Here

    public void testMyBusinessException() throws Exception {
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(BUSINESS_ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm my business is not going to well");

        try {
            template.sendBody("direct:a", "Hello business");
            fail("Should have thrown a MyBusinessException");
        } catch (RuntimeCamelException e) {
View Full Code Here

        // test that we also handles a configuration with 2 or more exceptions
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(SECURITY_ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm some security error");

        try {
            template.sendBody("direct:a", "I am not allowed to do this");
            fail("Should have thrown a GeneralSecurityException");
        } catch (RuntimeCamelException e) {
View Full Code Here

        // test that we also handles a configuration with a list of exceptions
        MockEndpoint result = getMockEndpoint(RESULT_QUEUE);
        result.expectedMessageCount(0);
        MockEndpoint mock = getMockEndpoint(ERROR_QUEUE);
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(MESSAGE_INFO, "Damm some access error");

        try {
            template.sendBody("direct:a", "I am not allowed to access this");
            fail("Should have thrown a GeneralSecurityException");
        } catch (RuntimeCamelException e) {
View Full Code Here

public class BeanPipelineTest extends ContextTestSupport {

    public void testBeanInPipeline() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello World from James");
        mock.expectedHeaderReceived("from", "James");

        template.sendBodyAndHeader("direct:input", "Hello World", "from", "Claus");
        mock.assertIsSatisfied();
    }
View Full Code Here

public class BeanWithAnnotationAndExchangeTest extends ContextTestSupport {

    public void testBeanWithAnnotationAndExchangeTest() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("StartMyBean");
        mock.expectedHeaderReceived("foo", "bar");
        mock.expectedHeaderReceived("user", "admin");

        template.requestBody("direct:in", "Start");

        mock.assertIsSatisfied();
View Full Code Here

    public void testBeanWithAnnotationAndExchangeTest() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("StartMyBean");
        mock.expectedHeaderReceived("foo", "bar");
        mock.expectedHeaderReceived("user", "admin");

        template.requestBody("direct:in", "Start");

        mock.assertIsSatisfied();
    }
View Full Code Here

    private void assertMailbox(String name) throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:" + name);
        mock.expectedMessageCount(1);
        mock.expectedBodiesReceived("Hello World");
        mock.expectedHeaderReceived("cc", "james@localhost");
    }

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.