org.junit.jupiter.api.Timeout Java Examples

The following examples show how to use org.junit.jupiter.api.Timeout. 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: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerBoundaryEventDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);

    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent", params);
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #2
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerMultipleInstances() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3);
    KieBase kbase = createKnowledgeBase("BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2");

    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    TestWorkItemHandler handler = new TestWorkItemHandler();

    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = ksession.startProcess("boundaryTimerMultipleInstances");
    assertProcessInstanceActive(processInstance);

    countDownListener.waitTillCompleted();

    List<WorkItem> workItems = handler.getWorkItems();
    assertThat(workItems).isNotNull();
    assertThat(workItems.size()).isEqualTo(3);

    for (WorkItem wi : workItems) {
        ksession.getWorkItemManager().completeWorkItem(wi.getId(), null);
    }

    assertProcessInstanceFinished(processInstance, ksession);
}
 
Example #3
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testIntermediateCatchEventTimerCycleISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 5);

    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);

    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);

    countDownListener.waitTillCompleted();
    assertProcessInstanceActive(processInstance);
    ksession.abortProcessInstance(processInstance.getId());

}
 
Example #4
Source File: CamelSinkElasticSearchITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testIndexOperation() {
    try {
        String topic = TestUtils.getDefaultTestTopic(this.getClass());

        ConnectorPropertyFactory propertyFactory = CamelElasticSearchPropertyFactory
                .basic()
                .withTopics(topic)
                .withOperation("Index")
                .withClusterName(ElasticSearchCommon.DEFAULT_ELASTICSEARCH_CLUSTER)
                .withHostAddress(elasticSearch.getHttpHostAddress())
                .withIndexName(ElasticSearchCommon.DEFAULT_ELASTICSEARCH_INDEX)
                .withTransformsConfig("ElasticSearchTransformer")
                    .withEntry("type", "org.apache.camel.kafkaconnector.elasticsearch.sink.transform.ConnectRecordValueToMapTransformer")
                    .withEntry("key", transformKey)
                    .end();

        runTest(propertyFactory);

        LOG.debug("Created the consumer ... About to receive messages");
    } catch (Exception e) {
        LOG.error("ElasticSearch test failed: {}", e.getMessage(), e);
        fail(e.getMessage());
    }
}
 
Example #5
Source File: StartEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testMultipleStartEventsStartOnTimer() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 2);
    KieBase kbase = createKnowledgeBase("BPMN2-MultipleStartEventProcess.bpmn2");
    ksession = createKnowledgeSession(kbase);
   
    ksession.addEventListener(countDownListener);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
            workItemHandler);
    final List<String> list = new ArrayList<>();
    ksession.addEventListener(new DefaultProcessEventListener() {
        public void beforeProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
        }
    });
    assertThat(list.size()).isEqualTo(0);
    // Timer in the process takes 500ms, so after 1 second, there should be 2 process IDs in the list.
    countDownListener.waitTillCompleted();
    assertThat(getNumberOfProcessInstances("MultipleStartEvents")).isEqualTo(2);
    
}
 
Example #6
Source File: StartEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerStartDuration() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1);
    KieBase kbase = createKnowledgeBase("BPMN2-TimerStartDuration.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    final List<String> list = new ArrayList<>();
    ksession.addEventListener(new DefaultProcessEventListener() {
        public void beforeProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
        }
    });

    assertThat(list.size()).isEqualTo(0);

    countDownListener.waitTillCompleted();

    assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(1);

}
 
Example #7
Source File: StartEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerStart() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5);
    KieBase kbase = createKnowledgeBase("BPMN2-TimerStart.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    final List<String> list = new ArrayList<>();
    ksession.addEventListener(new DefaultProcessEventListener() {
        public void beforeProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
        }
    });
    assertThat(list.size()).isEqualTo(0);
    countDownListener.waitTillCompleted();
    assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(5);

}
 
Example #8
Source File: StartEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testMultipleEventBasedStartEventsStartOnTimer()
        throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 2);
    KieBase kbase = createKnowledgeBase("BPMN2-MultipleEventBasedStartEventProcess.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
            workItemHandler);
    final List<String> list = new ArrayList<>();
    ksession.addEventListener(new DefaultProcessEventListener() {
        public void beforeProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
        }
    });
    assertThat(list.size()).isEqualTo(0);
    // Timer in the process takes 500ms, so after 1 second, there should be 2 process IDs in the list.
    countDownListener.waitTillCompleted();
    assertThat(getNumberOfProcessInstances("MultipleStartEvents")).isEqualTo(2);

}
 
Example #9
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerBoundaryEventCycle1() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);

    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycle1.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #10
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerBoundaryEventCycle2() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 3);

    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycle2.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();

    assertProcessInstanceActive(processInstance);
    ksession.abortProcessInstance(processInstance.getId());

}
 
Example #11
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerBoundaryEventInterrupting() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);

    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventInterrupting.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);

    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    logger.debug("Firing timer");

    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #12
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerBoundaryEventInterruptingOnTask() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);

    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventInterruptingOnTask.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",  new TestWorkItemHandler());
    ksession.addEventListener(countDownListener);

    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    logger.debug("Firing timer");

    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #13
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testIntermediateCatchEventTimerDuration() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);

    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession
            .startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
  
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted();

    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);

    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #14
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testIntermediateCatchEventTimerDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);

    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventTimerDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);

    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
    assertProcessInstanceActive(processInstance);
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted();

    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #15
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testIntermediateCatchEventTimerDurationISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);

    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);

    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    // now wait for 1.5 second for timer to trigger
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
            new DoNothingWorkItemHandler());

    assertProcessInstanceFinished(processInstance, ksession);

}
 
Example #16
Source File: StartEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testTimerStartCycleLegacy() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 2);
    KieBase kbase = createKnowledgeBase("BPMN2-TimerStartCycleLegacy.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    final List<String> list = new ArrayList<>();
    ksession.addEventListener(new DefaultProcessEventListener() {
        public void beforeProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
        }
    });
    logger.debug("About to start ###### " + new Date());

    assertThat(list.size()).isEqualTo(0);
    // then wait 5 times 5oo ms as that is period configured on the process
    countDownListener.waitTillCompleted();
    ksession.dispose();
    assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(2);

}
 
Example #17
Source File: IntermediateEventTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void testIntermediateTimerEventMI() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("After timer", 3);
    KieBase kbase = createKnowledgeBase("timer/BPMN2-IntermediateTimerEventMI.bpmn2");

    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    TestWorkItemHandler handler = new TestWorkItemHandler();

    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = ksession.startProcess("defaultprocessid");
    assertProcessInstanceActive(processInstance);

    countDownListener.waitTillCompleted();
    assertProcessInstanceActive(processInstance.getId(), ksession);

    ksession.abortProcessInstance(processInstance.getId());

    assertProcessInstanceAborted(processInstance.getId(), ksession);
}
 
Example #18
Source File: EventLoopSanityTest.java    From fastjgame with Apache License 2.0 6 votes vote down vote up
/**
 * 对于每一个生产者而言,都应该满足先入先出
 */
@Timeout(TEST_TIMEOUT)
@Test
void testFifo() {
    final int producerNum = 4;

    // 必须使用abort策略,否则生产者无法感知失败
    final EventLoop eventLoop = newEventLoop(RejectedExecutionHandlers.abort());
    final LongHolder fail = new LongHolder();
    final long[] lastSequences = new long[producerNum];

    final FIFOProducer[] producers = new FIFOProducer[producerNum];
    for (int index = 0; index < producerNum; index++) {
        producers[index] = new FIFOProducer(eventLoop, index, fail, lastSequences);
    }

    TestUtil.startAndJoin(Arrays.asList(producers), eventLoop, 1000);

    Assertions.assertEquals(0, fail.get(), "Observed out of order");
}
 
Example #19
Source File: EventLoopSanityTestGlobal.java    From fastjgame with Apache License 2.0 6 votes vote down vote up
/**
 * 对于每一个生产者而言,都应该满足先入先出
 */
@Timeout(TEST_TIMEOUT)
@Test
void testFifo() {
    final int producerNum = 4;

    final AtomicBoolean stop = new AtomicBoolean();
    final LongHolder fail = new LongHolder();
    final long[] lastSequences = new long[producerNum];

    final FIFOProducer[] producers = new FIFOProducer[producerNum];
    for (int index = 0; index < producerNum; index++) {
        producers[index] = new FIFOProducer(stop, index, fail, lastSequences);
    }

    TestUtil.startAndJoin(Arrays.asList(producers), stop, 1000);

    Assertions.assertEquals(0, fail.get(), "Observed out of order");
}
 
Example #20
Source File: CamelSourceSyslogITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testBasicSend() {
    try {
        ConnectorPropertyFactory connectorPropertyFactory = CamelSyslogPropertyFactory
                .basic()
                .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
                .withHost("localhost")
                .withPort(FREE_PORT)
                .withProtocol("udp");

        runBasicStringTest(connectorPropertyFactory);
    } catch (Exception e) {
        LOG.error("Syslog test failed: {} {}", e.getMessage(), e);
        fail(e.getMessage(), e);
    }
}
 
Example #21
Source File: CamelSinkSyslogITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testBasicReceive() {
    try {
        ConnectorPropertyFactory connectorPropertyFactory = CamelSyslogPropertyFactory
                .basic()
                .withTopics(TestUtils.getDefaultTestTopic(this.getClass()))
                .withHost("localhost")
                .withPort(FREE_PORT)
                .withProtocol("udp");

        runBasicProduceTest(connectorPropertyFactory);
    } catch (Exception e) {
        LOG.error("Syslog test failed: {} {}", e.getMessage(), e);
        fail(e.getMessage(), e);
    }
}
 
Example #22
Source File: CamelSourceCassandraITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Disabled("Disabled due to CAMEL-15219")
@Timeout(90)
@Test
public void testRetrieveFromCassandraWithCustomStrategy() throws ExecutionException, InterruptedException {
    String topic = TestUtils.getDefaultTestTopic(this.getClass());

    ConnectorPropertyFactory connectorPropertyFactory = CamelCassandraPropertyFactory
            .basic()
            .withKafkaTopic(topic)
            .withHosts(cassandraService.getCassandraHost())
            .withPort(cassandraService.getCQL3Port())
            .withKeySpace(TestDataDao.KEY_SPACE)
            .withResultSetConversionStrategy("#:" + TestResultSetConversionStrategy.class.getName())
            .withCql(testDataDao.getSelectStatement());

    runTest(connectorPropertyFactory);
}
 
Example #23
Source File: CamelSourceCassandraITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Timeout(90)
@Test
public void testRetrieveFromCassandra() throws ExecutionException, InterruptedException {
    String topic = TestUtils.getDefaultTestTopic(this.getClass());

    ConnectorPropertyFactory connectorPropertyFactory = CamelCassandraPropertyFactory
            .basic()
            .withKafkaTopic(topic)
            .withHosts(cassandraService.getCassandraHost())
            .withPort(cassandraService.getCQL3Port())
            .withKeySpace(TestDataDao.KEY_SPACE)
            .withResultSetConversionStrategy("ONE")
            .withCql(testDataDao.getSelectStatement());

    runTest(connectorPropertyFactory);
}
 
Example #24
Source File: CamelSourceSalesforceITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(180)
public void testBasicCDCUsingUrl() throws ExecutionException, InterruptedException {
    ConnectorPropertyFactory factory = CamelSalesforcePropertyFactory.basic()
            .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
            .withUserName(userName)
            .withPassword(password)
            .withClientId(clientId)
            .withClientSecret(clientSecret)
            .withApiVersion("37.0")
            .withUrl("data/AccountChangeEvent")
                .append("replayId", "-2")
                .append("rawPayload", "true")
                .buildUrl();

    runBasicTest(factory);
}
 
Example #25
Source File: CamelSourceSalesforceITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(180)
public void testBasicConsumeUsingUrl() throws ExecutionException, InterruptedException {
    ConnectorPropertyFactory factory = CamelSalesforcePropertyFactory.basic()
            .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
            .withUserName(userName)
            .withPassword(password)
            .withClientId(clientId)
            .withClientSecret(clientSecret)
            .withUrl("CamelKafkaConnectorTopic")
                .append("notifyForFields", "ALL")
                .append("updateTopic", "true")
                .append("rawPayload", "true")
                .append("sObjectClass", "org.apache.camel.salesforce.dto.Account")
                .append("sObjectQuery", "SELECT Id, Name FROM Account")
                .buildUrl();

    Executors.newCachedThreadPool().submit(this::updateTestAccount);

    runBasicTest(factory);
}
 
Example #26
Source File: CamelSourceSalesforceITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(180)
public void testBasicConsume() throws ExecutionException, InterruptedException {
    ConnectorPropertyFactory factory = CamelSalesforcePropertyFactory.basic()
            .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
            .withUserName(userName)
            .withPassword(password)
            .withClientId(clientId)
            .withClientSecret(clientSecret)
            .withNotifyForFields("ALL")
            .withUpdateTopic(true)
            .withRawPayload(true)
            .withPackages("org.apache.camel.salesforce.dto")
            .withSObjectClass("org.apache.camel.salesforce.dto.Account")
            .withSObjectQuery("SELECT Id, Name FROM Account")
            .withTopicName("CamelKafkaConnectorTopic");

    Executors.newCachedThreadPool().submit(this::updateTestAccount);

    runBasicTest(factory);
}
 
Example #27
Source File: CamelSinkSalesforceITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(180)
public void testBasicProduce() throws ExecutionException, InterruptedException {
    ConnectorPropertyFactory factory = CamelSalesforcePropertyFactory.basic()
            .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
            .withUserName(userName)
            .withPassword(password)
            .withClientId(clientId)
            .withClientSecret(clientSecret)
            .withRawPayload(true)
            .withPackages("org.apache.camel.salesforce.dto")
            .withSObjectName("Account")
            .withOperationName("createSObject");

    runTest(factory);

    TestUtils.waitFor(this::waitForRecordCreation);
    assertTrue(recordCreated, "The record was not created");
}
 
Example #28
Source File: CamelSinkHTTPITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testBasicSendReceiveUsingUrl() {
    try {
        String hostName = localServer.getInetAddress().getHostName() + ":" + HTTP_PORT + "/ckc";

        ConnectorPropertyFactory connectorPropertyFactory = CamelHTTPPropertyFactory.basic()
                .withTopics(TestUtils.getDefaultTestTopic(this.getClass()))
                .withUrl(hostName)
                    .buildUrl();


        runTest(connectorPropertyFactory);
    } catch (Exception e) {
        LOG.error("HTTP test failed: {} {}", e.getMessage(), e);
        fail(e.getMessage(), e);
    }
}
 
Example #29
Source File: CamelSinkHTTPITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testBasicSendReceive() {
    try {
        String url = localServer.getInetAddress().getHostName() + ":" + HTTP_PORT + "/ckc";

        ConnectorPropertyFactory connectorPropertyFactory = CamelHTTPPropertyFactory.basic()
                .withTopics(TestUtils.getDefaultTestTopic(this.getClass()))
                .withHttpUri(url);

        runTest(connectorPropertyFactory);
    } catch (Exception e) {
        LOG.error("HTTP test failed: {} {}", e.getMessage(), e);
        fail(e.getMessage(), e);
    }
}
 
Example #30
Source File: CamelSourceMongoDBITCase.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(90)
public void testFindAll() throws ExecutionException, InterruptedException {
    String connectionBeanRef = String.format("com.mongodb.client.MongoClients#create('mongodb://%s:%d')",
            mongoDBService.getHost(),
            mongoDBService.getPort());

    ConnectorPropertyFactory factory = CamelMongoDBPropertyFactory.basic()
            .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
            .withConnectionBean("mongo",
                    BasicConnectorPropertyFactory.classRef(connectionBeanRef))
            .withDatabase("testDatabase")
            .withCollection("testCollection")
            .withCreateCollection(true);

    runTest(factory);
}