org.apache.camel.component.mock.MockEndpoint

Here are the examples of the java api class org.apache.camel.component.mock.MockEndpoint taken from open source projects.

1. CamelJaxbTest#testUnmarshal()

Project: camel
Source File: CamelJaxbTest.java
View license
@Test
public void testUnmarshal() throws Exception {
    final String xml = "<Person><firstName>FOO</firstName><lastName>BAR</lastName></Person>";
    PersonType expected = new PersonType();
    expected.setFirstName("FOO");
    expected.setLastName("BAR");
    MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
    resultEndpoint.expectedBodiesReceived(expected);
    resultEndpoint.expectedHeaderReceived("foo", "bar");
    template.sendBodyAndHeader("direct:getJAXBElementValue", xml, "foo", "bar");
    resultEndpoint.assertIsSatisfied();
    resultEndpoint.reset();
    resultEndpoint.expectedMessageCount(1);
    template.sendBody("direct:getJAXBElement", xml);
    resultEndpoint.assertIsSatisfied();
    assertTrue("We should get the JAXBElement here", resultEndpoint.getExchanges().get(0).getIn().getBody() instanceof JAXBElement);
    resultEndpoint.reset();
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedBodiesReceived(expected);
    template.sendBody("direct:unmarshall", xml);
    resultEndpoint.assertIsSatisfied();
}

2. JmsSelectorOptionTest#testJmsMessageWithSelector()

Project: camel
Source File: JmsSelectorOptionTest.java
View license
@Test
public void testJmsMessageWithSelector() throws Exception {
    MockEndpoint endpointA = getMockEndpoint("mock:a");
    MockEndpoint endpointB = getMockEndpoint("mock:b");
    MockEndpoint endpointC = getMockEndpoint("mock:c");
    endpointA.expectedBodiesReceivedInAnyOrder("A blue car!", "A blue car, again!");
    endpointA.expectedHeaderReceived("color", "blue");
    endpointB.expectedHeaderReceived("color", "red");
    endpointB.expectedBodiesReceived("A red car!");
    endpointC.expectedBodiesReceived("Message1", "Message2");
    endpointC.expectedMessageCount(2);
    template.sendBodyAndHeader("activemq:queue:hello", "A blue car!", "color", "blue");
    template.sendBodyAndHeader("activemq:queue:hello", "A red car!", "color", "red");
    template.sendBodyAndHeader("activemq:queue:hello", "A blue car, again!", "color", "blue");
    template.sendBodyAndHeader("activemq:queue:hello", "Message1", "SIZE_NUMBER", 1505);
    template.sendBodyAndHeader("activemq:queue:hello", "Message3", "SIZE_NUMBER", 1300);
    template.sendBodyAndHeader("activemq:queue:hello", "Message2", "SIZE_NUMBER", 1600);
    assertMockEndpointsSatisfied();
}

3. QuartzTwoCamelContextSuspendResumeTest#testTwoCamelContextRestart()

View license
@Test
public void testTwoCamelContextRestart() throws Exception {
    MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(2);
    MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
    mock2.expectedMinimumMessageCount(6);
    mock1.assertIsSatisfied();
    camel1.suspend();
    mock2.assertIsSatisfied();
    // should resume triggers when we start camel 1 again
    mock1.reset();
    mock1.expectedMinimumMessageCount(2);
    camel1.resume();
    mock1.assertIsSatisfied();
}

4. QuartzTwoCamelContextSuspendResumeTest#testTwoCamelContextRestart()

View license
@Test
public void testTwoCamelContextRestart() throws Exception {
    MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(2);
    MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
    mock2.expectedMinimumMessageCount(6);
    mock1.assertIsSatisfied();
    camel1.suspend();
    mock2.assertIsSatisfied();
    // should resume triggers when we start camel 1 again
    mock1.reset();
    mock1.expectedMinimumMessageCount(2);
    camel1.resume();
    mock1.assertIsSatisfied();
}

5. JmsSelectorOptionTest#testJmsMessageWithSelector()

Project: camel
Source File: JmsSelectorOptionTest.java
View license
@Test
public void testJmsMessageWithSelector() throws Exception {
    MockEndpoint endpointA = getMockEndpoint("mock:a");
    MockEndpoint endpointB = getMockEndpoint("mock:b");
    MockEndpoint endpointC = getMockEndpoint("mock:c");
    endpointA.expectedBodiesReceivedInAnyOrder("A blue car!", "A blue car, again!");
    endpointA.expectedHeaderReceived("color", "blue");
    endpointB.expectedHeaderReceived("color", "red");
    endpointB.expectedBodiesReceived("A red car!");
    endpointC.expectedBodiesReceived("Message1", "Message2");
    endpointC.expectedMessageCount(2);
    template.sendBodyAndHeader("sjms:queue:hello", "A blue car!", "color", "blue");
    template.sendBodyAndHeader("sjms:queue:hello", "A red car!", "color", "red");
    template.sendBodyAndHeader("sjms:queue:hello", "A blue car, again!", "color", "blue");
    template.sendBodyAndHeader("sjms:queue:hello", "Message1", "SIZE_NUMBER", 1505);
    template.sendBodyAndHeader("sjms:queue:hello", "Message3", "SIZE_NUMBER", 1300);
    template.sendBodyAndHeader("sjms:queue:hello", "Message2", "SIZE_NUMBER", 1600);
    assertMockEndpointsSatisfied();
}

6. FilteringSpringTest#testFirstFilter()

View license
@Test
public void testFirstFilter() throws Exception {
    final MockEndpoint mockEndpointC = getMockEndpoint("mock:C");
    mockEndpointC.expectedMessageCount(1);
    mockEndpointC.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    final MockEndpoint mockEndpointAfterC = getMockEndpoint("mock:afterC");
    mockEndpointAfterC.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointAfterC.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    getMockEndpoint("mock:amel").expectedMessageCount(0);
    final MockEndpoint mockEndpointOther = getMockEndpoint("mock:other");
    mockEndpointOther.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointOther.expectedPropertyReceived(Exchange.FILTER_MATCHED, false);
    template.sendBody("direct:start", "Cooks Rocks");
    assertMockEndpointsSatisfied();
}

7. FilteringSpringTest#testSecondFilter()

View license
@Test
public void testSecondFilter() throws Exception {
    getMockEndpoint("mock:C").expectedMessageCount(0);
    final MockEndpoint mockEndpointAfterC = getMockEndpoint("mock:afterC");
    mockEndpointAfterC.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointAfterC.expectedPropertyReceived(Exchange.FILTER_MATCHED, false);
    final MockEndpoint mockEndpointAmel = getMockEndpoint("mock:amel");
    mockEndpointAmel.expectedMessageCount(1);
    mockEndpointAmel.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    final MockEndpoint mockEndpointOther = getMockEndpoint("mock:other");
    mockEndpointOther.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointOther.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    template.sendBody("direct:start", "amel is in Belgium");
    assertMockEndpointsSatisfied();
}

8. FilteringTest#testFirstFilter()

View license
@Test
public void testFirstFilter() throws Exception {
    final MockEndpoint mockEndpointC = getMockEndpoint("mock:C");
    mockEndpointC.expectedMessageCount(1);
    mockEndpointC.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    final MockEndpoint mockEndpointAfterC = getMockEndpoint("mock:afterC");
    mockEndpointAfterC.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointAfterC.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    getMockEndpoint("mock:amel").expectedMessageCount(0);
    final MockEndpoint mockEndpointOther = getMockEndpoint("mock:other");
    mockEndpointOther.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointOther.expectedPropertyReceived(Exchange.FILTER_MATCHED, false);
    template.sendBody("direct:start", "Cooks Rocks");
    assertMockEndpointsSatisfied();
}

9. FilteringTest#testSecondFilter()

View license
@Test
public void testSecondFilter() throws Exception {
    getMockEndpoint("mock:C").expectedMessageCount(0);
    final MockEndpoint mockEndpointAfterC = getMockEndpoint("mock:afterC");
    mockEndpointAfterC.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointAfterC.expectedPropertyReceived(Exchange.FILTER_MATCHED, false);
    final MockEndpoint mockEndpointAmel = getMockEndpoint("mock:amel");
    mockEndpointAmel.expectedMessageCount(1);
    mockEndpointAmel.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    final MockEndpoint mockEndpointOther = getMockEndpoint("mock:other");
    mockEndpointOther.expectedMessageCount(1);
    // FILTER_MATCHED set to true if message matched previous Filter Predicate
    mockEndpointOther.expectedPropertyReceived(Exchange.FILTER_MATCHED, true);
    template.sendBody("direct:start", "amel is in Belgium");
    assertMockEndpointsSatisfied();
}

10. FileToFileWithFlattenTest#testFlatternConsumer()

View license
public void testFlatternConsumer() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("file://target/flatten-in?recursive=true&flatten=true").to("file://target/flatten-out", "mock:result");
        }
    });
    context.start();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(3);
    // flatten files
    mock.expectedFileExists("target/flatten-out/bye.txt");
    mock.expectedFileExists("target/flatten-out/hello.txt");
    mock.expectedFileExists("target/flatten-out/goodday.txt");
    // default move files
    mock.expectedFileExists("target/flatten-in/.camel/bye.txt");
    mock.expectedFileExists("target/flatten-in/sub/.camel/hello.txt");
    mock.expectedFileExists("target/flatten-in/sub/sub2/.camel/goodday.txt");
    assertMockEndpointsSatisfied();
}

11. FileToFileWithFlattenTest#testFlatternProducer()

View license
public void testFlatternProducer() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("file://target/flatten-in?recursive=true").to("file://target/flatten-out?flatten=true", "mock:result");
        }
    });
    context.start();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(3);
    // flatten files
    mock.expectedFileExists("target/flatten-out/bye.txt");
    mock.expectedFileExists("target/flatten-out/hello.txt");
    mock.expectedFileExists("target/flatten-out/goodday.txt");
    // default move files
    mock.expectedFileExists("target/flatten-in/.camel/bye.txt");
    mock.expectedFileExists("target/flatten-in/sub/.camel/hello.txt");
    mock.expectedFileExists("target/flatten-in/sub/sub2/.camel/goodday.txt");
    assertMockEndpointsSatisfied();
}

12. ThrottlerTest#testSendLotsOfMessagesWithRejectExecution()

Project: camel
Source File: ThrottlerTest.java
View license
public void testSendLotsOfMessagesWithRejectExecution() throws Exception {
    if (!canTest()) {
        return;
    }
    MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
    resultEndpoint.expectedMessageCount(2);
    resultEndpoint.setResultWaitTime(2000);
    MockEndpoint errorEndpoint = resolveMandatoryEndpoint("mock:error", MockEndpoint.class);
    errorEndpoint.expectedMessageCount(4);
    errorEndpoint.setResultWaitTime(2000);
    for (int i = 0; i < 6; i++) {
        template.sendBody("direct:start", "<message>" + i + "</message>");
    }
    // lets pause to give the requests time to be processed
    // to check that the throttle really does kick in
    resultEndpoint.assertIsSatisfied();
    errorEndpoint.assertIsSatisfied();
}

13. GroovySetHeaderTest#testSetHeader()

Project: camel
Source File: GroovySetHeaderTest.java
View license
@Test
public void testSetHeader() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello World");
    mock.expectedHeaderReceived("one", "einz");
    mock.expectedHeaderReceived("two", "twei");
    mock.expectedHeaderReceived("beer", "Carlsberg");
    mock.expectedHeaderReceived("drink", "Carlsberg");
    mock.expectedHeaderReceived("camelId", context.getName());
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("one", "einz");
    headers.put("two", "twei");
    headers.put("beer", "Carlsberg");
    template.sendBodyAndHeaders("direct:start", "Hello World", headers);
    assertMockEndpointsSatisfied();
}

14. MailProcessOnlyUnseenMessagesTest#testProcessOnlyUnseenMessages()

View license
@Test
public void testProcessOnlyUnseenMessages() throws Exception {
    sendBody("direct:a", "Message 3");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Message 3");
    mock.assertIsSatisfied();
    // reset mock so we can make new assertions
    mock.reset();
    // send a new message, now we should only receive this new massages as all the others has been SEEN
    sendBody("direct:a", "Message 4");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Message 4");
    mock.assertIsSatisfied();
}

15. QuartzTwoCamelContextRestartTest#testTwoCamelContextRestart()

View license
@Test
public void testTwoCamelContextRestart() throws Exception {
    MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(2);
    MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
    mock2.expectedMinimumMessageCount(6);
    mock1.assertIsSatisfied();
    camel1.stop();
    mock2.assertIsSatisfied();
    // should resume triggers when we start camel 1 again
    // fetch mock endpoint again because we have stopped camel context
    mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(3);
    camel1.start();
    mock1.assertIsSatisfied();
}

16. QuartzTwoCamelContextRestartTest#testTwoCamelContextRestart()

View license
@Test
public void testTwoCamelContextRestart() throws Exception {
    MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(2);
    MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
    mock2.expectedMinimumMessageCount(6);
    mock1.assertIsSatisfied();
    camel1.stop();
    mock2.assertIsSatisfied();
    // should resume triggers when we start camel 1 again
    // fetch mock endpoint again because we have stopped camel context
    mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
    mock1.expectedMinimumMessageCount(3);
    camel1.start();
    mock1.assertIsSatisfied();
}

17. ZookeeperDoubleRouteAndDoublePolicyTest#routeDoublePoliciesAndTwoRoutes()

View license
@Test
public void routeDoublePoliciesAndTwoRoutes() throws Exception {
    // set up the parent used to control the election
    client.createPersistent("/someapp", "App node to contain policy election nodes...");
    client.createPersistent("/someapp/somepolicy", "Policy node used by route policy to control routes...");
    client.createPersistent("/someapp/someotherpolicy", "Policy node used by route policy to control routes...");
    context.addRoutes(new ZooKeeperPolicyEnforcedRoute());
    MockEndpoint mockedpolicy = getMockEndpoint("mock:controlled");
    mockedpolicy.setExpectedMessageCount(1);
    sendBody("direct:policy-controlled", "This is a test");
    mockedpolicy.await(5, TimeUnit.SECONDS);
    mockedpolicy.assertIsSatisfied();
    MockEndpoint mockedpolicy1 = getMockEndpoint("mock:controlled-1");
    mockedpolicy1.setExpectedMessageCount(1);
    sendBody("direct:policy-controlled-1", "This is a test");
    mockedpolicy1.await(5, TimeUnit.SECONDS);
    mockedpolicy1.assertIsSatisfied();
}

18. DoTrySpringTest#testDoTryHappy()

View license
@Test
public void testDoTryHappy() throws Exception {
    final MockEndpoint mockBefore = getMockEndpoint("mock:before");
    mockBefore.expectedBodiesReceived("Foo");
    final MockEndpoint mockError = getMockEndpoint("mock:error");
    mockError.expectedMessageCount(0);
    final MockEndpoint mockFinally = getMockEndpoint("mock:finally");
    mockFinally.expectedBodiesReceived("Made it!");
    final MockEndpoint mockAfter = getMockEndpoint("mock:after");
    mockAfter.expectedBodiesReceived("Made it!");
    String response = null;
    try {
        response = template.requestBody("direct:start", "Foo", String.class);
    } catch (Throwable e) {
        fail("Shouldn't get here");
    }
    assertEquals("Made it!", response);
    assertMockEndpointsSatisfied();
}

19. DoTrySpringTest#testDoTryError()

View license
@Test
public void testDoTryError() throws Exception {
    final MockEndpoint mockBefore = getMockEndpoint("mock:before");
    mockBefore.expectedBodiesReceived("Kaboom");
    final MockEndpoint mockError = getMockEndpoint("mock:error");
    mockError.expectedBodiesReceived("Kaboom");
    final MockEndpoint mockFinally = getMockEndpoint("mock:finally");
    mockFinally.expectedBodiesReceived("Something Bad Happened!");
    final MockEndpoint mockAfter = getMockEndpoint("mock:after");
    mockAfter.expectedBodiesReceived("Something Bad Happened!");
    String response = null;
    try {
        response = template.requestBody("direct:start", "Kaboom", String.class);
    } catch (Throwable e) {
        fail("Shouldn't get here");
    }
    assertEquals("Something Bad Happened!", response);
    assertMockEndpointsSatisfied();
}

20. DoTryTest#testDoTryHappy()

View license
@Test
public void testDoTryHappy() throws Exception {
    final MockEndpoint mockBefore = getMockEndpoint("mock:before");
    mockBefore.expectedBodiesReceived("Foo");
    final MockEndpoint mockError = getMockEndpoint("mock:error");
    mockError.expectedMessageCount(0);
    final MockEndpoint mockFinally = getMockEndpoint("mock:finally");
    mockFinally.expectedBodiesReceived("Made it!");
    final MockEndpoint mockAfter = getMockEndpoint("mock:after");
    mockAfter.expectedBodiesReceived("Made it!");
    String response = null;
    try {
        response = template.requestBody("direct:start", "Foo", String.class);
    } catch (Throwable e) {
        fail("Shouldn't get here");
    }
    assertEquals("Made it!", response);
    assertMockEndpointsSatisfied();
}

21. DoTryTest#testDoTryError()

View license
@Test
public void testDoTryError() throws Exception {
    final MockEndpoint mockBefore = getMockEndpoint("mock:before");
    mockBefore.expectedBodiesReceived("Kaboom");
    final MockEndpoint mockError = getMockEndpoint("mock:error");
    mockError.expectedBodiesReceived("Kaboom");
    final MockEndpoint mockFinally = getMockEndpoint("mock:finally");
    mockFinally.expectedBodiesReceived("Something Bad Happened!");
    final MockEndpoint mockAfter = getMockEndpoint("mock:after");
    mockAfter.expectedBodiesReceived("Something Bad Happened!");
    String response = null;
    try {
        response = template.requestBody("direct:start", "Kaboom", String.class);
    } catch (Throwable e) {
        fail("Shouldn't get here");
    }
    assertEquals("Something Bad Happened!", response);
    assertMockEndpointsSatisfied();
}

22. OnCompletionMultipleSpringTest#testOnCompletionDefinedAtRouteLevel()

View license
@Test
public void testOnCompletionDefinedAtRouteLevel() throws InterruptedException {
    // this block is defined first, the definition of the failure only will be considered
    MockEndpoint mockCompleted = getMockEndpoint("mock:completed");
    mockCompleted.setExpectedMessageCount(0);
    MockEndpoint mockFailed = getMockEndpoint("mock:failed");
    mockFailed.setExpectedMessageCount(0);
    // neither of the global completion blocks should be triggered
    MockEndpoint mockGlobalCompleted = getMockEndpoint("mock:globalCompleted");
    mockGlobalCompleted.setExpectedMessageCount(0);
    MockEndpoint mockGlobalFailed = getMockEndpoint("mock:globalFailed");
    mockGlobalFailed.setExpectedMessageCount(0);
    template.asyncSendBody("direct:in", "this message should be fine");
    assertMockEndpointsSatisfied();
}

23. OnCompletionMultipleSpringTest#testOnCompletionFailureAtRouteLevel()

View license
@Test
public void testOnCompletionFailureAtRouteLevel() throws InterruptedException {
    MockEndpoint mockFailed = getMockEndpoint("mock:failed");
    mockFailed.setExpectedMessageCount(1);
    mockFailed.message(0).body().isEqualTo("this message should explode");
    MockEndpoint mockCompleted = getMockEndpoint("mock:completed");
    mockCompleted.setExpectedMessageCount(0);
    // neither of the global completion blocks should be triggered
    MockEndpoint mockGlobalCompleted = getMockEndpoint("mock:globalCompleted");
    mockGlobalCompleted.setExpectedMessageCount(0);
    MockEndpoint mockGlobalFailed = getMockEndpoint("mock:globalFailed");
    mockGlobalFailed.setExpectedMessageCount(0);
    template.asyncSendBody("direct:in", "this message should explode");
    assertMockEndpointsSatisfied();
}

24. OnCompletionMultipleTest#testOnCompletionDefinedAtRouteLevel()

View license
@Test
public void testOnCompletionDefinedAtRouteLevel() throws InterruptedException {
    // this block is defined first, the definition of the failure only will be considered
    MockEndpoint mockCompleted = getMockEndpoint("mock:completed");
    mockCompleted.setExpectedMessageCount(0);
    MockEndpoint mockFailed = getMockEndpoint("mock:failed");
    mockFailed.setExpectedMessageCount(0);
    // neither of the global completion blocks should be triggered
    MockEndpoint mockGlobalCompleted = getMockEndpoint("mock:globalCompleted");
    mockGlobalCompleted.setExpectedMessageCount(0);
    MockEndpoint mockGlobalFailed = getMockEndpoint("mock:globalFailed");
    mockGlobalFailed.setExpectedMessageCount(0);
    template.asyncSendBody("direct:in", "this message should be fine");
    assertMockEndpointsSatisfied();
}

25. OnCompletionMultipleTest#testOnCompletionFailureAtRouteLevel()

View license
@Test
public void testOnCompletionFailureAtRouteLevel() throws InterruptedException {
    MockEndpoint mockFailed = getMockEndpoint("mock:failed");
    mockFailed.setExpectedMessageCount(1);
    mockFailed.message(0).body().isEqualTo("this message should explode");
    MockEndpoint mockCompleted = getMockEndpoint("mock:completed");
    mockCompleted.setExpectedMessageCount(0);
    // neither of the global completion blocks should be triggered
    MockEndpoint mockGlobalCompleted = getMockEndpoint("mock:globalCompleted");
    mockGlobalCompleted.setExpectedMessageCount(0);
    MockEndpoint mockGlobalFailed = getMockEndpoint("mock:globalFailed");
    mockGlobalFailed.setExpectedMessageCount(0);
    template.asyncSendBody("direct:in", "this message should explode");
    assertMockEndpointsSatisfied();
}

26. BeanWithExchangeExceptionAnnotationTest#testBeanWithAnnotationAndExchangeTest()

View license
public void testBeanWithAnnotationAndExchangeTest() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    MockEndpoint error = getMockEndpoint("mock:error");
    result.expectedMessageCount(0);
    error.expectedMessageCount(1);
    error.expectedBodiesReceived("The Body");
    template.requestBody("direct:start", "The Body");
    result.assertIsSatisfied();
    error.assertIsSatisfied();
}

27. FileConsumeNotEagerMaxMessagesPerPollTest#testMaxMessagesPerPoll()

View license
public void testMaxMessagesPerPoll() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("AAA", "BBB");
    mock.setResultWaitTime(4000);
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("CCC");
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
    assertMockEndpointsSatisfied();
}

28. SedaRemoveRouteThenAddAgainTest#testRemoveRouteAndThenAddAgain()

View license
public void testRemoveRouteAndThenAddAgain() throws Exception {
    MockEndpoint out = getMockEndpoint("mock:out");
    out.expectedMessageCount(1);
    out.expectedBodiesReceived("before removing the route");
    template.sendBody("seda:in", "before removing the route");
    out.assertIsSatisfied();
    // now stop & remove the route
    context.stopRoute("sedaToMock");
    context.removeRoute("sedaToMock");
    // and then add it back again
    context.addRoutes(createRouteBuilder());
    // the mock endpoint was removed, so need to grab it again
    out = getMockEndpoint("mock:out");
    out.expectedMessageCount(1);
    out.expectedBodiesReceived("after removing the route");
    template.sendBody("seda:in", "after removing the route");
    out.assertIsSatisfied();
}

29. DelayerAsyncDelayedTest#testSendingMessageGetsDelayed()

Project: camel
Source File: DelayerAsyncDelayedTest.java
View license
public void testSendingMessageGetsDelayed() throws Exception {
    MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
    // do not wait for the first message
    resultEndpoint.expectedMessageCount(0);
    resultEndpoint.setResultWaitTime(500);
    template.sendBodyAndHeader("seda:a", "<hello>world!</hello>", "MyDelay", 1000);
    // we should not receive it as we wait at most 0.5 sec and it take 1 sec to send
    resultEndpoint.assertIsSatisfied();
    // now if we wait a bit longer we should receive the message!
    resultEndpoint.reset();
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.assertIsSatisfied();
}

30. DelayerTest#testSendingMessageGetsDelayed()

Project: camel
Source File: DelayerTest.java
View license
public void testSendingMessageGetsDelayed() throws Exception {
    MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
    // do not wait for the first message
    resultEndpoint.expectedMessageCount(0);
    resultEndpoint.setResultWaitTime(500);
    template.sendBodyAndHeader("seda:a", "<hello>world!</hello>", "MyDelay", 1000);
    // we should not receive it as we wait at most 0.5 sec and it take 1 sec to send
    resultEndpoint.assertIsSatisfied();
    // now if we wait a bit longer we should receive the message!
    resultEndpoint.reset();
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.assertIsSatisfied();
}

31. FtpConsumerMaxMessagesPerPollTest#testMaxMessagesPerPoll()

View license
@Test
public void testMaxMessagesPerPoll() throws Exception {
    // start route
    context.startRoute("foo");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Bye World", "Godday World");
    mock.setResultWaitTime(4000);
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("Hello World");
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
    assertMockEndpointsSatisfied();
}

32. FtpConsumerNotEagerMaxMessagesPerPollTest#testMaxMessagesPerPoll()

View license
@Test
public void testMaxMessagesPerPoll() throws Exception {
    // start route
    context.startRoute("foo");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("AAA", "BBB");
    mock.setResultWaitTime(4000);
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("CCC");
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
    assertMockEndpointsSatisfied();
}

33. MailHeaderOverrulePreConfigurationRecipientsTest#testSendWithRecipientsInHeaders()

View license
@Test
public void testSendWithRecipientsInHeaders() throws Exception {
    Mailbox.clearAll();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello World");
    mock.expectedHeaderReceived("to", "[email protected]");
    mock.expectedHeaderReceived("cc", "[email protected]");
    mock.expectedHeaderReceived("bcc", "[email protected]");
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("to", "[email protected]");
    headers.put("cc", "[email protected]");
    headers.put("bcc", "[email protected]");
    template.sendBodyAndHeaders("smtp:[email protected]", "Hello World", headers);
    mock.assertIsSatisfied();
}

34. MailMaxMessagesPerPollTest#testBatchConsumer()

View license
@Test
public void testBatchConsumer() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.setResultWaitTime(2000);
    mock.expectedMessageCount(3);
    mock.message(0).body().isEqualTo("Message 0");
    mock.message(1).body().isEqualTo("Message 1");
    mock.message(2).body().isEqualTo("Message 2");
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 3);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(2);
    mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
    mock.message(0).body().isEqualTo("Message 3");
    mock.message(1).body().isEqualTo("Message 4");
    assertMockEndpointsSatisfied();
}

35. SpringContextScopeOnExceptionTest#testOrderOk()

View license
public void testOrderOk() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedBodiesReceived("Order OK");
    result.expectedHeaderReceived("orderid", "123");
    MockEndpoint error = getMockEndpoint("mock:error");
    error.expectedMessageCount(0);
    MockEndpoint dead = getMockEndpoint("mock:dead");
    dead.expectedMessageCount(0);
    Object out = template.requestBodyAndHeader("direct:start", "Order: MacBook Pro", "customerid", "444");
    assertEquals("Order OK", out);
    assertMockEndpointsSatisfied();
}

36. SpringContextScopeOnExceptionTest#testOrderError()

View license
public void testOrderError() throws Exception {
    MockEndpoint error = getMockEndpoint("mock:error");
    error.expectedBodiesReceived("Order ERROR");
    error.expectedHeaderReceived("orderid", "failed");
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedMessageCount(0);
    MockEndpoint dead = getMockEndpoint("mock:dead");
    dead.expectedMessageCount(0);
    Object out = template.requestBodyAndHeader("direct:start", "Order: kaboom", "customerid", "555");
    assertEquals("Order ERROR", out);
    assertMockEndpointsSatisfied();
}

37. SpringOnExceptionSubRouteTest#testOrderOk()

View license
public void testOrderOk() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedBodiesReceived("Order OK");
    result.expectedHeaderReceived("orderid", "123");
    MockEndpoint error = getMockEndpoint("mock:error");
    error.expectedMessageCount(0);
    MockEndpoint dead = getMockEndpoint("mock:dead");
    dead.expectedMessageCount(0);
    Object out = template.requestBodyAndHeader("direct:start", "Order: MacBook Pro", "customerid", "444");
    assertEquals("Order OK", out);
    assertMockEndpointsSatisfied();
}

38. SpringOnExceptionSubRouteTest#testOrderError()

View license
public void testOrderError() throws Exception {
    MockEndpoint error = getMockEndpoint("mock:error");
    error.expectedBodiesReceived("Order ERROR");
    error.expectedHeaderReceived("orderid", "failed");
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedMessageCount(0);
    MockEndpoint dead = getMockEndpoint("mock:dead");
    dead.expectedMessageCount(0);
    Object out = template.requestBodyAndHeader("direct:start", "Order: kaboom", "customerid", "555");
    assertEquals("Order ERROR", out);
    assertMockEndpointsSatisfied();
}

39. SplitParallelProcessingTimeoutSpringTest#testSplittingInParallel()

View license
@Test
public void testSplittingInParallel() throws InterruptedException {
    List<String> messageFragments = new ArrayList<String>();
    int fragmentCount = 50;
    for (int i = 0; i < fragmentCount; i++) {
        messageFragments.add("fragment" + i);
    }
    MockEndpoint mockSplit = getMockEndpoint("mock:split");
    mockSplit.setExpectedMessageCount(fragmentCount - 1);
    ArrayList<String> expectedFragments = new ArrayList<String>(messageFragments);
    int indexDelayed = 20;
    expectedFragments.remove(indexDelayed);
    mockSplit.expectedBodiesReceivedInAnyOrder(expectedFragments);
    MockEndpoint mockDelayed = getMockEndpoint("mock:delayed");
    mockDelayed.setExpectedMessageCount(1);
    MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(1);
    template.sendBody("direct:in", messageFragments);
    assertMockEndpointsSatisfied();
}

40. BeanInvokeTest#testA()

Project: camel
Source File: BeanInvokeTest.java
View license
public void testA() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:a");
    mock.expectedBodiesReceived("Hello World");
    template.sendBody("direct:a", "Hello World");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("");
    template.sendBody("direct:a", "");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(1);
    mock.message(0).body().isNull();
    template.sendBody("direct:a", null);
    assertMockEndpointsSatisfied();
}

41. BeanInvokeTest#testB()

Project: camel
Source File: BeanInvokeTest.java
View license
public void testB() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:b");
    mock.expectedBodiesReceived("Bye World");
    template.sendBody("direct:b", "Hello World");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(1);
    mock.message(0).body().isNull();
    template.sendBody("direct:b", "");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(1);
    mock.message(0).body().isNull();
    template.sendBody("direct:b", null);
    assertMockEndpointsSatisfied();
}

42. BeanInvokeTest#testC()

Project: camel
Source File: BeanInvokeTest.java
View license
public void testC() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:c");
    mock.expectedBodiesReceived("Hello World");
    template.sendBody("direct:c", "Hello World");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("");
    template.sendBody("direct:c", "");
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(1);
    mock.message(0).body().isNull();
    template.sendBody("direct:c", null);
    assertMockEndpointsSatisfied();
}

43. TwoCamelContextDirectEndpointTest#testTwoCamelContextDirectEndpoint()

View license
public void testTwoCamelContextDirectEndpoint() throws Exception {
    Endpoint start1 = camel1.getEndpoint("direct:start");
    Endpoint start2 = camel2.getEndpoint("direct:start");
    assertNotSame(start1, start2);
    Endpoint foo1 = camel1.getEndpoint("direct:foo");
    Endpoint foo2 = camel2.getEndpoint("direct:foo");
    assertNotSame(foo1, foo2);
    MockEndpoint mock1 = camel1.getEndpoint("mock:a", MockEndpoint.class);
    mock1.expectedBodiesReceived("Hello World");
    MockEndpoint mock2 = camel2.getEndpoint("mock:b", MockEndpoint.class);
    mock2.expectedBodiesReceived("Bye World");
    camel1.createProducerTemplate().sendBody("direct:start", "Hello World");
    camel2.createProducerTemplate().sendBody("direct:start", "Bye World");
    mock1.assertIsSatisfied();
    mock2.assertIsSatisfied();
}

44. DirectVmConsumerExpressionTest#testSelectEndpoint()

View license
public void testSelectEndpoint() throws Exception {
    MockEndpoint result2 = context2.getEndpoint("mock:result2", MockEndpoint.class);
    result2.expectedBodiesReceived("Hello World");
    MockEndpoint result3 = context3.getEndpoint("mock:result3", MockEndpoint.class);
    result3.expectedBodiesReceived("Hello World");
    MockEndpoint result4 = context4.getEndpoint("mock:result4", MockEndpoint.class);
    result4.expectedMessageCount(0);
    template.sendBody("direct:start", "Hello World");
    MockEndpoint.assertIsSatisfied(context2);
    MockEndpoint.assertIsSatisfied(context3);
    MockEndpoint.assertIsSatisfied(context4);
}

45. TimerRestartTest#testTimerRestart()

Project: camel
Source File: TimerRestartTest.java
View license
public void testTimerRestart() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(0);
    context.stop();
    Thread.sleep(2000);
    mock.reset();
    context.start();
    mock.expectedMinimumMessageCount(1);
    assertMockEndpointsSatisfied();
}

46. TimerSuspendCamelContextTest#testTimerSuspendResume()

View license
public void testTimerSuspendResume() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMessageCount(0);
    context.suspend();
    Thread.sleep(2000);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedMinimumMessageCount(1);
    context.resume();
    assertMockEndpointsSatisfied();
}

47. XsltContentCacheTest#testNotCached()

Project: camel
Source File: XsltContentCacheTest.java
View license
public void testNotCached() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
    template.sendBody("direct:a", "<hello>world!</hello>");
    mock.assertIsSatisfied();
    // now replace the file with a new XSL transformation
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
    mock.reset();
    // we expect the new output as the cache is not enabled, so it's "goodnight" and not "goodbye"
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodnight>world!</goodnight>");
    template.sendBody("direct:a", "<hello>world!</hello>");
    mock.assertIsSatisfied();
}

48. XsltContentCacheTest#testCached()

Project: camel
Source File: XsltContentCacheTest.java
View license
public void testCached() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
    template.sendBody("direct:b", "<hello>world!</hello>");
    mock.assertIsSatisfied();
    // now replace the file with a new XSL transformation
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
    mock.reset();
    // we expect the original output as the cache is enabled, so it's "goodbye" and not "goodnight"
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
    template.sendBody("direct:b", "<hello>world!</hello>");
    mock.assertIsSatisfied();
}

49. XsltContentCacheTest#testCachedIsDefault()

Project: camel
Source File: XsltContentCacheTest.java
View license
public void testCachedIsDefault() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
    template.sendBody("direct:c", "<hello>world!</hello>");
    mock.assertIsSatisfied();
    // now replace the file with a new XSL transformation
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
    mock.reset();
    // we expect the original output as the cache is enabled, so it's "goodbye" and not "goodnight"
    mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
    template.sendBody("direct:c", "<hello>world!</hello>");
    mock.assertIsSatisfied();
}

50. CharlesSplitAndTryCatchRollbackIssueTest#testSplitWithTryCatchAndRollbackOK()

View license
public void testSplitWithTryCatchAndRollbackOK() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B", "C");
    ile.expectedMessageCount(0);
    exception.expectedMessageCount(0);
    template.sendBody("direct:start", "A,B,C");
    assertMockEndpointsSatisfied();
}

51. CharlesSplitAndTryCatchRollbackIssueTest#testSplitWithTryCatchAndRollbackILE()

View license
public void testSplitWithTryCatchAndRollbackILE() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B", "C");
    ile.expectedMessageCount(1);
    exception.expectedMessageCount(0);
    template.sendBody("direct:start", "A,B,Forced,C");
    assertMockEndpointsSatisfied();
}

52. CharlesSplitAndTryCatchRollbackIssueTest#testSplitWithTryCatchAndRollbackException()

View license
public void testSplitWithTryCatchAndRollbackException() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B");
    ile.expectedMessageCount(0);
    exception.expectedMessageCount(1);
    try {
        template.sendBody("direct:start", "A,B,Kaboom,C");
        fail("Should thrown an exception");
    } catch (CamelExecutionException e) {
        CamelExchangeException ee = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
        assertTrue(ee.getMessage().startsWith("Sequential processing failed for number 2."));
        RollbackExchangeException re = assertIsInstanceOf(RollbackExchangeException.class, ee.getCause());
        assertTrue(re.getMessage().startsWith("Intended rollback"));
    }
    assertMockEndpointsSatisfied();
}

53. CharlesSplitAndTryCatchRollbackIssueTest#testSplitWithTryCatchAndRollbacILEAndException()

View license
public void testSplitWithTryCatchAndRollbacILEAndException() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B");
    ile.expectedMessageCount(1);
    exception.expectedMessageCount(1);
    try {
        template.sendBody("direct:start", "A,Forced,B,Kaboom,C");
        fail("Should thrown an exception");
    } catch (CamelExecutionException e) {
        CamelExchangeException ee = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
        assertTrue(ee.getMessage().startsWith("Sequential processing failed for number 3."));
        RollbackExchangeException re = assertIsInstanceOf(RollbackExchangeException.class, ee.getCause());
        assertTrue(re.getMessage().startsWith("Intended rollback"));
    }
    assertMockEndpointsSatisfied();
}

54. CharlesSplitUseBeanAsErrorHandlerIssueTest#testSplitBeanErrorHandlerOK()

View license
public void testSplitBeanErrorHandlerOK() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B", "C");
    ile.expectedMessageCount(0);
    exception.expectedMessageCount(0);
    template.sendBody("direct:start", "A,B,C");
    assertMockEndpointsSatisfied();
}

55. CharlesSplitUseBeanAsErrorHandlerIssueTest#testSplitBeanErrorHandlerHandled()

View license
public void testSplitBeanErrorHandlerHandled() throws Exception {
    MockEndpoint split = getMockEndpoint("mock:split");
    MockEndpoint ile = getMockEndpoint("mock:ile");
    MockEndpoint exception = getMockEndpoint("mock:exception");
    split.expectedBodiesReceived("A", "B", "C");
    ile.expectedBodiesReceived("Handled Forced Cause by Damn ILE");
    exception.expectedMessageCount(0);
    template.sendBody("direct:start", "A,B,Forced,C");
    assertMockEndpointsSatisfied();
    assertEquals("Forced", logged);
}

56. ExceptionTest#testExceptionWithoutHandler()

Project: camel
Source File: ExceptionTest.java
View license
public void testExceptionWithoutHandler() throws Exception {
    MockEndpoint errorEndpoint = getMockEndpoint("mock:error");
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    MockEndpoint exceptionEndpoint = getMockEndpoint("mock:exception");
    errorEndpoint.expectedBodiesReceived("<exception/>");
    exceptionEndpoint.expectedMessageCount(0);
    resultEndpoint.expectedMessageCount(0);
    // we don't expect any thrown exception here as there's no onException clause defined for this test
    // so that the general purpose dead letter channel will come into the play and then when all the attempts
    // to redelivery fails the exchange will be moved to "mock:error" and then from the client point of
    // view the exchange is completed.
    template.sendBody("direct:start", "<body/>");
    assertMockEndpointsSatisfied();
}

57. ExceptionTest#testExceptionWithHandler()

Project: camel
Source File: ExceptionTest.java
View license
public void testExceptionWithHandler() throws Exception {
    MockEndpoint errorEndpoint = getMockEndpoint("mock:error");
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    MockEndpoint exceptionEndpoint = getMockEndpoint("mock:exception");
    errorEndpoint.expectedMessageCount(0);
    exceptionEndpoint.expectedBodiesReceived("<exception/>");
    resultEndpoint.expectedMessageCount(0);
    try {
        template.sendBody("direct:start", "<body/>");
        fail("Should have thrown exception");
    } catch (Exception e) {
    }
    assertMockEndpointsSatisfied();
}

58. ExceptionTest#testExceptionWithLongHandler()

Project: camel
Source File: ExceptionTest.java
View license
public void testExceptionWithLongHandler() throws Exception {
    MockEndpoint errorEndpoint = getMockEndpoint("mock:error");
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    MockEndpoint exceptionEndpoint = getMockEndpoint("mock:exception");
    errorEndpoint.expectedMessageCount(0);
    exceptionEndpoint.expectedBodiesReceived("<not-handled/>");
    resultEndpoint.expectedMessageCount(0);
    try {
        template.sendBody("direct:start", "<body/>");
        fail("Should have thrown exception");
    } catch (Exception e) {
    }
    assertMockEndpointsSatisfied();
}

59. ExceptionTest#testLongRouteWithHandler()

Project: camel
Source File: ExceptionTest.java
View license
public void testLongRouteWithHandler() throws Exception {
    MockEndpoint errorEndpoint = getMockEndpoint("mock:error");
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    MockEndpoint exceptionEndpoint = getMockEndpoint("mock:exception");
    errorEndpoint.expectedMessageCount(0);
    exceptionEndpoint.expectedBodiesReceived("<exception/>");
    resultEndpoint.expectedMessageCount(0);
    try {
        template.sendBody("direct:start2", "<body/>");
        fail("Should have thrown exception");
    } catch (Exception e) {
    }
    assertMockEndpointsSatisfied();
}

60. InterceptFromPredicateProceedAndStopTest#testInterceptorNoPredicate()

View license
public void testInterceptorNoPredicate() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().to("mock:test");
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedBodiesReceived("Camel in Action");
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

61. InterceptFromPredicateProceedAndStopTest#testInterceptorNoPredicateAndProceed()

View license
public void testInterceptorNoPredicateAndProceed() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().to("mock:test");
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedBodiesReceived("Camel in Action");
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

62. InterceptFromPredicateProceedAndStopTest#testInterceptorNoPredicateAndStop()

View license
public void testInterceptorNoPredicateAndStop() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().to("mock:test").stop();
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedMessageCount(0);
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

63. InterceptFromPredicateProceedAndStopTest#testInterceptorWithPredicate()

View license
public void testInterceptorWithPredicate() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().when(header("user").isEqualTo("test")).to("mock:test");
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedBodiesReceived("Camel in Action");
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

64. InterceptFromPredicateProceedAndStopTest#testInterceptorWithPredicateAndProceed()

View license
public void testInterceptorWithPredicateAndProceed() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().when(header("user").isEqualTo("test")).to("mock:test");
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedBodiesReceived("Camel in Action");
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

65. InterceptFromPredicateProceedAndStopTest#testInterceptorWithPredicateAndStop()

View license
public void testInterceptorWithPredicateAndStop() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            interceptFrom().when(header("user").isEqualTo("test")).to("mock:test").stop();
            from("seda:order").to("mock:ok");
        }
    });
    MockEndpoint mockTest = getMockEndpoint("mock:test");
    mockTest.expectedBodiesReceived("Camel in Action");
    MockEndpoint mockOk = getMockEndpoint("mock:ok");
    mockOk.expectedMessageCount(0);
    template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
    mockTest.assertIsSatisfied();
    mockOk.assertIsSatisfied();
}

66. ExceptionWithManagementTest#testExceptionHandler()

View license
public void testExceptionHandler() throws Exception {
    MockEndpoint error = this.resolveMandatoryEndpoint("mock:error", MockEndpoint.class);
    error.expectedMessageCount(1);
    MockEndpoint out = this.resolveMandatoryEndpoint("mock:out", MockEndpoint.class);
    out.expectedMessageCount(0);
    template.send("direct:start", ExchangePattern.InOnly, new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("hello");
        }
    });
    error.assertIsSatisfied();
    out.assertIsSatisfied();
}

67. AggregateDiscardOnTimeoutTest#testAggregateDiscardOnTimeout()

View license
public void testAggregateDiscardOnTimeout() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:aggregated");
    mock.expectedMessageCount(0);
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    // wait 4 seconds
    Thread.sleep(4000);
    mock.assertIsSatisfied();
    // now send 3 which does not timeout
    mock.reset();
    mock.expectedBodiesReceived("C+D+E");
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    template.sendBodyAndHeader("direct:start", "C", "id", 123);
    // should complete before timeout
    mock.await(1500, TimeUnit.MILLISECONDS);
}

68. DistributedCompletionIntervalTest#testCamelContext1Wins()

View license
public void testCamelContext1Wins() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Message 19");
    MockEndpoint mock2 = getMockEndpoint2("mock:result");
    mock2.expectedMessageCount(0);
    // ensure messages are send after the 1s
    Thread.sleep(2000);
    sendMessages();
    mock.assertIsSatisfied();
    mock2.assertIsSatisfied();
}

69. DistributedCompletionIntervalTest#testCamelContext2Wins()

View license
public void testCamelContext2Wins() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(0);
    MockEndpoint mock2 = getMockEndpoint2("mock:result");
    mock2.expectedBodiesReceived("Message 19");
    // ensure messages are send after the 1s
    Thread.sleep(2000);
    sendMessages();
    mock2.assertIsSatisfied();
    mock.assertIsSatisfied();
}

70. DistributedOptimisticLockFailingTest#testAlwaysFails()

View license
public void testAlwaysFails() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(0);
    MockEndpoint mock2 = getMockEndpoint2("mock:result");
    mock2.expectedMessageCount(0);
    try {
        template.sendBodyAndHeader("direct:fails", "hello world", "id", 1);
        fail("Should throw CamelExecutionException");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(CamelExchangeException.class, e.getCause());
        assertIsInstanceOf(OptimisticLockingAggregationRepository.OptimisticLockingException.class, e.getCause().getCause());
    }
    try {
        template2.sendBodyAndHeader("direct:fails", "hello world", "id", 1);
        fail("Should throw CamelExecutionException");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(CamelExchangeException.class, e.getCause());
        assertIsInstanceOf(OptimisticLockingAggregationRepository.OptimisticLockingException.class, e.getCause().getCause());
    }
    mock.assertIsSatisfied();
    mock2.assertIsSatisfied();
}

71. FailOverLoadBalanceWithRedeliveryTest#testFailoverWithRedelivery()

View license
public void testFailoverWithRedelivery() throws Exception {
    counter = 0;
    MockEndpoint a = getMockEndpoint("mock:a");
    a.expectedMessageCount(3);
    MockEndpoint b = getMockEndpoint("mock:b");
    b.expectedMessageCount(2);
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedBodiesReceived("Bye World");
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
}

72. InterceptFromSimpleRouteTest#testIntercept()

View license
public void testIntercept() throws Exception {
    MockEndpoint intercepted = getMockEndpoint("mock:intercepted");
    intercepted.expectedBodiesReceived("Hello London");
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedBodiesReceived("Hello Paris");
    template.sendBodyAndHeader("seda:a", "Hello London", "city", "London");
    template.sendBodyAndHeader("seda:a", "Hello Paris", "city", "Paris");
    intercepted.assertIsSatisfied();
    result.assertIsSatisfied();
}

73. MulticastCompletedPropertyTest#testMulticastCompleted()

View license
public void testMulticastCompleted() throws Exception {
    MockEndpoint a = getMockEndpoint("mock:a");
    a.expectedMessageCount(1);
    a.message(0).exchangeProperty(Exchange.MULTICAST_COMPLETE).isEqualTo(false);
    MockEndpoint b = getMockEndpoint("mock:b");
    b.expectedMessageCount(1);
    b.message(0).exchangeProperty(Exchange.MULTICAST_COMPLETE).isEqualTo(false);
    MockEndpoint c = getMockEndpoint("mock:c");
    c.expectedMessageCount(1);
    c.message(0).exchangeProperty(Exchange.MULTICAST_COMPLETE).isEqualTo(true);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
}

74. MulticastParallelFailureEndpointTest#runTest()

View license
public Exchange runTest(String uri) throws Exception {
    MockEndpoint mr = getMockEndpoint("mock:run");
    MockEndpoint ma = getMockEndpoint("mock:a");
    MockEndpoint mb = getMockEndpoint("mock:b");
    mr.expectedMessageCount(0);
    ma.expectedMessageCount(0);
    mb.expectedMessageCount(1);
    Exchange request = new DefaultExchange(context, ExchangePattern.InOut);
    request.getIn().setBody("Hello World");
    Exchange result = template.send(uri, request);
    assertMockEndpointsSatisfied();
    return result;
}

75. RecipientListLeakTest#testRecipientListLeak()

Project: camel
Source File: RecipientListLeakTest.java
View license
public void testRecipientListLeak() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("Hello World", "Bye World");
    y.expectedBodiesReceived("Hello World", "Bye World");
    z.expectedBodiesReceived("Hello World", "Bye World");
    sendBody("Hello World");
    sendBody("Bye World");
    assertMockEndpointsSatisfied();
}

76. RecipientListNoCacheTest#testNoCache()

Project: camel
Source File: RecipientListNoCacheTest.java
View license
public void testNoCache() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("foo", "bar");
    y.expectedBodiesReceived("foo", "bar");
    z.expectedBodiesReceived("foo", "bar");
    sendBody("foo");
    sendBody("bar");
    assertMockEndpointsSatisfied();
}

77. RecipientListTest#testSendingAMessageUsingMulticastReceivesItsOwnExchange()

Project: camel
Source File: RecipientListTest.java
View license
public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    sendBody();
    assertMockEndpointsSatisfied();
}

78. RecipientListWithArrayHeaderTest#testSendingAMessageUsingMulticastReceivesItsOwnExchange()

View license
public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    sendBody();
    assertMockEndpointsSatisfied();
}

79. RecipientListWithDelimiterTest#testRecipientList()

View license
public void testRecipientList() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:a").recipientList(header("myHeader"), "#");
        }
    });
    context.start();
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    sendBody();
    assertMockEndpointsSatisfied();
}

80. RecipientListWithDelimiterTest#testRecipientListWithTokenizer()

View license
public void testRecipientListWithTokenizer() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:a").recipientList(header("myHeader").tokenize("#"));
        }
    });
    context.start();
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    sendBody();
    assertMockEndpointsSatisfied();
}

81. RecipientListWithStringDelimitedHeaderTest#testSendingAMessageUsingMulticastReceivesItsOwnExchange()

View license
public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    sendBody();
    assertMockEndpointsSatisfied();
}

82. RecipientListWithStringDelimitedPropertyTest#testSendingAMessageUsingMulticastReceivesItsOwnExchange()

View license
public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived(BODY);
    y.expectedBodiesReceived(BODY);
    z.expectedBodiesReceived(BODY);
    x.message(0).exchangeProperty("myProperty").isEqualTo(PROPERTY_VALUE);
    y.message(0).exchangeProperty("myProperty").isEqualTo(PROPERTY_VALUE);
    z.message(0).exchangeProperty("myProperty").isEqualTo(PROPERTY_VALUE);
    sendBody();
    assertMockEndpointsSatisfied();
}

83. RoutingSlipTest#testUpdatingOfRoutingSlipAllDefaults()

Project: camel
Source File: RoutingSlipTest.java
View license
public void testUpdatingOfRoutingSlipAllDefaults() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived(ANSWER);
    y.expectedBodiesReceived(ANSWER);
    z.expectedBodiesReceived(ANSWER);
    sendBody("direct:a", ROUTING_SLIP_HEADER, ",");
    assertMockEndpointsSatisfied();
}

84. RoutingSlipTest#testUpdatingOfRoutingSlipHeaderSet()

Project: camel
Source File: RoutingSlipTest.java
View license
public void testUpdatingOfRoutingSlipHeaderSet() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived(ANSWER);
    y.expectedBodiesReceived(ANSWER);
    z.expectedBodiesReceived(ANSWER);
    sendBody("direct:b", "aRoutingSlipHeader", ",");
    assertMockEndpointsSatisfied();
}

85. RoutingSlipTest#testUpdatingOfRoutingSlipHeaderAndDelimiterSet()

Project: camel
Source File: RoutingSlipTest.java
View license
public void testUpdatingOfRoutingSlipHeaderAndDelimiterSet() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived(ANSWER);
    y.expectedBodiesReceived(ANSWER);
    z.expectedBodiesReceived(ANSWER);
    sendBody("direct:c", "aRoutingSlipHeader", "#");
    assertMockEndpointsSatisfied();
}

86. RoutingSlipTest#testBodyExpression()

Project: camel
Source File: RoutingSlipTest.java
View license
public void testBodyExpression() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("mock:x, mock:y,mock:z");
    y.expectedBodiesReceived("mock:x, mock:y,mock:z");
    z.expectedBodiesReceived("mock:x, mock:y,mock:z");
    template.sendBody("direct:d", "mock:x, mock:y,mock:z");
    assertMockEndpointsSatisfied();
}

87. RoutingSlipNoCacheTest#testNoCache()

Project: camel
Source File: RoutingSlipNoCacheTest.java
View license
public void testNoCache() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("foo", "bar");
    y.expectedBodiesReceived("foo", "bar");
    z.expectedBodiesReceived("foo", "bar");
    sendBody("foo");
    sendBody("bar");
    assertMockEndpointsSatisfied();
}

88. SplitterTest#testSplitterWithException()

Project: camel
Source File: SplitterTest.java
View license
public void testSplitterWithException() throws Exception {
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    resultEndpoint.expectedMessageCount(4);
    resultEndpoint.expectedHeaderReceived("foo", "bar");
    MockEndpoint failedEndpoint = getMockEndpoint("mock:failed");
    failedEndpoint.expectedMessageCount(1);
    failedEndpoint.expectedHeaderReceived("foo", "bar");
    Exchange result = template.request("direct:exception", new Processor() {

        public void process(Exchange exchange) {
            Message in = exchange.getIn();
            in.setBody("James,Guillaume,Hiram,Rob,Exception");
            in.setHeader("foo", "bar");
        }
    });
    assertTrue("The result exchange should have a camel exception", result.getException() instanceof CamelException);
    assertMockEndpointsSatisfied();
}

89. ToEndpointPropertyTest#testRoutingSlipToEndpoint()

Project: camel
Source File: ToEndpointPropertyTest.java
View license
public void testRoutingSlipToEndpoint() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").routingSlip(header("foo"));
        }
    });
    context.start();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.message(0).exchangeProperty(Exchange.TO_ENDPOINT).isEqualTo("mock://result");
    MockEndpoint a = getMockEndpoint("mock:a");
    a.expectedMessageCount(1);
    a.message(0).exchangeProperty(Exchange.TO_ENDPOINT).isEqualTo("mock://a");
    MockEndpoint b = getMockEndpoint("mock:b");
    b.expectedMessageCount(1);
    b.message(0).exchangeProperty(Exchange.TO_ENDPOINT).isEqualTo("mock://b");
    template.sendBodyAndHeader("direct:start", "Hello World", "foo", "mock:a,mock:b,mock:result");
    assertMockEndpointsSatisfied();
}

90. WireTapNewExchangeTest#testFireAndForgetUsingExpressions()

Project: camel
Source File: WireTapNewExchangeTest.java
View license
public void testFireAndForgetUsingExpressions() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedBodiesReceived("Hello World");
    MockEndpoint tap = getMockEndpoint("mock:tap");
    tap.expectedBodiesReceived("Bye World");
    tap.expectedHeaderReceived("id", 123);
    String today = new SimpleDateFormat("yyyyMMdd").format(new Date());
    tap.expectedHeaderReceived("date", today);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
}

91. AvroProducerTestSupport#testInOnlyWithWrongMessageNameInMessage()

Project: camel
Source File: AvroProducerTestSupport.java
View license
@Test
public void testInOnlyWithWrongMessageNameInMessage() throws InterruptedException {
    MockEndpoint mockInMessageEnd = getMockEndpoint("mock:result-in-message-name");
    mockInMessageEnd.expectedMessageCount(0);
    MockEndpoint mockErrorChannel = getMockEndpoint("mock:in-message-name-error");
    mockErrorChannel.expectedMessageCount(1);
    Key key = Key.newBuilder().setKey("1").build();
    Value value = Value.newBuilder().setValue("test value").build();
    Object[] request = { key, value };
    template.sendBodyAndHeader("direct:in-message-name", request, AvroConstants.AVRO_MESSAGE_NAME, "/get");
    mockErrorChannel.assertIsSatisfied(5000);
    mockInMessageEnd.assertIsSatisfied();
}

92. EtcdWatchTest#testWatch()

Project: camel
Source File: EtcdWatchTest.java
View license
private void testWatch(String mockEndpoint, final String key, int updates) throws Exception {
    final String[] values = new String[updates];
    for (int i = 0; i < updates; i++) {
        values[i] = key + "=myValue-" + i;
    }
    MockEndpoint mock = getMockEndpoint(mockEndpoint);
    mock.expectedMessageCount(2);
    mock.expectedHeaderReceived(EtcdConstants.ETCD_NAMESPACE, EtcdNamespace.watch.name());
    mock.expectedHeaderReceived(EtcdConstants.ETCD_PATH, key);
    mock.expectedBodiesReceived(values);
    final EtcdClient client = getClient();
    for (int i = 0; i < updates; i++) {
        client.put(key, "myValue-" + i).send().get();
    }
    mock.assertIsSatisfied();
}

93. FreemarkerContentCacheTest#testNotCached()

View license
@Test
public void testNotCached() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello London");
    template.sendBodyAndHeader("direct:a", "Body", "name", "London");
    mock.assertIsSatisfied();
    // now change content in the file in the classpath and try again
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?fileExist=Override", "Bye ${headers.name}", Exchange.FILE_NAME, "hello.ftl");
    mock.reset();
    mock.expectedBodiesReceived("Bye Paris");
    template.sendBodyAndHeader("direct:a", "Body", "name", "Paris");
    mock.assertIsSatisfied();
}

94. FreemarkerContentCacheTest#testCached()

View license
@Test
public void testCached() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello London");
    template.sendBodyAndHeader("direct:b", "Body", "name", "London");
    mock.assertIsSatisfied();
    // now change content in the file in the classpath and try again
    template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?fileExist=Override", "Bye ${headers.name}", Exchange.FILE_NAME, "hello.ftl");
    mock.reset();
    // we must expected the original filecontent as the cache is enabled, so its Hello and not Bye
    mock.expectedBodiesReceived("Hello Paris");
    template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
    mock.assertIsSatisfied();
}

95. HawtDBAggregateDiscardOnTimeoutTest#testAggregateDiscardOnTimeout()

View license
@Test
public void testAggregateDiscardOnTimeout() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:aggregated");
    mock.expectedMessageCount(0);
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    // wait 4 seconds
    Thread.sleep(4000);
    mock.assertIsSatisfied();
    // now send 3 which does not timeout
    mock.reset();
    mock.expectedBodiesReceived("C+D+E");
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    template.sendBodyAndHeader("direct:start", "C", "id", 123);
    // should complete before timeout
    mock.await(1500, TimeUnit.MILLISECONDS);
}

96. JcloudsMultipleBlobStoreTest#testWithMultipleServices()

View license
@Test
public void testWithMultipleServices() throws InterruptedException {
    String message1 = "Blob 1";
    String message2 = "Blob 2";
    MockEndpoint mockEndpoint1 = resolveMandatoryEndpoint("mock:results1", MockEndpoint.class);
    mockEndpoint1.expectedBodiesReceived(message1);
    MockEndpoint mockEndpoint2 = resolveMandatoryEndpoint("mock:results2", MockEndpoint.class);
    mockEndpoint2.expectedBodiesReceived(message2);
    JcloudsBlobStoreHelper.writeBlob(blobStore1, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message1));
    JcloudsBlobStoreHelper.writeBlob(blobStore2, TEST_CONTAINER, TEST_BLOB2, new StringPayload(message2));
    mockEndpoint1.assertIsSatisfied();
    mockEndpoint2.assertIsSatisfied();
}

97. HttpRedirectTest#testHttpRedirectFromCamelRoute()

Project: camel
Source File: HttpRedirectTest.java
View license
@Test
public void testHttpRedirectFromCamelRoute() throws Exception {
    MockEndpoint errorEndpoint = context.getEndpoint("mock:error", MockEndpoint.class);
    errorEndpoint.expectedMessageCount(1);
    MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class);
    resultEndpoint.expectedMessageCount(0);
    try {
        template.requestBody("direct:start", "Hello World", String.class);
        fail("Should have thrown an exception");
    } catch (RuntimeCamelException e) {
        HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
        assertEquals(302, cause.getStatusCode());
    }
    errorEndpoint.assertIsSatisfied();
    resultEndpoint.assertIsSatisfied();
}

98. JmsRouteWithInOnlyAndMultipleAcksTest#testSendOrderWithMultipleAcks()

View license
@Test
public void testSendOrderWithMultipleAcks() throws Exception {
    MockEndpoint inbox = getMockEndpoint("mock:inbox");
    inbox.expectedBodiesReceived("Camel in Action");
    String orderId = "1";
    MockEndpoint notifCollector = getMockEndpoint("mock:orderNotificationAckCollector");
    notifCollector.expectedMessageCount(2);
    notifCollector.expectedHeaderReceived("JMSCorrelationID", orderId);
    notifCollector.setResultWaitTime(10000);
    Object out = template.requestBodyAndHeader("amq:queue:inbox", "Camel in Action", "JMSCorrelationID", orderId);
    assertEquals("OK: Camel in Action", out);
    assertMockEndpointsSatisfied();
}

99. XsltLosesHeaderTest#testXsltLosesHeader()

Project: camel
Source File: XsltLosesHeaderTest.java
View license
@Test
public void testXsltLosesHeader() throws Exception {
    MockEndpoint endpointAfter = getMockEndpoint("mock:After");
    MockEndpoint endpointBefore = getMockEndpoint("mock:Before");
    endpointBefore.expectedBodiesReceived("header:hello");
    endpointAfter.expectedBodiesReceived("header:hello");
    template.send("seda:xslttest", new Processor() {

        public void process(Exchange exchange) {
            Message in = exchange.getIn();
            in.setBody("dummy");
        }
    });
    endpointBefore.assertIsSatisfied();
    endpointAfter.assertIsSatisfied();
}

100. LevelDBAggregateDiscardOnTimeoutTest#testAggregateDiscardOnTimeout()

View license
@Test
public void testAggregateDiscardOnTimeout() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:aggregated");
    mock.expectedMessageCount(0);
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    // wait 3 seconds
    Thread.sleep(3000);
    mock.assertIsSatisfied();
    // now send 3 which does not timeout
    mock.reset();
    mock.expectedBodiesReceived("C+D+E");
    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    template.sendBodyAndHeader("direct:start", "C", "id", 123);
    // should complete before timeout
    mock.await(1500, TimeUnit.MILLISECONDS);
}