Search in sources :

Example 76 with MockEndpoint

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

the class DropboxProducerPutSingleFileWithRemotePathTest method testCamelDropbox.

@Test
public void testCamelDropbox() throws Exception {
    template.send("direct:start", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader("test", "test");
        }
    });
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    assertMockEndpointsSatisfied();
    List<Exchange> exchanges = mock.getReceivedExchanges();
    Exchange exchange = exchanges.get(0);
    Object header = exchange.getIn().getHeader(DropboxResultHeader.UPLOADED_FILE.name());
    Object body = exchange.getIn().getBody();
    assertNotNull(header);
    assertNotNull(body);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 77 with MockEndpoint

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

the class EtcdKeysTest method testKeys.

@Test(expected = EtcdException.class)
public void testKeys() throws Exception {
    final String path = "/camel/" + UUID.randomUUID().toString();
    final String value = UUID.randomUUID().toString();
    final EtcdClient client = getClient();
    final Map<String, Object> headers = new HashMap<>();
    // *******************************************
    // SET
    // *******************************************
    headers.clear();
    headers.put(EtcdConstants.ETCD_ACTION, EtcdConstants.ETCD_KEYS_ACTION_SET);
    headers.put(EtcdConstants.ETCD_PATH, path);
    sendBody("direct:keys-set", value, headers);
    MockEndpoint mockSet = getMockEndpoint("mock:result-set");
    mockSet.expectedMinimumMessageCount(1);
    mockSet.expectedHeaderReceived(EtcdConstants.ETCD_NAMESPACE, EtcdNamespace.keys.name());
    mockSet.expectedHeaderReceived(EtcdConstants.ETCD_PATH, path);
    mockSet.assertIsSatisfied();
    // *******************************************
    // GET
    // *******************************************
    headers.clear();
    headers.put(EtcdConstants.ETCD_ACTION, EtcdConstants.ETCD_KEYS_ACTION_GET);
    headers.put(EtcdConstants.ETCD_PATH, path);
    sendBody("direct:keys-get", value, headers);
    MockEndpoint mockGet = getMockEndpoint("mock:result-get");
    mockGet.expectedMinimumMessageCount(1);
    mockSet.expectedHeaderReceived(EtcdConstants.ETCD_NAMESPACE, EtcdNamespace.keys.name());
    mockGet.expectedHeaderReceived(EtcdConstants.ETCD_PATH, path);
    mockGet.expectedMessagesMatches(new Predicate() {

        @Override
        public boolean matches(Exchange exchange) {
            EtcdKeysResponse keysResponse = exchange.getIn().getBody(EtcdKeysResponse.class);
            assertNotNull(keysResponse);
            assertNotNull(keysResponse.node);
            assertNotNull(keysResponse.node.value);
            return keysResponse.node.value.equals(value);
        }
    });
    mockGet.assertIsSatisfied();
    // *******************************************
    // DELETE
    // *******************************************
    headers.clear();
    headers.put(EtcdConstants.ETCD_ACTION, EtcdConstants.ETCD_KEYS_ACTION_DELETE);
    headers.put(EtcdConstants.ETCD_PATH, path);
    sendBody("direct:keys-del", "value", headers);
    MockEndpoint mockDel = getMockEndpoint("mock:result-del");
    mockDel.expectedMinimumMessageCount(1);
    mockSet.expectedHeaderReceived(EtcdConstants.ETCD_NAMESPACE, EtcdNamespace.keys.name());
    mockDel.expectedHeaderReceived(EtcdConstants.ETCD_PATH, path);
    mockDel.assertIsSatisfied();
    // *******************************************
    // VALIDATION
    // *******************************************
    client.get(path).send().get();
    fail("EtcdException should have been thrown");
}
Also used : Exchange(org.apache.camel.Exchange) EtcdClient(mousio.etcd4j.EtcdClient) HashMap(java.util.HashMap) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) EtcdKeysResponse(mousio.etcd4j.responses.EtcdKeysResponse) Predicate(org.apache.camel.Predicate) Test(org.junit.Test)

Example 78 with MockEndpoint

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

the class EtcdStatsTest method testStatsConsumer.

protected void testStatsConsumer(String mockEnpoint, String expectedPath, final Class<?> expectedType) throws Exception {
    MockEndpoint mock = getMockEndpoint(mockEnpoint);
    mock.expectedMinimumMessageCount(1);
    mock.expectedHeaderReceived(EtcdConstants.ETCD_NAMESPACE, EtcdNamespace.stats.name());
    mock.expectedHeaderReceived(EtcdConstants.ETCD_PATH, expectedPath);
    mock.expectedMessagesMatches(new Predicate() {

        @Override
        public boolean matches(Exchange exchange) {
            return exchange.getIn().getBody().getClass() == expectedType;
        }
    });
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Predicate(org.apache.camel.Predicate)

Example 79 with MockEndpoint

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

the class FacebookComponentConsumerTest method testPage.

@Test
public void testPage() throws Exception {
    final MockEndpoint mock = getMockEndpoint("mock:testPage");
    mock.expectedMinimumMessageCount(1);
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 80 with MockEndpoint

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

the class FacebookComponentPageIdProducerTest method testProducers.

@Test
public void testProducers() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:page");
    mock.expectedMinimumMessageCount(3);
    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