Package org.apache.camel.component.mock

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


    @Test
    public void testSplit() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("A", "B", "C");
        mock.allMessages().header("foo").isEqualTo("cheese");
        mock.allMessages().property("bar").isEqualTo(123);

        template.send("direct:start", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setBody("A,B,C");
                exchange.getIn().setHeader("foo", "cheese");
View Full Code Here


        final MockEndpoint mock = (MockEndpoint) context.getBean("result");
        mock.expectedMessageCount(SIZE);
        // expect no duplicate bodies
        mock.expectsNoDuplicates().body();
        // and all replies should start with this text
        mock.allMessages().body().startsWith("Bye Message");

        // now send a lot of messages
        System.out.println("Sending ...");
        for (int i = 0; i < SIZE; i++) {
            producer.sendBody("direct:start", "Message " + i);
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

            return;
        }

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

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

        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();
       
        //To make sure there is no XML declaration.
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

    }

    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

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

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

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

    @Test
    public void testDisruptorConcurrentInOutWithAsync() throws Exception {
        final 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

        // 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

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.