Java Code Examples for org.apache.camel.component.mock.MockEndpoint#setMinimumExpectedMessageCount()

The following examples show how to use org.apache.camel.component.mock.MockEndpoint#setMinimumExpectedMessageCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuthenticatedODataRoute() throws Exception {
    Connector odataConnector = createODataConnector(
                                                    new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, authTestServer.servicePlainUri())
                                                        .property(BASIC_USER_NAME, ODataTestServer.USER),
                                                    new PropertyBuilder<ConfigurationProperty>()
                                                        .property(BASIC_PASSWORD, basicPasswordProperty())
                                                    );

    Step odataStep = createODataStep(odataConnector, authTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(authTestServer.getResultCount());

    context.start();

    result.assertIsSatisfied();
    testListResult(result, 0, TEST_SERVER_DATA_1, TEST_SERVER_DATA_2, TEST_SERVER_DATA_3);
}
 
Example 2
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testReferenceODataRouteComplexValue() throws Exception {
    String resourcePath = "Airports";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, REF_SERVER_AIRPORT_DATA_1);
}
 
Example 3
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testReferenceODataRouteQueryWithFilterAndExpand() throws Exception {
    String resourcePath = "People";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(QUERY_PARAMS, "$filter=LastName eq 'Whyte'&$expand=Trips"));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, REF_SERVER_PEOPLE_DATA_1_EXPANDED_TRIPS);
}
 
Example 4
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testReferenceODataRouteKeyPredicate() throws Exception {
    String resourcePath = "Airports";
    String keyPredicate = "KLAX";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, REF_SERVER_AIRPORT_DATA_KLAX);
}
 
Example 5
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testODataRouteWithSimpleQuery() throws Exception {
    String queryParams = "$filter=ID eq 1";

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, defaultTestServer.servicePlainUri())
                                                        .property(QUERY_PARAMS, queryParams));

    Step odataStep = createODataStep(odataConnector, defaultTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, TEST_SERVER_DATA_1);
}
 
Example 6
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuthenticatedODataRoute() throws Exception {
    Connector odataConnector = createODataConnector(
                                                new PropertyBuilder<String>()
                                                    .property(SERVICE_URI, authTestServer.servicePlainUri())
                                                    .property(BASIC_USER_NAME, ODataTestServer.USER),
                                                new PropertyBuilder<ConfigurationProperty>()
                                                    .property(BASIC_PASSWORD, basicPasswordProperty())
                                                );

    Step odataStep = createODataStep(odataConnector, authTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(authTestServer.getResultCount());

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, TEST_SERVER_DATA_1);
    testResult(result, 1, TEST_SERVER_DATA_2);
    testResult(result, 2, TEST_SERVER_DATA_3);
}
 
Example 7
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
/**
 * Needs to supply server certificate since the server is unknown to the default
 * certificate authorities that is loaded into the keystore by default
 */
@Test
public void testSSLODataRoute() throws Exception {
    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, sslTestServer.serviceSSLUri())
                                                        .property(SERVER_CERTIFICATE, ODataTestServer.serverCertificate()));

    Step odataStep = createODataStep(odataConnector, sslTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(sslTestServer.getResultCount());

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, TEST_SERVER_DATA_1);
    testResult(result, 1, TEST_SERVER_DATA_2);
    testResult(result, 2, TEST_SERVER_DATA_3);
}
 
Example 8
Source File: ODataReadRouteSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleODataRoute() throws Exception {
    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                            .property(SERVICE_URI, defaultTestServer.servicePlainUri()));

    Step odataStep = createODataStep(odataConnector, defaultTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);

    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(defaultTestServer.getResultCount());

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, TEST_SERVER_DATA_1);
    testResult(result, 1, TEST_SERVER_DATA_2);
    testResult(result, 2, TEST_SERVER_DATA_3);
}
 
Example 9
Source File: SplitParallelProcessingExceptionHandlingTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@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);
    }

    int indexOnWhichExceptionThrown = 20;
    MockEndpoint mockSplit = getMockEndpoint("mock:split");
    mockSplit.setMinimumExpectedMessageCount(indexOnWhichExceptionThrown);

    MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(0);

    try {
        template.sendBody("direct:in", messageFragments);
        fail();
    } catch (Exception e) {
        assertMockEndpointsSatisfied();
    }
}
 
Example 10
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
/**
 * Despite split being set to false, the existence of a key predicate
 * forces the split since a predicate demands only 1 result which is
 * pointless putting into an array.
 */
@Test
public void testODataRouteWithKeyPredicateWithBrackets() throws Exception {
    String keyPredicate = "(1)";
    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, defaultTestServer.servicePlainUri())
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, defaultTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    //
    // We expect the result object to be a single json object & not an array
    //
    testResult(result, 0, TEST_SERVER_DATA_1);
}
 
Example 11
Source File: EMailReadRouteTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
/**
 * Receive will parse and strip the html from the message
 * and just leave the plain text.
 */
@Test
public void testImapMessageHTMLToPlainText() throws Exception {
    server = imapServer();
    server.clear();

    String plainText = "Hi, how are you?";
    String body = "<html><body>Hi, <i>how are you?</i></body></html>";

    server.deliverMultipartMessage(TEST_ADDRESS, TEST_PASSWORD, "[email protected]",
                                                                   "An HTML Message", TEXT_HTML, body);
    assertEquals(1, server.getEmailCount());

    Connector mailConnector = RouteUtils.createEMailConnector(server,
                                                   new PropertyBuilder<String>()
                                                           .property(PROTOCOL, Protocol.IMAP.id())
                                                           .property(HOST, server.getHost())
                                                           .property(PORT, Integer.toString(server.getPort()))
                                                           .property(USER, TEST_ADDRESS)
                                                           .property(PASSWORD, TEST_PASSWORD));

    PropertyBuilder<String> configuredProperties = new PropertyBuilder<>();
    configuredProperties.property(TO_PLAIN_TEXT, Boolean.toString(true));
    Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction, configuredProperties.build());
    Integration mailIntegration = RouteUtils.createIntegrationWithMock(mailStep);

    RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration);
    context.addRoutes(routes);

    MockEndpoint result = RouteUtils.initMockEndpoint(context);
    result.setMinimumExpectedMessageCount(server.getEmailCount());

    context.start();

    RouteUtils.assertSatisfied(result);

    EMailMessageModel model = RouteUtils.extractModelFromExchgMsg(result, 0);
    assertThat(model.getContent()).isInstanceOf(String.class);
    assertEquals(plainText, model.getContent().toString().trim());
}
 
Example 12
Source File: EMailReadWithTLSRouteTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
/**
 * This test must be manually run since it requires a StartTLS enabled imap server.
 * No such test server is available (GreenMail doesn't support StartTLS)
 *
 * Change the credentials in the fields above then execute.
 */
@Ignore
@Test
public void testImapEMailRouteWithStartTLS() throws Exception {
    assumeThat(HOSTNAME).isNotEqualTo(NO_HOST);

    Protocol protocol = Protocol.IMAP;

    Connector mailConnector = RouteUtils.createEMailConnector(protocol.componentSchema(),
                                                   new PropertyBuilder<String>()
                                                           .property(PROTOCOL, protocol.id())
                                                           .property(SECURE_TYPE, SecureType.STARTTLS.id())
                                                           .property(HOST, HOSTNAME)
                                                           .property(PORT, Integer.toString(PORT_NO))
                                                           .property(USER, TEST_USER)
                                                           .property(PASSWORD, TEST_PASSWORD));

    Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction);
    Integration mailIntegration = RouteUtils.createIntegrationWithMock(mailStep);

    RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration);
    context.addRoutes(routes);

    MockEndpoint result = RouteUtils.initMockEndpoint(context);
    result.setMinimumExpectedMessageCount(1);

    context.start();
    result.assertIsSatisfied();
}
 
Example 13
Source File: EMailReadRouteTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testPop3sEMailRoute() throws Exception {
    server = pop3sServer();
    Connector mailConnector = RouteUtils.createEMailConnector(server,
                                                   new PropertyBuilder<String>()
                                                           .property(PROTOCOL, Protocol.POP3.id())
                                                           .property(SECURE_TYPE, SecureType.SSL_TLS.id())
                                                           .property(HOST, server.getHost())
                                                           .property(PORT, Integer.toString(server.getPort()))
                                                           .property(USER, TEST_ADDRESS)
                                                           .property(PASSWORD, TEST_PASSWORD)
                                                           .property(SERVER_CERTIFICATE, server.getCertificate()));

    Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction);
    Integration mailIntegration = RouteUtils.createIntegrationWithMock(mailStep);

    RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration);
    context.addRoutes(routes);

    MockEndpoint result = RouteUtils.initMockEndpoint(context);
    result.setMinimumExpectedMessageCount(server.getEmailCount());

    context.start();

    RouteUtils.assertSatisfied(result);

    List<EMailMessageModel> emails = server.getEmails();
    for (int i = 0; i < emails.size(); ++i) {
        RouteUtils.testResult(result, i, emails.get(i));
    }
}
 
Example 14
Source File: EMailReadRouteTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testImapsEMailRoute() throws Exception {
    server = imapsServer();
    Connector mailConnector = RouteUtils.createEMailConnector(server,
                                                   new PropertyBuilder<String>()
                                                           .property(PROTOCOL, Protocol.IMAP.id())
                                                           .property(SECURE_TYPE, SecureType.SSL_TLS.id())
                                                           .property(HOST, server.getHost())
                                                           .property(PORT, Integer.toString(server.getPort()))
                                                           .property(USER, TEST_ADDRESS)
                                                           .property(PASSWORD, TEST_PASSWORD)
                                                           .property(SERVER_CERTIFICATE, server.getCertificate()));

    Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction);
    Integration mailIntegration = RouteUtils.createIntegrationWithMock(mailStep);

    RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration);
    context.addRoutes(routes);

    MockEndpoint result = RouteUtils.initMockEndpoint(context);
    result.setMinimumExpectedMessageCount(server.getEmailCount());

    context.start();

    RouteUtils.assertSatisfied(result);

    List<EMailMessageModel> emails = server.getEmails();
    for (int i = 0; i < emails.size(); ++i) {
        RouteUtils.testResult(result, i, emails.get(i));
    }
}
 
Example 15
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore("Run manually as not strictly required")
public void testReferenceODataRoute() throws Exception {
    String resourcePath = "People";
    String queryParam = "$count=true";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(QUERY_PARAMS, queryParam)
                                                        .property(SERVER_CERTIFICATE, ODataTestServer.referenceServiceCertificate()));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();

    @SuppressWarnings( "unchecked" )
    List<String> json = extractJsonFromExchgMsg(result, 0, List.class);
    assertEquals(20, json.size());

    String expected = testData(REF_SERVER_PEOPLE_DATA_1);
    assertThatJson(json.get(0)).isEqualTo(expected);
    expected = testData(REF_SERVER_PEOPLE_DATA_2);
    assertThatJson(json.get(1)).isEqualTo(expected);
    expected = testData(REF_SERVER_PEOPLE_DATA_3);
    assertThatJson(json.get(2)).isEqualTo(expected);
}
 
Example 16
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testReferenceODataRouteIssue4791_1() throws Exception {
    String resourcePath = "Airports";
    String keyPredicate = "KLAX";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    //
    // Return singleton json object rather than list due to key predicate
    //
    testResult(result, 0, REF_SERVER_AIRPORT_DATA_KLAX);
}
 
Example 17
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testReferenceODataRouteIssue4791_2() throws Exception {
    String resourcePath = "Airports";
    String keyPredicate = "('KLAX')/Location";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    //
    // Return singleton json object rather than list due to key predicate
    //
    testResult(result, 0, REF_SERVER_PEOPLE_DATA_KLAX_LOC);
}
 
Example 18
Source File: GangliaIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void sendDefaultConfigurationShouldSucceed() throws Exception {

    CamelContext camelctx = assertSingleCamelContext();

    ProducerTemplate template = camelctx.createProducerTemplate();
    Integer port = template.requestBody("direct:getPort", null, Integer.class);

    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mockEndpoint.setMinimumExpectedMessageCount(0);
    mockEndpoint.setAssertPeriod(100L);
    mockEndpoint.whenAnyExchangeReceived(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            Ganglia_metadata_msg metadataMessage = exchange.getIn().getBody(Ganglia_metadata_msg.class);
            if (metadataMessage != null) {
                Assert.assertEquals(DEFAULT_METRIC_NAME, metadataMessage.gfull.metric.name);
                Assert.assertEquals(DEFAULT_TYPE.getGangliaType(), metadataMessage.gfull.metric.type);
                Assert.assertEquals(DEFAULT_SLOPE.getGangliaSlope(), metadataMessage.gfull.metric.slope);
                Assert.assertEquals(DEFAULT_UNITS, metadataMessage.gfull.metric.units);
                Assert.assertEquals(DEFAULT_TMAX, metadataMessage.gfull.metric.tmax);
                Assert.assertEquals(DEFAULT_DMAX, metadataMessage.gfull.metric.dmax);
            } else {
                Ganglia_value_msg valueMessage = exchange.getIn().getBody(Ganglia_value_msg.class);
                if (valueMessage != null) {
                    Assert.assertEquals("28.0", valueMessage.gstr.str);
                    Assert.assertEquals("%s", valueMessage.gstr.fmt);
                } else {
                    Assert.fail("Mock endpoint should only receive non-null metadata or value messages");
                }
            }
        }
    });

    template.sendBody(String.format("ganglia:localhost:%d?mode=UNICAST", port), "28.0");

    mockEndpoint.assertIsSatisfied();
}
 
Example 19
Source File: EMailReadRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testImapRouteWithConsumerDelayProperties() throws Exception {
    String delayValue = "1000";

    server = imapServer();
    Connector mailConnector = RouteUtils.createEMailConnector(server,
                                                   new PropertyBuilder<String>()
                                                           .property(PROTOCOL, Protocol.IMAP.id())
                                                           .property(HOST, server.getHost())
                                                           .property(PORT, Integer.toString(server.getPort()))
                                                           .property(USER, TEST_ADDRESS)
                                                           .property(PASSWORD, TEST_PASSWORD));

    PropertyBuilder<String> configuredProperties = new PropertyBuilder<>();
    configuredProperties.property(DELAY, delayValue);
    Step mailStep = RouteUtils.createEMailStep(mailConnector, this::createConnectorAction, configuredProperties.build());
    Integration mailIntegration = RouteUtils.createIntegrationWithMock(mailStep);

    RouteBuilder routes = RouteUtils.newIntegrationRouteBuilder(mailIntegration);
    context.addRoutes(routes);

    MockEndpoint result = RouteUtils.initMockEndpoint(context);
    result.setMinimumExpectedMessageCount(server.getEmailCount());

    context.start();

    RouteUtils.assertSatisfied(result);

    List<EMailMessageModel> emails = server.getEmails();
    for (int i = 0; i < emails.size(); ++i) {
        RouteUtils.testResult(result, i, emails.get(i));
    }

    Collection<Endpoint> endpoints = context.getEndpoints();
    MailEndpoint mailEndpoint = null;
    for (Endpoint endpoint : endpoints) {
        if (endpoint instanceof MailEndpoint) {
            mailEndpoint = (MailEndpoint) endpoint;
        }
    }
    assertNotNull(mailEndpoint);

    Map<String, Object> consumerProperties = mailEndpoint.getSchedulerProperties();
    assertNotNull(consumerProperties);
    assertTrue(consumerProperties.size() > 0);
    assertEquals(delayValue, consumerProperties.get(DELAY));
}
 
Example 20
Source File: ODataReadRouteNoSplitResultsTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testODataRouteAlreadySeen() throws Exception {
    int backoffIdleThreshold = 1;
    int backoffMultiplier = 1;

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, defaultTestServer.servicePlainUri())
                                                        .property(FILTER_ALREADY_SEEN, Boolean.TRUE.toString())
                                                        .property(BACKOFF_IDLE_THRESHOLD, Integer.toString(backoffIdleThreshold))
                                                        .property(BACKOFF_MULTIPLIER, Integer.toString(backoffMultiplier)));

    Step odataStep = createODataStep(odataConnector, defaultTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();

    @SuppressWarnings( "unchecked" )
    List<String> json = extractJsonFromExchgMsg(result, 0, List.class);
    assertEquals(3, json.size());

    String expected;
    expected = testData(TEST_SERVER_DATA_1);
    assertThatJson(json.get(0)).isEqualTo(expected);
    expected = testData(TEST_SERVER_DATA_2);
    assertThatJson(json.get(1)).isEqualTo(expected);
    expected = testData(TEST_SERVER_DATA_3);
    assertThatJson(json.get(2)).isEqualTo(expected);

    //
    // Check backup consumer options carried through to olingo4 component
    //
    Olingo4Endpoint olingo4Endpoint = context.getEndpoint(OLINGO4_READ_FROM_ENDPOINT, Olingo4Endpoint.class);
    assertNotNull(olingo4Endpoint);
    assertEquals(backoffIdleThreshold, olingo4Endpoint.getBackoffIdleThreshold());
    assertEquals(backoffMultiplier, olingo4Endpoint.getBackoffMultiplier());
}