Package org.apache.camel

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


    public void testCxfBusConfiguration() throws Exception {
        // get the camelContext from application context
        CamelContext camelContext = (CamelContext) ctx.getBean("camel");
        ProducerTemplate template = camelContext.createProducerTemplate();
        try {
            template.send("cxf:bean:serviceEndpoint", new Processor() {
                public void process(final Exchange exchange) {
                    final List<String> params = new ArrayList<String>();
                    params.add("hello");
                    exchange.getIn().setBody(params);
                    exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
View Full Code Here


    protected CamelContext camelContext;

    public void testSendingRequest() throws Exception {
        assertNotNull("the camelContext should not be null", camelContext);
        ProducerTemplate template = camelContext.createProducerTemplate();
        Exchange exchange = template.send("jetty:http://localhost:9000/test", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setBody("<hello>Willem</hello>");
                exchange.getIn().setHeader("Operation", "greetMe");
            }
View Full Code Here

    assertNotNull("mockEndpoint for test purpose is null", mockEndpoint);

    mockEndpoint.expectedMessageCount(1);
    exchange = new DefaultExchange(camelContext);

    producer.send("direct:tdrRuleTest1", exchange);

    assertEquals("Wrong expected message count", 1, mockEndpoint.getReceivedCounter());

    receivedExchange = mockEndpoint.getExchanges().get(0);
    assertNotNull("receivedExchange is null", receivedExchange);
View Full Code Here

    // Test route 1 - 10 messages
    mockEndpoint.expectedMessageCount(10);

    for(int i=0; i<10; i++) {
      exchange = new DefaultExchange(camelContext);
      producer.send("direct:tdrRuleTest1", exchange);
    }

    assertEquals("Wrong expected message count", 10, mockEndpoint.getReceivedCounter());

    Exchange lastExchange = null;
View Full Code Here

    assertNotNull("mockEndpoint for test purpose is null", mockEndpoint);

    mockEndpoint.expectedMessageCount(1);
    exchange = new DefaultExchange(camelContext);

    producer.send("direct:tdrRuleTest2", exchange);

    assertEquals("Wrong expected message count", 1, mockEndpoint.getReceivedCounter());

    receivedExchange = mockEndpoint.getExchanges().get(0);
    assertNotNull("receivedExchange is null", receivedExchange);
View Full Code Here

    assertNotNull("mockEndpoint for test purpose is null", mockEndpoint);

    mockEndpoint.expectedMessageCount(1);
    exchange = new DefaultExchange(camelContext);

    producer.send("direct:tdrRuleTest3", exchange);

    assertEquals("Wrong expected message count", 1, mockEndpoint.getReceivedCounter());

    receivedExchange = mockEndpoint.getExchanges().get(0);
    assertNotNull("receivedExchange is null", receivedExchange);
View Full Code Here

    mockEndpoint.expectedMessageCount(1);
    exchange = new DefaultExchange(camelContext);
    exchange.getIn().setHeader("Header1", "Value header 1");

    producer.send("direct:tdrRuleTest4", exchange);

    assertEquals("Wrong expected message count", 1, mockEndpoint.getReceivedCounter());

    receivedExchange = mockEndpoint.getExchanges().get(0);
    assertNotNull("receivedExchange is null", receivedExchange);
View Full Code Here

    mockEndpoint.expectedMessageCount(1);
    exchange = new DefaultExchange(camelContext);
    exchange.getIn().setHeader("DynamicHeader", "DynamicValue");

    producer.send("direct:tdrRuleTest5", exchange);
    assertEquals("Wrong expected message count", 1, mockEndpoint.getReceivedCounter());
    assertEquals("Wrong tdrQueueService size", 1, tdrQueueService.getQueueSize());

    tdrData = tdrQueueService.getOrWait();
    // Now the queue is empty
View Full Code Here

    // Sends 10 message
    for(int i=0; i<10; i++) {
      exchange = new DefaultExchange(camelContext);
      exchange.getIn().setHeader("DynamicHeader", "DynamicValue"+i);

      producer.send("direct:tdrRuleTest5", exchange);
    }
    assertEquals("Wrong expected message count", 10,
        mockEndpoint.getReceivedCounter());
    tdrData = tdrQueueService.getOrWait();
    // Now the queue is 9
View Full Code Here

    // Sends 10 message
    for (int i = 0; i < 10; i++) {
      exchange = new DefaultExchange(camelContext);
      exchange.getIn().setHeader("DynamicHeader", "DynamicValue" + i);

      producer.send("direct:tdrRuleTest5", exchange);
    }
    assertEquals("Wrong expected message count", 10,
        mockEndpoint.getReceivedCounter());
    assertEquals("Wrong tdrQueueService size", 10,
        tdrQueueService.getQueueSize());
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.