Package org.apache.camel

Examples of org.apache.camel.ProducerTemplate.sendBody()


    public void shouldNotBreakRedeliveriesOfSecondContextAfterFirstBeingStopped() throws Exception {
        DefaultCamelContext context1 = createContext();
        ProducerTemplate producer1 = context1.createProducerTemplate();
        ConsumerTemplate consumer1 = context1.createConsumerTemplate();
        context1.start();
        producer1.sendBody("seda://input", "Hey1");
        Exchange ex1 = consumer1.receive("seda://output", 5000);

        DefaultCamelContext context2 = createContext();
        ProducerTemplate producer2 = context2.createProducerTemplate();
        ConsumerTemplate consumer2 = context2.createConsumerTemplate();
View Full Code Here


        // now stop 1, and see that 2 is still working
        consumer1.stop();
        producer1.stop();
        context1.stop();

        producer2.sendBody("seda://input", "Hey2");
        Exchange ex2 = consumer2.receive("seda://output", 5000);

        Assert.assertNotNull(ex1);
        Assert.assertEquals("Hey1", ex1.getIn().getBody());
        Assert.assertNotNull(ex2);
View Full Code Here

        assertEquals("JMX value incorrect, should be 0", new Long(0), exchangesCompleted);

        NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create();

        ProducerTemplate template = camelContext.createProducerTemplate();
        template.sendBody("seda:foo", "test");

        notify.matchesMockWaitTime();

        exchangesCompleted = statistics.getRouteStatistic(camelContext, list.get(0).getId(), "ExchangesCompleted");
        assertEquals("JMX value incorrect, should be 1", new Long(1), exchangesCompleted);
View Full Code Here

                + "    <name>Raul</name>\n"
                + "    <surname>Kripalani</surname>\n"
                + "</hello>";

        ProducerTemplate template = ctx.createProducerTemplate();
        template.sendBody("direct:start", body);
        mock.assertIsSatisfied();
        String result = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
        String spacesRemoved = result.replaceAll("\\s+", result);
        assertEquals("{\"name\":\"Raul\",\"surname\":\"Kripalani\"}", spacesRemoved);
    }
View Full Code Here

        ProducerTemplate template = main.getCamelTemplate();
        assertNotNull("should have a template!", template);
        MockEndpoint endpoint = camelContext.getEndpoint(uri, MockEndpoint.class);
        endpoint.expectedBodiesReceived(expectedBody);

        template.sendBody(uri, expectedBody);

        endpoint.assertIsSatisfied();
    }

    @After
View Full Code Here

    }

    public void sendBody(String endpointUri, Object body) throws Exception {
        ProducerTemplate template = context.createProducerTemplate();
        try {
            template.sendBody(endpointUri, body);
        } finally {
            template.stop();
        }
    }
View Full Code Here

        ProducerTemplate template = ctx.createProducerTemplate();

        MockEndpoint mock = ctx.getEndpoint("mock:dead", MockEndpoint.class);
        mock.expectedMessageCount(1);

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

        mock.assertIsSatisfied();
        template.stop();
    }
View Full Code Here

        ProducerTemplate template = ctx.createProducerTemplate();

        MockEndpoint mock = ctx.getEndpoint("mock:dead", MockEndpoint.class);
        mock.expectedMessageCount(1);

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

        mock.assertIsSatisfied();
        template.stop();
    }
View Full Code Here

        MockEndpoint foo = ctx.getEndpoint("mock:foo", MockEndpoint.class);
        foo.expectedMessageCount(1);
        MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class);
        result.expectedMessageCount(1);

        myTemplate.sendBody("direct:start", "Hello World");

        foo.assertIsSatisfied();
        result.assertIsSatisfied();

        myTemplate.stop();
View Full Code Here

        MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
        mock.message(0).body().isInstanceOf(String.class);

        template.sendBody("direct:start", "<hello>world!</hello>");

        mock.assertIsSatisfied();
        template.stop();
    }
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.