Search in sources :

Example 16 with MockEndpoint

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

the class ConsulEventWatchTest method testWatchEvent.

@Test
public void testWatchEvent() throws Exception {
    List<String> values = generateRandomListOfStrings(3);
    MockEndpoint mock = getMockEndpoint("mock:event-watch");
    mock.expectedMessageCount(values.size());
    mock.expectedBodiesReceived(values);
    mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
    values.forEach(v -> client.fireEvent(key, v));
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 17 with MockEndpoint

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

the class ConsulKeyValueWatchTest method testWatchKey.

@Test
public void testWatchKey() throws Exception {
    List<String> values = generateRandomListOfStrings(3);
    MockEndpoint mock = getMockEndpoint("mock:kv-watch");
    mock.expectedMessageCount(values.size());
    mock.expectedBodiesReceived(values);
    mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
    for (String val : values) {
        client.putValue(key, val);
        Thread.sleep(250 + random.nextInt(250));
    }
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 18 with MockEndpoint

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

the class CoAPComponentTest method testCoAP.

@Test
public void testCoAP() throws Exception {
    NetworkConfig.createStandardWithoutFile();
    CoapClient client = new CoapClient("coap://localhost:" + PORT + "/TestResource");
    CoapResponse rsp = client.get();
    assertEquals("Hello ", rsp.getResponseText());
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.expectedBodiesReceived("Hello");
    sender.sendBody("Hello");
    assertMockEndpointsSatisfied();
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) CoapClient(org.eclipse.californium.core.CoapClient) Test(org.junit.Test)

Example 19 with MockEndpoint

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

the class ECDSASignatureTest method doSignatureRouteTest.

public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();
        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);
        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 20 with MockEndpoint

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

the class SignatureTests method testVerifyHeadersNotCleared.

@Test
public void testVerifyHeadersNotCleared() throws Exception {
    setupMock();
    template.requestBody("direct:headers", payload);
    assertMockEndpointsSatisfied();
    assertMockEndpointsSatisfied();
    MockEndpoint mock = getMockEndpoint("mock:result");
    Exchange e = mock.getExchanges().get(0);
    Message result = e == null ? null : e.hasOut() ? e.getOut() : e.getIn();
    assertNotNull(result.getHeader(DigitalSignatureConstants.SIGNATURE));
}
Also used : Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) 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