From 00c8f813cbf6008e57b5f38edcec5296aae608f0 Mon Sep 17 00:00:00 2001 From: Tijs Rademakers Date: Thu, 3 Aug 2023 09:49:23 +0200 Subject: [PATCH] More Flowable5 unit test fixes --- .../test/deployment/DeploymentTest.java | 129 ++++++++++-------- .../impl/webservice/MaxValueReachedFault.java | 2 +- .../webservice/WebServiceDataStructure.java | 4 +- .../impl/webservice/WebServiceMock.java | 6 +- .../impl/webservice/WebServiceMockImpl.java | 2 +- modules/flowable5-spring-test/pom.xml | 5 + .../spring/test/email/JndiEmailTest.java | 4 +- .../src/test/resources/jndi.properties | 4 + 8 files changed, 90 insertions(+), 66 deletions(-) create mode 100644 modules/flowable5-spring-test/src/test/resources/jndi.properties diff --git a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/deployment/DeploymentTest.java b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/deployment/DeploymentTest.java index 55b79201909..605f242e45c 100644 --- a/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/deployment/DeploymentTest.java +++ b/modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/deployment/DeploymentTest.java @@ -382,64 +382,77 @@ public void multipleSameDeploymentsInTenant() throws Exception { @Test public void multipleDeploymentsInTenant() throws Exception { - repositoryService.createDeployment() - .name("deploymentA") - .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple.dmn") - .tenantId("myTenant") - .enableDuplicateFiltering() - .deploy(); - - org.flowable.dmn.api.DmnDeployment deployment = repositoryService.createDeploymentQuery() - .deploymentName("deploymentA") - .deploymentTenantId("myTenant") - .singleResult(); - assertThat(deployment).isNotNull(); - - List decisions = repositoryService.createDecisionQuery() - .decisionKey("decision") - .decisionTenantId("myTenant") - .list(); - assertThat(decisions).hasSize(1); - - repositoryService.createDeployment() - .name("deploymentA") - .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple2.dmn") - .tenantId("myTenant") - .enableDuplicateFiltering() - .deploy(); - - List deployments = repositoryService.createDeploymentQuery() - .deploymentName("deploymentA") - .deploymentTenantId("myTenant") - .list(); - assertThat(deployments).hasSize(2); - - decisions = repositoryService.createDecisionQuery() - .decisionKey("anotherDecision") - .decisionTenantId("myTenant") - .list(); - assertThat(decisions).hasSize(1); - - repositoryService.createDeployment() - .name("deploymentA") - .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple2.dmn") - .tenantId("myTenant") - .enableDuplicateFiltering() - .deploy(); - - deployments = repositoryService.createDeploymentQuery() - .deploymentName("deploymentA") - .deploymentTenantId("myTenant") - .list(); - assertThat(deployments).hasSize(2); - - decisions = repositoryService.createDecisionQuery() - .decisionKey("anotherDecision") - .decisionTenantId("myTenant") - .list(); - assertThat(decisions).hasSize(1); - - deleteDeployments(); + try { + repositoryService.createDeployment() + .name("deploymentA") + .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple.dmn") + .tenantId("myTenant") + .enableDuplicateFiltering() + .deploy(); + + org.flowable.dmn.api.DmnDeployment deployment = repositoryService.createDeploymentQuery() + .deploymentName("deploymentA") + .deploymentTenantId("myTenant") + .singleResult(); + assertThat(deployment).isNotNull(); + + List decisions = repositoryService.createDecisionQuery() + .decisionKey("decision") + .decisionTenantId("myTenant") + .list(); + assertThat(decisions).hasSize(1); + + Calendar deployCal = new GregorianCalendar(); + deployCal.add(Calendar.DATE, 2); + dmnEngineConfiguration.getClock().setCurrentTime(deployCal.getTime()); + + repositoryService.createDeployment() + .name("deploymentA") + .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple2.dmn") + .tenantId("myTenant") + .enableDuplicateFiltering() + .deploy(); + + List deployments = repositoryService.createDeploymentQuery() + .deploymentName("deploymentA") + .deploymentTenantId("myTenant") + .list(); + assertThat(deployments).hasSize(2); + + decisions = repositoryService.createDecisionQuery() + .decisionKey("anotherDecision") + .decisionTenantId("myTenant") + .list(); + assertThat(decisions).hasSize(1); + + deployCal = new GregorianCalendar(); + deployCal.add(Calendar.DATE, 4); + dmnEngineConfiguration.getClock().setCurrentTime(deployCal.getTime()); + + repositoryService.createDeployment() + .name("deploymentA") + .addClasspathResource("org/flowable/dmn/engine/test/deployment/simple2.dmn") + .tenantId("myTenant") + .enableDuplicateFiltering() + .deploy(); + + deployments = repositoryService.createDeploymentQuery() + .deploymentName("deploymentA") + .deploymentTenantId("myTenant") + .list(); + assertThat(deployments).hasSize(2); + + decisions = repositoryService.createDecisionQuery() + .decisionKey("anotherDecision") + .decisionTenantId("myTenant") + .list(); + assertThat(decisions).hasSize(1); + + deleteDeployments(); + + } finally { + dmnEngineConfiguration.getClock().reset(); + } } @Test diff --git a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/MaxValueReachedFault.java b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/MaxValueReachedFault.java index ec125ffde92..fd42ac41544 100644 --- a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/MaxValueReachedFault.java +++ b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/MaxValueReachedFault.java @@ -12,7 +12,7 @@ */ package org.activiti.engine.impl.webservice; -import javax.xml.ws.WebFault; +import jakarta.xml.ws.WebFault; /** * An implementation of a fault returned by the counter WS diff --git a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceDataStructure.java b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceDataStructure.java index 1c91a563dda..1eed8b867fd 100644 --- a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceDataStructure.java +++ b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceDataStructure.java @@ -14,8 +14,8 @@ import java.util.Date; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlSchemaType; public class WebServiceDataStructure { diff --git a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMock.java b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMock.java index 4f4112e3929..0139dec1cf6 100644 --- a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMock.java +++ b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMock.java @@ -14,9 +14,9 @@ import java.util.Date; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; +import jakarta.jws.WebParam; +import jakarta.jws.WebResult; +import jakarta.jws.WebService; /** * A simple WS for unit test purpose diff --git a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMockImpl.java b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMockImpl.java index 95f6b016fe0..dc2b03715a2 100644 --- a/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMockImpl.java +++ b/modules/flowable5-cxf-test/src/test/java/org/activiti/engine/impl/webservice/WebServiceMockImpl.java @@ -14,7 +14,7 @@ import java.util.Date; -import javax.jws.WebService; +import jakarta.jws.WebService; /** * An implementation of a Counter WS diff --git a/modules/flowable5-spring-test/pom.xml b/modules/flowable5-spring-test/pom.xml index 02406485ab3..be8b764fd89 100644 --- a/modules/flowable5-spring-test/pom.xml +++ b/modules/flowable5-spring-test/pom.xml @@ -180,6 +180,11 @@ slf4j-log4j12 test + + com.github.h-thurow + simple-jndi + test + diff --git a/modules/flowable5-spring-test/src/test/java/org/activiti/spring/test/email/JndiEmailTest.java b/modules/flowable5-spring-test/src/test/java/org/activiti/spring/test/email/JndiEmailTest.java index b72934b314e..c9f5eef9057 100644 --- a/modules/flowable5-spring-test/src/test/java/org/activiti/spring/test/email/JndiEmailTest.java +++ b/modules/flowable5-spring-test/src/test/java/org/activiti/spring/test/email/JndiEmailTest.java @@ -23,6 +23,7 @@ import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.test.Deployment; import org.junit.BeforeClass; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; @@ -55,9 +56,10 @@ public void setUp() throws NoSuchProviderException, NamingException { .bind("Session", mailSession); } + @Test @Deployment(resources = { "org/activiti/spring/test/email/EmailTaskUsingJndi.bpmn20.xml" }) public void testEmailUsingJndi() { - Map variables = new HashMap(); + Map variables = new HashMap<>(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("EmailJndiProcess", variables); assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); } diff --git a/modules/flowable5-spring-test/src/test/resources/jndi.properties b/modules/flowable5-spring-test/src/test/resources/jndi.properties new file mode 100644 index 00000000000..0c99e9b7182 --- /dev/null +++ b/modules/flowable5-spring-test/src/test/resources/jndi.properties @@ -0,0 +1,4 @@ +java.naming.factory.initial = org.osjava.sj.SimpleJndiContextFactory +org.osjava.sj.delimiter = . +jndi.syntax.separator = / +org.osjava.sj.jndi.shared = true