Skip to content

Commit

Permalink
fixed all non-idempotent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyaok2 committed May 29, 2024
1 parent 492f41a commit d8783b3
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public void testRunMultiEventProcessPerProcessInstanceRuntimeManager() {

processInstance = ksession.getProcessInstance(processInstance.getId());
assertNull(processInstance);

manager.disposeRuntimeEngine(runtime);

// close manager which will close session maintained by the manager
manager.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) {
assertEquals(ksession1Id, ksessionUsed.iterator().next().longValue());


manager.disposeRuntimeEngine(runtime);
manager.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public void testMultiplePerRequestManagerFromSingleThread() {
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance2.getState());

manager.disposeRuntimeEngine(runtime1);
manager.disposeRuntimeEngine(runtime2);
manager2.disposeRuntimeEngine(runtime2);

// close manager which will close session maintained by the manager
manager.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {

@Test(timeout=10000)
public void testRunProcessWithAsyncHandlerCallbackErrorRetry() throws Exception {
int initialIncrement = IncrementService.get();
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder()
.userGroupCallback(userGroupCallback)
Expand Down Expand Up @@ -527,7 +528,7 @@ public List<ProcessEventListener> getProcessEventListeners( RuntimeEngine runtim
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);

assertEquals(0, IncrementService.get());
assertEquals(initialIncrement, IncrementService.get());

Map<String, Object> params = new HashMap<String, Object>();
params.put("retryAsync", "1s, 2s, 4s");
Expand All @@ -548,7 +549,7 @@ public List<ProcessEventListener> getProcessEventListeners( RuntimeEngine runtim
processInstance = ksession.getProcessInstance(processInstance.getId());
assertNull(processInstance);

assertEquals(1, IncrementService.get());
assertEquals(initialIncrement + 1, IncrementService.get());
}

@Test(timeout=10000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public void testSerializationClassesLimitedInDeploymentItself() {
limitDeploymentUnit.setDeploymentDescriptor(depDesc);

deploymentService.deploy(limitDeploymentUnit);
units.add(limitDeploymentUnit);
verifyDeployedUnitContainsCorrectClasses(limitDeploymentUnit);

depDesc = new DeploymentDescriptorImpl().getBuilder()
Expand All @@ -364,6 +365,7 @@ public void testSerializationClassesLimitedInDeploymentItself() {
allDeploymentUnit.setDeploymentDescriptor(depDesc);

deploymentService.deploy(allDeploymentUnit);
units.add(allDeploymentUnit);
verifyDeployedUnitContainsCorrectClasses(allDeploymentUnit);
}

Expand Down Expand Up @@ -427,6 +429,7 @@ public void testSerializationClassesLimitedInDeploymentDependencies() {
.get();
childDeploymentUnit.setDeploymentDescriptor(depDesc);
deploymentService.deploy(childDeploymentUnit);
units.add(childDeploymentUnit);

KModuleDeploymentUnit parentDeploymentUnit = new KModuleDeploymentUnit(groupId, parentArtifactId, version);
DeploymentDescriptor parentDepDesc = new DeploymentDescriptorImpl().getBuilder()
Expand All @@ -435,6 +438,7 @@ public void testSerializationClassesLimitedInDeploymentDependencies() {
parentDeploymentUnit.setDeploymentDescriptor(parentDepDesc);

deploymentService.deploy(parentDeploymentUnit);
units.add(parentDeploymentUnit);

verifyDeployedUnitContainsCorrectClasses(parentDeploymentUnit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class AsyncMultisubprocessTest extends JbpmTestCase {

private static CountDownLatch latch = new CountDownLatch(1);
private CountDownLatch latch;

private static final String BPMN_AICS = "org/jbpm/test/functional/async/AsyncSubMultiprocess.bpmn2";
private static final String PROCESS_AICS = "TestSubMult";
Expand All @@ -55,6 +55,7 @@ public class AsyncMultisubprocessTest extends JbpmTestCase {
public void setUp() throws Exception {
setupDataSource = true;
super.setUp();
latch = new CountDownLatch(1);

executorService = ExecutorServiceFactory.newExecutorService(getEmf());
executorService.setInterval(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jbpm.test.JbpmTestCase;
import org.jbpm.test.entity.Application;
import org.jbpm.test.entity.Person;
import org.junit.After;
import org.junit.Test;
import org.kie.api.marshalling.ObjectMarshallingStrategy;
import org.kie.api.runtime.EnvironmentName;
Expand All @@ -59,6 +60,16 @@ public ParentChildMarshallingJpaTest() {
super(true, true);
}

@After
public void tearDown() {
EntityManager em = emfDomain.createEntityManager();
em.getTransaction().begin();
em.createQuery("DELETE FROM Application WHERE person IS NOT NULL").executeUpdate();
em.createQuery("DELETE FROM Person").executeUpdate();
em.getTransaction().commit();
em.close();
}

@Test
public void testProcess() throws Exception {

Expand Down Expand Up @@ -120,6 +131,9 @@ public void testProcess() throws Exception {
int size = em.createQuery("select i from Person i").getResultList().size();
assertEquals(1, size);

// close manager which will close session maintained by the manager
manager.close();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ public void testRulesAndProcesses() throws Exception {
checkTotalSessions(aggrMonitor2, 3);
checkStatsForProcess(aggrMonitor2, "com.sample.HelloWorld" ,6,6,18);
checkStatsForProcess(aggrMonitor2, "com.sample.CiaoWorld" ,3,3,9);

kc.dispose();
}

private void checkStatsForProcess(GenericKieSessionMonitoringMXBean mb, String ruleName, long iStarted, long iCompleted, long nodesTriggered) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void tearDown() {
} catch (Exception ex) {
ex.printStackTrace();
}
CounterCommand.resetCounter();
}

public static class CounterCommand implements Command {
Expand All @@ -97,6 +98,10 @@ public static int getCounter() {
return counter;
}

public static void resetCounter() {
counter = 0;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public void setClientApiVersion() {

@Test
public void testPooledClientCreationWithDefaultTimeouts() {
// clear cached client to ensure starting from fresh state
RESTWorkItemHandler.cachedClient = null;

RESTWorkItemHandler handler = spy(RESTWorkItemHandler.class);
when(handler.getDoCacheClient()).thenReturn(true);

Expand Down

0 comments on commit d8783b3

Please sign in to comment.