Package org.apache.camel.component.mock

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


        // reset the mock endpoint to get rid of the previous message
        mockJSON.reset();
        // all three messages should arrive, should be of type byte[] and
        // identical to one another
        mockJSON.expectedMessageCount(3);
        mockJSON.allMessages().body().isInstanceOf(byte[].class);
        mockJSON.expectedBodiesReceived(Arrays.asList(expectedBody, expectedBody, expectedBody));

        // start bombarding the route
        Object json = template.requestBody("direct:marshal", inDOM);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
View Full Code Here


    }

    public void testSplitParallelStopOnExceptionStop() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:split");
        mock.expectedMinimumMessageCount(0);
        mock.allMessages().body().isNotEqualTo("Kaboom");

        try {
            template.sendBody("direct:start", "Hello World,Goodday World,Kaboom,Bye World");
            fail("Should thrown an exception");
        } catch (CamelExecutionException e) {
View Full Code Here

    }

    public void testSedaConcurrentInOut() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(20);
        mock.allMessages().body().startsWith("Bye");

        // should at least take 3 sec
        mock.setMinimumResultWaitTime(3000);

        ExecutorService executors = Executors.newFixedThreadPool(10);
View Full Code Here

    }

    public void testSedaConcurrentInOutWithAsync() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(20);
        mock.allMessages().body().startsWith("Bye");

        // should at least take 3 sec
        mock.setMinimumResultWaitTime(3000);

        // use our own template that has a higher thread pool than default camel that uses 5
View Full Code Here

    public void testSplitParallelNoStopOnExceptionStop() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:split");
        mock.expectedMinimumMessageCount(0);
        // we do NOT stop so we receive all messages except the one that goes kaboom
        mock.allMessages().body().isNotEqualTo("Kaboom");
        mock.expectedBodiesReceivedInAnyOrder("Hello World", "Goodday World", "Bye World", "Hi World");

        try {
            template.sendBody("direct:start", "Hello World,Goodday World,Kaboom,Bye World,Hi World");
            fail("Should thrown an exception");
View Full Code Here

        MockEndpoint result = getMockEndpoint("mock:result");
        result.expectedMessageCount(1);

        XPathExpression xpath = new XPathExpression("/foo = 'bar'");
        xpath.setResultType(Boolean.class);
        result.allMessages().body().matches(xpath);

        template.sendBody("direct:start", "<foo>bar</foo>");

        assertMockEndpointsSatisfied();
    }
View Full Code Here

        MockEndpoint mock = resolveMandatoryEndpoint("mock:marshal", MockEndpoint.class);
        mock.expectedMessageCount(1);

        XPathExpression xpath = new XPathExpression("count(//*[namespace-uri() = 'http://example.camel.org/apache' and local-name() = 'po']) = 1");
        xpath.setResultType(Boolean.class);
        mock.allMessages().body().matches(xpath);

        template.sendBody("direct:marshal", bean);

        mock.assertIsSatisfied();
    }
View Full Code Here

        });
        context.start();

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello World", "Bye World");
        mock.allMessages().header("Content-Type").isEqualTo("text/plain");

        Map headers = new HashMap();
        headers.put("To", "jones@localhost");
        headers.put("Content-Type", "text/plain");
        template.sendBodyAndHeaders("smtp://localhost?ignoreUnsupportedCharset=true", "Hello World", headers);
View Full Code Here

        });
        context.start();

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello World");
        mock.allMessages().header("Content-Type").isEqualTo("text/plain");

        Map headers = new HashMap();
        headers.put("To", "jones@localhost");
        headers.put("Content-Type", "text/plain");
        template.sendBodyAndHeaders("smtp://localhost?ignoreUnsupportedCharset=false", "Hello World", headers);
View Full Code Here

            return;
        }

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);
        mock.allMessages().body().isInstanceOf(String.class);

        template.sendBody("direct:start", "Hello Nagios");

        assertMockEndpointsSatisfied();
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.