Package org.apache.camel

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


       
        resultEndpoint.reset();
        fileEndpoint.reset();
       
        ProducerTemplate template = camelContext.createProducerTemplate();
        template.sendBodyAndHeader("direct:start", "Hello form Willem", "Operation", "greetMe");

        // Sleep a while and wait for the message whole processing
        Thread.sleep(2000);
        template.stop();
View Full Code Here


        assertNotNull(camelContext);

        ProducerTemplate template = camelContext.createProducerTemplate();
        List<String> params = new ArrayList<String>();
        params.add("Willem");
        Object result = template.sendBodyAndHeader("cxf://bean:serviceEndpoint", ExchangePattern.InOut ,
                                                   params, CxfConstants.OPERATION_NAME, "greetMe");
        assertTrue("Result is a list instance ", result instanceof List);
        assertEquals("Get the wrong response", ((List<?>)result).get(0), "HelloWillem");
        try {
            template.sendBodyAndHeader("cxf://bean:serviceEndpoint", ExchangePattern.InOut ,
View Full Code Here

        Object result = template.sendBodyAndHeader("cxf://bean:serviceEndpoint", ExchangePattern.InOut ,
                                                   params, CxfConstants.OPERATION_NAME, "greetMe");
        assertTrue("Result is a list instance ", result instanceof List);
        assertEquals("Get the wrong response", ((List<?>)result).get(0), "HelloWillem");
        try {
            template.sendBodyAndHeader("cxf://bean:serviceEndpoint", ExchangePattern.InOut ,
                                            params, CxfConstants.OPERATION_NAME, "pingMe");
            fail("Expect exception here.");
        } catch (Exception ex) {
            assertTrue("Get a wrong exception.", ex instanceof CamelExecutionException);
            assertTrue("Get a wrong exception cause. ", ex.getCause() instanceof PingMeFault);
View Full Code Here

    public void testMocksAreValid() throws Exception {
        assertNotNull(camelContext);
        assertNotNull(resultEndpoint);

        ProducerTemplate template = camelContext.createProducerTemplate();
        template.sendBodyAndHeader("jms:requestQueue", "Willem", CxfConstants.OPERATION_NAME, "greetMe");

        // Sleep a while and wait for the message whole processing
        Thread.sleep(4000);
        template.stop();
View Full Code Here

    @Test
    public void testFileWithOnewayOperation() throws Exception {
        deleteDirectory("target/messages/input/");
        greeterImpl.resetOneWayCounter();
        ProducerTemplate template = context.createProducerTemplate();
        template.sendBodyAndHeader("file://target/messages/input/", "Hello World", Exchange.FILE_NAME, "hello.txt");

        // Sleep a while and wait for the message whole processing
        Thread.sleep(4000);
        template.stop();
       
View Full Code Here

        context.start();

        // send out the request message
        for (int i = 0; i < 2; i++) {
            template.sendBodyAndHeader("jms:queue:loanRequestQueue",
                                       "Quote for the lowerst rate of loaning bank",
                                       Constants.PROPERTY_SSN, "Client-A" + i);
            Thread.sleep(100);
        }
        // wait for the response
View Full Code Here

        // now send a lot of messages
        System.out.println("Writing files ...");

        for (int i = 0; i < SIZE; i++) {
            producer.sendBodyAndHeader("file:target//inbox", "File " + i, Exchange.FILE_NAME, i + ".txt");
        }

        System.out.println("... Wrote " + SIZE + " files");

        System.exit(0);
View Full Code Here

       
        String expectedBody = "<matched/>";

        resultEndpoint.expectedBodiesReceived(expectedBody);

        template.sendBodyAndHeader("direct:start", expectedBody, "foo", "bar");

        resultEndpoint.assertIsSatisfied();
       
        resultEndpoint.reset();
       
View Full Code Here

       
        resultEndpoint.reset();
       
        resultEndpoint.expectedMessageCount(0);

        template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue");

        resultEndpoint.assertIsSatisfied();
    }

}
View Full Code Here

public class KratiProducerTest extends CamelTestSupport {

    @Test
    public void testPut() throws InterruptedException {
        ProducerTemplate template = context.createProducerTemplate();
        template.sendBodyAndHeader("direct:put", new ValueObject("TEST1"), KratiConstants.KEY, new KeyObject("1"));
        template.sendBodyAndHeader("direct:put", new ValueObject("TEST2"), KratiConstants.KEY, new KeyObject("2"));
        template.sendBodyAndHeader("direct:put", new ValueObject("TEST3"), KratiConstants.KEY, new KeyObject("3"));
        MockEndpoint endpoint = context.getEndpoint("mock:results", MockEndpoint.class);
        endpoint.expectedMessageCount(3);
        endpoint.assertIsSatisfied();
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.