From a0945e1356382704e21a63f1cafd659bc3ae7de0 Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Wed, 20 Nov 2024 10:50:29 +0100 Subject: [PATCH] More tests moved to JUnit5 --- .../kie-ci-with-domain/tests/pom.xml | 6 ++-- .../kieci/withdomain/KJarLoadingTest.java | 10 +++---- .../kie-ci-without-domain/tests/pom.xml | 6 ++-- .../kieci/withoutdomain/KJarLoadingTest.java | 10 +++---- .../test-integration-nomvel/pom.xml | 5 ++++ .../integrationtests/nomvel/TimerTest.java | 3 +- .../integrationtests/nomvel/VerifyTest.java | 2 +- .../test-integration-notms/pom.xml | 6 +++- .../integrationtests/notms/NoTmsTest.java | 30 ++++++++----------- .../test-integration-noxml/pom.xml | 10 +++---- .../integrationtests/noxml/CommandTest.java | 2 +- .../integrationtests/noxml/NoXmlTest.java | 2 +- 12 files changed, 48 insertions(+), 44 deletions(-) diff --git a/drools-test-coverage/standalone/kie-ci-with-domain/tests/pom.xml b/drools-test-coverage/standalone/kie-ci-with-domain/tests/pom.xml index 9b8ff7c8d4a..a844387f49c 100644 --- a/drools-test-coverage/standalone/kie-ci-with-domain/tests/pom.xml +++ b/drools-test-coverage/standalone/kie-ci-with-domain/tests/pom.xml @@ -98,10 +98,10 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test - + diff --git a/drools-test-coverage/standalone/kie-ci-with-domain/tests/src/test/java/org/drools/testcoverage/kieci/withdomain/KJarLoadingTest.java b/drools-test-coverage/standalone/kie-ci-with-domain/tests/src/test/java/org/drools/testcoverage/kieci/withdomain/KJarLoadingTest.java index b445e929da1..8dcd61b7a5e 100644 --- a/drools-test-coverage/standalone/kie-ci-with-domain/tests/src/test/java/org/drools/testcoverage/kieci/withdomain/KJarLoadingTest.java +++ b/drools-test-coverage/standalone/kie-ci-with-domain/tests/src/test/java/org/drools/testcoverage/kieci/withdomain/KJarLoadingTest.java @@ -22,9 +22,9 @@ import org.drools.testcoverage.domain.Drink; import org.drools.testcoverage.domain.Order; import org.drools.testcoverage.kieci.withdomain.util.KJarLoadUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.runtime.KieContainer; @@ -45,13 +45,13 @@ public class KJarLoadingTest { private KieSession kieSession; - @Before + @BeforeEach public void init() { final KieContainer container = KS.newKieContainer(KJAR_RELEASE_ID, this.getClass().getClassLoader()); this.kieSession = container.newKieSession(); } - @After + @AfterEach public void dispose() { if (this.kieSession != null) { this.kieSession.dispose(); diff --git a/drools-test-coverage/standalone/kie-ci-without-domain/tests/pom.xml b/drools-test-coverage/standalone/kie-ci-without-domain/tests/pom.xml index 3a89a203fd9..c7c1e7bb0af 100644 --- a/drools-test-coverage/standalone/kie-ci-without-domain/tests/pom.xml +++ b/drools-test-coverage/standalone/kie-ci-without-domain/tests/pom.xml @@ -93,10 +93,10 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test - + diff --git a/drools-test-coverage/standalone/kie-ci-without-domain/tests/src/test/java/org/drools/testcoverage/kieci/withoutdomain/KJarLoadingTest.java b/drools-test-coverage/standalone/kie-ci-without-domain/tests/src/test/java/org/drools/testcoverage/kieci/withoutdomain/KJarLoadingTest.java index 06a5f294f66..aecebd946d8 100644 --- a/drools-test-coverage/standalone/kie-ci-without-domain/tests/src/test/java/org/drools/testcoverage/kieci/withoutdomain/KJarLoadingTest.java +++ b/drools-test-coverage/standalone/kie-ci-without-domain/tests/src/test/java/org/drools/testcoverage/kieci/withoutdomain/KJarLoadingTest.java @@ -19,9 +19,9 @@ package org.drools.testcoverage.kieci.withoutdomain; import org.drools.testcoverage.kieci.withoutdomain.util.KJarLoadUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.runtime.KieContainer; @@ -42,13 +42,13 @@ public class KJarLoadingTest { private KieSession kieSession; - @Before + @BeforeEach public void init() { final KieContainer container = KS.newKieContainer(KJAR_RELEASE_ID); this.kieSession = container.newKieSession(); } - @After + @AfterEach public void dispose() { if (this.kieSession != null) { this.kieSession.dispose(); diff --git a/drools-test-coverage/test-integration-nomvel/pom.xml b/drools-test-coverage/test-integration-nomvel/pom.xml index 3472bf3087f..09a4e65fba9 100644 --- a/drools-test-coverage/test-integration-nomvel/pom.xml +++ b/drools-test-coverage/test-integration-nomvel/pom.xml @@ -79,6 +79,11 @@ test-jar test + + org.junit.jupiter + junit-jupiter + test + org.assertj diff --git a/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/TimerTest.java b/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/TimerTest.java index f31c25f1bd7..0922a34df74 100644 --- a/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/TimerTest.java +++ b/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/TimerTest.java @@ -27,7 +27,7 @@ import org.drools.core.ClockType; import org.drools.core.time.impl.PseudoClockScheduler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.model.KieModuleModel; import org.kie.api.conf.EventProcessingOption; @@ -35,7 +35,6 @@ import org.kie.api.runtime.conf.ClockTypeOption; import org.kie.api.runtime.rule.FactHandle; import org.kie.api.time.Calendar; -import org.kie.api.time.SessionClock; import static org.assertj.core.api.Assertions.assertThat; import static org.drools.compiler.integrationtests.nomvel.TestUtil.getKieSession; diff --git a/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/VerifyTest.java b/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/VerifyTest.java index e41ad34bec3..bf857690360 100644 --- a/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/VerifyTest.java +++ b/drools-test-coverage/test-integration-nomvel/src/test/java/org/drools/compiler/integrationtests/nomvel/VerifyTest.java @@ -19,7 +19,7 @@ package org.drools.compiler.integrationtests.nomvel; import org.drools.testcoverage.common.model.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.Results; import org.kie.api.runtime.KieContainer; diff --git a/drools-test-coverage/test-integration-notms/pom.xml b/drools-test-coverage/test-integration-notms/pom.xml index 4f51657a1e6..8ca004d44f6 100644 --- a/drools-test-coverage/test-integration-notms/pom.xml +++ b/drools-test-coverage/test-integration-notms/pom.xml @@ -84,7 +84,11 @@ test-jar test - + + org.junit.jupiter + junit-jupiter + test + org.assertj assertj-core diff --git a/drools-test-coverage/test-integration-notms/src/test/java/org/drools/compiler/integrationtests/notms/NoTmsTest.java b/drools-test-coverage/test-integration-notms/src/test/java/org/drools/compiler/integrationtests/notms/NoTmsTest.java index 097a5779c4d..0eb91b67b23 100644 --- a/drools-test-coverage/test-integration-notms/src/test/java/org/drools/compiler/integrationtests/notms/NoTmsTest.java +++ b/drools-test-coverage/test-integration-notms/src/test/java/org/drools/compiler/integrationtests/notms/NoTmsTest.java @@ -18,16 +18,15 @@ */ package org.drools.compiler.integrationtests.notms; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -35,21 +34,17 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) + public class NoTmsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - public NoTmsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testUnsupportedTms() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnsupportedTms(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; \n" + "" + @@ -70,8 +65,9 @@ public void testUnsupportedTms() { assertThat(errors.get(0).getText().contains("drools-tms")).isTrue(); } - @Test - public void testPlainInsert() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPlainInsert(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; \n" + "" + diff --git a/drools-test-coverage/test-integration-noxml/pom.xml b/drools-test-coverage/test-integration-noxml/pom.xml index a65f9429e32..579873e9314 100644 --- a/drools-test-coverage/test-integration-noxml/pom.xml +++ b/drools-test-coverage/test-integration-noxml/pom.xml @@ -45,11 +45,11 @@ drools-engine test - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + org.assertj assertj-core diff --git a/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/CommandTest.java b/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/CommandTest.java index 07e8a754d38..c36e37218c6 100644 --- a/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/CommandTest.java +++ b/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/CommandTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.drools.model.codegen.ExecutableModelProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.model.KieModuleModel; diff --git a/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/NoXmlTest.java b/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/NoXmlTest.java index 3a7a8145c6d..1322cbb09f5 100644 --- a/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/NoXmlTest.java +++ b/drools-test-coverage/test-integration-noxml/src/test/java/org/drools/compiler/integrationtests/noxml/NoXmlTest.java @@ -19,7 +19,7 @@ package org.drools.compiler.integrationtests.noxml; import org.drools.model.codegen.ExecutableModelProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.model.KieModuleModel;