Search in sources :

Example 81 with MockEndpoint

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

the class SearchByExchangeDirectTest method testSearchTimelineWithStaticQuery.

@Test
public void testSearchTimelineWithStaticQuery() throws Exception {
    template.sendBody(null);
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.assertIsSatisfied();
    List<Exchange> tweets = mock.getExchanges();
    for (Exchange e : tweets) {
        log.info("Tweet: " + e.getIn().getBody(String.class));
    }
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 82 with MockEndpoint

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

the class SearchByExchangeDirectTest method testDoubleSearchKeepingOld.

@Test
public void testDoubleSearchKeepingOld() throws Exception {
    templateDouble.sendBodyAndHeader(null, TwitterConstants.TWITTER_KEYWORDS, "java");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.assertIsSatisfied();
    List<Exchange> tweets = mock.getExchanges();
    for (Exchange e : tweets) {
        log.info("Tweet: " + e.getIn().getBody(String.class));
    }
    // calls the same query again, expecting to receive the same amount of
    // tweets, because we told this route to not filter old(consumed) tweets
    int total = mock.getReceivedCounter();
    templateDouble.sendBodyAndHeader(null, TwitterConstants.TWITTER_KEYWORDS, "java");
    // due race condition
    assertTrue(mock.getReceivedCounter() >= total);
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 83 with MockEndpoint

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

the class ECDSASignatureTest method setupMock.

private MockEndpoint setupMock(String payload) {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived(payload);
    return mock;
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 84 with MockEndpoint

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

the class SignatureAlgorithmTest method setupMock.

private MockEndpoint setupMock(String payload) {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived(payload);
    return mock;
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 85 with MockEndpoint

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

the class SignatureAlgorithmTest 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 : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3401 Test (org.junit.Test)2024 Exchange (org.apache.camel.Exchange)511 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