diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ActivityTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ActivityTest.java index b46d3f2016..fdcd1b8bfd 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ActivityTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ActivityTest.java @@ -38,7 +38,7 @@ import org.jbpm.process.instance.event.listeners.TriggerRulesEventListener; import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.workflow.instance.WorkflowRuntimeException; import org.jbpm.workflow.instance.node.DynamicNodeInstance; import org.jbpm.workflow.instance.node.DynamicUtils; @@ -546,7 +546,7 @@ public Void execute(Context context) { @Test(timeout=10000) @RequirePersistence public void testProcesWithHumanTaskWithTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-SubProcessWithTimer.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -756,7 +756,7 @@ public void testCallActivityWithHistoryLog() throws Exception { @Test(timeout=10000) @RequirePersistence public void testCallActivityWithTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-ParentProcess.bpmn2", "BPMN2-SubProcessWithTimer.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1364,7 +1364,7 @@ public void testBusinessRuleTaskWithContionalEvent() throws Exception { @RequirePersistence @Test(timeout=10000) public void testNullVariableInScriptTaskProcess() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Timer", 1, true); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1, true); KieBase kbase = createKnowledgeBase("BPMN2-NullVariableInScriptTaskProcess.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -1396,7 +1396,7 @@ public void testScriptTaskWithVariableByName() throws Exception { @Test public void testCallActivityWithBoundaryEvent() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Boundary event", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Boundary event", 1); KieBase kbase = createKnowledgeBase( "BPMN2-CallActivityWithBoundaryEvent.bpmn2", "BPMN2-CallActivitySubProcessWithBoundaryEvent.bpmn2"); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/FlowTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/FlowTest.java index d751de0404..cc9462fb30 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/FlowTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/FlowTest.java @@ -22,7 +22,7 @@ import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.workflow.instance.impl.NodeInstanceImpl; import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl; import org.jbpm.workflow.instance.node.CompositeContextNodeInstance; @@ -458,7 +458,7 @@ public void testInclusiveSplitAndJoinWithEnd() throws Exception { @Test(timeout=10000) public void testInclusiveSplitAndJoinWithTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); KieBase kbase = createKnowledgeBase("BPMN2-InclusiveSplitAndJoinWithTimer.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -1358,7 +1358,7 @@ public void testMultiInstanceLoopCharacteristicsTask() throws Exception { @Test public void testMultipleInOutgoingSequenceFlows() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); System.setProperty("jbpm.enable.multi.con", "true"); KieBase kbase = createKnowledgeBase("BPMN2-MultipleInOutgoingSequenceFlows.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1517,7 +1517,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test public void testTimerAndGateway() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("timer/BPMN2-ParallelSplitWithTimerProcess.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java index 63141fc0e5..a606fa7c3e 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java @@ -51,7 +51,7 @@ import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.process.instance.timer.TimerInstance; import org.jbpm.process.instance.timer.TimerManager; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; @@ -370,7 +370,7 @@ public void testEventBasedSplitAfter() throws Exception { @Test(timeout=10000) public void testEventBasedSplit2() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit2.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("Email1", @@ -776,7 +776,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=10000) public void testEventSubprocessTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Script Task 1", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 1); KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessTimer.bpmn2"); @@ -802,7 +802,7 @@ public void testEventSubprocessTimer() throws Exception { @Test(timeout=10000) @RequirePersistence public void testEventSubprocessTimerCycle() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Script Task 1", 4); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 4); KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessTimerCycle.bpmn2"); @@ -865,7 +865,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=10000) public void testEventSubprocessMessageWithLocalVars() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("subprocess/BPMN2-EventSubProcessWithLocalVariables.bpmn2"); final Set variablevalues = new HashSet(); @@ -1023,7 +1023,7 @@ public void testMessageBoundaryEventOnTaskComplete() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventDuration() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventDuration.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); @@ -1038,7 +1038,7 @@ public void testTimerBoundaryEventDuration() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventDurationISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventDurationISO.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); @@ -1053,7 +1053,7 @@ public void testTimerBoundaryEventDurationISO() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventDateISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1072,7 +1072,7 @@ public void testTimerBoundaryEventDateISO() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventCycle1() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycle1.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1088,7 +1088,7 @@ public void testTimerBoundaryEventCycle1() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventCycle2() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 3); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycle2.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1106,7 +1106,7 @@ public void testTimerBoundaryEventCycle2() throws Exception { @Test(timeout=10000) @RequirePersistence(false) public void testTimerBoundaryEventCycleISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 2); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycleISO.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -1121,7 +1121,7 @@ public void testTimerBoundaryEventCycleISO() throws Exception { @Test(timeout=10000) @RequirePersistence public void testTimerBoundaryEventCycleISOWithPersistence() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 2); // load up the knowledge base KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycleISO.bpmn2"); @@ -1151,7 +1151,7 @@ public void testTimerBoundaryEventCycleISOWithPersistence() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventInterrupting() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventInterrupting.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1170,7 +1170,7 @@ public void testTimerBoundaryEventInterrupting() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventInterruptingOnTask() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventInterruptingOnTask.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1250,7 +1250,7 @@ public void testIntermediateCatchEventMessage() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerDuration() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1273,7 +1273,7 @@ public void testIntermediateCatchEventTimerDuration() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerDateISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventTimerDateISO.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1294,7 +1294,7 @@ public void testIntermediateCatchEventTimerDateISO() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerDurationISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationISO.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1315,7 +1315,7 @@ public void testIntermediateCatchEventTimerDurationISO() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerCycle1() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycle1.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1336,7 +1336,7 @@ public void testIntermediateCatchEventTimerCycle1() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerCycleISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 5); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleISO.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1354,7 +1354,7 @@ public void testIntermediateCatchEventTimerCycleISO() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerCycle2() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycle2.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1435,7 +1435,7 @@ public void testIntermediateCatchEventConditionFilterByProcessInstance() @RequirePersistence(false) public void testIntermediateCatchEventTimerCycleWithError() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -1461,7 +1461,7 @@ public void testIntermediateCatchEventTimerCycleWithError() @Test(timeout=10000) @RequirePersistence public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -2036,7 +2036,7 @@ public void testIntermediateCatchEventSignalWithRef() throws Exception { @Test(timeout=10000) public void testTimerMultipleInstances() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -2062,7 +2062,7 @@ public void testTimerMultipleInstances() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerCycleCron() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleCron.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -2079,7 +2079,7 @@ public void testIntermediateCatchEventTimerCycleCron() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimerDurationValueFromGlobal() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-GlobalTimerInterrupted.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -2097,7 +2097,7 @@ public void testIntermediateCatchEventTimerDurationValueFromGlobal() throws Exce @Test(timeout=10000) public void testTimerBoundaryEventCronCycle() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Send Update Timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-BoundaryTimerCycleCron.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -2124,9 +2124,9 @@ public void testTimerBoundaryEventCronCycle() throws Exception { @Test(timeout=10000) public void testIntermediateTimerParallelGateway() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Timer1", 1); - CountDownProcessEventListener countDownListener2 = new CountDownProcessEventListener("Timer2", 1); - CountDownProcessEventListener countDownListener3 = new CountDownProcessEventListener("Timer3", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer1", 1); + NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Timer2", 1); + NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Timer3", 1); KieBase kbase = createKnowledgeBase("timer/BPMN2-IntermediateTimerParallelGateway.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -2148,7 +2148,7 @@ public void testIntermediateTimerParallelGateway() throws Exception { @Test(timeout=10000) public void testIntermediateTimerEventMI() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("After timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("After timer", 3); KieBase kbase = createKnowledgeBase("timer/BPMN2-IntermediateTimerEventMI.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -2456,7 +2456,7 @@ public boolean accept(Object object) { @RequirePersistence public void testIntermediateCatchEventTimerDurationWithError() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationWithError.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -2487,7 +2487,7 @@ public void testIntermediateCatchEventTimerDurationWithError() @Test(timeout=10000) public void testTimerBoundaryEventCronCycleVariable() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Send Update Timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 3); KieBase kbase = createKnowledgeBase("BPMN2-BoundaryTimerCycleCronVariable.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -2518,7 +2518,7 @@ public void testTimerBoundaryEventCronCycleVariable() throws Exception { @Test(timeout=10000) public void testMultipleTimerBoundaryEventCronCycleVariable() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Send Update Timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 2); KieBase kbase = createKnowledgeBase("BPMN2-MultipleBoundaryTimerCycleCronVariable.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -2552,10 +2552,10 @@ public void testMultipleTimerBoundaryEventCronCycleVariable() throws Exception { public void testEventBasedSplitWithCronTimerAndSignal() throws Exception { System.setProperty("jbpm.enable.multi.con", "true"); try { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Request photos of order in use", 1); - CountDownProcessEventListener countDownListener2 = new CountDownProcessEventListener("Request an online review", 1); - CountDownProcessEventListener countDownListener3 = new CountDownProcessEventListener("Send a thank you card", 1); - CountDownProcessEventListener countDownListener4 = new CountDownProcessEventListener("Request an online review", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Request photos of order in use", 1); + NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Request an online review", 1); + NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Send a thank you card", 1); + NodeLeftCountDownProcessEventListener countDownListener4 = new NodeLeftCountDownProcessEventListener("Request an online review", 1); KieBase kbase = createKnowledgeBase("timer/BPMN2-CronTimerWithEventBasedGateway.bpmn2"); ksession = createKnowledgeSession(kbase); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java index f725d805e5..2889c0eaa2 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java @@ -20,7 +20,7 @@ import org.jbpm.persistence.session.objects.TestWorkItemHandler; import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.ruleflow.core.RuleFlowProcessFactory; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.Test; import org.kie.internal.io.ResourceFactory; import org.kie.internal.runtime.StatefulKnowledgeSession; @@ -94,7 +94,7 @@ public void testCompositeNode() throws Exception { @Test(timeout=10000) public void testBoundaryTimerTimeCycle() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("BoundaryTimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("BoundaryTimerEvent", 1); RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.jbpm.process"); factory // header @@ -135,7 +135,7 @@ public void testBoundaryTimerTimeCycle() throws Exception { @Test(timeout=10000) public void testBoundaryTimerTimeDuration() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("BoundaryTimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("BoundaryTimerEvent", 1); RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.jbpm.process"); factory // header diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java index 819c5c1758..4f74f338f2 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java @@ -38,12 +38,10 @@ import org.jbpm.bpmn2.objects.ExceptionService; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; -import org.jbpm.process.audit.JPAAuditLogService; import org.jbpm.process.audit.VariableInstanceLog; import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; -import org.jbpm.test.util.CountDownProcessEventListener; -import org.junit.After; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -380,7 +378,7 @@ public void testEventBasedSplitAfter() throws Exception { @Test(timeout=10000) public void testEventBasedSplit2() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit2.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -551,7 +549,7 @@ public void testErrorBoundaryEvent() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEvent() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventDuration.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -564,7 +562,7 @@ public void testTimerBoundaryEvent() throws Exception { @Test(timeout=10000) public void testTimerBoundaryEventInterrupting() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventInterrupting.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -654,7 +652,7 @@ public void testIntermediateCatchEventMessage() throws Exception { @Test(timeout=10000) public void testIntermediateCatchEventTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -744,7 +742,7 @@ public void testConditionalStart() throws Exception { @Test(timeout=10000) public void testTimerStart() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5); KieBase kbase = createKnowledgeBase("BPMN2-TimerStart.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StartEventTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StartEventTest.java index e05d23a221..f143ff3f5c 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StartEventTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/StartEventTest.java @@ -31,7 +31,7 @@ import org.jbpm.bpmn2.objects.NotAvailableGoodsReport; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; @@ -105,7 +105,7 @@ public void testConditionalStart() throws Exception { @Test(timeout=10000) public void testTimerStartCycleLegacy() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5); KieBase kbase = createKnowledgeBase("BPMN2-TimerStartCycleLegacy.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -127,7 +127,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerStart() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5); KieBase kbase = createKnowledgeBase("BPMN2-TimerStart.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -145,7 +145,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerStartDateISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1); byte[] content = IoUtils.readBytesFromInputStream(this.getClass().getResourceAsStream("/BPMN2-TimerStartDate.bpmn2")); String processContent = new String(content, "UTF-8"); @@ -173,7 +173,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerStartCycleISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 6); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 6); KieBase kbase = createKnowledgeBase("BPMN2-TimerStartISO.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -191,7 +191,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerStartDuration() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1); KieBase kbase = createKnowledgeBase("BPMN2-TimerStartDuration.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -212,7 +212,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerStartCron() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5); KieBase kbase = createKnowledgeBase("BPMN2-TimerStartCron.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -333,7 +333,7 @@ public void testMultipleStartEventsRegularStart() throws Exception { @Test(timeout=10000) public void testMultipleStartEventsStartOnTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartTimer", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 5); KieBase kbase = createKnowledgeBase("BPMN2-MultipleStartEventProcess.bpmn2"); ksession = createKnowledgeSession(kbase); try { @@ -424,7 +424,7 @@ public void afterProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testMultipleEventBasedStartEventsTimerDifferentPaths() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartTimer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 2); KieBase kbase = createKnowledgeBase("BPMN2-MultipleStartEventProcessDifferentPaths.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -497,7 +497,7 @@ public void afterProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testMultipleEventBasedStartEventsStartOnTimer() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartTimer", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 5); KieBase kbase = createKnowledgeBase("BPMN2-MultipleEventBasedStartEventProcess.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -519,7 +519,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerCycle() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("start", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("start", 5); KieBase kbase = createKnowledgeBase("timer/BPMN2-StartTimerCycle.bpmn2"); ksession = createKnowledgeSession(kbase); @@ -535,7 +535,7 @@ public void testTimerCycle() throws Exception { @Test(timeout=10000) public void testSignalStartWithTransformation() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1); KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-SignalStartWithTransformation.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); @@ -559,7 +559,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { */ @Test(timeout=10000) public void testTimerDelay() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("start", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("start", 1); KieBase kbase = createKnowledgeBase("timer/BPMN2-StartTimerDuration.bpmn2"); ksession = createKnowledgeSession(kbase); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/TimerCycleOnBinaryPackageTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/TimerCycleOnBinaryPackageTest.java index 2321c1571a..2f4577e483 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/TimerCycleOnBinaryPackageTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/TimerCycleOnBinaryPackageTest.java @@ -22,7 +22,7 @@ import org.jbpm.process.audit.AuditLoggerFactory; import org.jbpm.process.audit.AuditLoggerFactory.Type; import org.jbpm.process.instance.event.listeners.TriggerRulesEventListener; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; @@ -68,7 +68,7 @@ public void dispose() { @Test(timeout=20000) public void testStartTimerCycleFromDisc() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("start", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("start", 2); KieBase kbase = createKnowledgeBaseFromDisc("BPMN2-StartTimerCycle.bpmn2"); try { StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); @@ -96,7 +96,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { logger.info("dispose"); ksession.dispose(); - countDownListener = new CountDownProcessEventListener("start", 2); + countDownListener = new NodeLeftCountDownProcessEventListener("start", 2); ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env); @@ -128,7 +128,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=20000) public void testStartTimerCycleFromClassPath() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("start", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("start", 2); KieBase kbase = createKnowledgeBase("BPMN2-StartTimerCycle.bpmn2"); try { StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); @@ -154,7 +154,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { logger.info("dispose"); ksession.dispose(); - countDownListener = new CountDownProcessEventListener("start", 2); + countDownListener = new NodeLeftCountDownProcessEventListener("start", 2); ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env); ksession.addEventListener(countDownListener); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/UnmarshallingOverdueTimersTest.java b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/UnmarshallingOverdueTimersTest.java index 000f67e73c..e50e166de2 100644 --- a/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/UnmarshallingOverdueTimersTest.java +++ b/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/persistence/UnmarshallingOverdueTimersTest.java @@ -30,8 +30,8 @@ import org.drools.core.impl.KnowledgeBaseFactory; import org.jbpm.bpmn2.concurrency.MultipleProcessesPerThreadTest; import org.jbpm.persistence.util.PersistenceUtil; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -102,7 +102,7 @@ private KieSession reloadStatefulKnowledgeSession(String bpmn2FileName, int kses @Test(timeout=10000) public void startDisposeAndReloadTimerProcess() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); if( debug ) { String shellVar = "TEST"; String shellVarVal = System.getenv(shellVar); diff --git a/jbpm-bpmn2/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java b/jbpm-bpmn2/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java deleted file mode 100644 index 4efe933240..0000000000 --- a/jbpm-bpmn2/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.test.util; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - private boolean reactOnBeforeNodeLeft = false; - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - public CountDownProcessEventListener(String nodeName, int threads, boolean reactOnBeforeNodeLeft) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - this.reactOnBeforeNodeLeft = reactOnBeforeNodeLeft; - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - @Override - public void beforeNodeLeft(ProcessNodeLeftEvent event) { - if (reactOnBeforeNodeLeft && nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownListenerFactory.java b/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownListenerFactory.java index e1c879c95c..1b83a2d31a 100644 --- a/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownListenerFactory.java +++ b/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownListenerFactory.java @@ -19,24 +19,26 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; + public class CountDownListenerFactory { - private static Map listeners = new ConcurrentHashMap<>(); + private static Map listeners = new ConcurrentHashMap<>(); - public static CountDownProcessEventListener get(String id, String nodeName, int threads) { + public static NodeLeftCountDownProcessEventListener get(String id, String nodeName, int threads) { if (listeners.containsKey(id)) { return listeners.get(id); } - CountDownProcessEventListener listener = new CountDownProcessEventListener(nodeName, threads); + NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener(nodeName, threads); listeners.put(id, listener); return listener; } - public static CountDownProcessEventListener getExisting(String id) { + public static NodeLeftCountDownProcessEventListener getExisting(String id) { return listeners.get(id); } - public static CountDownProcessEventListener removeExisting(String id) { + public static NodeLeftCountDownProcessEventListener removeExisting(String id) { return listeners.remove(id); } diff --git a/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownProcessEventListener.java b/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownProcessEventListener.java deleted file mode 100644 index 4fbb488e80..0000000000 --- a/jbpm-case-mgmt/jbpm-case-mgmt-impl/src/test/java/org/jbpm/casemgmt/impl/util/CountDownProcessEventListener.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.casemgmt.impl.util; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/pom.xml b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/pom.xml index 08aef4e56c..cb48f0a5b3 100644 --- a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/pom.xml +++ b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/pom.xml @@ -146,14 +146,15 @@ drools-core test - - org.drools - drools-persistence-api - org.jbpm jbpm-human-task-core + + org.jbpm + jbpm-test-util + test + org.jbpm jbpm-bpmn2 diff --git a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/archive/EJBService.java b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/archive/EJBService.java index a0a6b5e8b7..631cbecdf1 100644 --- a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/archive/EJBService.java +++ b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/archive/EJBService.java @@ -37,10 +37,10 @@ import org.jbpm.test.container.AbstractEJBServicesTest; import org.jbpm.test.container.AbstractRuntimeEJBServicesTest; import org.jbpm.test.container.JbpmContainerTest; -import org.jbpm.test.container.listeners.CountDownProcessEventListener; import org.jbpm.test.container.listeners.TrackingAgendaEventListener; import org.jbpm.test.container.tools.IntegrationMavenResolver; import org.jbpm.test.container.webspherefix.WebSphereFixedJtaPlatform; +import org.jbpm.test.listener.DefaultCountDownProcessEventListener; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -97,7 +97,7 @@ public WebArchive buildArchive() throws Exception { .addClass(EJBService.class) // Workaroud for https://hibernate.atlassian.net/browse/HHH-11606 .addClass(WebSphereFixedJtaPlatform.class) - .addClass(CountDownProcessEventListener.class) + .addClass(DefaultCountDownProcessEventListener.class) .addClass(JbpmContainerTest.class) .addClass(AbstractEJBServicesTest.class) .addClass(AbstractRuntimeEJBServicesTest.class) diff --git a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/ejbcompl/EThreadInfoTest.java b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/ejbcompl/EThreadInfoTest.java index 9cec228a9b..be2b028868 100644 --- a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/ejbcompl/EThreadInfoTest.java +++ b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/ejbcompl/EThreadInfoTest.java @@ -24,9 +24,9 @@ import org.assertj.core.api.Assertions; import org.jbpm.test.container.AbstractRuntimeEJBServicesTest; import org.jbpm.test.container.groups.EAP; -import org.jbpm.test.container.listeners.CountDownProcessEventListener; import org.jbpm.test.container.mock.RestService; import org.jbpm.services.api.model.VariableDesc; +import org.jbpm.test.listener.DefaultCountDownProcessEventListener; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -47,7 +47,7 @@ @Category({EAP.class}) public class EThreadInfoTest extends AbstractRuntimeEJBServicesTest { - private static CountDownProcessEventListener listener = new CountDownProcessEventListener() { + private static DefaultCountDownProcessEventListener listener = new DefaultCountDownProcessEventListener() { @Override public void afterProcessCompleted(ProcessCompletedEvent event) { if ("org.jboss.qa.bpms.ThreadInfo".equals(event.getProcessInstance().getProcessId())) { diff --git a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/tx/ETransactionTest.java b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/tx/ETransactionTest.java index f62c56dab0..118fef0830 100644 --- a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/tx/ETransactionTest.java +++ b/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/test/java/org/jbpm/test/container/test/ejbservices/tx/ETransactionTest.java @@ -35,8 +35,8 @@ import org.jbpm.test.container.groups.EAP; import org.jbpm.test.container.groups.WAS; import org.jbpm.test.container.groups.WLS; -import org.jbpm.test.container.listeners.CountDownProcessEventListener; import org.jbpm.test.container.listeners.TrackingAgendaEventListener; +import org.jbpm.test.listener.DefaultCountDownProcessEventListener; import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; @@ -246,7 +246,7 @@ public void testRuleFlowGroup() throws Exception { @Test public void testTimer() throws Exception { - CountDownProcessEventListener listener = new CountDownProcessEventListener(0) { + DefaultCountDownProcessEventListener listener = new DefaultCountDownProcessEventListener(0) { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { if ("Timer".equals(event.getNodeInstance().getNodeName())) { diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/ConcurrentOperationsTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/ConcurrentOperationsTest.java index 36b71adc16..2ef2b37640 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/ConcurrentOperationsTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/ConcurrentOperationsTest.java @@ -20,8 +20,8 @@ import org.jbpm.runtime.manager.impl.RuntimeEngineImpl; import org.jbpm.runtime.manager.util.TestUtil; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; import org.junit.Before; @@ -81,7 +81,7 @@ public void teardown() { @Test(timeout=10000) public void testExecuteProcessWithAsyncHandler() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Log", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Log", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) @@ -141,7 +141,7 @@ public List getProcessEventListeners(RuntimeEngine runtime @Test(timeout=10000) public void testExecuteHumanTaskWithAsyncHandler() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Log", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Log", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/MultiInstanceCallActivityRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/MultiInstanceCallActivityRuntimeManagerTest.java index a22b7b3b9f..f0611712bf 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/MultiInstanceCallActivityRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/MultiInstanceCallActivityRuntimeManagerTest.java @@ -31,8 +31,8 @@ import org.jbpm.runtime.manager.impl.jpa.EntityManagerFactoryManager; import org.jbpm.runtime.manager.util.TestUtil; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; import org.junit.Before; @@ -60,7 +60,7 @@ public class MultiInstanceCallActivityRuntimeManagerTest extends AbstractBaseTes private EntityManagerFactory emf; private RuntimeManager manager; - private CountDownProcessEventListener countDownListener; + private NodeLeftCountDownProcessEventListener countDownListener; private int numberOfChildProcesses = 15; @@ -143,7 +143,7 @@ public void testMultiInstanceCallactivityCompleteAtTheSameTime(Context startC private RuntimeEnvironment createEnvironment() { - countDownListener = new CountDownProcessEventListener("timer", numberOfChildProcesses); + countDownListener = new NodeLeftCountDownProcessEventListener("timer", numberOfChildProcesses); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java index ce1826c9d7..acee8d0b00 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java @@ -31,8 +31,8 @@ import org.jbpm.runtime.manager.impl.jpa.EntityManagerFactoryManager; import org.jbpm.runtime.manager.util.TestUtil; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; import org.junit.Before; @@ -370,7 +370,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testTimerOnPerCaseManager() throws Exception { final Set ksessionUsed = new HashSet(); - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); final List timerExpirations = new ArrayList(); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() @@ -483,7 +483,7 @@ public void testSignalEventWithDeactivate() { @Test(timeout=10000) public void testTimerStartWithDeactivate() { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManagerTest.java index cb2263ed2e..0e041a13e8 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerProcessInstanceRuntimeManagerTest.java @@ -42,8 +42,8 @@ import org.jbpm.services.task.audit.JPATaskLifeCycleEventListener; import org.jbpm.services.task.events.DefaultTaskEventListener; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; import org.junit.Before; @@ -704,7 +704,7 @@ public void close() { @Test(timeout=30000) public void testRestoreTimersAfterManagerClose() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); final List timerExpirations = new ArrayList(); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() @@ -1153,7 +1153,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout=10000) public void testReusableSubprocessWithWaitForCompletionFalse() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("SLATimer", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("SLATimer", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) @@ -1374,7 +1374,7 @@ public void testSignalEventWithDeactivate() { } @Test(timeout=10000) public void testTimerStartWithDeactivate() { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) @@ -1462,7 +1462,7 @@ public Map getWorkItemHandlers(RuntimeEngine runtime) { @Test(timeout=20000) public void testTimersOnMultiInstanceSubprocess() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("MIDelayTimer", 2); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("MIDelayTimer", 2); final List timerExpirations = new ArrayList(); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/SingletonRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/SingletonRuntimeManagerTest.java index 3006c0c060..9cb14c7365 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/SingletonRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/SingletonRuntimeManagerTest.java @@ -25,8 +25,8 @@ import org.jbpm.runtime.manager.impl.error.ExecutionErrorHandlerInterceptor; import org.jbpm.runtime.manager.util.TestUtil; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.jbpm.workflow.instance.WorkflowRuntimeException; import org.junit.After; @@ -847,7 +847,7 @@ public void testSignalEventWithDeactivate() { @Test(timeout=10000) public void testTimerStartWithDeactivate() { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .userGroupCallback(userGroupCallback) diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/TimerInitFailureRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/TimerInitFailureRuntimeManagerTest.java index 24d9f6e2d2..2ed20f5bf7 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/TimerInitFailureRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/TimerInitFailureRuntimeManagerTest.java @@ -33,8 +33,8 @@ import org.jbpm.runtime.manager.impl.jpa.EntityManagerFactoryManager; import org.jbpm.runtime.manager.util.TestUtil; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; import org.junit.Before; @@ -92,7 +92,7 @@ public void teardown() { @Test(timeout=15000) @BMScript(value = "byteman-scripts/failOnRuntimeManagerInitRules.btm") public void testPerProcessInstanceRuntimeManager() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Intermediate Catch Event 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Intermediate Catch Event 1", 1); RuntimeEnvironment environment = createEnvironment(countDownListener); manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first"); assertNotNull(manager); @@ -135,7 +135,7 @@ public void testPerProcessInstanceRuntimeManager() throws Exception { @Test(timeout=10000) @BMScript(value = "byteman-scripts/failOnRuntimeManagerInitRules.btm") public void testPerCaseRuntimeManager() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Intermediate Catch Event 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Intermediate Catch Event 1", 1); RuntimeEnvironment environment = createEnvironment(countDownListener); manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first"); assertNotNull(manager); @@ -178,7 +178,7 @@ public void testPerCaseRuntimeManager() throws Exception { } - private RuntimeEnvironment createEnvironment(CountDownProcessEventListener countDownListener) { + private RuntimeEnvironment createEnvironment(NodeLeftCountDownProcessEventListener countDownListener) { RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java b/jbpm-runtime-manager/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java deleted file mode 100644 index ec2aa4038f..0000000000 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.test.util; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncContinuationSupportTest.java b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncContinuationSupportTest.java index 894f97722b..84e12cb4c3 100644 --- a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncContinuationSupportTest.java +++ b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncContinuationSupportTest.java @@ -38,8 +38,9 @@ import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; +import org.jbpm.test.listener.NodeTriggeredCountDownProcessEventListener; import org.jbpm.test.util.AbstractExecutorBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.ExecutorTestUtil; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; @@ -104,7 +105,7 @@ public void teardown() { @Test(timeout=10000) public void testAsyncScriptTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncScriptTask.bpmn2"), ResourceType.BPMN2) @@ -191,7 +192,7 @@ public Map getWorkItemHandlers(RuntimeEngine runtime) { @Test(timeout=10000) public void testAsyncServiceTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncServiceProcess.bpmn2"), ResourceType.BPMN2) @@ -247,7 +248,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncMIUserTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1, true); + final NodeTriggeredCountDownProcessEventListener countDownListener = new NodeTriggeredCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2"), ResourceType.BPMN2) @@ -328,7 +329,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncMISubProcess() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-MultiInstanceLoopCharacteristicsProcess.bpmn2"), ResourceType.BPMN2) @@ -398,7 +399,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncSubProcess() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncSubProcess.bpmn2"), ResourceType.BPMN2) @@ -451,7 +452,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testSubProcessWithAsyncNodes() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-SubProcessAsyncNodes.bpmn2"), ResourceType.BPMN2) @@ -521,7 +522,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testSubProcessWithSomeAsyncNodes() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello2", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello2", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-SubProcessSomeAsyncNodes.bpmn2"), ResourceType.BPMN2) @@ -579,7 +580,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncCallActivityTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("CallActivity", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("CallActivity", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -631,7 +632,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncAndSyncServiceTasks() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Async Service", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Async Service", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncServiceTask.bpmn2"), ResourceType.BPMN2) @@ -697,7 +698,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncScriptTaskIgnoreNotExistingDeployments() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncScriptTask.bpmn2"), ResourceType.BPMN2) @@ -767,7 +768,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncModeWithScriptTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("EndProcess", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -827,7 +828,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testAsyncModeWithAsyncScriptTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("EndProcess", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncScriptTask.bpmn2"), ResourceType.BPMN2) @@ -886,7 +887,7 @@ public List getProcessEventListeners(RuntimeEngine runtime @Test(timeout=10000) public void testAsyncModeWithServiceTask() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("EndProcess", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ServiceProcess.bpmn2"), ResourceType.BPMN2) @@ -945,7 +946,7 @@ public List getProcessEventListeners(RuntimeEngine runtime @Test(timeout=10000) public void testAsyncModeWithSubProcess() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("EndProcess", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-SubProcess.bpmn2"), ResourceType.BPMN2) @@ -997,8 +998,8 @@ public List getProcessEventListeners(RuntimeEngine runtime @Test(timeout=10000) public void testAsyncModeWithSignalProcess() throws Exception { - final CountDownProcessEventListener countDownListenerSignalAsync = new CountDownProcessEventListener("Signal", 1, true); - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("EndProcess", 1); + final NodeTriggeredCountDownProcessEventListener countDownListenerSignalAsync = new NodeTriggeredCountDownProcessEventListener("Signal", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("EndProcess", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-WaitForEvent.bpmn2"), ResourceType.BPMN2) @@ -1059,7 +1060,7 @@ public List getProcessEventListeners(RuntimeEngine runtime @Test(timeout=10000) public void testAsyncParallelGateway() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("REST", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("REST", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-AsyncParallelGateway.bpmn2"), ResourceType.BPMN2) diff --git a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java index a6cfdfb70b..fcd5642ac2 100644 --- a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java +++ b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java @@ -49,8 +49,8 @@ import org.jbpm.services.task.events.DefaultTaskEventListener; import org.jbpm.services.task.exception.TaskExecutionException; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.AbstractExecutorBaseTest; -import org.jbpm.test.util.CountDownProcessEventListener; import org.jbpm.test.util.ExecutorTestUtil; import org.jbpm.test.util.PoolingDataSource; import org.junit.After; @@ -118,7 +118,7 @@ public void teardown() { @Test(timeout=10000) public void testRunProcessWithAsyncHandler() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Hello", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Hello", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -158,7 +158,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testRunProcessWithAsyncHandlerWithAbort() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -201,7 +201,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testRunProcessWithAsyncHandlerDuplicatedRegister() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -246,7 +246,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testRunProcessWithAsyncHandlerDelayed() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTaskWithParams.bpmn2"), ResourceType.BPMN2) @@ -289,7 +289,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testRunProcessWithAsyncHandlerAndReturnNullCommand() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -487,7 +487,7 @@ public Map getWorkItemHandlers(RuntimeEngine runtime) { @Test(timeout=10000) public void testRunProcessWithAsyncHandlerCallbackErrorRetry() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTaskWithError.bpmn2"), ResourceType.BPMN2) @@ -541,7 +541,7 @@ public List getProcessEventListeners( RuntimeEngine runtim @Test(timeout=10000) public void testRunProcessWithAsyncHandlerWthSecurityManager() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -602,7 +602,7 @@ public void checkPermission() throws SecurityException { @Test(timeout=20000) public void testRunProcessWithAsyncHandlerCallbackErrorRetryUpdateJobData() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) @@ -730,7 +730,7 @@ public Map getWorkItemHandlers(RuntimeEngine runtime) { @Test(timeout=10000) public void testRunProcessWithAsyncHandlerSkipExecutionError() throws Exception { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Handling error", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Handling error", 1); ((ExecutorServiceImpl) executorService).setRetries(0); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) diff --git a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java deleted file mode 100644 index 07e5e33e6e..0000000000 --- a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.test.util; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.kie.api.event.process.ProcessNodeTriggeredEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - private boolean reactOnNodeTriggered = false; - - public CountDownProcessEventListener() { - - } - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - public CountDownProcessEventListener(String nodeName, int threads, boolean reactOnNodeTriggered) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - this.reactOnNodeTriggered = reactOnNodeTriggered; - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - @Override - public void afterNodeTriggered(ProcessNodeTriggeredEvent event) { - if (reactOnNodeTriggered && nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownListenerFactory.java b/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownListenerFactory.java index b20508acc3..711c9af16d 100644 --- a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownListenerFactory.java +++ b/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownListenerFactory.java @@ -19,17 +19,19 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; + public class CountDownListenerFactory { - private static Map listeners = new ConcurrentHashMap<>(); + private static Map listeners = new ConcurrentHashMap<>(); private static Map tasklisteners = new ConcurrentHashMap<>(); - public static CountDownProcessEventListener get(String id, String nodeName, int threads) { + public static NodeLeftCountDownProcessEventListener get(String id, String nodeName, int threads) { if (listeners.containsKey(id)) { return listeners.get(id); } - CountDownProcessEventListener listener = new CountDownProcessEventListener(nodeName, threads); + NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener(nodeName, threads); listeners.put(id, listener); return listener; } @@ -43,11 +45,11 @@ public static CountDownTaskEventListener getTask(String id, int threads) { return listener; } - public static CountDownProcessEventListener getExisting(String id) { + public static NodeLeftCountDownProcessEventListener getExisting(String id) { return listeners.get(id); } - public static CountDownProcessEventListener removeExisting(String id) { + public static NodeLeftCountDownProcessEventListener removeExisting(String id) { return listeners.remove(id); } diff --git a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownProcessEventListener.java b/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownProcessEventListener.java deleted file mode 100644 index 8e8a9eed02..0000000000 --- a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/test/util/CountDownProcessEventListener.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.kie.test.util; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/pom.xml b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/pom.xml index 84ab36b911..54da60cc60 100644 --- a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/pom.xml +++ b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/pom.xml @@ -143,6 +143,12 @@ org.kie kie-internal + + + org.jbpm + jbpm-test-util + test + ch.qos.logback logback-classic diff --git a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/src/test/java/org/jbpm/services/ejb/test/AsyncExecutionProcessServiceEJBIntegrationTest.java b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/src/test/java/org/jbpm/services/ejb/test/AsyncExecutionProcessServiceEJBIntegrationTest.java index d7554ee85e..eaf57b0d63 100644 --- a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/src/test/java/org/jbpm/services/ejb/test/AsyncExecutionProcessServiceEJBIntegrationTest.java +++ b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-impl/src/test/java/org/jbpm/services/ejb/test/AsyncExecutionProcessServiceEJBIntegrationTest.java @@ -36,7 +36,7 @@ import org.jbpm.services.ejb.api.DeploymentServiceEJBLocal; import org.jbpm.services.ejb.api.ProcessServiceEJBLocal; import org.jbpm.services.ejb.api.RuntimeDataServiceEJBLocal; -import org.jbpm.test.util.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,7 +61,7 @@ public static WebArchive createDeployment() { } WebArchive war = ShrinkWrap.createFromZipFile(WebArchive.class, archive); war.addPackage("org.jbpm.services.ejb.test"); // test cases - war.addClass("org.jbpm.test.util.CountDownProcessEventListener"); + war.addClass("org.jbpm.test.listener.NodeLeftCountDownProcessEventListener"); // deploy test kjar deployKjar(); @@ -117,7 +117,7 @@ public void cleanup() { @Test public void testStartProcessWithParms() throws Exception { assertNotNull(deploymentService); - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); diff --git a/jbpm-test-coverage/src/main/java/org/jbpm/test/listener/CountDownProcessEventListener.java b/jbpm-test-coverage/src/main/java/org/jbpm/test/listener/CountDownProcessEventListener.java deleted file mode 100644 index 9b2676f9bb..0000000000 --- a/jbpm-test-coverage/src/main/java/org/jbpm/test/listener/CountDownProcessEventListener.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.test.listener; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.drools.persistence.api.TransactionManager; -import org.drools.persistence.api.TransactionManagerFactory; -import org.drools.persistence.api.TransactionSynchronization; -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - private boolean reactOnBeforeNodeLeft = false; - - public CountDownProcessEventListener() { - - } - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - public CountDownProcessEventListener(String nodeName, int threads, boolean reactOnBeforeNodeLeft) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - this.reactOnBeforeNodeLeft = reactOnBeforeNodeLeft; - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - @Override - public void beforeNodeLeft(ProcessNodeLeftEvent event) { - if (reactOnBeforeNodeLeft && nodeName.equals(event.getNodeInstance().getNodeName())) { - countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void reset(int threads) { - this.latch = new CountDownLatch(threads); - } - - public void reset(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - protected void countDown() { - try { - TransactionManager tm = TransactionManagerFactory.get().newTransactionManager(); - if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION - && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK - && tm.getStatus() != TransactionManager.STATUS_COMMITTED) { - tm.registerTransactionSynchronization(new TransactionSynchronization() { - - @Override - public void beforeCompletion() { - } - - @Override - public void afterCompletion(int status) { - latch.countDown(); - } - }); - } else { - latch.countDown(); - } - } catch (Exception e) { - latch.countDown(); - } - } -} diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncThreadContinuationTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncThreadContinuationTest.java index b2bccdf7a5..cf1e8afd0c 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncThreadContinuationTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncThreadContinuationTest.java @@ -24,7 +24,7 @@ import org.assertj.core.api.Assertions; import org.jbpm.executor.ExecutorServiceFactory; import org.jbpm.test.JbpmTestCase; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.test.wih.FirstErrorWorkItemHandler; import org.junit.After; import org.junit.Before; @@ -126,7 +126,7 @@ public void testRepeatFailingSyncTask() { @Test(timeout = 10000) public void testRepeatIntermediateTimerAfterException() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("MySignal", 1, true); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("MySignal", 1, true); KieSession ksession = createKSession(BPMN_IT); ksession.addEventListener(countDownListener); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/event/BoundaryEventOnTaskWithCalendarTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/event/BoundaryEventOnTaskWithCalendarTest.java index 0f3bb43fcb..9d4ddc29a5 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/event/BoundaryEventOnTaskWithCalendarTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/event/BoundaryEventOnTaskWithCalendarTest.java @@ -23,7 +23,7 @@ import org.drools.core.time.TimeUtils; import org.jbpm.process.core.timer.BusinessCalendarImpl; import org.jbpm.test.JbpmTestCase; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.Test; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.manager.RuntimeEngine; @@ -40,7 +40,7 @@ public BoundaryEventOnTaskWithCalendarTest() { @Test(timeout=10000) public void testProcess() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("deadline1", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("deadline1", 1); addProcessEventListener(countDownListener); createRuntimeManager("org/jbpm/test/functional/event/BoundaryEventWithCalendar.bpmn2"); RuntimeEngine runtimeEngine = getRuntimeEngine(); @@ -68,7 +68,7 @@ public void testProcess() throws Exception { @Test(timeout=10000) public void testProcessWithTimeCycleISO() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("deadline1", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("deadline1", 1); addProcessEventListener(countDownListener); createRuntimeManager("org/jbpm/test/functional/event/BoundaryEventWithCycleCalendar.bpmn2"); RuntimeEngine runtimeEngine = getRuntimeEngine(); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskCallbackTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskCallbackTest.java index e9b9cd0ad7..ec99693eaa 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskCallbackTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskCallbackTest.java @@ -24,7 +24,7 @@ import org.jbpm.process.audit.JPAAuditLogService; import org.jbpm.process.audit.VariableInstanceLog; import org.jbpm.test.JbpmAsyncJobTestCase; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.Test; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.process.ProcessInstance; @@ -74,7 +74,7 @@ public void tearDown() throws Exception { @Test(timeout=30000) public void testTaskCallback() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Continue", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Continue", 1); addProcessEventListener(countDownListener); KieSession ksession = createKSession(ASYNC_EXECUTOR_CALLBACK, ASYNC_DATA_EXECUTOR); WorkItemManager wim = ksession.getWorkItemManager(); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskTest.java index 6f3c5ef030..890f3a8446 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskTest.java @@ -24,7 +24,7 @@ import org.jbpm.executor.impl.wih.AsyncWorkItemHandler; import org.jbpm.test.JbpmAsyncJobTestCase; import org.jbpm.test.listener.CountDownAsyncJobListener; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.Test; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.process.ProcessInstance; @@ -49,7 +49,7 @@ public class AsyncTaskTest extends JbpmAsyncJobTestCase { @Test(timeout=10000) public void testTaskErrorHandling() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Task 1", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); addProcessEventListener(countDownListener); KieSession ksession = createKSession(ASYNC_EXECUTOR); WorkItemManager wim = ksession.getWorkItemManager(); @@ -82,7 +82,7 @@ public void testTaskErrorHandling() throws Exception { @Test(timeout=10000) @BZ("1121027") public void testTaskComplete() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Process async", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Process async", 1); CountDownAsyncJobListener countDownJobListener = new CountDownAsyncJobListener(1); try { ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownJobListener); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/ExceptionAfterTimerNodeTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/ExceptionAfterTimerNodeTest.java index d15d696fb9..9776852563 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/ExceptionAfterTimerNodeTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/ExceptionAfterTimerNodeTest.java @@ -20,7 +20,7 @@ import java.util.Collection; import org.jbpm.test.JbpmTestCase; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -64,7 +64,7 @@ public void cleanup() { @Test(timeout=10000) public void testExceptionAfterTimer() { - final CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("TimerEvent", 1, true); + final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1, true); createRuntimeManager("org/jbpm/test/functional/timer/ExceptionAfterTimer.bpmn2"); RuntimeEngine runtimeEngine = getRuntimeEngine(); KieSession ksession = runtimeEngine.getKieSession(); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalQuartzDBTimerServiceTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalQuartzDBTimerServiceTest.java index 757b44e412..1b1fd5bbf4 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalQuartzDBTimerServiceTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalQuartzDBTimerServiceTest.java @@ -37,7 +37,7 @@ import org.jbpm.process.core.timer.impl.QuartzSchedulerService; import org.jbpm.runtime.manager.impl.AbstractRuntimeManager; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -124,7 +124,7 @@ protected RuntimeManager getManager(RuntimeEnvironment environment, boolean wait @Test(timeout=20000) public void testTimerStartManagerClose() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 3); QuartzSchedulerService additionalCopy = new QuartzSchedulerService(); additionalCopy.initScheduler(null); // prepare listener to assert results @@ -261,7 +261,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=20000) public void testContinueTimer() throws Exception { // JBPM-4443 - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -359,7 +359,7 @@ public void testContinueTimerWithMisfire() throws Exception { // RHBPMS-4729 System.setProperty("org.quartz.properties", "quartz-db-short-misfire.properties"); - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 2); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalThreadPoolTimerServiceTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalThreadPoolTimerServiceTest.java index 7c5d1354d7..1559e6f9ab 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalThreadPoolTimerServiceTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalThreadPoolTimerServiceTest.java @@ -20,14 +20,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import javax.persistence.Persistence; import org.jbpm.process.core.timer.impl.ThreadPoolSchedulerService; import org.jbpm.test.functional.timer.addon.TransactionalThreadPoolSchedulerService; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -95,7 +93,7 @@ protected RuntimeManager getManager(RuntimeEnvironment environment, boolean wait @Test(timeout=20000) public void testInterediateTimerWithGlobalTestServiceWithinTransaction() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); globalScheduler = new TransactionalThreadPoolSchedulerService(3); // prepare listener to assert results diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceBaseTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceBaseTest.java index 8905599f39..152eea204c 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceBaseTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceBaseTest.java @@ -41,14 +41,12 @@ import org.jbpm.persistence.jta.ContainerManagedTransactionManager; import org.jbpm.process.core.timer.GlobalSchedulerService; import org.jbpm.process.core.timer.TimerServiceRegistry; -import org.jbpm.process.core.timer.impl.QuartzSchedulerService; import org.jbpm.runtime.manager.impl.AbstractRuntimeManager; import org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment; import org.jbpm.runtime.manager.impl.jpa.EntityManagerFactoryManager; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; import org.jbpm.services.task.persistence.JPATaskPersistenceContextManager; -import org.jbpm.test.functional.timer.TimerBaseTest.TestRegisterableItemsFactory; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.jbpm.workflow.instance.WorkflowProcessInstance; import org.jbpm.workflow.instance.node.HumanTaskNodeInstance; import org.junit.Ignore; @@ -113,7 +111,7 @@ public void cleanup() { @Test(timeout=20000) public void testInterediateTimerWithGlobalTestService() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -169,7 +167,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=20000) public void testTimerStart() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("StartProcess", 5); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 5); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -239,7 +237,7 @@ public void beforeMatchFired(BeforeMatchFiredEvent event) { @Test(timeout=20000) public void testInterediateTimerWithHTAfterWithGlobalTestService() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); // prepare listener to assert results final List timerExpirations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -309,7 +307,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=20000) public void testInterediateTimerWithHTBeforeWithGlobalTestService() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -726,7 +724,7 @@ public void testHumanTaskDeadlineWithGlobalTimerServiceMultipleInstances() throw @Test(timeout=20000) public void testInterediateTimerWithGlobalTestServiceSimulateCMT() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ @@ -841,7 +839,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test(timeout=20000) public void testTimerFailureAndRetrigger() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Timer_1m", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer_1m", 3); final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceVolumeTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceVolumeTest.java index 8fd62e6d42..848bb56aa8 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceVolumeTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceVolumeTest.java @@ -40,7 +40,7 @@ import org.jbpm.process.core.timer.impl.GlobalTimerService.GlobalJobHandle; import org.jbpm.process.core.timer.impl.QuartzSchedulerService; import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -88,7 +88,7 @@ public class GlobalTimerServiceVolumeTest extends TimerBaseTest { private EntityManagerFactory emf; private int numberOfProcesses = 10; - private CountDownProcessEventListener countDownListener; + private NodeLeftCountDownProcessEventListener countDownListener; @Parameters(name = "Strategy : {0}") public static Collection data() { @@ -122,7 +122,7 @@ public void setup() { emf = Persistence.createEntityManagerFactory("org.jbpm.test.persistence"); - countDownListener = new CountDownProcessEventListener("timer", numberOfProcesses); + countDownListener = new NodeLeftCountDownProcessEventListener("timer", numberOfProcesses); // prepare listener to assert results final List timerExporations = new ArrayList(); ProcessEventListener listener = new DefaultProcessEventListener(){ diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/MultipleTimerServicesTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/MultipleTimerServicesTest.java index f0ea8c9364..8d2bd3cb97 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/MultipleTimerServicesTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/MultipleTimerServicesTest.java @@ -28,7 +28,7 @@ import org.jbpm.process.core.timer.GlobalSchedulerService; import org.jbpm.process.core.timer.impl.QuartzSchedulerService; import org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -133,9 +133,9 @@ public void testGlobalTimerServiceOnIndependentProcessInstanceManager() throws E } public void testGlobalTimerServiceOnIndependentManager() throws Exception { - - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("timer", 3); - CountDownProcessEventListener countDownListener2 = new CountDownProcessEventListener("timer", 3); + + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); + NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("timer", 3); // prepare listener to assert results final List timerExporations = new ArrayList(); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/TimerUpdateTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/TimerUpdateTest.java index bc824911f7..a132a5eba8 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/TimerUpdateTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/TimerUpdateTest.java @@ -21,7 +21,7 @@ import org.assertj.core.api.Assertions; import org.jbpm.process.instance.command.UpdateTimerCommand; import org.jbpm.test.JbpmTestCase; -import org.jbpm.test.listener.CountDownProcessEventListener; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.Before; import org.junit.Test; import org.kie.api.event.process.DefaultProcessEventListener; @@ -72,7 +72,7 @@ public void setup() { @Test(timeout = 30000) public void updateTimerLongerDelayTest() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener(TIMER_NAME, 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(TIMER_NAME, 1); //delay is set for 5s setProcessScenario(TIMER_FILE); @@ -104,7 +104,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout = 30000) public void updateTimerShortherDelayTest() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener(TIMER_NAME, 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(TIMER_NAME, 1); //delay is set for 5s setProcessScenario(TIMER_FILE); @@ -136,7 +136,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout = 30000) public void updateTimerBeforeDelayTest() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener(TIMER_NAME, 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(TIMER_NAME, 1); //delay is set for 5s setProcessScenario(TIMER_FILE); @@ -168,7 +168,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout = 30000) public void updateBoundaryTimerTest() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener(BOUNDARY_TIMER_NAME, 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(BOUNDARY_TIMER_NAME, 1); //timer is set for long duration (100s) setProcessScenario(BOUNDARY_TIMER_FILE); @@ -200,7 +200,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test(timeout = 30000) public void updateTimerSubprocessLongerDelayTest() { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener(TIMER_SUBPROCESS_NAME, 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(TIMER_SUBPROCESS_NAME, 1); //delay is set for 5s setProcessScenario(TIMER_SUBPROCESS_FILE); diff --git a/jbpm-test-coverage/src/test/resources/org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT2.bpmn2 b/jbpm-test-coverage/src/test/resources/org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT2.bpmn2 index 64894cfae3..332830c78b 100644 --- a/jbpm-test-coverage/src/test/resources/org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT2.bpmn2 +++ b/jbpm-test-coverage/src/test/resources/org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT2.bpmn2 @@ -104,7 +104,7 @@ - + diff --git a/jbpm-test-util/pom.xml b/jbpm-test-util/pom.xml index 59dab3eedc..c0260ebaa0 100644 --- a/jbpm-test-util/pom.xml +++ b/jbpm-test-util/pom.xml @@ -16,6 +16,14 @@ jBPM Test Util + + org.kie + kie-api + + + org.drools + drools-persistence-api + org.jboss.narayana.jta narayana-jta diff --git a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/main/java/org/jbpm/test/container/listeners/CountDownProcessEventListener.java b/jbpm-test-util/src/main/java/org/jbpm/test/listener/DefaultCountDownProcessEventListener.java similarity index 89% rename from jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/main/java/org/jbpm/test/container/listeners/CountDownProcessEventListener.java rename to jbpm-test-util/src/main/java/org/jbpm/test/listener/DefaultCountDownProcessEventListener.java index 8f330c3d7f..5933b7fd07 100644 --- a/jbpm-container-test/jbpm-in-container-test/jbpm-container-test-suite/src/main/java/org/jbpm/test/container/listeners/CountDownProcessEventListener.java +++ b/jbpm-test-util/src/main/java/org/jbpm/test/listener/DefaultCountDownProcessEventListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jbpm.test.container.listeners; +package org.jbpm.test.listener; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -27,17 +27,17 @@ import org.slf4j.LoggerFactory; -public class CountDownProcessEventListener extends DefaultProcessEventListener { +public class DefaultCountDownProcessEventListener extends DefaultProcessEventListener { - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultCountDownProcessEventListener.class); - private CountDownLatch latch; + protected CountDownLatch latch; - public CountDownProcessEventListener() { + public DefaultCountDownProcessEventListener() { } - public CountDownProcessEventListener(int threads) { + public DefaultCountDownProcessEventListener(int threads) { this.latch = new CountDownLatch(threads); } diff --git a/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeCountDownProcessEventListener.java b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeCountDownProcessEventListener.java new file mode 100644 index 0000000000..748d191612 --- /dev/null +++ b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeCountDownProcessEventListener.java @@ -0,0 +1,41 @@ +/* + * Copyright 2017 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jbpm.test.listener; + +import java.util.concurrent.CountDownLatch; + +import org.kie.api.event.process.ProcessNodeLeftEvent; + + +public class NodeCountDownProcessEventListener extends DefaultCountDownProcessEventListener { + + protected String nodeName; + + public NodeCountDownProcessEventListener() { + + } + + public NodeCountDownProcessEventListener(String nodeName, int threads) { + super(threads); + this.nodeName = nodeName; + } + + public void reset(String nodeName, int threads) { + this.nodeName = nodeName; + this.latch = new CountDownLatch(threads); + } +} diff --git a/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeLeftCountDownProcessEventListener.java b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeLeftCountDownProcessEventListener.java new file mode 100644 index 0000000000..68a7e5b522 --- /dev/null +++ b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeLeftCountDownProcessEventListener.java @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jbpm.test.listener; + +import org.kie.api.event.process.ProcessNodeLeftEvent; + + +public class NodeLeftCountDownProcessEventListener extends NodeCountDownProcessEventListener { + + private boolean reactOnBeforeNodeLeft = false; + + public NodeLeftCountDownProcessEventListener() { + + } + + public NodeLeftCountDownProcessEventListener(String nodeName, int threads) { + super(nodeName, threads); + } + + public NodeLeftCountDownProcessEventListener(String nodeName, int threads, boolean reactOnBeforeNodeLeft) { + super(nodeName, threads); + this.reactOnBeforeNodeLeft = reactOnBeforeNodeLeft; + } + + @Override + public void afterNodeLeft(ProcessNodeLeftEvent event) { + if (nodeName.equals(event.getNodeInstance().getNodeName())) { + countDown(); + } + } + + @Override + public void beforeNodeLeft(ProcessNodeLeftEvent event) { + if (reactOnBeforeNodeLeft && nodeName.equals(event.getNodeInstance().getNodeName())) { + countDown(); + } + } +} diff --git a/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeTriggeredCountDownProcessEventListener.java b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeTriggeredCountDownProcessEventListener.java new file mode 100644 index 0000000000..9796045026 --- /dev/null +++ b/jbpm-test-util/src/main/java/org/jbpm/test/listener/NodeTriggeredCountDownProcessEventListener.java @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jbpm.test.listener; + +import org.kie.api.event.process.ProcessNodeTriggeredEvent; + + +public class NodeTriggeredCountDownProcessEventListener extends NodeCountDownProcessEventListener { + + private boolean reactOnBeforeNodeTriggered = false; + + public NodeTriggeredCountDownProcessEventListener() { + + } + + public NodeTriggeredCountDownProcessEventListener(String nodeName, int threads) { + super(nodeName, threads); + } + + public NodeTriggeredCountDownProcessEventListener(String nodeName, int threads, boolean reactOnBeforeNodeTriggered) { + super(nodeName, threads); + this.reactOnBeforeNodeTriggered = reactOnBeforeNodeTriggered; + } + + @Override + public void afterNodeTriggered(ProcessNodeTriggeredEvent event) { + if (nodeName.equals(event.getNodeInstance().getNodeName())) { + countDown(); + } + } + + @Override + public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { + if (reactOnBeforeNodeTriggered && nodeName.equals(event.getNodeInstance().getNodeName())) { + countDown(); + } + } +} diff --git a/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/CountDownProcessEventListener.java b/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/CountDownProcessEventListener.java deleted file mode 100644 index 3f7e0cfb82..0000000000 --- a/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/CountDownProcessEventListener.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.process.workitem.bpmn2; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private CountDownLatch latch; - - public CountDownProcessEventListener(String nodeName, int threads) { - this.nodeName = nodeName; - this.latch = new CountDownLatch(threads); - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - latch.countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName); - } - } -} diff --git a/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/JaxWSServiceTaskTest.java b/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/JaxWSServiceTaskTest.java index 90462f344a..d60c59cdd1 100644 --- a/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/JaxWSServiceTaskTest.java +++ b/jbpm-workitems/jbpm-workitems-bpmn2/src/test/java/org/jbpm/process/workitem/bpmn2/JaxWSServiceTaskTest.java @@ -30,6 +30,7 @@ import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl; import org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler; import org.jbpm.test.AbstractBaseTest; +import org.jbpm.test.listener.NodeLeftCountDownProcessEventListener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -86,7 +87,7 @@ public void testServiceInvocation() throws Exception { @Test(timeout = 10000) public void testAsyncServiceInvocation() throws Exception { - CountDownProcessEventListener countDownListener = new CountDownProcessEventListener("Service Task", + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Service Task", 1); KieBase kbase = readKnowledgeBase(); KieSession ksession = createSession(kbase); diff --git a/jbpm-workitems/jbpm-workitems-core/src/test/java/org/jbpm/process/workitem/core/CountDownProcessEventListener.java b/jbpm-workitems/jbpm-workitems-core/src/test/java/org/jbpm/process/workitem/core/CountDownProcessEventListener.java deleted file mode 100644 index 1d85c46c0d..0000000000 --- a/jbpm-workitems/jbpm-workitems-core/src/test/java/org/jbpm/process/workitem/core/CountDownProcessEventListener.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jbpm.process.workitem.core; - -import org.kie.api.event.process.DefaultProcessEventListener; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CountDownProcessEventListener extends DefaultProcessEventListener { - - private static final Logger logger = LoggerFactory.getLogger(CountDownProcessEventListener.class); - - private String nodeName; - private java.util.concurrent.CountDownLatch latch; - - public CountDownProcessEventListener(String nodeName, - int threads) { - this.nodeName = nodeName; - this.latch = new java.util.concurrent.CountDownLatch(threads); - } - - @Override - public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (nodeName.equals(event.getNodeInstance().getNodeName())) { - latch.countDown(); - } - } - - public void waitTillCompleted() { - try { - latch.await(); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", - nodeName); - } - } - - public void waitTillCompleted(long timeOut) { - try { - latch.await(timeOut, - java.util.concurrent.TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.debug("Interrputed thread while waiting for all triggers for node {}", - nodeName); - } - } -}