Search in sources :

Example 6 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class ProgrammaticLookupTest method sendMessageToInbound.

@Test
public void sendMessageToInbound() throws InterruptedException {
    ProducerTemplate inbound = producers.select(Uri.Literal.of("direct:inbound")).get();
    MockEndpoint outbound = endpoints.select(MockEndpoint.class, Uri.Literal.of("mock:outbound")).get();
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");
    inbound.sendBody("test");
    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 7 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class ChronicleEngineConsumerTest method testMapEvents.

@Test
public void testMapEvents() throws Exception {
    final String key = UUID.randomUUID().toString();
    MockEndpoint mock = getMockEndpoint("mock:map-events");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("val");
    mock.expectedHeaderReceived(ChronicleEngineConstants.PATH, "/my/path");
    mock.expectedHeaderReceived(ChronicleEngineConstants.KEY, key);
    Map<String, String> map = client().acquireMap("/my/path", String.class, String.class);
    map.put(key, "val");
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 8 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class ChronicleEngineConsumerTest method testMapEventsFiltering.

@Test
public void testMapEventsFiltering() throws Exception {
    final String key = UUID.randomUUID().toString();
    MockEndpoint mock = getMockEndpoint("mock:map-events-filtering");
    mock.expectedMessageCount(2);
    Map<String, String> map = client().acquireMap("/my/path", String.class, String.class);
    map.put(key, "val-1");
    map.put(key, "val-2");
    map.remove(key);
    mock.assertIsSatisfied();
    assertEquals(mock.getExchanges().get(0).getIn().getHeader(ChronicleEngineConstants.MAP_EVENT_TYPE), ChronicleEngineMapEventType.INSERT);
    assertEquals(mock.getExchanges().get(0).getIn().getBody(String.class), "val-1");
    assertEquals(mock.getExchanges().get(1).getIn().getHeader(ChronicleEngineConstants.MAP_EVENT_TYPE), ChronicleEngineMapEventType.REMOVE);
    assertEquals(mock.getExchanges().get(1).getIn().getHeader(ChronicleEngineConstants.OLD_VALUE), "val-2");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 9 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class ChronicleEngineConsumerTest method testTopicEvents.

@Test
public void testTopicEvents() throws Exception {
    final String key = UUID.randomUUID().toString();
    MockEndpoint mock = getMockEndpoint("mock:topic-events");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("val");
    mock.expectedHeaderReceived(ChronicleEngineConstants.PATH, "/my/path");
    Map<String, String> map = client().acquireMap("/my/path", String.class, String.class);
    map.put(key, "val");
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 10 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class ChronicleEngineConsumerTest method testTopologicalEvents.

@Test
public void testTopologicalEvents() throws Exception {
    final String key = UUID.randomUUID().toString();
    MockEndpoint mock = getMockEndpoint("mock:topological-events");
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived((String) null);
    mock.expectedHeaderReceived(ChronicleEngineConstants.PATH, "/my/path");
    mock.expectedHeaderReceived(ChronicleEngineConstants.TOPOLOGICAL_EVENT_FULL_NAME, "/my/path");
    Map<String, String> map = client().acquireMap("/my/path", String.class, String.class);
    map.put(key, "val");
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3393 Test (org.junit.Test)2016 Exchange (org.apache.camel.Exchange)506 RouteBuilder (org.apache.camel.builder.RouteBuilder)302 Processor (org.apache.camel.Processor)148 File (java.io.File)144 HashMap (java.util.HashMap)130 ObjectName (javax.management.ObjectName)90 MBeanServer (javax.management.MBeanServer)85 Message (org.apache.camel.Message)85 InputStream (java.io.InputStream)73 ArrayList (java.util.ArrayList)63 CamelExecutionException (org.apache.camel.CamelExecutionException)63 List (java.util.List)57 CamelContext (org.apache.camel.CamelContext)57 ProducerTemplate (org.apache.camel.ProducerTemplate)51 Tx (org.nhindirect.common.tx.model.Tx)49 ByteArrayInputStream (java.io.ByteArrayInputStream)47 Map (java.util.Map)43 RuntimeCamelException (org.apache.camel.RuntimeCamelException)38