From af1486af3677ba40d69da3ce0403a05bd3bb40f6 Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Tue, 19 Nov 2024 23:14:33 +0900 Subject: [PATCH 1/7] [incubator-kie-issues-1622] Drools DISCLAIMER-BINARY lists files that are no longer in the source release (#6157) --- DISCLAIMER-BINARY | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 DISCLAIMER-BINARY diff --git a/DISCLAIMER-BINARY b/DISCLAIMER-BINARY deleted file mode 100644 index eca04fe2690..00000000000 --- a/DISCLAIMER-BINARY +++ /dev/null @@ -1,28 +0,0 @@ - - -## Disclaimer for (Test) Binaries - -The following binaries are included in this project for testing purposes only: - -efesto/efesto-core/efesto-common-api/src/test/resources/TestJar.jar : a compressed JSON file for test -efesto/efesto-core/efesto-common-core/src/test/resources/TestJar.jar : a compressed JSON file for test -efesto/efesto-core/efesto-runtime-manager/efesto-runtime-manager-core/src/test/resources/TestJar.jar : a compressed JSON file for test - -These files are used to validate the functionality and reliability of Apache KIE. They are not intended for production use or distribution beyond the scope of testing within this project. From 17bf77411aeeebf1d977c788cf4b49f983787a21 Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Wed, 20 Nov 2024 11:53:30 +0100 Subject: [PATCH 2/7] Migrated more tests to JUnit5 (#6162) --- .../DeclarativeAgendaTest.java | 128 +++++++----- .../mvel/integrationtests/HelloWorldTest.java | 37 ++-- .../integrationtests/KieBaseIncludesTest.java | 45 ++--- .../mvel/integrationtests/KieBuilderTest.java | 121 +++++------ .../KieCompilationCacheTest.java | 38 ++-- .../integrationtests/KieContainerTest.java | 79 ++++---- .../KieDefaultPackageTest.java | 55 +++-- .../integrationtests/KieHelloWorldTest.java | 128 ++++++------ .../mvel/integrationtests/KieLoggersTest.java | 86 ++++---- .../integrationtests/KieRepositoryTest.java | 2 +- .../mvel/integrationtests/KieRuntimeTest.java | 26 +-- .../integrationtests/KieServicesTest.java | 176 ++++++++-------- .../KieSessionIterationTest.java | 10 +- .../mvel/integrationtests/KmoduleXmlTest.java | 53 +++-- .../KnowledgeBuilderTest.java | 17 +- .../KnowledgeContextTest.java | 37 ++-- .../KnownExecModelDifferenceTest.java | 51 +++-- .../mvel/integrationtests/QueryCepTest.java | 47 ++--- .../RuleEventListenerTest.java | 26 +-- .../integrationtests/RuleExecutionTest.java | 43 ++-- .../integrationtests/RuleExtensionTest.java | 76 +++---- .../integrationtests/RuleMetadataTest.java | 81 ++++---- .../integrationtests/SegmentCreationTest.java | 103 +++++----- .../SegmentMemorySegmentPrototypeTest.java | 42 ++-- .../SerializedPackageMergeTwoSteps1Test.java | 7 +- .../SerializedPackageMergeTwoSteps2Test.java | 7 +- .../SeveralKieSessionsTest.java | 41 ++-- .../integrationtests/ShadowProxyTest.java | 36 ++-- .../integrationtests/StatelessStressTest.java | 30 +-- .../integrationtests/StrEvaluatorTest.java | 85 ++++---- .../StrictAnnotationTest.java | 66 +++--- .../SwitchOverStringTest.java | 41 ++-- .../BasicConcurrentInsertionsTest.java | 46 ++--- ...ConcurrentInsertionsToSubnetworksTest.java | 64 +++--- .../concurrency/MultithreadTest.java | 89 +++++---- .../integrationtests/phreak/AddRuleTest.java | 188 ++++++++++-------- .../phreak/BaseLeftTuplesBuilder.java | 1 - .../integrationtests/phreak/LeftBuilder.java | 1 - .../integrationtests/phreak/LeftMemory.java | 1 - .../phreak/PhreakJoinNodeTest.java | 2 +- .../phreak/PhreakLiaNodeTest.java | 31 ++- .../phreak/PhreakNotNodeTest.java | 2 +- .../phreak/RemoveRuleTest.java | 158 ++++++++------- .../integrationtests/phreak/ScenarioTest.java | 2 +- .../phreak/SegmentPropagationTest.java | 2 +- .../phreak/StagedBuilder.java | 1 - .../sequential/SequentialTest.java | 115 ++++++----- .../waltz/ReteOOWaltzTest.java | 16 +- .../mvel/integrationtests/waltz/Waltz.java | 20 +- .../integrationtests/waltz/WaltzMain.java | 5 +- 50 files changed, 1261 insertions(+), 1303 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DeclarativeAgendaTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DeclarativeAgendaTest.java index b666ceedfe2..c1cf2398f5f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DeclarativeAgendaTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DeclarativeAgendaTest.java @@ -20,16 +20,16 @@ import java.util.ArrayList; import java.util.Arrays; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -53,23 +53,17 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DeclarativeAgendaTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DeclarativeAgendaTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // Declarative Agenda is experimental. Not supported by exec-model - return TestParametersUtil.getKieBaseCloudConfigurations(false); + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test(timeout=10000) - public void testSimpleBlockingUsingForall() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSimpleBlockingUsingForall(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -107,8 +101,10 @@ public void testSimpleBlockingUsingForall() { ksession.dispose(); } - @Test(timeout=10000) - public void testBasicBlockOnAnnotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testBasicBlockOnAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -169,9 +165,11 @@ public void testBasicBlockOnAnnotation() { ksession.dispose(); } - @Test(timeout=10000) - public void testApplyBlockerFirst() { - KieSession ksession = getStatefulKnowledgeSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testApplyBlockerFirst(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession ksession = getStatefulKnowledgeSession(kieBaseTestConfiguration); List list = new ArrayList(); ksession.setGlobal( "list", @@ -193,9 +191,11 @@ public void testApplyBlockerFirst() { assertThat(list.contains("rule1:go1")).isTrue(); } - @Test(timeout=10000) - public void testApplyBlockerFirstWithFireAllRulesInbetween() { - KieSession ksession = getStatefulKnowledgeSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testApplyBlockerFirstWithFireAllRulesInbetween(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession ksession = getStatefulKnowledgeSession(kieBaseTestConfiguration); List list = new ArrayList(); ksession.setGlobal( "list", @@ -219,9 +219,11 @@ public void testApplyBlockerFirstWithFireAllRulesInbetween() { assertThat(list.contains("rule1:go1")).isTrue(); } - @Test(timeout=10000) - public void testApplyBlockerSecond() { - KieSession ksession = getStatefulKnowledgeSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testApplyBlockerSecond(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession ksession = getStatefulKnowledgeSession(kieBaseTestConfiguration); List list = new ArrayList(); ksession.setGlobal( "list", @@ -242,9 +244,11 @@ public void testApplyBlockerSecond() { assertThat(list.contains("rule1:go1")).isTrue(); } - @Test(timeout=10000) - public void testApplyBlockerSecondWithUpdate() { - KieSession ksession = getStatefulKnowledgeSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testApplyBlockerSecondWithUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession ksession = getStatefulKnowledgeSession(kieBaseTestConfiguration); List list = new ArrayList(); ksession.setGlobal( "list", @@ -273,9 +277,11 @@ public void testApplyBlockerSecondWithUpdate() { assertThat(list.contains("rule1:go1")).isTrue(); } - @Test(timeout=10000) - public void testApplyBlockerSecondAfterUpdate() { - KieSession ksession = getStatefulKnowledgeSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testApplyBlockerSecondAfterUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession ksession = getStatefulKnowledgeSession(kieBaseTestConfiguration); List list = new ArrayList(); ksession.setGlobal( "list", @@ -312,7 +318,7 @@ public void testApplyBlockerSecondAfterUpdate() { assertThat(list.contains("rule1:go1")).isTrue(); } - public KieSession getStatefulKnowledgeSession() { + public KieSession getStatefulKnowledgeSession(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -342,8 +348,10 @@ public KieSession getStatefulKnowledgeSession() { return ksession; } - @Test(timeout=10000) - public void testMultipleBlockers() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMultipleBlockers(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -419,8 +427,10 @@ public void testMultipleBlockers() { ksession.dispose(); } - @Test(timeout=10000) - public void testMultipleBlockersWithUnblockAll() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMultipleBlockersWithUnblockAll(KieBaseTestConfiguration kieBaseTestConfiguration) { // This test is a bit wierd as it recurses. Maybe unblockAll is not feasible... String str = ""; str += "package org.domain.test \n"; @@ -503,8 +513,10 @@ public void testMultipleBlockersWithUnblockAll() { assertThat(list.contains("blockerAllSalesRules3:rule0:go3")).isTrue(); } - @Test(timeout=10000) - public void testIterativeUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIterativeUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -641,8 +653,10 @@ public void testIterativeUpdate() { assertThat(list.contains("block:rule2")).isTrue(); } - @Test(timeout=10000) - public void testCancelActivation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCancelActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -715,8 +729,10 @@ public void matchCancelled(MatchCancelledEvent event) { ksession.dispose(); } - @Test(timeout=10000) - public void testActiveInActiveChanges() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testActiveInActiveChanges(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.domain.test \n"; str += "import " + Match.class.getName() + "\n"; @@ -770,8 +786,10 @@ public void testActiveInActiveChanges() { ksession.dispose(); } - @Test(timeout=10000) - public void testCancelMultipleActivations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCancelMultipleActivations(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.domain.test\n" + "import " + Match.class.getName() + "\n" + "global java.util.List list\n" + @@ -811,8 +829,10 @@ public void testCancelMultipleActivations() { ksession.dispose(); } - @Test(timeout=10000) - public void testCancelActivationOnInsertAndUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCancelActivationOnInsertAndUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.domain.test\n" + "import " + Match.class.getName() + "\n" + "global java.util.List list\n" + @@ -860,8 +880,9 @@ public void testCancelActivationOnInsertAndUpdate() { ksession.dispose(); } - @Test - public void testFiredRuleDoNotRefireAfterUnblock() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFiredRuleDoNotRefireAfterUnblock(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1038076 String drl = "package org.drools.mvel.integrationtests\n" + @@ -947,8 +968,9 @@ public boolean add( T t ) { } } - @Test - public void testExplicitUndercutWithDeclarativeAgenda() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExplicitUndercutWithDeclarativeAgenda(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test;\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/HelloWorldTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/HelloWorldTest.java index fd8bf498272..6493698f078 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/HelloWorldTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/HelloWorldTest.java @@ -19,18 +19,17 @@ package org.drools.mvel.integrationtests; import java.io.File; -import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.stream.Stream; import org.drools.mvel.compiler.Message; import org.drools.mvel.expr.MVELDebugHandler; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.logger.KieRuntimeLogger; import org.kie.api.runtime.KieSession; @@ -44,25 +43,18 @@ /** * This is a sample class to launch a rule. */ -@RunWith(Parameterized.class) public class HelloWorldTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public HelloWorldTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // not for exec-model - return TestParametersUtil.getKieBaseCloudConfigurations(false); + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testHelloWorld() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // load up the knowledge base - KieBase kbase = readKnowledgeBase(); + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); File testTmpDir = new File("target/test-tmp/"); testTmpDir.mkdirs(); @@ -77,8 +69,9 @@ public void testHelloWorld() throws Exception { logger.close(); } - @Test - public void testHelloWorldDebug() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldDebug(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Set knownVariables = new HashSet(); MVELRuntime.resetDebugger(); MVELDebugHandler.setDebugMode(true); @@ -92,7 +85,7 @@ public int onBreak(Frame frame) { String source = "org.drools.integrationtests.Rule_Hello_World"; MVELRuntime.registerBreakpoint(source, 1); // load up the knowledge base - KieBase kbase = readKnowledgeBase(); + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); File testTmpDir = new File("target/test-tmp/"); testTmpDir.mkdirs(); @@ -114,7 +107,7 @@ public int onBreak(Frame frame) { assertThat(knownVariables.contains("myMessage")).isTrue(); } - private KieBase readKnowledgeBase() throws Exception { + private KieBase readKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { return KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "Sample.drl"); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBaseIncludesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBaseIncludesTest.java index f68ac7bcfa3..95e7d9856f9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBaseIncludesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBaseIncludesTest.java @@ -21,13 +21,13 @@ import java.io.IOException; 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.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.KieServices; import org.kie.api.builder.KieBuilder; @@ -42,18 +42,10 @@ import static org.assertj.core.api.Assertions.assertThat; // DROOLS-1044 -@RunWith(Parameterized.class) public class KieBaseIncludesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieBaseIncludesTest(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(); } /** @@ -61,8 +53,9 @@ public static Collection getParameters() { *

* The 2 KieBases use different package names for the rules (i.e. "rules" and "rules2"). */ - @Test - public void testKieBaseIncludesCrossKJarDifferentPackageNames() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieBaseIncludesCrossKJarDifferentPackageNames(KieBaseTestConfiguration kieBaseTestConfiguration) { // @formatter:off String pomContent1 = "\n" + @@ -148,8 +141,9 @@ public void testKieBaseIncludesCrossKJarDifferentPackageNames() { *

* The 2 KieBases use the same package names for the rules (i.e. "rules"). */ - @Test - public void testKieBaseIncludesCrossKJarSamePackageNames() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieBaseIncludesCrossKJarSamePackageNames(KieBaseTestConfiguration kieBaseTestConfiguration) { // @formatter:off String pomContent1 = "\n" + @@ -254,8 +248,9 @@ private static long getNumberOfRules(KieBase kieBase) { *

* The 2 KieBases use the duplicate rule names, so an error should be reported */ - @Test - public void kieBaseIncludesCrossKJarDuplicateRuleNames_shouldReportError() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kieBaseIncludesCrossKJarDuplicateRuleNames_shouldReportError(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { String pomContentMain = "\n" + "4.0.0\n" + @@ -328,8 +323,9 @@ public void kieBaseIncludesCrossKJarDuplicateRuleNames_shouldReportError() throw /** * One KieBase that includes another KieBase from the same KJAR. Not duplicate names. */ - @Test - public void kieBaseIncludesSameKJar() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kieBaseIncludesSameKJar(KieBaseTestConfiguration kieBaseTestConfiguration) { String pomContent = "\n" + "4.0.0\n" + @@ -387,8 +383,9 @@ public void kieBaseIncludesSameKJar() { /** * One KieBase that includes another KieBase from the same KJAR. Duplicate rule names. */ - @Test - public void kieBaseIncludesSameKJarDuplicateRuleNames_shouldReportError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kieBaseIncludesSameKJarDuplicateRuleNames_shouldReportError(KieBaseTestConfiguration kieBaseTestConfiguration) { String pomContent = "\n" + "4.0.0\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java index a57101c8a95..8a38692c5d5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieBuilderTest.java @@ -18,19 +18,18 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.List; import java.util.function.Predicate; +import java.util.stream.Stream; import org.drools.compiler.kie.builder.impl.InternalKieModule; import org.drools.compiler.kproject.models.KieModuleModelImpl; import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.KieServices; import org.kie.api.builder.KieBuilder; @@ -55,23 +54,16 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class KieBuilderTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieBuilderTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testResourceInclusion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testResourceInclusion(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.mvel.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -128,8 +120,9 @@ public void testResourceInclusion() { ksession.dispose(); } - @Test - public void testValidXsdTargetNamespace() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testValidXsdTargetNamespace(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.mvel.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -153,8 +146,9 @@ public void testValidXsdTargetNamespace() { ks.newKieContainer( km.getReleaseId() ); } - @Test - public void testInvalidXsdTargetNamespace() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidXsdTargetNamespace(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -179,8 +173,9 @@ public void testInvalidXsdTargetNamespace() { .hasMessageContaining("XSD validation failed"); } - @Test - public void testOldXsdTargetNamespace() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOldXsdTargetNamespace(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.mvel.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -205,8 +200,9 @@ public void testOldXsdTargetNamespace() { ks.newKieContainer( km.getReleaseId() ); } - @Test - public void testGetKieBaseAfterKieSessionCreation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetKieBaseAfterKieSessionCreation(KieBaseTestConfiguration kieBaseTestConfiguration) { final String KBASE_NAME = "kieBase"; final String KSESSION_NAME = "kieSession"; @@ -244,8 +240,9 @@ public void testGetKieBaseAfterKieSessionCreation() { assertThat(kieBase).isNotNull(); } - @Test - public void testReportKBuilderErrorWhenUsingAJavaClassWithNoPkg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReportKBuilderErrorWhenUsingAJavaClassWithNoPkg(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-995018 final String java = "public class JavaClass { }\n"; final KieServices ks = KieServices.Factory.get(); @@ -261,8 +258,9 @@ public void testReportKBuilderErrorWhenUsingAJavaClassWithNoPkg() { assertThat(results.getMessages().size()).isEqualTo(1); } - @Test - public void testJavaSourceFileAndDrlDeploy() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaSourceFileAndDrlDeploy(KieBaseTestConfiguration kieBaseTestConfiguration) { final String java = "package org.drools.mvel.compiler;\n" + "public class JavaSourceMessage { }\n"; final String drl = "package org.drools.mvel.compiler;\n" + @@ -298,8 +296,9 @@ public void testJavaSourceFileAndDrlDeploy() { } } - @Test - public void testJavaSourceFileAndDrlDeployWithClassFilter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaSourceFileAndDrlDeployWithClassFilter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String allowedJava = "package org.drools.mvel.compiler;\n" + "public class JavaSourceMessage { }\n"; final String filteredJava = "package org.drools.mvel.compiler;\n" + @@ -355,8 +354,9 @@ public void testJavaSourceFileAndDrlDeployWithClassFilter() { } } - @Test - public void testKieBuilderWithDotFiles() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieBuilderWithDotFiles(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1044409 final String KBASE_NAME = "kieBase"; final String KSESSION_NAME = "kieSession"; @@ -398,8 +398,9 @@ public void testKieBuilderWithDotFiles() { assertThat(kieBase).isNotNull(); } - @Test - public void testMultipleKBaseWithDrlError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleKBaseWithDrlError(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2651 final String drl = "package org.drools.compiler;\n" + "rule \"test\"\n" + @@ -433,8 +434,9 @@ public void testMultipleKBaseWithDrlError() { assertThat(messages.get(3).toString().contains("kbase2")).isTrue(); } - @Test - public void testBuildWithKBaseAndKSessionWithIdenticalNames() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildWithKBaseAndKSessionWithIdenticalNames(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2689 final String kmodule = "\n" + @@ -443,11 +445,12 @@ public void testBuildWithKBaseAndKSessionWithIdenticalNames() { " \n" + ""; - checkKModule( kmodule, 0 ); + checkKModule( kieBaseTestConfiguration, kmodule, 0 ); } - @Test - public void testBuildWithDuplicatedKSessionNames() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildWithDuplicatedKSessionNames(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2689 final String kmodule = "\n" + @@ -459,11 +462,12 @@ public void testBuildWithDuplicatedKSessionNames() { " \n" + ""; - checkKModule( kmodule, 1 ); + checkKModule( kieBaseTestConfiguration, kmodule, 1 ); } - @Test - public void testBuildWithDuplicatedKBaseNames() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildWithDuplicatedKBaseNames(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2689 final String kmodule = "\n" + @@ -475,10 +479,10 @@ public void testBuildWithDuplicatedKBaseNames() { " \n" + ""; - checkKModule( kmodule, 1 ); + checkKModule( kieBaseTestConfiguration, kmodule, 1 ); } - private void checkKModule( final String kmodule, final int expectedErrors ) { + private void checkKModule(KieBaseTestConfiguration kieBaseTestConfiguration , final String kmodule, final int expectedErrors) { final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId = ks.newReleaseId( "org.kie", "test-kie-builder", "1.0.0" ); final KieFileSystem kfs = ks.newKieFileSystem().generateAndWritePomXML( releaseId ).writeKModuleXML( kmodule ); @@ -488,8 +492,9 @@ private void checkKModule( final String kmodule, final int expectedErrors ) { assertThat(((InternalKieBuilder) kieBuilder ).getKieModuleIgnoringErrors()).isNotNull(); } - @Test - public void testAddMissingResourceToPackageBuilder() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddMissingResourceToPackageBuilder(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); assertThatThrownBy(() -> kbuilder.add(ResourceFactory.newClassPathResource("some.rf"), ResourceType.DRL)) @@ -499,8 +504,9 @@ public void testAddMissingResourceToPackageBuilder() throws Exception { .isInstanceOf(RuntimeException.class); } - @Test - public void testDeclarativeChannelRegistration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarativeChannelRegistration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.mvel.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -532,8 +538,9 @@ public void testDeclarativeChannelRegistration() { assertThat(kieSession.getChannels().containsKey("testChannel")).isTrue(); } - @Test - public void testStatelessSessionDeclarativeChannelRegistration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStatelessSessionDeclarativeChannelRegistration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.mvel.compiler\n" + "rule R1 when\n" + " $m : Message()\n" + @@ -567,11 +574,11 @@ public void testStatelessSessionDeclarativeChannelRegistration() { public static class MockChannel implements Channel { - @Override - public void send(Object object) { - //NO=OP - } - + @Override + public void send(Object object) { + //NO=OP + } + } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieCompilationCacheTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieCompilationCacheTest.java index eee8d9b4c09..cf893759c0e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieCompilationCacheTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieCompilationCacheTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.compiler.io.File; import org.drools.compiler.compiler.io.memory.MemoryFileSystem; @@ -27,10 +27,9 @@ import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.KieServices; import org.kie.api.builder.KieBuilder; @@ -51,22 +50,15 @@ /** * This is a sample class to launch a rule. */ -@RunWith(Parameterized.class) public class KieCompilationCacheTest { - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieCompilationCacheTest(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 testCompilationCache() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationCache(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.compiler\n" + "declare type X\n" + " foo : String\n" + @@ -106,8 +98,9 @@ public void testCompilationCache() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testHelloWorldWithPackagesAnd2KieBases() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithPackagesAnd2KieBases(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl1 = "package org.pkg1\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R11 when\n" + @@ -178,8 +171,9 @@ public void testHelloWorldWithPackagesAnd2KieBases() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testCacheWigAccumulate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCacheWigAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl1 = "package org.pkg1\n" + "rule R11 when\n" + " Number() from accumulate(String(), \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieContainerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieContainerTest.java index 7c85701728b..386fab98b13 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieContainerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieContainerTest.java @@ -23,8 +23,8 @@ import java.lang.reflect.Constructor; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.apache.commons.io.IOUtils; import org.drools.base.definitions.InternalKnowledgePackage; @@ -36,10 +36,10 @@ import org.drools.core.impl.InternalKieContainer; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -57,23 +57,16 @@ import static org.drools.core.util.DroolsAssert.assertEnumerationSize; import static org.drools.core.util.DroolsAssert.assertUrlEnumerationContainsMatch; -@RunWith(Parameterized.class) public class KieContainerTest { - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieContainerTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testMainKieModule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMainKieModule(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices ks = KieServices.Factory.get(); // Create an in-memory jar for version 1.0.0 ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0"); @@ -84,8 +77,9 @@ public void testMainKieModule() { assertThat(kmodule.getReleaseId()).isEqualTo(releaseId); } - @Test - public void testUpdateToNonExistingRelease() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateToNonExistingRelease(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1562 KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "test-release", "1.0.0"); @@ -98,8 +92,9 @@ public void testUpdateToNonExistingRelease() { assertThat(((InternalKieContainer) kieContainer).getContainerReleaseId().getVersion()).isEqualTo("1.0.0"); } - @Test - public void testReleaseIdGetters() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReleaseIdGetters(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete-v", "1.0.1"); ReleaseId newReleaseId = ks.newReleaseId("org.kie", "test-delete-v", "1.0.2"); @@ -110,7 +105,7 @@ public void testReleaseIdGetters() { KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration, createDRL("ruleA")); ReleaseId configuredReleaseId = ks.newReleaseId("org.kie", "test-delete-v", "RELEASE"); - KieContainer kieContainer = ks.newKieContainer(configuredReleaseId); + KieContainer kieContainer = ks.newKieContainer(configuredReleaseId); InternalKieContainer iKieContainer = (InternalKieContainer) kieContainer; assertThat(iKieContainer.getConfiguredReleaseId()).isEqualTo(configuredReleaseId); @@ -129,8 +124,9 @@ public void testReleaseIdGetters() { assertThat(iKieContainer.getContainerReleaseId()).isEqualTo(newReleaseId); } - @Test - public void testSharedTypeDeclarationsUsingClassLoader() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedTypeDeclarationsUsingClassLoader(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String type = "package org.drools.test\n" + "declare Message\n" + " message : String\n" + @@ -181,8 +177,9 @@ public void testSharedTypeDeclarationsUsingClassLoader() throws Exception { // assertNotSame(cls1, cls2); } - @Test - public void testSharedTypeDeclarationsUsingFactTypes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedTypeDeclarationsUsingFactTypes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String type = "package org.drools.test\n" + "declare Message\n" + " message : String\n" + @@ -252,8 +249,10 @@ private void insertMessageFromTypeDeclaration(KieSession ksession) throws Instan } - @Test(timeout = 20000) - public void testIncrementalCompilationSynchronization() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testIncrementalCompilationSynchronization(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.Factory.get(); ReleaseId releaseId = kieServices.newReleaseId("org.kie.test", "sync-scanner-test", "1.0.0"); @@ -309,8 +308,9 @@ private static boolean previousRuleExists(KieContainer kieContainer, int i) { return rule != null; } - @Test - public void testMemoryFileSystemFolderUniqueness() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMemoryFileSystemFolderUniqueness(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices kieServices = KieServices.Factory.get(); String drl = "package org.drools.test\n" + "rule R1 when\n" + @@ -342,8 +342,9 @@ public void testMemoryFileSystemFolderUniqueness() { assertThat(secondFolder.getParent()).isEqualTo(firstFolder.getParent()); } - @Test - public void testClassLoaderGetResources() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassLoaderGetResources(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { KieServices kieServices = KieServices.Factory.get(); String drl1 = "package org.drools.testdrl;\n" + "rule R1 when\n" + @@ -392,8 +393,9 @@ public void testClassLoaderGetResources() throws IOException { assertUrlEnumerationContainsMatch("^mfs\\:/$", classLoader.getResources("")); } - @Test - public void testGetDefaultKieSessionModel() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetDefaultKieSessionModel(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices kieServices = KieServices.Factory.get(); String drl = "package org.drools.test\n" + "rule R1 when\n" + @@ -420,8 +422,9 @@ public void testGetDefaultKieSessionModel() { assertThat(sessionModel.getName()).isEqualTo("testKsession"); } - @Test - public void testGetDefaultKieSessionModelEmptyKmodule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetDefaultKieSessionModelEmptyKmodule(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices kieServices = KieServices.Factory.get(); String drl = "package org.drools.test\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieDefaultPackageTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieDefaultPackageTest.java index 6c250b66f27..3c0b8883629 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieDefaultPackageTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieDefaultPackageTest.java @@ -18,15 +18,14 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -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.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -36,22 +35,15 @@ /** * Testing use of default Package. */ -@RunWith(Parameterized.class) public class KieDefaultPackageTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieDefaultPackageTest(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 testAllInDefaultPackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllInDefaultPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //This Model will be in the "default package" String model_drl = "" + "declare Smurf\n" @@ -76,8 +68,9 @@ public void testAllInDefaultPackage() throws Exception { assertThat(builder.getResults().getMessages().size()).isEqualTo(0); } - @Test - public void testInTestPackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInTestPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String javaClass = "" + "package org.jbpm;\n" + "public class Test{}\n"; @@ -94,9 +87,10 @@ public void testInTestPackage() throws Exception { } - @Test - @Ignore("How do you access Type 'Smurf'? Test 1 - No import prefix") - public void testModelInDefaultPackage1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("How do you access Type 'Smurf'? Test 1 - No import prefix") + public void testModelInDefaultPackage1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //This Model will be in the "default package" String model_drl = "" + "declare Smurf\n" @@ -123,8 +117,9 @@ public void testModelInDefaultPackage1() throws Exception { assertThat(builder.getResults().getMessages().size()).isEqualTo(0); } - @Test - public void testModelInDefaultPackage2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModelInDefaultPackage2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //This Model will be in the "default package" String model_drl = "" + "declare Smurf\n" @@ -151,8 +146,9 @@ public void testModelInDefaultPackage2() throws Exception { assertThat(builder.getResults().getMessages().size()).isEqualTo(0); } - @Test - public void testAllInExplicitPackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllInExplicitPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //This Model will be in package "org.smurf" String model_drl = "" + "package org.smurf\n" @@ -179,8 +175,9 @@ public void testAllInExplicitPackage() throws Exception { assertThat(builder.getResults().getMessages().size()).isEqualTo(0); } - @Test - public void testAllInDifferentExplicitPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllInDifferentExplicitPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //This Model will be in package "org.smurf" String model_drl = "" + "package org.smurf\n" diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieHelloWorldTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieHelloWorldTest.java index 8b5260098e5..01bb905d2c1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieHelloWorldTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieHelloWorldTest.java @@ -24,8 +24,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.drools.compiler.kie.builder.impl.KieProject; @@ -33,11 +33,10 @@ import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; +import org.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.wiring.api.classloader.ProjectClassLoader; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -62,23 +61,16 @@ /** * This is a sample class to launch a rule. */ -@RunWith(Parameterized.class) public class KieHelloWorldTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieHelloWorldTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testHelloWorld() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieServices ks = KieServices.Factory.get(); KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", createDrl( "R1" ) ); @@ -92,8 +84,9 @@ public void testHelloWorld() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testClassLoaderStore() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassLoaderStore(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1766 String drl = "package org; declare Person name : String end"; KieServices ks = KieServices.Factory.get(); @@ -112,8 +105,9 @@ public void testClassLoaderStore() throws Exception { assertThat(pcl.getStore().get("org/Person.class")).isNotNull(); } - @Test - public void testHelloWorldWithResource() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithResource(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-351 KieServices ks = KieServices.Factory.get(); @@ -132,8 +126,9 @@ public void testHelloWorldWithResource() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testHelloWorldWithEmptyFile() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithEmptyFile(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = createDrl("R1"); KieServices ks = KieServices.Factory.get(); @@ -151,8 +146,9 @@ public void testHelloWorldWithEmptyFile() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testFailingHelloWorld() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFailingHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.mvel.integrationtests\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -169,8 +165,9 @@ public void testFailingHelloWorld() throws Exception { assertThat(kb.getResults().getMessages().size()).isEqualTo(1); } - @Test - public void testHelloWorldWithKBaseInclude() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithKBaseInclude(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.mvel.integrationtests\n" + "declare CancelFact\n" + " cancel : boolean = true\n" + @@ -214,8 +211,9 @@ public void testHelloWorldWithKBaseInclude() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testHelloWorldWithPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "hello-world", "1.0"); @@ -234,8 +232,9 @@ public void testHelloWorldWithPackages() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testHelloWorldUsingPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldUsingPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drlDef = "package org.pkg1\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R_def when\n" + @@ -261,8 +260,9 @@ public void testHelloWorldUsingPackages() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testHelloWorldUsingFolders() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldUsingFolders(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drlDef = "package org.drools.mvel.integrationtests\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R_def when\n" + @@ -290,8 +290,9 @@ public void testHelloWorldUsingFolders() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testHelloWorldWithWildcardPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithWildcardPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "hello-world", "1.0"); @@ -312,8 +313,9 @@ public void testHelloWorldWithWildcardPackages() throws Exception { assertThat(list.get(0)).isEqualTo("R1"); } - @Test - public void testHelloWorldWithWildcardPackagesComplex() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithWildcardPackagesComplex(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1174563 KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "hello-world", "1.0"); @@ -384,13 +386,14 @@ private KieModuleModel createKieProjectWithPackages(KieServices ks, String pkg) return kproj; } - @Test - public void testHelloWorldOnVersionRange() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldOnVersionRange(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieServices ks = KieServices.Factory.get(); - buildVersion(ks, "Hello World", "1.0"); - buildVersion(ks, "Aloha Earth", "1.1"); - buildVersion(ks, "Hi Universe", "1.2"); + buildVersion(kieBaseTestConfiguration, ks, "Hello World", "1.0"); + buildVersion(kieBaseTestConfiguration, ks, "Aloha Earth", "1.1"); + buildVersion(kieBaseTestConfiguration, ks, "Hi Universe", "1.2"); ReleaseId latestReleaseId = ks.newReleaseId("org.kie", "hello-world", "LATEST"); @@ -423,12 +426,13 @@ public void testHelloWorldOnVersionRange() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(0); } - @Test - public void testGetDefaultKieSessionWithNullName() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetDefaultKieSessionWithNullName(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1276 KieServices ks = KieServices.Factory.get(); - buildVersion(ks, "Hello World", "1.0"); + buildVersion(kieBaseTestConfiguration, ks, "Hello World", "1.0"); ReleaseId releaseId1 = ks.newReleaseId("org.kie", "hello-world", "1.0"); @@ -437,7 +441,7 @@ public void testGetDefaultKieSessionWithNullName() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - private void buildVersion(KieServices ks, String message, String version) { + private void buildVersion(KieBaseTestConfiguration kieBaseTestConfiguration, KieServices ks, String message, String version) { String drl = "package org.drools.mvel.integrationtests\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -454,8 +458,9 @@ private void buildVersion(KieServices ks, String message, String version) { KieUtil.getKieBuilderFromKieFileSystem(kieBaseTestConfiguration, kfs, false); } - @Test - public void testHelloWorldWithPackagesAnd2KieBases() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithPackagesAnd2KieBases(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl1 = "package org.pkg1\n" + "import " + Message.class.getCanonicalName() + "\n" + "rule R11 when\n" + @@ -532,8 +537,9 @@ private KieModuleModel createKieProjectWithPackagesAnd2KieBases(KieServices ks) return kproj; } - @Test - public void testImport() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImport(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-859 String drl1 = "package rules\n" + "import " + Message.class.getCanonicalName() + "\n" + @@ -582,8 +588,9 @@ public void testImport() throws Exception { assertThat(results.get(0)).isEqualTo("ok"); } - @Test - public void testErrorReportingWithWrongKmodule() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testErrorReportingWithWrongKmodule(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // RHDM-69 String kmodule = "\n" + @@ -602,8 +609,9 @@ public void testErrorReportingWithWrongKmodule() throws Exception { assertThat(kb.getResults().getMessages().get(0).toString().contains("ABC")).isTrue(); } - @Test - public void testHelloWorldWithSpace() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorldWithSpace(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2338 final KieServices kieServices = KieServices.get(); @@ -632,8 +640,9 @@ public void testHelloWorldWithSpace() throws Exception { assertThat(count).isEqualTo(1); } - @Test - public void testVeyifyNotExistingKieBase() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testVeyifyNotExistingKieBase(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2757 KieServices ks = KieServices.Factory.get(); @@ -649,8 +658,9 @@ public void testVeyifyNotExistingKieBase() throws Exception { } } - @Test - public void testDeclarativeCalendars() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarativeCalendars(KieBaseTestConfiguration kieBaseTestConfiguration) { String weekendCalendarSource = "package org.mypackage;\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieLoggersTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieLoggersTest.java index 5f5a6bd9255..71a4c0c8124 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieLoggersTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieLoggersTest.java @@ -19,15 +19,14 @@ package org.drools.mvel.integrationtests; import java.io.File; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -48,34 +47,27 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class KieLoggersTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieLoggersTest(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 testKieConsoleLogger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieConsoleLogger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + - "import org.drools.mvel.compiler.Message;\n" + - "rule \"Hello World\"\n" + - " when\n" + - " m : Message( myMessage : message )\n" + - " then\n" + - "end"; + "import org.drools.mvel.compiler.Message;\n" + + "rule \"Hello World\"\n" + + " when\n" + + " m : Message( myMessage : message )\n" + + " then\n" + + "end"; // get the resource Resource dt = ResourceFactory.newByteArrayResource( drl.getBytes() ).setTargetPath( "org/drools/integrationtests/hello.drl" ); // create the builder - KieSession ksession = getKieSession( dt ); + KieSession ksession = getKieSession(kieBaseTestConfiguration, dt ); KieRuntimeLogger logger = KieServices.Factory.get().getLoggers().newConsoleLogger( ksession ); ksession.insert( new Message("Hello World") ); @@ -85,8 +77,9 @@ public void testKieConsoleLogger() throws Exception { logger.close(); } - @Test - public void testDeclarativeKieConsoleLogger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarativeKieConsoleLogger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + "rule \"Hello World\"\n" + @@ -118,8 +111,9 @@ public void testDeclarativeKieConsoleLogger() throws Exception { logger.close(); } - @Test - public void testKieConsoleLoggerStateless() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieConsoleLoggerStateless(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + "rule \"Hello World\"\n" + @@ -131,7 +125,7 @@ public void testKieConsoleLoggerStateless() throws Exception { Resource dt = ResourceFactory.newByteArrayResource( drl.getBytes() ).setTargetPath("org/drools/integrationtests/hello.drl"); // create the builder - StatelessKieSession ksession = getStatelessKieSession(dt); + StatelessKieSession ksession = getStatelessKieSession(kieBaseTestConfiguration, dt); KieRuntimeLogger logger = KieServices.Factory.get().getLoggers().newConsoleLogger( ksession ); AgendaEventListener ael = mock( AgendaEventListener.class ); @@ -144,8 +138,9 @@ public void testKieConsoleLoggerStateless() throws Exception { logger.close(); } - @Test - public void testDeclarativeKieConsoleLoggerStateless() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarativeKieConsoleLoggerStateless(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + "rule \"Hello World\"\n" + @@ -178,8 +173,9 @@ public void testDeclarativeKieConsoleLoggerStateless() throws Exception { logger.close(); } - @Test - public void testKieFileLogger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieFileLogger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + "rule \"Hello World\"\n" + @@ -191,7 +187,7 @@ public void testKieFileLogger() throws Exception { Resource dt = ResourceFactory.newByteArrayResource(drl.getBytes()).setTargetPath( "org/drools/integrationtests/hello.drl" ); // create the builder - KieSession ksession = getKieSession(dt); + KieSession ksession = getKieSession(kieBaseTestConfiguration, dt); String fileName = "target/testKieFileLogger"; File file = new File(fileName + ".log"); @@ -213,8 +209,9 @@ public void testKieFileLogger() throws Exception { file.delete(); } - @Test - public void testKieFileLoggerWithImmediateFlushing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieFileLoggerWithImmediateFlushing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-991 String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + @@ -227,7 +224,7 @@ public void testKieFileLoggerWithImmediateFlushing() throws Exception { Resource dt = ResourceFactory.newByteArrayResource(drl.getBytes()).setTargetPath( "org/drools/integrationtests/hello.drl" ); // create the builder - KieSession ksession = getKieSession(dt); + KieSession ksession = getKieSession(kieBaseTestConfiguration, dt); String fileName = "target/testKieFileLogger"; File file = new File(fileName + ".log"); @@ -251,8 +248,9 @@ public void testKieFileLoggerWithImmediateFlushing() throws Exception { file.delete(); } - @Test - public void testDeclarativeKieFileLogger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarativeKieFileLogger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.integrationtests\n" + "import org.drools.mvel.compiler.Message;\n" + "rule \"Hello World\"\n" + @@ -294,23 +292,23 @@ public void testDeclarativeKieFileLogger() throws Exception { file.delete(); } - private KieSession getKieSession(Resource dt) { - KieServices ks = populateKieFileSystem( dt ); + private KieSession getKieSession(KieBaseTestConfiguration kieBaseTestConfiguration, Resource dt) { + KieServices ks = populateKieFileSystem(kieBaseTestConfiguration, dt ); // get the session KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession(); return ksession; } - private StatelessKieSession getStatelessKieSession(Resource dt) { - KieServices ks = populateKieFileSystem( dt ); + private StatelessKieSession getStatelessKieSession(KieBaseTestConfiguration kieBaseTestConfiguration, Resource dt) { + KieServices ks = populateKieFileSystem(kieBaseTestConfiguration, dt ); // get the session StatelessKieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newStatelessKieSession(); return ksession; } - private KieServices populateKieFileSystem(Resource dt) { + private KieServices populateKieFileSystem(KieBaseTestConfiguration kieBaseTestConfiguration, Resource dt) { KieServices ks = KieServices.Factory.get(); KieFileSystem kfs = ks.newKieFileSystem().write( dt ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRepositoryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRepositoryTest.java index c126b292722..07a310bc72e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRepositoryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRepositoryTest.java @@ -21,7 +21,7 @@ import java.net.URL; import java.net.URLClassLoader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; import org.kie.api.builder.KieRepository; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRuntimeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRuntimeTest.java index 0f3becd4840..77290b83865 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRuntimeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieRuntimeTest.java @@ -19,35 +19,27 @@ package org.drools.mvel.integrationtests; import java.io.IOException; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.CommonTestMethodBase; import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; -@RunWith(Parameterized.class) public class KieRuntimeTest extends CommonTestMethodBase { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieRuntimeTest(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 testKieRuntimeAccess() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieRuntimeAccess(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { String str = ""; str += "package org.drools.mvel.compiler.test\n"; str += "import " + Message.class.getName() + "\n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieServicesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieServicesTest.java index 17a3aead1f4..376e47c0a56 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieServicesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieServicesTest.java @@ -18,18 +18,16 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; -import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.drools.compiler.kie.builder.impl.KieServicesImpl; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; import org.kie.api.builder.ReleaseId; @@ -38,101 +36,97 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class KieServicesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieServicesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } + + private KieServices ks; - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + @BeforeEach + public void init() { + ks = KieServices.Factory.get(); + (( KieServicesImpl ) ks).nullKieClasspathContainer(); + ((KieServicesImpl) ks).nullAllContainerIds(); } - - private KieServices ks; - - @Before - public void init() { - ks = KieServices.Factory.get(); - (( KieServicesImpl ) ks).nullKieClasspathContainer(); - ((KieServicesImpl) ks).nullAllContainerIds(); - } - - @After - public void shutdown() { - ((KieServicesImpl) ks).nullKieClasspathContainer(); - ((KieServicesImpl) ks).nullAllContainerIds(); - } - - @Test - public void testGetKieClasspathIDs() { - String myId = "myId"; - - KieContainer c1 = ks.getKieClasspathContainer(myId); + + @AfterEach + public void shutdown() { + ((KieServicesImpl) ks).nullKieClasspathContainer(); + ((KieServicesImpl) ks).nullAllContainerIds(); + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetKieClasspathIDs(KieBaseTestConfiguration kieBaseTestConfiguration) { + String myId = "myId"; + + KieContainer c1 = ks.getKieClasspathContainer(myId); assertThat(ks.getKieClasspathContainer()).isEqualTo(c1); assertThat(ks.getKieClasspathContainer(myId)).isEqualTo(c1); - try { - ks.getKieClasspathContainer("invalid"); - fail("this is not the containerId for the global singleton."); - } catch (IllegalStateException is) { - // ok. - } - } - - @Test - public void testNewKieClasspathIDs() { - KieContainer c1 = ks.newKieClasspathContainer("id1"); - KieContainer c2 = ks.newKieClasspathContainer("id2"); - try { - ks.newKieClasspathContainer("id2"); - fail("should not allow repeated container IDs."); - } catch (IllegalStateException is) { - // ok. - } - } - - @Test - public void testNewKieContainerIDs() { - ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0"); + try { + ks.getKieClasspathContainer("invalid"); + fail("this is not the containerId for the global singleton."); + } catch (IllegalStateException is) { + // ok. + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewKieClasspathIDs(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieContainer c1 = ks.newKieClasspathContainer("id1"); + KieContainer c2 = ks.newKieClasspathContainer("id2"); + try { + ks.newKieClasspathContainer("id2"); + fail("should not allow repeated container IDs."); + } catch (IllegalStateException is) { + // ok. + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewKieContainerIDs(KieBaseTestConfiguration kieBaseTestConfiguration) { + ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0"); KieModule km = KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration, createDRL("ruleA")); - KieContainer c1 = ks.newKieContainer("id1", releaseId); - KieContainer c2 = ks.newKieClasspathContainer("id2"); - try { - ks.newKieContainer("id2", releaseId); - fail("should not allow repeated container IDs."); - } catch (IllegalStateException is) { - // ok. - } - try { - ks.newKieClasspathContainer("id1"); - fail("should not allow repeated container IDs."); - } catch (IllegalStateException is) { - // ok. - } - } - - @Test - public void testDisposeClearTheIDReference() { - ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0"); + KieContainer c1 = ks.newKieContainer("id1", releaseId); + KieContainer c2 = ks.newKieClasspathContainer("id2"); + try { + ks.newKieContainer("id2", releaseId); + fail("should not allow repeated container IDs."); + } catch (IllegalStateException is) { + // ok. + } + try { + ks.newKieClasspathContainer("id1"); + fail("should not allow repeated container IDs."); + } catch (IllegalStateException is) { + // ok. + } + } + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDisposeClearTheIDReference(KieBaseTestConfiguration kieBaseTestConfiguration) { + ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0"); KieModule km = KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration, createDRL("ruleA")); - KieContainer c1 = ks.newKieContainer("id1", releaseId); - try { - ks.newKieClasspathContainer("id1"); - fail("should not allow repeated container IDs."); - } catch (IllegalStateException is) { - // ok. - } - - c1.dispose(); - - ks.newKieClasspathContainer("id1"); // now OK. - } + KieContainer c1 = ks.newKieContainer("id1", releaseId); + try { + ks.newKieClasspathContainer("id1"); + fail("should not allow repeated container IDs."); + } catch (IllegalStateException is) { + // ok. + } + + c1.dispose(); + + ks.newKieClasspathContainer("id1"); // now OK. + } private String createDRL(String ruleName) { return "package org.kie.test\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieSessionIterationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieSessionIterationTest.java index 34fff749d83..446b88dd080 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieSessionIterationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KieSessionIterationTest.java @@ -21,9 +21,9 @@ import java.util.ArrayList; import java.util.Collection; -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.KieBase; import org.kie.api.runtime.KieSession; import org.kie.internal.utils.KieHelper; @@ -37,7 +37,7 @@ public class KieSessionIterationTest { private KieBase kieBase; - @Before + @BeforeEach public void setup() { this.kieBase = new KieHelper().build(); // create several KieSessions @@ -46,7 +46,7 @@ public void setup() { this.kieBase.newKieSession(); } - @After + @AfterEach public void cleanup() { if (this.kieBase != null) { // copying the KieSession collection is also workaround for ConcurrentModificationException in the test diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KmoduleXmlTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KmoduleXmlTest.java index ff01c6167c2..697874e1f33 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KmoduleXmlTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KmoduleXmlTest.java @@ -18,15 +18,14 @@ */ package org.drools.mvel.integrationtests; -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.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.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -34,58 +33,54 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class KmoduleXmlTest { enum Element { KBASE, KSESSION } - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KmoduleXmlTest(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 kbaseEmptyName() throws Exception { - List errors = buildKmoduleWithEmptyValue("name", Element.KBASE); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kbaseEmptyName(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + List errors = buildKmoduleWithEmptyValue(kieBaseTestConfiguration, "name", Element.KBASE); assertThat(errors).isNotEmpty(); assertThat(errors.get(0).getText()).contains("kbase name is empty in kmodule.xml"); } - @Test - public void kbaseEmptyIncludes() throws Exception { - List errors = buildKmoduleWithEmptyValue("includes", Element.KBASE); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kbaseEmptyIncludes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + List errors = buildKmoduleWithEmptyValue(kieBaseTestConfiguration, "includes", Element.KBASE); assertThat(errors).as("Empty includes is fine. It's ignored") .isEmpty(); } - @Test - public void kbaseEmptyPackages() throws Exception { - List errors = buildKmoduleWithEmptyValue("packages", Element.KBASE); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void kbaseEmptyPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + List errors = buildKmoduleWithEmptyValue(kieBaseTestConfiguration, "packages", Element.KBASE); assertThat(errors).as("Empty packages is fine. It means the default package") .isEmpty(); } - @Test - public void ksessionEmptyName() throws Exception { - List errors = buildKmoduleWithEmptyValue("name", Element.KSESSION); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void ksessionEmptyName(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + List errors = buildKmoduleWithEmptyValue(kieBaseTestConfiguration, "name", Element.KSESSION); assertThat(errors).isNotEmpty(); assertThat(errors.get(0).getText()).contains("ksession name is empty in kmodule.xml"); } - private List buildKmoduleWithEmptyValue(String emptyAttribute, Element element) throws Exception { + private List buildKmoduleWithEmptyValue(KieBaseTestConfiguration kieBaseTestConfiguration, String emptyAttribute, Element element) throws Exception { String drl = "package org.example\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeBuilderTest.java index 13690ca611d..f081334d42c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeBuilderTest.java @@ -29,10 +29,10 @@ import org.drools.core.util.FileManager; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.definition.rule.Rule; import org.kie.api.definition.type.FactType; @@ -50,12 +50,12 @@ public class KnowledgeBuilderTest { private FileManager fileManager; - @Before + @BeforeEach public void setUp() throws Exception { this.fileManager = new FileManager().setUp(); } - @After + @AfterEach public void tearDown() throws Exception { this.fileManager.tearDown(); } @@ -197,7 +197,8 @@ public void testDifferentPackages() throws Exception { assertThat(list.get(0)).isEqualTo("OK"); } - @Test @Ignore("All the classes generated by type declarations are now defined in the ProjectClassLoader") + @Test + @Disabled("All the classes generated by type declarations are now defined in the ProjectClassLoader") public void testUndoTypeDeclaration() throws Exception { String rule = "package org.drools.mvel.compiler.test\n" + "import org.drools.compiler.test.FactA\n" + @@ -390,7 +391,7 @@ public void testAddPackageArray() throws Exception { } - @Ignore + @Disabled @Test public void testResourceMapping() throws Exception { String rule = "package org.drools.mvel.compiler.test\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeContextTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeContextTest.java index 52de6f887fb..2f872a754b2 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeContextTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnowledgeContextTest.java @@ -19,46 +19,39 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class KnowledgeContextTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KnowledgeContextTest(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 testKnowledgeContextJava() { - testKnowledgeContext("test_KnowledgeContextJava.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeContextJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + testKnowledgeContext(kieBaseTestConfiguration, "test_KnowledgeContextJava.drl"); } - @Test - public void testKnowledgeContextMVEL() { - testKnowledgeContext("test_KnowledgeContextMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeContextMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + testKnowledgeContext(kieBaseTestConfiguration, "test_KnowledgeContextMVEL.drl"); } - private void testKnowledgeContext(final String drlResourceName) { + private void testKnowledgeContext(KieBaseTestConfiguration kieBaseTestConfiguration, final String drlResourceName) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, drlResourceName); KieSession ksession = kbase.newKieSession(); final List list = new ArrayList(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnownExecModelDifferenceTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnownExecModelDifferenceTest.java index f42c3ab4cce..ca274f0d8e8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnownExecModelDifferenceTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/KnownExecModelDifferenceTest.java @@ -20,18 +20,17 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.mvel.integrationtests.facts.VarargsFact; 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.Level; @@ -43,22 +42,15 @@ * This is a place where known behavior differences between exec-model and non-exec-model. * They are not treated as a bug and should be documented in "Migration from non-executable model to executable model" section */ -@RunWith(Parameterized.class) public class KnownExecModelDifferenceTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KnownExecModelDifferenceTest(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 setter_intToWrapperLongCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void setter_intToWrapperLongCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7196 // Java doesn't coerce int to Long String str = "package com.example.reproducer\n" + @@ -85,8 +77,9 @@ public void setter_intToWrapperLongCoercion() { } } - @Test - public void setter_intToPrimitiveLongCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void setter_intToPrimitiveLongCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7196 // Java coerces int to long String str = "package com.example.reproducer\n" + @@ -109,8 +102,9 @@ public void setter_intToPrimitiveLongCoercion() { assertThat(fact.getValueList()).containsExactly(10L); // Coerced with both cases } - @Test - public void setter_intToWrapperLongCoercionVarargs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void setter_intToWrapperLongCoercionVarargs(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7196 // Java doesn't coerce int to Long. Same for varargs String str = "package com.example.reproducer\n" + @@ -138,8 +132,9 @@ public void setter_intToWrapperLongCoercionVarargs() { } } - @Test - public void setter_intToPrimitiveLongCoercionVarargs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void setter_intToPrimitiveLongCoercionVarargs(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7196 // Java coerces int to long. Same for varargs String str = "package com.example.reproducer\n" + @@ -162,8 +157,9 @@ public void setter_intToPrimitiveLongCoercionVarargs() { assertThat(fact.getValueList()).containsExactly(10L, 20L); // Coerced with both cases } - @Test - public void invalid_cast_intToString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void invalid_cast_intToString(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7198 // Cast from int to String : It's invalid in Java // Non-exec-model is tolerant to accept the invalid cast. @@ -194,8 +190,9 @@ public void invalid_cast_intToString() { } } - @Test - public void generics_addStringToBigDecimalList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void generics_addStringToBigDecimalList(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7218 // Add String to List : It's invalid in Java // Non-exec-model is tolerant to accept the addition (No compile-time check. Possible to add at runtime due to type erasure) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepTest.java index f670eef942f..e7588c9dfec 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepTest.java @@ -18,17 +18,15 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -44,18 +42,10 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class QueryCepTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryCepTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } private KieSession ksession; @@ -64,8 +54,7 @@ public static Collection getParameters() { private EntryPoint firstEntryPoint, secondEntryPoint; - @Before - public void prepare() { + public void prepare(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests\n" + "import " + TestEvent.class.getCanonicalName() + "\n" + "declare TestEvent\n" + @@ -102,14 +91,18 @@ public void prepare() { clock = ksession.getSessionClock(); } - @Test - public void noResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void noResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); QueryResults results = ksession.getQueryResults("EventsFromStream"); assertThat(results.size()).isEqualTo(0); } - @Test - public void withResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); secondEntryPoint.insert(new TestEvent("minusOne")); clock.advanceTime(5, TimeUnit.SECONDS); @@ -126,8 +119,10 @@ public void withResultTest() { assertThat(results.size()).isEqualTo(1); } - @Test - public void withNoResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withNoResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); secondEntryPoint.insert(new TestEvent("minusOne")); clock.advanceTime(5, TimeUnit.SECONDS); @@ -145,7 +140,7 @@ public void withNoResultTest() { assertThat(results.size()).isEqualTo(0); } - @After + @AfterEach public void cleanup() { if (ksession != null) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleEventListenerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleEventListenerTest.java index d49db912dcf..e745f10a3b9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleEventListenerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleEventListenerTest.java @@ -20,16 +20,15 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import org.kie.api.runtime.rule.Match; @@ -38,22 +37,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RuleEventListenerTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleEventListenerTest(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 testRuleEventListener() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleEventListener(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List list\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExecutionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExecutionTest.java index 48322a8003d..276e1abd1e0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExecutionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExecutionTest.java @@ -19,16 +19,15 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -36,23 +35,16 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RuleExecutionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleExecutionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with testAllWithBeforeAndAfter, testOnDeleteMatchConsequence. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with testAllWithBeforeAndAfter, testOnDeleteMatchConsequence. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testNoAll() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoAll(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "rule R1 when\n" + @@ -87,8 +79,9 @@ public void testNoAll() throws Exception { assertThat(list).isEqualTo(asList(-1, 1, -2, 2, -3, 3)); } - @Test - public void testAll() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAll(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "rule R1 when\n" + @@ -123,8 +116,9 @@ public void testAll() throws Exception { assertThat(list).isEqualTo(asList(-1, -2, -3, 1, 2, 3)); } - @Test - public void testAllWithBeforeAndAfter() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllWithBeforeAndAfter(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "rule R1 when\n" + @@ -167,8 +161,9 @@ public void testAllWithBeforeAndAfter() throws Exception { )); } - @Test - public void testOnDeleteMatchConsequence() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOnDeleteMatchConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import " + Person.class.getCanonicalName() + ";\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExtensionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExtensionTest.java index a0f1e0504d2..9ce009ac2fb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExtensionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleExtensionTest.java @@ -21,37 +21,29 @@ 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; import org.kie.api.runtime.KieSession; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RuleExtensionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleExtensionTest(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 testRuleExtendsNonexistingRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsNonexistingRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -75,8 +67,9 @@ public void testRuleExtendsNonexistingRule() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testRuleExtendsBetweenDRLs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsBetweenDRLs(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -115,8 +108,9 @@ public void testRuleExtendsBetweenDRLs() { } - @Test - public void testRuleExtendsOnIncrementalKB() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsOnIncrementalKB(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -155,8 +149,9 @@ public void testRuleExtendsOnIncrementalKB() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testRuleExtendsMissingOnIncrementalKB() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsMissingOnIncrementalKB(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -187,8 +182,9 @@ public void testRuleExtendsMissingOnIncrementalKB() { - @Test - public void testRuleExtendsWithCompositeKBuilder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsWithCompositeKBuilder(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -227,8 +223,9 @@ public void testRuleExtendsWithCompositeKBuilder() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testRuleExtendsNonExistingWithCompositeKBuilder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsNonExistingWithCompositeKBuilder(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -258,8 +255,9 @@ public void testRuleExtendsNonExistingWithCompositeKBuilder() { } - @Test - public void testRuleExtendsNonExistingWithCompositeKBuilderOutOfOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsNonExistingWithCompositeKBuilderOutOfOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -292,8 +290,9 @@ public void testRuleExtendsNonExistingWithCompositeKBuilderOutOfOrder() { assertThat(errors.toString().contains("Base")).isTrue(); } - @Test - public void testRuleExtendsWithCompositeKBuilderFreeOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsWithCompositeKBuilderFreeOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str = "package org.drools.test;\n" + @@ -332,8 +331,9 @@ public void testRuleExtendsWithCompositeKBuilderFreeOrder() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testRuleExtendsExtendsWithCompositeKBuilderFreeOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsExtendsWithCompositeKBuilderFreeOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str1 = "package org.drools.test;\n" + @@ -380,8 +380,9 @@ public void testRuleExtendsExtendsWithCompositeKBuilderFreeOrder() { assertThat((int) list.get(0)).isEqualTo(10); } - @Test - public void testRuleCircularExtension() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleCircularExtension(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-100 String str1 = "package org.drools.test;\n" + @@ -422,8 +423,9 @@ public void testRuleCircularExtension() { assertThat(errors.iterator().next().toString().contains("Circular")).isTrue(); } - @Test - public void testManyExtensions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testManyExtensions(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7542 String base = "package org.drools.test;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleMetadataTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleMetadataTest.java index c20fee3b272..ded01718922 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleMetadataTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/RuleMetadataTest.java @@ -18,40 +18,32 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.impl.InternalRuleBase; import org.drools.base.rule.ConsequenceMetaData; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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 static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RuleMetadataTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleMetadataTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs. This test may not be necessary for exec-model - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs. This test may not be necessary for exec-model + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "modify( $a ) { setA( 20 ), setB( $bb ) }"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -71,10 +63,11 @@ public void testModify() { assertThat(field2.isLiteral()).isFalse(); } - @Test - public void testModify2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModify2(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "modify( $a ) { setC( $bc ) };\n modify( $b ) { c = \"Hello\" };"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -99,10 +92,11 @@ public void testModify2() { assertThat(field2.isLiteral()).isTrue(); } - @Test - public void testRetract() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetract(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "retract( $b );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -113,10 +107,11 @@ public void testRetract() { assertThat(statment.getFactClassName()).isEqualTo(RuleMetadataTest.B.class.getName()); } - @Test - public void testRetractWithFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetractWithFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "retract( getA($a) );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -127,10 +122,11 @@ public void testRetractWithFunction() { assertThat(statment.getFactClassName()).isEqualTo("org.drools.A"); } - @Test - public void testUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$a.setA( 20 );\n $a.setB( $bb );\n update( $a );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -150,10 +146,11 @@ public void testUpdate() { assertThat(field2.isLiteral()).isFalse(); } - @Test - public void testUpdate2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdate2(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$a.setC( $bc );\n $b.c = \"Hello\";\n update( $a );\n update( $b );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -178,10 +175,11 @@ public void testUpdate2() { assertThat(field2.isLiteral()).isTrue(); } - @Test - public void testInsert() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsert(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "insert( new A(1, $bb, \"3\") );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -205,10 +203,11 @@ public void testInsert() { assertThat(field3.isLiteral()).isTrue(); } - @Test - public void testInsert2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsert2(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "insert( new B(1, $ab) );"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); RuleImpl rule = getRule(kbase, "R0"); ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData(); @@ -218,7 +217,7 @@ public void testInsert2() { assertThat(statment.getFactClassName()).isEqualTo(RuleMetadataTest.B.class.getName()); } - private KieBase getKnowledgeBase(String... consequences) { + private KieBase getKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, String... consequences) { String rule = "package org.drools\n" + "import " + RuleMetadataTest.B.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java index 0e88c104d1f..242110f8052 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.common.InternalWorkingMemory; @@ -41,33 +41,25 @@ import org.drools.core.reteoo.SegmentMemory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -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.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SegmentCreationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SegmentCreationTest(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 testSingleEmptyLhs() throws Exception { - KieBase kbase = buildKnowledgeBase(" "); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleEmptyLhs(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " "); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -89,9 +81,10 @@ public void testSingleEmptyLhs() throws Exception { assertThat(smem.getFirst()).isNull(); } - @Test - public void testSingleSharedEmptyLhs() throws Exception { - KieBase kbase = buildKnowledgeBase( " ", " "); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleSharedEmptyLhs(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " ", " "); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -120,9 +113,10 @@ public void testSingleSharedEmptyLhs() throws Exception { assertThat(rtnSmem2.getTipNode()).isEqualTo(rtn2); } - @Test - public void testSinglePattern() throws Exception { - KieBase kbase = buildKnowledgeBase(" A() \n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSinglePattern(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " A() \n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -141,9 +135,10 @@ public void testSinglePattern() throws Exception { assertThat(smem).isNull(); } - @Test - public void testSingleSharedPattern() throws Exception { - KieBase kbase = buildKnowledgeBase( " A() B()\n", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleSharedPattern(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " A() B()\n", " A() B()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -175,9 +170,10 @@ public void testSingleSharedPattern() throws Exception { assertThat(rtnSmem2.getTipNode()).isEqualTo(rtn2); } - @Test - public void testMultiSharedPattern() throws Exception { - KieBase kbase = buildKnowledgeBase( " X() A() \n", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultiSharedPattern(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " X() A() \n", " X() A() B() \n", " X() A() B() C() \n"); @@ -234,9 +230,10 @@ public void testMultiSharedPattern() throws Exception { assertThat(cSmem.getTipNode()).isEqualTo(rtn3); // note rtn3 is in the same segment as C } - @Test - public void testSubnetworkNoSharing() throws Exception { - KieBase kbase = buildKnowledgeBase( " A() not ( B() and C() ) \n" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubnetworkNoSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " A() not ( B() and C() ) \n" ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -275,9 +272,10 @@ public void testSubnetworkNoSharing() throws Exception { } - @Test - public void tesSubnetworkAfterShare() throws Exception { - KieBase kbase = buildKnowledgeBase( " X() A() \n", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void tesSubnetworkAfterShare(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " X() A() \n", " X() A() not ( B() and C() ) \n" ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -324,9 +322,10 @@ public void tesSubnetworkAfterShare() throws Exception { assertThat(bSmem.getFirst()).isNull(); } - @Test - public void tesShareInSubnetwork() throws Exception { - KieBase kbase = buildKnowledgeBase( " X() A() \n", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void tesShareInSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " X() A() \n", " X() A() B() C() \n", " X() A() not ( B() and C() ) \n" ); @@ -385,9 +384,10 @@ public void tesShareInSubnetwork() throws Exception { assertThat(notSmem.getTipNode()).isEqualTo(rtn3); } - @Test - public void testBranchCESingleSegment() throws Exception { - KieBase kbase = buildKnowledgeBase( " $a : A() \n" + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBranchCESingleSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " $a : A() \n" + " if ( $a != null ) do[t1] \n" + " B() \n" ); @@ -432,9 +432,10 @@ public void testBranchCESingleSegment() throws Exception { assertThat(pmem.isRuleLinked()).isTrue(); } - @Test - public void testBranchCEMultipleSegments() throws Exception { - KieBase kbase = buildKnowledgeBase( " X() $a : A() \n", // r1 + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBranchCEMultipleSegments(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " X() $a : A() \n", // r1 " X() $a : A() \n" + " if ( $a != null ) do[t1] \n" + " B() \n", // r2 @@ -501,11 +502,13 @@ public void testBranchCEMultipleSegments() throws Exception { assertThat(pmemr3.isRuleLinked()).isTrue(); } - @Test @Ignore + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled // TODO the conditional branch node is broken for node sharing, it's dropping the 3rd rules [t1] rtn // This is because is probably because the network buider, that handles candidate node for sharing isn't being applied branch logic. - public void testShorterBranchInMultipleSegments() throws Exception { - KieBase kbase = buildKnowledgeBase( " X() $a : A() \n", // r0 + public void testShorterBranchInMultipleSegments(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + KieBase kbase = buildKnowledgeBase(kieBaseTestConfiguration, " X() $a : A() \n", // r0 " X() $a : A() \n" + " if ( $a != null ) do[t1] \n" + " B() \n", // r1 @@ -525,7 +528,7 @@ public void testShorterBranchInMultipleSegments() throws Exception { assertThat(list).contains("t1-rule1", "t1-rule2"); // r1 } - private KieBase buildKnowledgeBase(String... rules) { + private KieBase buildKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, String... rules) { String str = ""; str += "package org.kie \n"; str += "import " + LinkingTest.A.class.getCanonicalName() + "\n" ; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentMemorySegmentPrototypeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentMemorySegmentPrototypeTest.java index 338c1a200b2..6ade89b23b4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentMemorySegmentPrototypeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentMemorySegmentPrototypeTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.impl.RuleBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; @@ -34,32 +34,22 @@ import org.drools.mvel.integrationtests.DynamicRulesChangesTest.Sprinkler; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; import org.kie.api.runtime.rule.FactHandle; import org.kie.internal.runtime.conf.ForceEagerActivationOption; -import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SegmentMemorySegmentPrototypeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SegmentMemorySegmentPrototypeTest(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(); } private static final String DRL = @@ -110,8 +100,9 @@ public static Collection getParameters() { " events.add( \"Everything is ok\" );\n" + "end"; - @Test - public void testSegmentMemoryPrototype() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMemoryPrototype(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, DRL); KieSession ksession = kbase.newKieSession(); try { @@ -129,8 +120,9 @@ public void testSegmentMemoryPrototype() { } } - @Test - public void testSessionCache() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSessionCache(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, DRL); StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kbase.newKieSession(); @@ -170,8 +162,9 @@ private void checkKieSession(KieSession ksession) { assertThat(events.size()).isEqualTo(5); } - @Test - public void testEnsureRiaSegmentCreationUsingPrototypes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEnsureRiaSegmentCreationUsingPrototypes(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1739 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -214,8 +207,9 @@ public void testEnsureRiaSegmentCreationUsingPrototypes() { } } - @Test - public void testSessionReset() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSessionReset(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "import " + Address.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps1Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps1Test.java index 7b3d088036d..c1305175b51 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps1Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps1Test.java @@ -23,8 +23,8 @@ import java.util.Collection; import org.drools.base.common.DroolsObjectOutputStream; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.io.ResourceType; import org.kie.internal.builder.KnowledgeBuilder; @@ -38,7 +38,8 @@ public class SerializedPackageMergeTwoSteps1Test { public static final String[] BINPKG = { System.getProperty( "java.io.tmpdir" ) + File.separator + "SerializedPackageMergeTwoSteps_1.bin", System.getProperty( "java.io.tmpdir" ) + File.separator + "SerializedPackageMergeTwoSteps_2.bin" }; - @Test @Ignore("DROOLS-5620 - test failed randomly and it doesn't reproduce the original issue (DROOLS-2224) scenario on CI."+ + @Test + @Disabled("DROOLS-5620 - test failed randomly and it doesn't reproduce the original issue (DROOLS-2224) scenario on CI."+ "It can be tested manually") public void testBuildAndSerializePackagesInTwoSteps1() { String str1 = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps2Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps2Test.java index e08c64281bb..9f766f295c9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps2Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTwoSteps2Test.java @@ -34,8 +34,8 @@ import org.drools.base.common.DroolsObjectOutputStream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.runtime.KieSession; @@ -45,7 +45,8 @@ public class SerializedPackageMergeTwoSteps2Test { // kpackage serialization is not supported. But leave it for standard-drl. - @Test @Ignore("DROOLS-5620 - test failed randomly and it doesn't reproduce the original issue (DROOLS-2224) scenario on CI."+ + @Test + @Disabled("DROOLS-5620 - test failed randomly and it doesn't reproduce the original issue (DROOLS-2224) scenario on CI."+ "It can be tested manually") public void testBuildAndSerializePackagesInTwoSteps2() throws IOException, ClassNotFoundException { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SeveralKieSessionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SeveralKieSessionsTest.java index 09a5b90b5b5..1ebde58414f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SeveralKieSessionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SeveralKieSessionsTest.java @@ -20,16 +20,14 @@ import java.io.Serializable; import java.util.ArrayList; -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.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Before; -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.KieServices; import org.kie.api.builder.KieBuilder; @@ -50,21 +48,13 @@ * Tests evaluation of a backward chaining family relationships example using * several KieSessions. */ -@RunWith(Parameterized.class) public class SeveralKieSessionsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SeveralKieSessionsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - + // DROOLS-145 private static final String PACKAGE = SeveralKieSessionsTest.class.getPackage().getName(); @@ -73,9 +63,8 @@ public static Collection getParameters() { private ReleaseId kieModuleId; - @Before - public void init() { - kieModuleId = prepareKieModule(); + public void init(KieBaseTestConfiguration kieBaseTestConfiguration) { + kieModuleId = prepareKieModule(kieBaseTestConfiguration); } /** @@ -83,9 +72,12 @@ public void init() { * two KieSessions created from the same KieBase. * * KieSessions are constructed using different KieContainer instances. + * @param kieBaseTestConfiguration */ - @Test - public void testFamilyWithTwoKieSessionsFromKieContainer() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFamilyWithTwoKieSessionsFromKieContainer(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + init(kieBaseTestConfiguration); final KieServices ks = KieServices.Factory.get(); final KieContainer kieContainer = ks.newKieContainer(kieModuleId); @@ -100,10 +92,11 @@ public void testFamilyWithTwoKieSessionsFromKieContainer() throws Exception { /** * Inserts a new KieModule containing single KieBase and two KieSession * instances into KieRepository. + * @param kieBaseTestConfiguration * * @return created module ReleaseId */ - private ReleaseId prepareKieModule() { + private ReleaseId prepareKieModule(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId = ks.newReleaseId("org.drools.compiler", "severalKieSessionsTest", "1.0.0"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ShadowProxyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ShadowProxyTest.java index 39750d9b886..391ed6fac25 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ShadowProxyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ShadowProxyTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheesery; import org.drools.mvel.compiler.Child; @@ -28,31 +28,23 @@ import org.drools.mvel.compiler.ObjectWithSet; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ShadowProxyTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ShadowProxyTest(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 testShadowProxyInHierarchies() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testShadowProxyInHierarchies(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ShadowProxyInHierarchies.drl"); KieSession ksession = kbase.newKieSession(); try { @@ -63,8 +55,9 @@ public void testShadowProxyInHierarchies() throws Exception { } } - @Test - public void testShadowProxyOnCollections() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testShadowProxyOnCollections(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ShadowProxyOnCollections.drl"); KieSession ksession = kbase.newKieSession(); try { @@ -83,8 +76,9 @@ public void testShadowProxyOnCollections() throws Exception { } } - @Test - public void testShadowProxyOnCollections2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testShadowProxyOnCollections2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ShadowProxyOnCollections2.drl"); KieSession ksession = kbase.newKieSession(); try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StatelessStressTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StatelessStressTest.java index 48f7f5c6369..850ff3b1de8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StatelessStressTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StatelessStressTest.java @@ -19,17 +19,16 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Address; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.StatelessKieSession; @@ -37,25 +36,16 @@ * This is for testing possible PermSpace issues (leaking) when spawning lots of sessions in concurrent threads. * Normally this test will be XXX'ed out, as when running it will not terminate. */ -@RunWith(Parameterized.class) public class StatelessStressTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public StatelessStressTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{KieBaseTestConfiguration.CLOUD_IDENTITY_MODEL_PATTERN}); // choose config - return parameters; + public static Stream parameters() { + return Stream.of(KieBaseTestConfiguration.CLOUD_IDENTITY_MODEL_PATTERN); } - @Ignore - @Test - public void testLotsOfStateless() throws Exception { + @Disabled + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLotsOfStateless(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "thread_class_test.drl"); int numThreads = 100; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrEvaluatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrEvaluatorTest.java index c2ef7adea4e..0c711ed6644 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrEvaluatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrEvaluatorTest.java @@ -19,41 +19,33 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.mvel.compiler.RoutingMessage; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class StrEvaluatorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public StrEvaluatorTest(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 testStrStartsWith() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrStartsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -75,9 +67,10 @@ public void testStrStartsWith() { } } - @Test - public void testStrEndsWith() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrEndsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -99,9 +92,10 @@ public void testStrEndsWith() { } } - @Test - public void testStrLengthEquals() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrLengthEquals(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -119,9 +113,10 @@ public void testStrLengthEquals() { } } - @Test - public void testStrNotStartsWith() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrNotStartsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -139,9 +134,10 @@ public void testStrNotStartsWith() { } } - @Test - public void testStrNotEndsWith() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrNotEndsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -161,9 +157,10 @@ public void testStrNotEndsWith() { } } - @Test - public void testStrLengthNoEquals() { - KieBase kbase = readKnowledgeBase(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrLengthNoEquals(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieBase kbase = readKnowledgeBase(kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); try { List list = new ArrayList(); @@ -184,8 +181,9 @@ public void testStrLengthNoEquals() { } } - @Test - public void testStrWithLogicalOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrWithLogicalOr(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests\n" + "import org.drools.mvel.compiler.RoutingMessage\n" + "rule R1\n" @@ -209,8 +207,9 @@ public void testStrWithLogicalOr() { } } - @Test - public void testStrWithInlineCastAndFieldOnThis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrWithInlineCastAndFieldOnThis(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests " + "import " + Person.class.getName() + "; " + "rule R1 " + @@ -230,8 +229,9 @@ public void testStrWithInlineCastAndFieldOnThis() { } } - @Test - public void testStrWithInlineCastOnThis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrWithInlineCastOnThis(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests " + "rule R1 " + " when " + @@ -250,13 +250,14 @@ public void testStrWithInlineCastOnThis() { } } - private KieBase readKnowledgeBase() { + private KieBase readKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "strevaluator_test.drl"); return kbase; } - @Test - public void testUrlInStringComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUrlInStringComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6983 String drl = "package org.drools.mvel.integrationtests " + "import " + FactMap.class.getCanonicalName() + "; " + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrictAnnotationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrictAnnotationTest.java index 602b8ead083..cef9c8c7072 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrictAnnotationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/StrictAnnotationTest.java @@ -24,11 +24,11 @@ import java.lang.annotation.Target; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.stream.Stream; import org.drools.core.common.DefaultEventHandle; import org.drools.core.impl.RuleBaseFactory; @@ -36,12 +36,11 @@ 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.Assume; -import org.junit.BeforeClass; -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.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -58,29 +57,22 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class StrictAnnotationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public StrictAnnotationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @BeforeClass + @BeforeAll public static void checkSkip() { // if new antlr4 parser is enabled, skip this test, because DRL6_STRICT is not supported - Assume.assumeFalse(DrlParser.ANTLR4_PARSER_ENABLED); + Assumptions.assumeFalse(DrlParser.ANTLR4_PARSER_ENABLED); } - @Test - public void testUnknownAnnotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnknownAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.simple \n" + "@Xyz rule yyy \n" + @@ -101,8 +93,9 @@ public void testUnknownAnnotation() { assertThat(results.getMessages().size()).isEqualTo(1); } - @Test - public void testImportedAnnotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportedAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.simple \n" + "import " + Xyz.class.getCanonicalName() + " \n" + @@ -124,8 +117,9 @@ public void testImportedAnnotation() { assertThat(results.getMessages().size()).isEqualTo(0); } - @Test - public void testEagerEvaluation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEagerEvaluation(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.simple \n" + "@Propagation(EAGER) rule xxx \n" + @@ -163,8 +157,9 @@ public void matchCreated(org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test - public void testWatch() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWatch(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package com.sample;\n" + "import " + MyClass.class.getCanonicalName() + ";\n" + @@ -188,8 +183,9 @@ public void testWatch() { } } - @Test - public void testStirctWatchWithoutQuotes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStirctWatchWithoutQuotes(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package com.sample;\n" + "import " + MyClass.class.getCanonicalName() + ";\n" + @@ -211,8 +207,9 @@ public void testStirctWatchWithoutQuotes() { assertThat(results.getMessages().size()).isEqualTo(1); } - @Test - public void testExplictPositionalArguments() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExplictPositionalArguments(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { String str = "package org.test;\n" + "global java.util.List names;\n" + "declare Person\n" + @@ -249,8 +246,9 @@ public void testExplictPositionalArguments() throws InstantiationException, Ille } } - @Test - public void testJavaSqlTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaSqlTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package " + Message.class.getPackage().getName() + "\n" + "@Role( Role.Type.EVENT ) @Timestamp( \"startTime\" ) @Duration( \"duration\" )\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SwitchOverStringTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SwitchOverStringTest.java index c7d3a22c768..cd9a90e861c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SwitchOverStringTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SwitchOverStringTest.java @@ -18,35 +18,26 @@ */ package org.drools.mvel.integrationtests; -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.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Assume; -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.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SwitchOverStringTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SwitchOverStringTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } private static final String FUNCTION_WITH_SWITCH_OVER_STRING = "function void theTest(String input) {\n" + @@ -60,15 +51,16 @@ public static Collection getParameters() { " }\n" + "}"; - @After + @AfterEach public void cleanUp() { System.clearProperty("drools.dialect.java.compiler.lnglevel"); } - @Test - public void testCompileSwitchOverStringWithLngLevel17() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompileSwitchOverStringWithLngLevel17(KieBaseTestConfiguration kieBaseTestConfiguration) { double javaVersion = Double.valueOf(System.getProperty("java.specification.version")); - Assume.assumeTrue("Test only makes sense on Java 7+.", javaVersion >= 1.7); + Assumptions.assumeTrue(javaVersion >= 1.7, "Test only makes sense on Java 7+."); System.setProperty("drools.dialect.java.compiler.lnglevel", "1.7"); try { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, FUNCTION_WITH_SWITCH_OVER_STRING); @@ -79,8 +71,9 @@ public void testCompileSwitchOverStringWithLngLevel17() { } } - @Test - public void testShouldFailToCompileSwitchOverStringWithLngLevel16() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testShouldFailToCompileSwitchOverStringWithLngLevel16(KieBaseTestConfiguration kieBaseTestConfiguration) { System.setProperty("drools.dialect.java.compiler.lnglevel", "1.6"); try { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, FUNCTION_WITH_SWITCH_OVER_STRING); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/BasicConcurrentInsertionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/BasicConcurrentInsertionsTest.java index e2321972f34..9e48e5a1870 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/BasicConcurrentInsertionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/BasicConcurrentInsertionsTest.java @@ -18,33 +18,27 @@ */ package org.drools.mvel.integrationtests.concurrency; -import java.util.Collection; import java.util.concurrent.Callable; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; -@RunWith(Parameterized.class) public class BasicConcurrentInsertionsTest extends AbstractConcurrentInsertionsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public BasicConcurrentInsertionsTest(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(timeout = 20000) - public void testConcurrentInsertionsFewObjectsManyThreads() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentInsertionsFewObjectsManyThreads(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "import " + Bean.class.getCanonicalName() + ";\n" + "\n" + "rule \"R\"\n" + @@ -55,8 +49,10 @@ public void testConcurrentInsertionsFewObjectsManyThreads() throws InterruptedEx testConcurrentInsertions(drl, 1, 1000, false, false, kieBaseTestConfiguration); } - @Test(timeout = 20000) - public void testConcurrentInsertionsManyObjectsFewThreads() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentInsertionsManyObjectsFewThreads(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "import " + Bean.class.getCanonicalName() + ";\n" + "\n" + "rule \"R\"\n" + @@ -67,8 +63,10 @@ public void testConcurrentInsertionsManyObjectsFewThreads() throws InterruptedEx testConcurrentInsertions(drl, 1000, 4, false, false, kieBaseTestConfiguration); } - @Test(timeout = 20000) - public void testConcurrentInsertionsNewSessionEachThreadUpdateFacts() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentInsertionsNewSessionEachThreadUpdateFacts(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // This tests also ObjectTypeNode concurrency final String drl = "import " + Bean.class.getCanonicalName() + ";\n" + " query existsBeanSeed5More() \n" + @@ -89,8 +87,10 @@ public void testConcurrentInsertionsNewSessionEachThreadUpdateFacts() throws Int testConcurrentInsertions(drl, 10, 1000, true, true, kieBaseTestConfiguration); } - @Test(timeout = 20000) - public void testConcurrentInsertionsNewSessionEachThread() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentInsertionsNewSessionEachThread(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "import " + Bean.class.getCanonicalName() + ";\n" + " query existsBeanSeed5More() \n" + " Bean( seed > 5 ) \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentInsertionsToSubnetworksTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentInsertionsToSubnetworksTest.java index 41ece663f31..e5db50770a6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentInsertionsToSubnetworksTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentInsertionsToSubnetworksTest.java @@ -24,45 +24,37 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; -@RunWith(Parameterized.class) public class ConcurrentInsertionsToSubnetworksTest extends AbstractConcurrentInsertionsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - protected final String drl; - - @Parameterized.Parameters(name = "DRL={0}, KieBase type={2}") - public static List getTestParameter() { + public static Stream parameters() { List drlParams = Arrays.asList( new String[]{"sharedSubnetworkAccumulateRule", sharedSubnetworkAccumulateRule}, new String[]{"noSharingSubnetworkAccumulateRule", noSharingSubnetworkAccumulateRule}, new String[]{"sharedSubnetworkNotRule", sharedSubnetworkNotRule}, new String[]{"sharedSubnetworkExistsRule", sharedSubnetworkExistsRule}); // TODO: EM failed with some tests. File JIRAs - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(false); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(false); // combine - List params = new ArrayList<>(); - for (Object[] drlParam : drlParams) { - for (Object[] kbParam : kbParams) { - params.add(new Object[]{drlParam[0], drlParam[1], kbParam[0]}); + List params = new ArrayList<>(); + for (String[] drlParam : drlParams) { + for (KieBaseTestConfiguration kbParam : kbParams) { + params.add(Arguments.of(drlParam[1], kbParam)); } } - return params; + return params.stream(); } - public ConcurrentInsertionsToSubnetworksTest(final String drlName, final String drl, final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.drl = drl; - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } private final static String sharedSubnetworkAccumulateRule = "import " + AtomicInteger.class.getCanonicalName() + ";\n" + @@ -148,28 +140,38 @@ public ConcurrentInsertionsToSubnetworksTest(final String drlName, final String " System.out.println(\"R2\");" + "end\n"; - @Test(timeout = 80000) - public void testConcurrentInsertionsFewObjectsManyThreads() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(80000) + public void testConcurrentInsertionsFewObjectsManyThreads(String drl, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { testConcurrentInsertions(drl, 1, 1000, false, false, kieBaseTestConfiguration); } - @Test(timeout = 80000) - public void testConcurrentInsertionsManyObjectsFewThreads() throws InterruptedException { + @ParameterizedTest(name = "DRL={0}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void testConcurrentInsertionsManyObjectsFewThreads(String drl, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { testConcurrentInsertions(drl, 500, 4, false, false, kieBaseTestConfiguration); } - @Test(timeout = 80000) - public void testConcurrentInsertionsManyObjectsSingleThread() throws InterruptedException { + @ParameterizedTest(name = "DRL={0}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void testConcurrentInsertionsManyObjectsSingleThread(String drl, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { testConcurrentInsertions(drl, 1000, 1, false, false, kieBaseTestConfiguration); } - @Test(timeout = 80000) - public void testConcurrentInsertionsNewSessionEachThread() throws InterruptedException { + @ParameterizedTest(name = "DRL={0}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void testConcurrentInsertionsNewSessionEachThread(String drl, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { testConcurrentInsertions(drl, 10, 1000, true, false, kieBaseTestConfiguration); } - @Test(timeout = 80000) - public void testConcurrentInsertionsNewSessionEachThreadUpdate() throws InterruptedException { + @ParameterizedTest(name = "DRL={0}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void testConcurrentInsertionsNewSessionEachThreadUpdate(String drl, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { testConcurrentInsertions(drl, 10, 1000, true, true, kieBaseTestConfiguration); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/MultithreadTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/MultithreadTest.java index 163114dc6f4..09040371bfc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/MultithreadTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/MultithreadTest.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests.concurrency; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; @@ -31,17 +30,18 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.impl.RuleBaseFactory; import org.drools.mvel.compiler.StockTick; 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.Ignore; -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.api.Disabled; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -62,24 +62,18 @@ /** * This is a test case for multi-thred issues */ -@RunWith(Parameterized.class) public class MultithreadTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MultithreadTest(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(); } private static final Logger LOG = LoggerFactory.getLogger(MultithreadTest.class); - @Test(timeout = 2000000) - public void testSlidingTimeWindows() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(2000000) + public void testSlidingTimeWindows(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools\n" + "global java.util.List list; \n" + "import " + StockTick.class.getCanonicalName() + "; \n" + @@ -97,7 +91,7 @@ public void testSlidingTimeWindows() { final List errors = new ArrayList<>(); - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, str); final KieSession ksession = kbase.newKieSession(); @@ -182,8 +176,10 @@ public void testSlidingTimeWindows() { } } - @Test(timeout = 20000) - public void testClassLoaderRace() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testClassLoaderRace(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.integrationtests;\n" + "" + @@ -252,8 +248,10 @@ public String toString() { } } - @Test(timeout = 20000) - public void testRaceOnAccumulateNodeSimple() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testRaceOnAccumulateNodeSimple(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.integrationtests;\n" + "" + @@ -279,7 +277,7 @@ public void testRaceOnAccumulateNodeSimple() throws InterruptedException { "end\n" + "\n"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, drl); @@ -329,9 +327,10 @@ public void setId(final String id) { } } - @Test - @Ignore - public void testConcurrencyWithChronThreads() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testConcurrencyWithChronThreads(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package it.intext.drools.fusion.bug;\n" + "\n" + @@ -352,7 +351,7 @@ public void testConcurrencyWithChronThreads() throws InterruptedException { " list.add( $count ); \n" + "end"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, drl); final KieSessionConfiguration conf = RuleBaseFactory.newKnowledgeSessionConfiguration(); @@ -426,8 +425,10 @@ public Throwable getError() { } } - @Test(timeout = 20000) - public void testConcurrentQueries() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentQueries(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-175 final StringBuilder drl = new StringBuilder(); drl.append("package org.drools.test;\n" + @@ -482,8 +483,10 @@ public void testConcurrentQueries() { } } - @Test(timeout = 40000) - public void testConcurrentDelete() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testConcurrentDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + SlowBean.class.getCanonicalName() + ";\n" + "rule R when\n" + @@ -557,8 +560,10 @@ public String toString() { } } - @Test(timeout = 20000) - public void testConcurrentFireAndDispose() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testConcurrentFireAndDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-1103 final String drl = "rule R no-loop timer( int: 1s )\n" + "when\n" + @@ -566,7 +571,7 @@ public void testConcurrentFireAndDispose() throws InterruptedException { "then\n" + "end"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, drl); final KieSessionConfiguration ksconf = KieServices.Factory.get().newKieSessionConfiguration(); @@ -607,8 +612,10 @@ public void run() { LOG.info("last line of test."); } - @Test(timeout = 20000) - public void testFireUntilHaltAndDispose() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(20000) + public void testFireUntilHaltAndDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-1103 final String drl = "rule R no-loop timer( int: 1s )\n" + "when\n" + @@ -616,7 +623,7 @@ public void testFireUntilHaltAndDispose() throws InterruptedException { "then\n" + "end"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, drl); final KieSessionConfiguration ksconf = KieServices.Factory.get().newKieSessionConfiguration(); @@ -644,8 +651,10 @@ public void testFireUntilHaltAndDispose() throws InterruptedException { } } - @Test(timeout = 40000) - public void testJittingShortComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testJittingShortComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1633 final String drl = "import " + BeanA.class.getCanonicalName() + "\n;" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java index e0b5bf652b8..e1286df43a9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.common.BaseNode; @@ -62,10 +63,9 @@ import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; 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.KieServices; import org.kie.api.builder.ReleaseId; @@ -76,24 +76,18 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AddRuleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - public AddRuleTest(KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); - } - - @Test - public void testAddThenSplitProtoAllJoins() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddThenSplitProtoAllJoins(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " a : A() B() C() X() E()\n"); + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " a : A() B() C() X() E()\n"); InternalWorkingMemory wm = (InternalWorkingMemory) kbase1.newKieSession(); ObjectTypeNode aotn = getObjectTypeNode(kbase1.getRete(), A.class); ObjectTypeNode cotn = getObjectTypeNode(kbase1.getRete(), C.class); @@ -141,12 +135,13 @@ public void testAddThenSplitProtoAllJoins() { assertThat(nodes[5]).isSameAs(smemProto1.getNodesInSegment()[2]); } - @Test - public void testAddThenSplitProtoWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddThenSplitProtoWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; // This only really checks that the linkedNodeMask is set, for the 'not' bits - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " a : A() not B() C() not X() E()\n"); + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " a : A() not B() C() not X() E()\n"); InternalWorkingMemory wm = (InternalWorkingMemory) kbase1.newKieSession(); ObjectTypeNode aotn = getObjectTypeNode(kbase1.getRete(), A.class); ObjectTypeNode cotn = getObjectTypeNode(kbase1.getRete(), C.class); @@ -174,11 +169,12 @@ public void testAddThenSplitProtoWithNot() { assertThat(smemProto1.getLinkedNodeMask()).isEqualTo(1); assertThat(smemProto1.getNodeTypesInSegment()).isEqualTo(BuildtimeSegmentUtilities.JOIN_NODE_BIT | BuildtimeSegmentUtilities.NOT_NODE_BIT); } - @Test - public void testAddWithSplitThenCreateThirdSplit() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddWithSplitThenCreateThirdSplit(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() C() E(1;) E(2;) E(3;) E(4;)\n", " A() B() C() X()\n"); @@ -230,11 +226,12 @@ public void testAddWithSplitThenCreateThirdSplit() { assertThat(smemProtoE2.getAllLinkedMaskTest()).isEqualTo(1); } - @Test - public void testAddWithSplitThenCreateThirdSplitInSamePos() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddWithSplitThenCreateThirdSplitInSamePos(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() C() E(1;) E(2;) E(3;) E(4;)\n", " A() B() C() X() Y()\n"); @@ -299,11 +296,12 @@ private static void addRuleAtGivenSplit(InternalKnowledgeBase kbase1, InternalWo new EagerPhreakBuilder().addRule(rtn, Collections.singletonList(wm), kbase1); } - @Test - public void testAddWithSplitAndEvalThenCreateThirdSplit() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddWithSplitAndEvalThenCreateThirdSplit(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() C() eval(1==1) eval(2==2) E(3;) E(4;)\n", " A() B() C() X()\n"); @@ -342,11 +340,12 @@ public void testAddWithSplitAndEvalThenCreateThirdSplit() { assertThat(smemProtoE4.getAllLinkedMaskTest()).isEqualTo(1); } - @Test - public void testChildProtosPosAndEndNodeSegmentsUpdated() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChildProtosPosAndEndNodeSegmentsUpdated(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() B(1;) C(1;) X() X(1;) X(2;) E()\n", " a : A() B() B(1;) C(1;) X() X(1;) X(3;)\n", " a : A() B() B(1;) C(2;)\n"); @@ -378,11 +377,12 @@ public void testChildProtosPosAndEndNodeSegmentsUpdated() { /** * This tests that masks and segments are not set, when outside of the subnetwork for a given path. */ - @Test - public void testDataStructuresWithSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDataStructuresWithSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { if (!PhreakBuilder.isEagerSegmentCreation()) return; - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() exists ( C() and C(1;) ) E() X()\n"); InternalWorkingMemory wm = (InternalWorkingMemory) kbase1.newKieSession(); @@ -406,9 +406,10 @@ public void testDataStructuresWithSubnetwork() { assertThat(endNode1.getPathMemSpec().smemCount()).isEqualTo(2); } - @Test - public void testFindNewBrancheRootsSimple() { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFindNewBrancheRootsSimple(KieBaseTestConfiguration kieBaseTestConfiguration) { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B() C() E()\n", " a : A() B() X() E()\n"); @@ -431,9 +432,10 @@ public void testFindNewBrancheRootsSimple() { assertThat(((Pair)branchRoots.toArray()[0]).child).isSameAs(xBeta); } - @Test - public void testNewBrancheRootsWithSubnetwork() { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r", + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewBrancheRootsWithSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r", " a : A() B(1;) C() E() X()\n", " a : A() B(1;) C() exists ( E() and F() ) B(2;)\n"); @@ -541,8 +543,9 @@ private static void assertSegmentsLengthAndPos(PathEndNode endNode, int s, Segme } - @Test - public void testPopulatedSingleRuleNoSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSingleRuleNoSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices ks = KieServices.get(); KieContainer kieContainer = KieUtil.getKieContainerFromDrls(kieBaseTestConfiguration, KieSessionTestConfiguration.STATEFUL_PSEUDO); InternalWorkingMemory wm = (InternalWorkingMemory) kieContainer.newKieSession(); @@ -581,8 +584,9 @@ public void testPopulatedSingleRuleNoSharing() { assertThat(list.get(0).getRule().getName()).isEqualTo("r1"); } - @Test - public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieServices ks = KieServices.get(); KieContainer kieContainer = KieUtil.getKieContainerFromDrls(kieBaseTestConfiguration, KieSessionTestConfiguration.STATEFUL_PSEUDO); InternalWorkingMemory wm = (InternalWorkingMemory) kieContainer.newKieSession(); @@ -632,9 +636,10 @@ public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart() throws Excep assertThat(((Match) list.get(0)).getRule().getName()).isEqualTo("r1"); } - @Test - public void testPopulatedRuleMidwayShare() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " a : A() B() C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedRuleMidwayShare(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " a : A() B() C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -651,7 +656,7 @@ public void testPopulatedRuleMidwayShare() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(3); - kbase1.addPackages( buildKnowledgePackage("r2", " a : A() B() C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a : A() B() C(2;) X() E()\n") ); ObjectTypeNode aotn = getObjectTypeNode(kbase1, A.class ); LeftInputAdapterNode liaNode = (LeftInputAdapterNode) aotn.getObjectSinkPropagator().getSinks()[0]; @@ -695,9 +700,10 @@ public void testPopulatedRuleMidwayShare() throws Exception { assertThat(((A) ((Match) list.get(5)).getDeclarationValue("a")).getObject()).isEqualTo(1); } - @Test - public void testPopulatedRuleWithEvals() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " a:A() B() eval(1==1) eval(1==1) C(1;) \n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedRuleWithEvals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " a:A() B() eval(1==1) eval(1==1) C(1;) \n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -712,7 +718,7 @@ public void testPopulatedRuleWithEvals() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(3); - kbase1.addPackages( buildKnowledgePackage("r2", " a:A() B() eval(1==1) eval(1==1) C(2;) \n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a:A() B() eval(1==1) eval(1==1) C(2;) \n") ); ObjectTypeNode aotn = getObjectTypeNode(kbase1, A.class ); LeftInputAdapterNode liaNode = (LeftInputAdapterNode) aotn.getObjectSinkPropagator().getSinks()[0]; @@ -759,9 +765,10 @@ public void testPopulatedRuleWithEvals() throws Exception { assertThat(((A) ((Match) list.get(5)).getDeclarationValue("a")).getObject()).isEqualTo(1); } - @Test - public void testPopulatedSharedLiaNode() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A() B(1;) C() X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSharedLiaNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A() B(1;) C() X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -778,7 +785,7 @@ public void testPopulatedSharedLiaNode() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(3); - kbase1.addPackages( buildKnowledgePackage("r2", " a : A() B(2;) C() X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a : A() B(2;) C() X() E()\n") ); ObjectTypeNode aotn = getObjectTypeNode(kbase1, A.class ); LeftInputAdapterNode liaNode = (LeftInputAdapterNode) aotn.getObjectSinkPropagator().getSinks()[0]; @@ -810,9 +817,10 @@ public void testPopulatedSharedLiaNode() throws Exception { assertThat(results.containsAll(asList(1, 2, 3))).isTrue(); } - @Test - public void testPopulatedSharedToRtn() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A() B() C() X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSharedToRtn(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A() B() C() X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -827,7 +835,7 @@ public void testPopulatedSharedToRtn() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r2", " A() B() C() X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A() B() C() X() E()\n") ); ObjectTypeNode eotn = getObjectTypeNode(kbase1, E.class ); JoinNode eNode = (JoinNode) eotn.getObjectSinkPropagator().getSinks()[0]; @@ -849,9 +857,10 @@ public void testPopulatedSharedToRtn() throws Exception { assertThat(((Match) list.get(3)).getRule().getName()).isEqualTo("r2"); } - @Test - public void testPopulatedMultipleShares() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedMultipleShares(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList<>(); wm.setGlobal("list", list); @@ -870,9 +879,9 @@ public void testPopulatedMultipleShares() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); wm.fireAllRules(); assertThat(list.size()).isEqualTo(5); @@ -882,12 +891,13 @@ public void testPopulatedMultipleShares() throws Exception { assertThat(list.stream().filter(m -> m.getRule().getName().equals("r3")).count()).isEqualTo(1); } - @Test - public void testSplitTwoBeforeCreatedSegment() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSplitTwoBeforeCreatedSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -913,7 +923,7 @@ public void testSplitTwoBeforeCreatedSegment() throws Exception { assertThat(sm.getSegmentPosMaskBit()).isEqualTo(4); assertThat(pm1.getLinkedSegmentMask()).isEqualTo(4); - kbase1.addPackages( buildKnowledgePackage("r5", " A(1;) A(2;) B(1;) B(2;) \n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r5", " A(1;) A(2;) B(1;) B(2;) \n") ); smems = pm1.getSegmentMemories(); assertThat(smems.length).isEqualTo(5); @@ -941,12 +951,13 @@ public void testSplitTwoBeforeCreatedSegment() throws Exception { } - @Test - public void testSplitOneBeforeCreatedSegment() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSplitOneBeforeCreatedSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -982,7 +993,7 @@ public void testSplitOneBeforeCreatedSegment() throws Exception { assertThat(sm.getSegmentPosMaskBit()).isEqualTo(2); assertThat(pm1.getLinkedSegmentMask()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r5", " A(1;) A(2;) B(1;) B(2;) \n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r5", " A(1;) A(2;) B(1;) B(2;) \n") ); smems = pm1.getSegmentMemories(); assertThat(smems.length).isEqualTo(5); @@ -1019,13 +1030,14 @@ public void testSplitOneBeforeCreatedSegment() throws Exception { } } - @Test - public void testSplitOnCreatedSegment() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSplitOnCreatedSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // this test splits D1 and D2 on the later add rule - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -1050,7 +1062,7 @@ public void testSplitOnCreatedSegment() throws Exception { assertThat(sm.getSegmentPosMaskBit()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r5", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(3;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r5", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(3;)\n") ); wm.fireAllRules(); assertThat(pm1.getLinkedSegmentMask()).isEqualTo(6); @@ -1088,7 +1100,7 @@ private RuleTerminalNode getRtn(String ruleName, KieBase kbase) { return ( RuleTerminalNode ) ((InternalRuleBase) kbase).getReteooBuilder().getTerminalNodes(ruleName)[0]; } - private InternalKnowledgeBase buildKnowledgeBase(String ruleName, String... rule) { + private InternalKnowledgeBase buildKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, String ruleName, String... rule) { return (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, buildKnowledgePackageDrl(ruleName, rule)); } @@ -1115,7 +1127,7 @@ private String buildKnowledgePackageDrl(String ruleName, String... rule) { return str; } - private Collection buildKnowledgePackage(String ruleName, String rule) { + private Collection buildKnowledgePackage(KieBaseTestConfiguration kieBaseTestConfiguration, String ruleName, String rule) { return KieBaseUtil.getKieBaseFromKieModuleFromDrl("tmp", kieBaseTestConfiguration, buildKnowledgePackageDrl(ruleName, rule)).getKiePackages(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/BaseLeftTuplesBuilder.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/BaseLeftTuplesBuilder.java index c7b5ae45f2f..003c6e9a341 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/BaseLeftTuplesBuilder.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/BaseLeftTuplesBuilder.java @@ -22,7 +22,6 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.TupleSets; import org.drools.core.reteoo.LeftTuple; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.RightTuple; import org.drools.core.reteoo.TupleFactory; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftBuilder.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftBuilder.java index c229acf6b81..9d778418901 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftBuilder.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftBuilder.java @@ -22,7 +22,6 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.PhreakPropagationContext; import org.drools.core.common.TupleSets; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.SegmentMemory; import org.drools.core.reteoo.TupleFactory; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftMemory.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftMemory.java index 20237677351..76b7eb79d0f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftMemory.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/LeftMemory.java @@ -23,7 +23,6 @@ import org.drools.core.common.PhreakPropagationContext; import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.BetaNode; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.SegmentMemory; import org.drools.core.reteoo.TupleFactory; import org.drools.core.reteoo.TupleImpl; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java index ae302e8a87f..a71fa8cf1b1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java @@ -40,7 +40,7 @@ import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.rule.JavaDialectRuntimeData; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.conf.CompositeBaseConfiguration; import static org.drools.mvel.integrationtests.phreak.Pair.t; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakLiaNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakLiaNodeTest.java index cce59619322..4a0ad7dbd12 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakLiaNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakLiaNodeTest.java @@ -19,37 +19,29 @@ package org.drools.mvel.integrationtests.phreak; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.InternalFactHandle; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PhreakLiaNodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PhreakLiaNodeTest(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 test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.mvel.compiler.test\n" + "\n" + "import " + A.class.getCanonicalName() + "\n" + @@ -141,8 +133,9 @@ private void assertFiredRules(List result, String... ruleNames) { result.clear(); } - @Test - public void test2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.mvel.compiler.test\n" + "\n" + "import " + A.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java index 6893b15caf6..9489b831424 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java @@ -40,7 +40,7 @@ import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.rule.JavaDialectRuntimeData; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.conf.CompositeBaseConfiguration; import static org.drools.mvel.integrationtests.phreak.A.a; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java index d7be71f427d..74095758621 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java @@ -36,10 +36,9 @@ import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.definition.KiePackage; import org.kie.api.runtime.rule.Match; @@ -47,26 +46,20 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static org.drools.core.phreak.PhreakBuilder.isEagerSegmentCreation; -@RunWith(Parameterized.class) public class RemoveRuleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RemoveRuleTest(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 testPopulatedSingleRuleNoSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSingleRuleNoSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -80,7 +73,7 @@ public void testPopulatedSingleRuleNoSharing() throws Exception { wm.fireAllRules(); - kbase.addPackages( buildKnowledgePackage("r1", " A() B() C(object == 2) X() E()\n") ); + kbase.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r1", " A() B() C(object == 2) X() E()\n") ); List list = new ArrayList(); wm.setGlobal("list", list); @@ -114,8 +107,9 @@ public void testPopulatedSingleRuleNoSharing() throws Exception { assertThat(countNodeMemories(nms)).isEqualTo(0); } - @Test - public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); @@ -128,7 +122,7 @@ public void testPopulatedSingleRuleNoSharingWithSubnetworkAtStart() throws Excep wm.fireAllRules(); - kbase.addPackages( buildKnowledgePackage("r1", " A() not( B() and C() ) X() E()\n") ); + kbase.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r1", " A() not( B() and C() ) X() E()\n") ); List list = new ArrayList(); wm.setGlobal("list", list); @@ -154,9 +148,10 @@ private int countNodeMemories(NodeMemories nms) { return count; } - @Test - public void testPopulatedRuleMidwayShare() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A() B() C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedRuleMidwayShare(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A() B() C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -174,7 +169,7 @@ public void testPopulatedRuleMidwayShare() throws Exception { assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(6); - kbase1.addPackages( buildKnowledgePackage("r2", " a : A() B() C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a : A() B() C(2;) X() E()\n") ); wm.fireAllRules(); ObjectTypeNode aotn = getObjectTypeNode(kbase1, A.class ); @@ -214,9 +209,10 @@ public void testPopulatedRuleMidwayShare() throws Exception { assertThat(list.size()).isEqualTo(7); // only one more added, as second rule as removed } - @Test - public void testPopulatedRuleWithEvals() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " a:A() B() eval(1==1) eval(1==1) C(1;) \n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedRuleWithEvals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " a:A() B() eval(1==1) eval(1==1) C(1;) \n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -234,7 +230,7 @@ public void testPopulatedRuleWithEvals() throws Exception { assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(6); - kbase1.addPackages( buildKnowledgePackage("r2", " a:A() B() eval(1==1) eval(1==1) C(2;) \n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a:A() B() eval(1==1) eval(1==1) C(2;) \n") ); wm.fireAllRules(); ObjectTypeNode aotn = getObjectTypeNode(kbase1, A.class ); @@ -277,9 +273,10 @@ public void testPopulatedRuleWithEvals() throws Exception { assertThat(list.size()).isEqualTo(7); // only one more added, as second rule as removed } - @Test - public void testPopulatedSharedLiaNode() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A() B(1;) C() X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSharedLiaNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A() B(1;) C() X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -297,7 +294,7 @@ public void testPopulatedSharedLiaNode() throws Exception { assertThat(list.size()).isEqualTo(3); assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(6); - kbase1.addPackages( buildKnowledgePackage("r2", " a : A() B(2;) C() X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a : A() B(2;) C() X() E()\n") ); wm.fireAllRules(); assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(11); @@ -349,9 +346,10 @@ public void testPopulatedSharedLiaNode() throws Exception { assertThat(list.size()).isEqualTo(7); // only one more added, as second rule as removed } - @Test - public void testPopulatedSharedLiaNodeNoBeta() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSharedLiaNodeNoBeta(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -364,7 +362,7 @@ public void testPopulatedSharedLiaNodeNoBeta() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r2", " a : A()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " a : A()\n") ); wm.fireAllRules(); assertThat(list.size()).isEqualTo(4); @@ -381,10 +379,11 @@ public void testPopulatedSharedLiaNodeNoBeta() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test - public void testAlphaTerminalNodesDontShareWithLian() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) B(1;) C(1;)\n") ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaTerminalNodesDontShareWithLian(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) B(1;) C(1;)\n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); @@ -399,9 +398,10 @@ public void testAlphaTerminalNodesDontShareWithLian() throws Exception { } } - @Test - public void testPopulatedSharedToRtn() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A() B() C() X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedSharedToRtn(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A() B() C() X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -417,7 +417,7 @@ public void testPopulatedSharedToRtn() throws Exception { assertThat(list.size()).isEqualTo(2); assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(6); - kbase1.addPackages( buildKnowledgePackage("r2", " A() B() C() X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A() B() C() X() E()\n") ); wm.fireAllRules(); assertThat(countNodeMemories(wm.getNodeMemories())).isEqualTo(7); assertThat(list.size()).isEqualTo(4); @@ -461,9 +461,10 @@ public void testPopulatedSharedToRtn() throws Exception { } - @Test - public void testPopulatedMultipleSharesRemoveFirst() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedMultipleSharesRemoveFirst(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -482,8 +483,8 @@ public void testPopulatedMultipleSharesRemoveFirst() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); wm.fireAllRules(); assertThat(list.size()).isEqualTo(5); @@ -498,9 +499,10 @@ public void testPopulatedMultipleSharesRemoveFirst() throws Exception { assertThat(list.size()).isEqualTo(3); } - @Test - public void testPopulatedMultipleSharesRemoveMid() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedMultipleSharesRemoveMid(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -519,8 +521,8 @@ public void testPopulatedMultipleSharesRemoveMid() throws Exception { wm.fireAllRules(); assertThat(list.size()).isEqualTo(2); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); wm.fireAllRules(); assertThat(list.size()).isEqualTo(5); @@ -535,9 +537,10 @@ public void testPopulatedMultipleSharesRemoveMid() throws Exception { assertThat(list.size()).isEqualTo(3); } - @Test - public void testPopulatedMultipleSharesRemoveLast() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPopulatedMultipleSharesRemoveLast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) X() E()\n"); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -561,7 +564,7 @@ public void testPopulatedMultipleSharesRemoveLast() throws Exception { assertThat(pmem1.getSegmentMemories().length).isEqualTo(1); assertSegmentMemory(pmem1, 0, 127, 127, 127); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(2;) X() E()\n") ); list.clear(); update10Facts(wm, fh1, fh2, fh3, fh4, fh5, fh6, fh7, fh8, fh9, fh10); @@ -579,7 +582,7 @@ public void testPopulatedMultipleSharesRemoveLast() throws Exception { assertSegmentMemory(pmem2, 0, 15, 15, 15); assertSegmentMemory(pmem2, 1, 7, 7, 7); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(3;) B(1;) B(2;) C(2;) X() E()\n") ); list.clear(); update10Facts(wm, fh1, fh2, fh3, fh4, fh5, fh6, fh7, fh8, fh9, fh10); @@ -641,11 +644,12 @@ private static void update10Facts(InternalWorkingMemory wm, InternalFactHandle f wm.update(fh10, fh10.getObject()); } - @Test - public void testPathMemorySizeAfterSegmentMerge() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPathMemorySizeAfterSegmentMerge(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // The two A(1;) are not actually shared, as r2 creates an AlphaTerminalNode - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) B(1;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;)\n") ); + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) B(1;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;)\n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); wm.setGlobal("list", list); @@ -665,10 +669,11 @@ public void testPathMemorySizeAfterSegmentMerge() throws Exception { assertThat(wm.getNodeMemory(rtn1).getSegmentMemories().length).isEqualTo(1); } - @Test - public void testPathMemorySizeAfterSegmentMergeNonInitialized() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) B(1;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;)\n") ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPathMemorySizeAfterSegmentMergeNonInitialized(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) B(1;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;)\n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); @@ -682,12 +687,13 @@ public void testPathMemorySizeAfterSegmentMergeNonInitialized() throws Exception assertThat(wm.getNodeMemory(rtn1).getSegmentMemories().length).isEqualTo(1); } - @Test - public void testSplitTwoBeforeCreatedSegment() throws Exception { - InternalKnowledgeBase kbase1 = buildKnowledgeBase("r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); - kbase1.addPackages( buildKnowledgePackage("r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); - kbase1.addPackages( buildKnowledgePackage("r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSplitTwoBeforeCreatedSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + InternalKnowledgeBase kbase1 = buildKnowledgeBase(kieBaseTestConfiguration, "r1", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n"); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r2", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;) E(1;) E(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r3", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) X(1;) X(2;)\n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r4", " A(1;) A(2;) B(1;) B(2;) C(1;) C(2;) \n") ); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase1.newKieSession()); List list = new ArrayList(); @@ -713,7 +719,7 @@ public void testSplitTwoBeforeCreatedSegment() throws Exception { assertThat(sm.getSegmentPosMaskBit()).isEqualTo(4); assertThat(pm1.getLinkedSegmentMask()).isEqualTo(4); - kbase1.addPackages( buildKnowledgePackage("r5", " A(1;) A(2;) B(1;) B(2;) \n") ); + kbase1.addPackages( buildKnowledgePackage(kieBaseTestConfiguration, "r5", " A(1;) A(2;) B(1;) B(2;) \n") ); smems = pm1.getSegmentMemories(); assertThat(smems.length).isEqualTo(5); @@ -769,11 +775,11 @@ private String addRule(String ruleName, String rule) { return str; } - private InternalKnowledgeBase buildKnowledgeBase(String ruleName, String rule) { + private InternalKnowledgeBase buildKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, String ruleName, String rule) { return (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, buildKnowledgePackageDrl(ruleName, rule)); } - private Collection buildKnowledgePackage(String ruleName, String rule) { + private Collection buildKnowledgePackage(KieBaseTestConfiguration kieBaseTestConfiguration, String ruleName, String rule) { return KieBaseUtil.getKieBaseFromKieModuleFromDrl("tmp", kieBaseTestConfiguration, buildKnowledgePackageDrl(ruleName, rule)).getKiePackages(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java index 16b3650d6a6..ba126e729fe 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java @@ -39,7 +39,7 @@ import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.rule.JavaDialectRuntimeData; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.conf.CompositeBaseConfiguration; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java index af39809bc01..983f0c4026a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java @@ -39,7 +39,7 @@ import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.rule.JavaDialectRuntimeData; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.conf.CompositeBaseConfiguration; import static org.drools.mvel.integrationtests.phreak.Pair.t; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/StagedBuilder.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/StagedBuilder.java index 711c14ee925..2d1cea88e52 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/StagedBuilder.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/StagedBuilder.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests.phreak; import org.drools.core.common.TupleSetsImpl; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.SegmentMemory; public class StagedBuilder extends BaseLeftTuplesBuilder { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/sequential/SequentialTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/sequential/SequentialTest.java index 29ed3bab67f..6f106a89555 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/sequential/SequentialTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/sequential/SequentialTest.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.drl.parser.DroolsParserException; import org.drools.kiesession.rulebase.InternalKnowledgeBase; @@ -34,10 +35,10 @@ 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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -62,22 +63,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SequentialTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SequentialTest(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 testSequentialPlusPhreakOperationComplex() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSequentialPlusPhreakOperationComplex(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test\n"; str +="import " + A.class.getCanonicalName() + "\n"; @@ -180,8 +174,9 @@ public void testSequentialPlusPhreakOperationComplex() throws Exception { assertThat(list.get(5)).isEqualTo("r9"); } - @Test - public void testSequentialPlusPhreakRevisitOriginallyEmptyGroup() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSequentialPlusPhreakRevisitOriginallyEmptyGroup(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test\n"; str +="import " + A.class.getCanonicalName() + "\n"; @@ -226,8 +221,9 @@ public void testSequentialPlusPhreakRevisitOriginallyEmptyGroup() throws Excepti assertThat(list.get(0)).isEqualTo("r9"); } - @Test - public void testBasicOperation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBasicOperation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieModule kieModule = KieUtil.getKieModuleFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "simpleSequential.drl"); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, SequentialOption.YES); StatelessKieSession ksession = kbase.newStatelessKieSession(); @@ -253,8 +249,9 @@ public void testBasicOperation() throws Exception { assertThat(list.size()).isEqualTo(3); } - @Test - public void testSalience() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalience(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieModule kieModule = KieUtil.getKieModuleFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "simpleSalience.drl"); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, SequentialOption.YES); StatelessKieSession ksession = kbase.newStatelessKieSession(); @@ -272,8 +269,9 @@ public void testSalience() throws Exception { assertThat(list.get(2)).isEqualTo("rule 1"); } - @Test - public void testKnowledgeRuntimeAccess() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeRuntimeAccess(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test\n"; str +="import org.drools.mvel.compiler.Message\n"; @@ -291,8 +289,9 @@ public void testKnowledgeRuntimeAccess() throws Exception { ksession.execute( new Message( "help" ) ); } - @Test - public void testEvents() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvents(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test\n"; str +="import org.drools.mvel.compiler.Message\n"; @@ -389,8 +388,9 @@ public void objectUpdated( ObjectUpdatedEvent event ) { // JBRULES-1567 - ArrayIndexOutOfBoundsException in sequential execution after calling RuleBase.addPackage(..) - @Test - public void testSequentialWithRulebaseUpdate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSequentialWithRulebaseUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieModule kieModule = KieUtil.getKieModuleFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "simpleSalience.drl"); final InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, SequentialOption.YES); StatelessKieSession ksession = kbase.newStatelessKieSession(); @@ -419,60 +419,66 @@ public void testSequentialWithRulebaseUpdate() throws Exception { assertThat(list.get(6)).isEqualTo(person); } - @Test - public void testProfileSequential() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testProfileSequential(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { - runTestProfileManyRulesAndFacts( true, "Sequential mode", 0, "sequentialProfile.drl" ); - runTestProfileManyRulesAndFacts( true, "Sequential mode", 0, "sequentialProfile.drl" ); + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, true, "Sequential mode", 0, "sequentialProfile.drl" ); + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, true, "Sequential mode", 0, "sequentialProfile.drl" ); System.gc(); Thread.sleep( 100 ); } - @Test - public void testProfileRETE() throws Exception { - runTestProfileManyRulesAndFacts( false, "Normal RETE mode", 0, "sequentialProfile.drl" ); - runTestProfileManyRulesAndFacts( false, "Normal RETE mode", 0, "sequentialProfile.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testProfileRETE(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, false, "Normal RETE mode", 0, "sequentialProfile.drl" ); + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, false, "Normal RETE mode", 0, "sequentialProfile.drl" ); System.gc(); Thread.sleep( 100 ); } - @Test - public void testNumberofIterationsSeq() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNumberofIterationsSeq(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //test throughput - runTestProfileManyRulesAndFacts( true, + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, true, "SEQUENTIAL", 2000, "sequentialProfile.drl" ); } - @Test - public void testNumberofIterationsRETE() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNumberofIterationsRETE(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //test throughput - runTestProfileManyRulesAndFacts( false, + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, false, "RETE", 2000, "sequentialProfile.drl" ); } - @Test - public void testPerfJDT() throws Exception { - runTestProfileManyRulesAndFacts( true, + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPerfJDT(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, true, "JDT", 2000, "sequentialProfile.drl" ); } - @Test - public void testPerfMVEL() throws Exception { - runTestProfileManyRulesAndFacts( true, + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPerfMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + runTestProfileManyRulesAndFacts(kieBaseTestConfiguration, true, "MVEL", 2000, "sequentialProfileMVEL.drl" ); } - private void runTestProfileManyRulesAndFacts(boolean sequentialMode, + private void runTestProfileManyRulesAndFacts(KieBaseTestConfiguration kieBaseTestConfiguration, boolean sequentialMode, String message, int timetoMeasureIterations, String file) throws DroolsParserException, IOException, Exception { @@ -532,8 +538,10 @@ private void runTestProfileManyRulesAndFacts(boolean sequentialMode, } - @Test(timeout = 10000L) - public void testSequentialWithNoLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSequentialWithNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1228098 String str = "package org.drools.mvel.compiler.test\n" + @@ -559,8 +567,9 @@ public void testSequentialWithNoLoop() throws Exception { assertThat(result.size()).isEqualTo(2); } - @Test - public void testSharedSegment() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedSegment(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1228313 String str = "package org.drools.mvel.compiler.test\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/ReteOOWaltzTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/ReteOOWaltzTest.java index 6d3ce10de58..e4926f738e5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/ReteOOWaltzTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/ReteOOWaltzTest.java @@ -18,22 +18,14 @@ */ package org.drools.mvel.integrationtests.waltz; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; -@RunWith(Parameterized.class) public class ReteOOWaltzTest extends Waltz { - public ReteOOWaltzTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/Waltz.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/Waltz.java index 4cbf79fe5c7..6cf3c92c9f0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/Waltz.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/Waltz.java @@ -26,7 +26,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.junit.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; @@ -37,17 +39,13 @@ */ public abstract class Waltz { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public Waltz(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test(timeout = 60000 ) - public void testWaltz() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(60000 ) + public void testWaltz(KieBaseTestConfiguration kieBaseTestConfiguration) { try { //load up the rulebase - final KieBase kBase = readKnowledegBase(); + final KieBase kBase = readKnowledegBase(kieBaseTestConfiguration); for ( int i = 0; i < 50; i++ ) { KieSession kSession = kBase.newKieSession(); @@ -81,7 +79,7 @@ public void testWaltz() { } } - public KieBase readKnowledegBase() { + public KieBase readKnowledegBase(KieBaseTestConfiguration kieBaseTestConfiguration) { return KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "waltz.drl"); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/WaltzMain.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/WaltzMain.java index 5807cd66bca..eeebe26d412 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/WaltzMain.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/waltz/WaltzMain.java @@ -22,11 +22,8 @@ public class WaltzMain extends ReteOOWaltzTest { - public WaltzMain(KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } public static final void main(String[] args) { - new WaltzMain(KieBaseTestConfiguration.CLOUD_IDENTITY).testWaltz(); + new WaltzMain().testWaltz(KieBaseTestConfiguration.CLOUD_IDENTITY); } } From aaad2b1a2d2a6c83f414e205303b30d15131c50c Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Thu, 21 Nov 2024 02:17:42 +0900 Subject: [PATCH 3/7] [NO-ISSUE] mvel.jj license (#6164) * [NO-ISSUE] mvel.jj license * - adjust words * - fixed a period --- LICENSE | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index bf91a1a0b63..0ffd00649bc 100644 --- a/LICENSE +++ b/LICENSE @@ -243,4 +243,8 @@ for drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/Ja Included by permission of the http://tpop.awl.com/ web site, which says: "You may use this code for any purpose, as long as you leave the - copyright notice and book citation attached." \ No newline at end of file + copyright notice and book citation attached." + + ------------------------------------------------------------------------------------ + for drools-model/drools-mvel-parser/src/main/javacc/mvel.jj + JavaParser is dual licensed under LGPL license and Apache License Version 2.0 license. We choose the Apache License Version 2.0. \ No newline at end of file From 72b4e693ef94b4a4bb5eed2950279258891893fe Mon Sep 17 00:00:00 2001 From: Roberto Oliveira Date: Mon, 25 Nov 2024 08:55:37 -0500 Subject: [PATCH 4/7] adding OMG XSD files License info (#6156) * adding OMG XSD files License info * fixing rat-excludes and adjusting file list of OMG files * adjusted trisotech related license and copyright info # Conflicts: # .rat-excludes --- LICENSE | 138 +++++++++++++++++- NOTICE | 4 + .../kie-dmn-backend/src/test/resources/DC.xsd | 1 + .../kie-dmn-backend/src/test/resources/DI.xsd | 1 + .../src/test/resources/DMN11.xsd | 1 + .../src/test/resources/DMN12.xsd | 1 + .../src/test/resources/DMN13.xsd | 1 + .../src/test/resources/DMN14.xsd | 1 + .../src/test/resources/DMN15.xsd | 1 + .../src/test/resources/DMNDI12.xsd | 1 + .../src/test/resources/DMNDI13.xsd | 1 + .../src/test/resources/DMNDI15.xsd | 1 + .../kie-dmn-feel/src/main/resources/dmn.xsd | 19 --- .../src/test/resources/DC.xsd | 19 --- .../src/test/resources/DI.xsd | 19 --- .../src/test/resources/DMN13.xsd | 19 --- .../src/test/resources/DMNDI13.xsd | 19 --- .../org/omg/spec/DMN/20151101/dmn.xsd | 19 --- .../org/omg/spec/DMN/20180521/DC.xsd | 19 --- .../org/omg/spec/DMN/20180521/DI.xsd | 19 --- .../org/omg/spec/DMN/20180521/DMN12.xsd | 19 --- .../org/omg/spec/DMN/20180521/DMNDI12.xsd | 19 --- .../org/omg/spec/DMN/20191111/DC.xsd | 19 --- .../org/omg/spec/DMN/20191111/DI.xsd | 19 --- .../org/omg/spec/DMN/20191111/DMN13.xsd | 19 --- .../org/omg/spec/DMN/20191111/DMNDI13.xsd | 19 --- .../org/omg/spec/DMN/20211108/DC.xsd | 19 --- .../org/omg/spec/DMN/20211108/DI.xsd | 19 --- .../org/omg/spec/DMN/20211108/DMN14.xsd | 19 --- .../org/omg/spec/DMN/20211108/DMNDI13.xsd | 19 --- .../org/omg/spec/DMN/20230324/DC.xsd | 19 --- .../org/omg/spec/DMN/20230324/DI.xsd | 19 --- .../org/omg/spec/DMN/20230324/DMN15.xsd | 19 --- .../org/omg/spec/DMN/20230324/DMNDI15.xsd | 19 --- 34 files changed, 151 insertions(+), 419 deletions(-) diff --git a/LICENSE b/LICENSE index 0ffd00649bc..bdfb8e372d8 100644 --- a/LICENSE +++ b/LICENSE @@ -245,6 +245,142 @@ for drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/Ja "You may use this code for any purpose, as long as you leave the copyright notice and book citation attached." + ------------------------------------------------------------------------------------ + for kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DI.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMN11.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMN12.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMN13.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMN14.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMN15.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMNDI12.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMNDI13.xsd + kie-dmn/kie-dmn-backend/src/test/resources/DMNDI15.xsd + kie-dmn/kie-dmn-feel/src/main/resources/dmn.xsd + kie-dmn/kie-dmn-trisotech/src/test/resources/DC.xsd + kie-dmn/kie-dmn-trisotech/src/test/resources/DI.xsd + kie-dmn/kie-dmn-trisotech/src/test/resources/DMN13.xsd + kie-dmn/kie-dmn-trisotech/src/test/resources/DMNDI13.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20151101/dmn.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DC.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DI.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DMN12.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DMNDI12.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20191111/DC.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20191111/DI.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20191111/DMN13.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20191111/DMNDI13.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20211108/DC.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20211108/DI.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20211108/DMN14.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20211108/DMNDI13.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DC.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DI.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMN15.xsd + kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd + +Copyright © 2019-2021, 88solutions +Copyright © 2019-2023, BOC Products & Services AG +Copyright © 2015-2023, Camunda Services GmbH +Copyright © 2013-2023, Decision Management Solutions +Copyright © 2019-2021, Department of Veterans Affairs +Copyright © 2013-2019, Escape Velocity LLC +Copyright © 2013-2023, Fair Isaac Corporation +Copyright © 2019-2023, GfSE e.V. +Copyright © 2013-2023, International Business Machines Corporation +Copyright © 2013-2023, KU Leuven +Copyright © 2013-2019, Model Systems Limited +Copyright © 2015-2019, Oracle Incorporated +Copyright © 2019-2023, PNA Group +Copyright © 2020-2023, processCentric GmbH +Copyright © 2013-2023, Red Hat Inc +Copyright © 2013-2023, Sapiens Decision NA +Copyright © 2019-2021, Signavio GmbH +Copyright © 2019-2023, Sparx Systems Pty Ltd +Copyright © 2019-2023, Thematix Partners LLC +Copyright © 2014-2019, TIBCO Software Inc. +Copyright © 2015-2023, Trisotech +Copyright © 2015-2023, Object Management Group, Inc. + +USE OF SPECIFICATION – TERMS, CONDITIONS & NOTICES +The material in this document details an Object Management Group specification in accordance with the terms, +conditions and notices set forth below. This document does not represent a commitment to implement any portion of this +specification in any company's products. The information contained in this document is subject to change without notice. + +LICENSES +The companies listed above have granted to the Object Management Group, Inc. (OMG) a nonexclusive, royalty-free, +paid up, worldwide license to copy and distribute this document and to modify this document and distribute copies of the +modified version. Each of the copyright holders listed above has agreed that no person shall be deemed to have infringed +the copyright in the included material of any such copyright holder by reason of having used the specification set forth +herein or having conformed any computer software to the specification. +Subject to all of the terms and conditions below, the owners of the copyright in this specification hereby grant you a +fully-paid up, non-exclusive, nontransferable, perpetual, worldwide license (without the right to sublicense), to use this +specification to create and distribute software and special purpose specifications that are based upon this specification, +and to use, copy, and distribute this specification as provided under the Copyright Act; provided that: (1) both the +copyright notice identified above and this permission notice appear on any copies of this specification; (2) the use of the +specifications is for informational purposes and will not be copied or posted on any network computer or broadcast in +any media and will not be otherwise resold or transferred for commercial purposes; and (3) no modifications are made to +this specification. This limited permission automatically terminates without notice if you breach any of these terms or +conditions. Upon termination, you will destroy immediately any copies of the specifications in your possession or +control. + +PATENTS +The attention of adopters is directed to the possibility that compliance with or adoption of OMG specifications may +require use of an invention covered by patent rights. OMG shall not be responsible for identifying patents for which a +license may be required by any OMG specification, or for conducting legal inquiries into the legal validity or scope of +those patents that are brought to its attention. OMG specifications are prospective and advisory only. Prospective users +are responsible for protecting themselves against liability for infringement of patents. + +GENERAL USE RESTRICTIONS +Any unauthorized use of this specification may violate copyright laws, trademark laws, and communications regulations +and statutes. This document contains information which is protected by copyright. All Rights Reserved. No part of this +work covered by copyright herein may be reproduced or used in any form or by any means--graphic, electronic, or +mechanical, including photocopying, recording, taping, or information storage and retrieval systems--without permission +of the copyright owner. + +DISCLAIMER OF WARRANTY +WHILE THIS PUBLICATION IS BELIEVED TO BE ACCURATE, IT IS PROVIDED "AS IS" AND MAY CONTAIN +ERRORS OR MISPRINTS. THE OBJECT MANAGEMENT GROUP AND THE COMPANIES LISTED ABOVE +MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS PUBLICATION, +INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF TITLE OR OWNERSHIP, IMPLIED WARRANTY +OF MERCHANTABILITY OR WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE. IN NO +EVENT SHALL THE OBJECT MANAGEMENT GROUP OR ANY OF THE COMPANIES LISTED ABOVE BE +LIABLE FOR ERRORS CONTAINED HEREIN OR FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +CONSEQUENTIAL, RELIANCE OR COVER DAMAGES, INCLUDING LOSS OF PROFITS, REVENUE, DATA +OR USE, INCURRED BY ANY USER OR ANY THIRD PARTY IN CONNECTION WITH THE FURNISHING, +PERFORMANCE, OR USE OF THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. +The entire risk as to the quality and performance of software developed using this specification is borne by you. This +disclaimer of warranty constitutes an essential part of the license granted to you to use this specification. + +RESTRICTED RIGHTS LEGEND +Use, duplication or disclosure by the U.S. Government is subject to the restrictions set forth in subparagraph (c) (1) (ii) of +The Rights in Technical Data and Computer Software Clause at DFARS 252.227-7013 or in subparagraph (c)(1) and (2) +of the Commercial Computer Software - Restricted Rights clauses at 48 C.F.R. 52.227-19 or as specified in 48 C.F.R. +227-7202-2 of the DoD F.A.R. Supplement and its successors, or as specified in 48 C.F.R. 12.212 of the Federal +Acquisition Regulations and its successors, as applicable. The specification copyright owners are as indicated above and +may be contacted through the Object Management Group, 9C Medway Rd, PMB 274, Milford, MA 01757, U.S.A. + +TRADEMARKS +CORBA®, CORBA logos®, FIBO®, Financial Industry Business Ontology®, FINANCIAL INSTRUMENT GLOBAL +IDENTIFIER®, IIOP®, IMM®, Model Driven Architecture®, MDA®, Object Management Group®, OMG®, OMG Logo, +SoaML®, SOAML®, SysML®, UAF®, Unified Modeling Language®, UML®, UML Cube Logo®, VSIPL®, and XMI® are +registered trademarks of the Object Management Group, Inc. +For a complete list of trademarks, see: https://www.omg.org/legal/tm_list.htm. All other products or company names +mentioned are used for identification purposes only and may be trademarks of their respective owners. + +COMPLIANCE +The copyright holders listed above acknowledge that the Object Management Group (acting itself or through its +designees) is and shall at all times be the sole entity that may authorize developers, suppliers and sellers of computer +software to use certification marks, trademarks or other special designations to indicate compliance with these materials. +Software developed under the terms of this license may claim compliance or conformance with this specification if and +only if the software compliance is of a nature fully matching the applicable compliance points as stated in the +specification. Software developed only partially matching the applicable compliance points may claim only that the +software was based on this specification, but may not claim compliance or conformance with this specification. In the +event that testing suites are implemented or approved by Object Management Group, Inc., software developed using this +specification may claim compliance or conformance with the specification only if the software satisfactorily completes +the testing suites. + ------------------------------------------------------------------------------------ for drools-model/drools-mvel-parser/src/main/javacc/mvel.jj - JavaParser is dual licensed under LGPL license and Apache License Version 2.0 license. We choose the Apache License Version 2.0. \ No newline at end of file + JavaParser is dual licensed under LGPL license and Apache License Version 2.0 license. We choose the Apache License Version 2.0. diff --git a/NOTICE b/NOTICE index c4276f2d54e..2b750e3e963 100644 --- a/NOTICE +++ b/NOTICE @@ -7,3 +7,7 @@ The Apache Software Foundation (http://www.apache.org/). The Initial Developer of some parts of the framework, which are copied from, derived from, or inspired by KIE (Knowledge Is Everything) group, is Red Hat, Inc (https://www.redhat.com/). Copyright Red Hat, Inc. and/or its affiliates.. All Rights Reserved. + +The Initial Developer of the kie-dmn/kie-dmn-trisotech/src/main/resources/org/kie/dmn/trisotech/validation/extension/TrisotechDMN13.xsd +is Trisotech Inc (https://www.trisotech.com/). +Copyright 2015 - 2024 Trisotech Inc. All Rights Reserved. diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd b/kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd index 634ba13a3ef..ee7d40dd358 100644 --- a/kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd +++ b/kie-dmn/kie-dmn-backend/src/test/resources/DC.xsd @@ -1,4 +1,5 @@ + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/DMN12.xsd b/kie-dmn/kie-dmn-backend/src/test/resources/DMN12.xsd index 47ade4cedde..0787357fcb0 100644 --- a/kie-dmn/kie-dmn-backend/src/test/resources/DMN12.xsd +++ b/kie-dmn/kie-dmn-backend/src/test/resources/DMN12.xsd @@ -1,4 +1,5 @@ + + + + diff --git a/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI12.xsd b/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI12.xsd index c3776064d82..484af60b2fd 100644 --- a/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI12.xsd +++ b/kie-dmn/kie-dmn-backend/src/test/resources/DMNDI12.xsd @@ -1,4 +1,5 @@ + + + diff --git a/kie-dmn/kie-dmn-feel/src/main/resources/dmn.xsd b/kie-dmn/kie-dmn-feel/src/main/resources/dmn.xsd index b2dc0d5aade..cf7800220fc 100644 --- a/kie-dmn/kie-dmn-feel/src/main/resources/dmn.xsd +++ b/kie-dmn/kie-dmn-feel/src/main/resources/dmn.xsd @@ -1,23 +1,4 @@  - - diff --git a/kie-dmn/kie-dmn-trisotech/src/test/resources/DC.xsd b/kie-dmn/kie-dmn-trisotech/src/test/resources/DC.xsd index d83ec42ffd0..634ba13a3ef 100644 --- a/kie-dmn/kie-dmn-trisotech/src/test/resources/DC.xsd +++ b/kie-dmn/kie-dmn-trisotech/src/test/resources/DC.xsd @@ -1,23 +1,4 @@ - - - - - - - - - - diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DC.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DC.xsd index d83ec42ffd0..634ba13a3ef 100644 --- a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DC.xsd +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20180521/DC.xsd @@ -1,23 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd index 1c1d75a32b1..87e84f9cf89 100644 --- a/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd +++ b/kie-dmn/kie-dmn-validation/src/main/resources/org/kie/dmn/validation/org/omg/spec/DMN/20230324/DMNDI15.xsd @@ -1,23 +1,4 @@ - - From 063308eaf2e6f8923a4b86cc3156612e1cd6c462 Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Fri, 22 Nov 2024 08:19:50 +0100 Subject: [PATCH 5/7] [incubator-kie-drools-6136] Migrate drools test coverage to JUnit5 - #5 (#6168) * Migrated tests to JUnit5 * More tests migrated * Migrated tests to Junit5 * Migrated more tests * Migrated test suite to JUnit5 * 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 +- .../NegativePatternsTest.java | 53 +++--- .../concurrency/AbstractConcurrentTest.java | 33 ++-- .../ConcurrentBasesParallelTest.java | 164 +++++++++++------ ...aTypeEvaluationConcurrentSessionsTest.java | 171 ++++++++++++------ .../EnumEvaluationConcurrentSessionsTest.java | 40 ++-- .../JoinsConcurrentSessionsTest.java | 41 +++-- .../SharedSessionParallelTest.java | 109 ++++++----- .../SubnetworkConcurrentSessionsTest.java | 89 +++++---- .../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 +- drools-test-coverage/test-suite/pom.xml | 6 +- .../testcoverage/common/KieSessionTest.java | 20 +- .../common/util/TestParametersUtil2.java | 19 +- .../common/util/TestParametersUtilTest.java | 43 ++--- .../functional/DecisionTableTest.java | 123 +++++++------ .../functional/DeclarativeAgendaTest.java | 21 ++- .../functional/DuplicityTest.java | 26 +-- .../functional/FactHandleTest.java | 28 +-- .../functional/InternalMatchGroupTest.java | 54 +++--- .../functional/KieContainerDefaultsTest.java | 6 +- .../functional/KieContainerTest.java | 6 +- .../functional/KieRepositoryTest.java | 6 +- .../functional/LiveQueriesBadResultTest.java | 46 ++--- .../LogicalInsertFromCollectionTest.java | 44 ++--- .../functional/QueryBadResultTest.java | 49 +++-- .../functional/ResourcesTest.java | 51 +++--- .../functional/RuleTemplateTest.java | 25 +-- .../functional/TemplatesTest.java | 87 ++++----- .../testcoverage/functional/UnicodeTest.java | 54 +++--- .../DecisionTableKieContainerTest.java | 2 +- .../functional/model/RulesWithInTest.java | 2 +- .../functional/oopath/OOPathCepTest.java | 130 +++++++------ .../functional/oopath/OOPathDslTest.java | 2 +- .../functional/oopath/OOPathDtablesTest.java | 54 +++--- .../oopath/OOPathLogicalBranchesTest.java | 80 ++++---- .../functional/oopath/OOPathSmokeTest.java | 38 ++-- .../functional/parser/DrlParserTest.java | 18 +- .../functional/parser/DslParserTest.java | 37 ++-- .../functional/parser/ParserTest.java | 23 +-- .../functional/parser/SmokeParserTest.java | 21 +-- .../memory/KieScannerMemoryTest.java | 17 +- .../AbstractCompositeRestrictionTest.java | 26 +-- .../AccumulateRecalculationTest.java | 2 +- .../regression/AmbiguousExceptionTest.java | 26 +-- .../BetaMemoryLeakOnDeleteTest.java | 3 +- .../regression/DateExtendingFactTest.java | 26 +-- .../regression/DeclarationWithOrTest.java | 26 +-- ...serializationWithCompositeTriggerTest.java | 34 ++-- .../regression/DroolsGcCausesNPETest.java | 13 +- .../regression/EqualityKeyOverrideTest.java | 26 ++- .../regression/EscapesInMetadataTest.java | 27 +-- .../EventDeserializationInPastTest.java | 2 +- .../EventFactHandleDeserializationTest.java | 2 +- .../regression/FixedPatternTest.java | 30 ++- .../regression/FromGenericCollectionTest.java | 27 +-- .../regression/FusionAfterBeforeTest.java | 34 ++-- .../regression/GenericsWithModifyTest.java | 43 ++--- .../regression/GlobalOnLHSTest.java | 27 ++- .../regression/ImportReplaceTest.java | 27 +-- .../regression/InaccurateComparisonTest.java | 27 +-- .../regression/InternalMatchTest.java | 24 ++- .../LogicalInsertionsSerializationTest.java | 35 ++-- .../MultiRestrictionPatternTest.java | 46 ++--- .../MultipleKieBaseListenersTest.java | 27 +-- .../MultipleSalienceUpdateFactTest.java | 28 ++- .../regression/MultipleSheetsLoadingTest.java | 29 ++- .../MvelOverloadedMethodsUsageTest.java | 26 ++- .../regression/NonStringCompareTest.java | 48 +++-- .../regression/NotInFusionTest.java | 60 +++--- .../regression/NullInListInFromTest.java | 26 +-- .../regression/POJOAnnotationMergeTest.java | 26 +-- .../regression/PropertyListenerTest.java | 26 +-- .../SerializableGeneratedTypesTest.java | 27 +-- .../SerializableInstantiationTest.java | 24 ++- .../SerializationWithCollectTest.java | 10 +- .../SessionInsertMultiThreadingTest.java | 47 +++-- .../regression/StarImportTest.java | 28 ++- ...TruthMaintenanceSystemConcurrencyTest.java | 2 +- .../UnwantedStringConversionTest.java | 27 +-- .../regression/XSDResourceTest.java | 3 +- .../regression/mvel/MvelLinkageErrorTest.java | 2 +- 91 files changed, 1431 insertions(+), 1498 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-compiler-integration/src/test/java/org/drools/compiler/integrationtests/NegativePatternsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/NegativePatternsTest.java index 6aa38d2258a..b8e8dbaa79e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/NegativePatternsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/NegativePatternsTest.java @@ -19,20 +19,18 @@ package org.drools.compiler.integrationtests; import java.io.Serializable; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; +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.KieSessionTestConfiguration; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.DefaultAgendaEventListener; @@ -48,29 +46,22 @@ * inserted through one or more entry points. * BZ-978979 */ -@RunWith(Parameterized.class) public class NegativePatternsTest { private static final int LOOPS = 300; private static final int SHORT_SLEEP_TIME = 20; private static final int LONG_SLEEP_TIME = 30; - private final KieBaseTestConfiguration kieBaseTestConfiguration; private KieSession ksession; private TrackingAgendaEventListener firedRulesListener; - public NegativePatternsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - - @Before - public void prepareKieSession() { + + public void prepareKieSession(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests\n" + "\n" + "import " + NegativePatternsTest.TestEvent.class.getCanonicalName() + "\n" + @@ -124,15 +115,17 @@ public void prepareKieSession() { ksession.addEventListener(firedRulesListener); } - @After + @AfterEach public void cleanKieSession() { if (ksession != null) { ksession.dispose(); } } - @Test - public void testSingleEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepareKieSession(kieBaseTestConfiguration); final EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); int count = 0; @@ -169,8 +162,10 @@ public void testSingleEvent() { assertThat(firedRulesListener.ruleFiredCount("SingleAbsence")).isEqualTo(count); } - @Test - public void testConstrainedAbsence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConstrainedAbsence(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepareKieSession(kieBaseTestConfiguration); final EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); int count = 0; @@ -198,8 +193,10 @@ public void testConstrainedAbsence() { assertThat(firedRulesListener.ruleFiredCount("SingleConstrained")).isEqualTo(count); } - @Test - public void testMultipleEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepareKieSession(kieBaseTestConfiguration); final EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); int count = 0; @@ -237,8 +234,10 @@ public void testMultipleEvents() { assertThat(firedRulesListener.ruleFiredCount("MultipleEvents")).isEqualTo(count); } - @Test - public void testMultipleEntryPoints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepareKieSession(kieBaseTestConfiguration); final EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); final EntryPoint otherStream = ksession.getEntryPoint("OtherStream"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/AbstractConcurrentTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/AbstractConcurrentTest.java index c92061492b3..4a8253f4ac4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/AbstractConcurrentTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/AbstractConcurrentTest.java @@ -45,20 +45,12 @@ public abstract class AbstractConcurrentTest { - protected final boolean enforcedJitting; - protected final boolean serializeKieBase; - protected final boolean sharedKieBase; - protected final boolean sharedKieSession; - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbstractConcurrentTest(final boolean enforcedJitting, final boolean serializeKieBase, - final boolean sharedKieBase, final boolean sharedKieSession, KieBaseTestConfiguration kieBaseTestConfiguration) { - this.enforcedJitting = enforcedJitting; - this.serializeKieBase = serializeKieBase; - this.sharedKieBase = sharedKieBase; - this.sharedKieSession = sharedKieSession; - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } + protected boolean enforcedJitting; + protected boolean isKieBaseSerialized; + protected boolean isKieBaseShared; + protected boolean isKieSessionShared; + protected KieBaseTestConfiguration kieBaseTestConfiguration; + interface TestWithSessionExecutor { boolean execute(KieSession kieSession, int counter); @@ -67,6 +59,15 @@ interface TestWithSessionExecutor { interface TestExecutor { boolean execute(int counter); } + + protected void initTest(boolean enforcedJitting, boolean isKieBaseSerialized, + boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) { + this.enforcedJitting = enforcedJitting; + this.isKieBaseSerialized = isKieBaseSerialized; + this.isKieBaseShared = isKieBaseShared; + this.isKieSessionShared = isKieSessionShared; + this.kieBaseTestConfiguration = kieBaseTestConfiguration; + } protected void parallelTest(final int threadCount, final TestExecutor testExecutor) throws InterruptedException { final List> tasks = new ArrayList<>(); @@ -96,8 +97,8 @@ protected void parallelTest(final int repetitions, final int threadCount, final for (int i = 0; i < threadCount; i++) { final int counter = i; tasks.add(() -> { - final KieBase kieBaseForTest = this.sharedKieBase ? sharedKieBase : getKieBase(drls); - if (this.sharedKieSession) { + final KieBase kieBaseForTest = this.isKieBaseShared ? sharedKieBase : getKieBase(drls); + if (this.isKieSessionShared) { return testExecutor.execute(sharedKieSession, counter); } else { return executeInSeparateSession(testExecutor, kieBaseForTest, globalName, global, counter); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentBasesParallelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentBasesParallelTest.java index c0208f8a904..e354b9c4c6f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentBasesParallelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/ConcurrentBasesParallelTest.java @@ -23,56 +23,55 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.BeanA; import org.drools.mvel.integrationtests.facts.BeanB; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.QueryResults; import org.kie.api.runtime.rule.QueryResultsRow; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; + /** * Test each thread having it's own separate KieBase and KieSession. */ -@RunWith(Parameterized.class) public class ConcurrentBasesParallelTest extends AbstractConcurrentTest { - @Parameterized.Parameters(name = "Enforced jitting={0}, KieBase type={1}") - public static List getTestParameters() { - List baseParams = Arrays.asList( - new Boolean[]{false}, - new Boolean[]{true}); + public static Stream parameters() { + List baseParams = Arrays.asList(false, true); - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(true); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(true); // combine - List params = new ArrayList<>(); - for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + List params = new ArrayList<>(); + for (Boolean baseParam : baseParams) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[]{baseParam[0], kbParam[0]}); + params.add(arguments(baseParam, kbParam)); } } } - return params; + return params.stream(); } private static final Integer NUMBER_OF_THREADS = 10; - public ConcurrentBasesParallelTest(final boolean enforcedJitting, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, false, false, kieBaseTestConfiguration); - }; - - @Test(timeout = 40000) - public void testOneOfAllFactsMatches() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testOneOfAllFactsMatches(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int numberOfObjects = 100; final TestExecutor exec = counter -> { @@ -99,8 +98,11 @@ public void testOneOfAllFactsMatches() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testNoFactMatches() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testNoFactMatches(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final TestExecutor exec = counter -> { final String rule = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule Rule_" + counter + " " + @@ -128,8 +130,11 @@ public void testNoFactMatches() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testFireAndGlobalSeparation() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireAndGlobalSeparation(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final TestExecutor exec = counter -> { final String rule = "import " + BeanA.class.getCanonicalName() + ";\n" + "global " + AtomicInteger.class.getCanonicalName() + " result;\n" + @@ -158,8 +163,11 @@ public void testFireAndGlobalSeparation() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testFireAndGlobalSeparation2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireAndGlobalSeparation2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -197,8 +205,11 @@ public void testFireAndGlobalSeparation2() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testNonMatchingFact() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testNonMatchingFact(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "rule ${ruleName} " + @@ -231,8 +242,11 @@ public void testNonMatchingFact() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testMatchingFact() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testMatchingFact(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "rule ${ruleName} " + @@ -265,8 +279,11 @@ public void testMatchingFact() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testNot() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testNot(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "rule ${ruleName} " + @@ -300,8 +317,11 @@ public void testNot() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testExists() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testExists(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "rule ${ruleName} " + @@ -336,8 +356,11 @@ public void testExists() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testSubnetwork(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + "import " + BeanB.class.getCanonicalName() + ";\n" + "rule ${ruleName} " + @@ -383,8 +406,11 @@ public void testSubnetwork() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testAccumulatesMatchOnlyBeanA() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testAccumulatesMatchOnlyBeanA(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleA = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule RuleA " + "when " + @@ -421,8 +447,11 @@ public void testAccumulatesMatchOnlyBeanA() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testAccumulatesMatchBoth() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testAccumulatesMatchBoth(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleA = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule RuleA " + "when " + @@ -454,8 +483,11 @@ public void testAccumulatesMatchBoth() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testAccumulatesMatchOnlyOne() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testAccumulatesMatchOnlyOne(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleA = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule RuleA " + "when " + @@ -491,8 +523,11 @@ public void testAccumulatesMatchOnlyOne() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testNotsMatchOnlyOne() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testNotsMatchOnlyOne(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleA = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule RuleNotA " + "when " + @@ -528,8 +563,11 @@ public void testNotsMatchOnlyOne() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testNotsMatchBoth() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testNotsMatchBoth(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String ruleA = "import " + BeanA.class.getCanonicalName() + ";\n" + "rule RuleNotA " + "when " + @@ -565,8 +603,11 @@ public void testNotsMatchBoth() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testFunctions() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testFunctions(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String rule = "import " + BeanA.class.getCanonicalName() + ";\n" + "global java.util.List list;" + "rule Rule " + @@ -602,8 +643,11 @@ public void testFunctions() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testFunctions2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testFunctions2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int objectCount = 100; final String rule = "import " + BeanA.class.getCanonicalName() + ";\n" + @@ -651,8 +695,11 @@ public void testFunctions2() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testQueries() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testQueries(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int numberOfObjects = 100; final TestExecutor exec = counter -> { @@ -686,8 +733,11 @@ public void testQueries() throws InterruptedException { parallelTest(NUMBER_OF_THREADS, exec); } - @Test(timeout = 40000) - public void testQueries2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testQueries2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int numberOfObjects = 100; final String queryTemplate = "import " + BeanA.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/DataTypeEvaluationConcurrentSessionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/DataTypeEvaluationConcurrentSessionsTest.java index 5e840e1f2f8..b51c6ff2ea0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/DataTypeEvaluationConcurrentSessionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/DataTypeEvaluationConcurrentSessionsTest.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.AnEnum; import org.drools.mvel.integrationtests.facts.FactWithBigDecimal; @@ -38,21 +39,21 @@ import org.drools.mvel.integrationtests.facts.FactWithShort; import org.drools.mvel.integrationtests.facts.FactWithString; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; -@RunWith(Parameterized.class) public class DataTypeEvaluationConcurrentSessionsTest extends AbstractConcurrentTest { private static final Integer NUMBER_OF_THREADS = 10; private static final Integer NUMBER_OF_REPETITIONS = 1; - @Parameterized.Parameters(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") - public static List getTestParameters() { + public static Stream parameters() { List baseParams = Arrays.asList( new Boolean[]{false, false, false}, new Boolean[]{true, false, false}, @@ -64,118 +65,170 @@ public static List getTestParameters() { new Boolean[]{false, true, true}, new Boolean[]{true, true, true}); // TODO: EM failed with some tests. File JIRAs - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(false); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(false); // combine - List params = new ArrayList<>(); + List params = new ArrayList<>(); for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam[0] && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[]{baseParam[0], baseParam[1], baseParam[2], kbParam[0]}); + params.add(arguments(baseParam[0], baseParam[1], baseParam[2], kbParam)); } } } - return params; + return params.stream(); } - public DataTypeEvaluationConcurrentSessionsTest(final boolean enforcedJitting, - final boolean sharedKieBase, final boolean sharedKieSession, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, sharedKieBase, sharedKieSession, kieBaseTestConfiguration); + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testBooleanPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); + testFactAttributeType(" $factWithBoolean: FactWithBoolean(booleanValue == false) \n", new FactWithBoolean(false)); } - @Test(timeout = 40000) - public void testBooleanPrimitive() throws InterruptedException { - testFactAttributeType(" $factWithBoolean: FactWithBoolean(booleanValue == false) \n", new FactWithBoolean(false)); - } - - @Test(timeout = 40000) - public void testBoolean() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testBoolean(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithBoolean: FactWithBoolean(booleanObjectValue == false) \n", new FactWithBoolean(false)); } - @Test(timeout = 40000) - public void testBytePrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testBytePrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithByte: FactWithByte(byteValue == 15) \n", new FactWithByte((byte) 15)); } - @Test(timeout = 40000) - public void testByte() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testByte(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithByte: FactWithByte(byteObjectValue == 15) \n", new FactWithByte((byte) 15)); } - @Test(timeout = 40000) - public void testShortPrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testShortPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithShort: FactWithShort(shortValue == 15) \n", new FactWithShort((short) 15)); } - @Test(timeout = 40000) - public void testShort() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testShort(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithShort: FactWithShort(shortObjectValue == 15) \n", new FactWithShort((short) 15)); } - @Test(timeout = 40000) - public void testIntPrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testIntPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithInt: FactWithInteger(intValue == 15) \n", new FactWithInteger(15)); } - @Test(timeout = 40000) - public void testInteger() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testInteger(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithInteger: FactWithInteger(integerValue == 15) \n", new FactWithInteger(15)); } - @Test(timeout = 40000) - public void testLongPrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testLongPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithLong: FactWithLong(longValue == 15) \n", new FactWithLong(15)); } - @Test(timeout = 40000) - public void testLong() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testLong(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithLong: FactWithLong(longObjectValue == 15) \n", new FactWithLong(15)); } - @Test(timeout = 40000) - public void testFloatPrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testFloatPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithFloat: FactWithFloat(floatValue == 15.1) \n", new FactWithFloat(15.1f)); } - @Test(timeout = 40000) - public void testFloat() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testFloat(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithFloat: FactWithFloat(floatObjectValue == 15.1) \n", new FactWithFloat(15.1f)); } - @Test(timeout = 40000) - public void testDoublePrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testDoublePrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithDouble: FactWithDouble(doubleValue == 15.1) \n", new FactWithDouble(15.1d)); } - @Test(timeout = 40000) - public void testDouble() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testDouble(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithDouble: FactWithDouble(doubleObjectValue == 15.1) \n", new FactWithDouble(15.1d)); } - @Test(timeout = 40000) - public void testBigDecimal() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testBigDecimal(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithBigDecimal: FactWithBigDecimal(bigDecimalValue == 10) \n", new FactWithBigDecimal(BigDecimal.TEN)); } - @Test(timeout = 40000) - public void testCharPrimitive() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testCharPrimitive(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithChar: FactWithCharacter(charValue == 'a') \n", new FactWithCharacter('a')); } - @Test(timeout = 40000) - public void testCharacter() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testCharacter(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithChar: FactWithCharacter(characterValue == 'a') \n", new FactWithCharacter('a')); } - @Test(timeout = 40000) - public void testString() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testString(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithString: FactWithString(stringValue == \"test\") \n", new FactWithString("test")); } - @Test(timeout = 40000) - public void testEnum() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, Share KieSession={2}, KieBase type={3}") + @MethodSource("parameters") + @Timeout(40000) + public void testEnum(boolean enforcedJitting, boolean isKieBaseShared, boolean isKieSessionShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, isKieSessionShared, kieBaseTestConfiguration); testFactAttributeType(" $factWithEnum: FactWithEnum(enumValue == AnEnum.FIRST) \n", new FactWithEnum(AnEnum.FIRST)); } @@ -195,10 +248,10 @@ private void testFactAttributeType(final String ruleConstraint, final Object fac parallelTest(NUMBER_OF_REPETITIONS, NUMBER_OF_THREADS, (kieSession, counter) -> { kieSession.insert(factInserted); final int rulesFired = kieSession.fireAllRules(); - return sharedKieSession || rulesFired == 1; + return isKieSessionShared || rulesFired == 1; }, "numberOfFirings", numberOfFirings, drl); - if (sharedKieSession) { + if (isKieSessionShared) { // This is 1 because engine doesn't insert an already existing object twice, so when sharing a session // the object should be present just once in the session. When not sharing a session, there is N separate // sessions, so each one should fire. diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/EnumEvaluationConcurrentSessionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/EnumEvaluationConcurrentSessionsTest.java index c0b1469f58c..e270e41caf0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/EnumEvaluationConcurrentSessionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/EnumEvaluationConcurrentSessionsTest.java @@ -22,51 +22,51 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.CategoryTypeEnum; import org.drools.mvel.integrationtests.facts.Product; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.params.provider.Arguments.arguments; -@RunWith(Parameterized.class) public class EnumEvaluationConcurrentSessionsTest extends AbstractConcurrentTest { private static final Integer NUMBER_OF_THREADS = 10; private static final Integer NUMBER_OF_REPETITIONS = 1; - @Parameterized.Parameters(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") - public static List getTestParameters() { + public static Stream parameters() { List baseParams = Arrays.asList( new Boolean[]{false, false}, new Boolean[]{true, false}, new Boolean[]{false, true}, new Boolean[]{true, true}); - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(true); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(true); // combine - List params = new ArrayList<>(); + List params = new ArrayList<>(); for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam[0] == true && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[]{baseParam[0], baseParam[1], kbParam[0]}); + params.add(arguments(baseParam[0], baseParam[1], kbParam)); } } } - return params; - } - - public EnumEvaluationConcurrentSessionsTest(final boolean enforcedJitting, - final boolean sharedKieBase, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, sharedKieBase, false, kieBaseTestConfiguration); + return params.stream(); } - @Test(timeout = 40000) - public void testEnum2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(40000) + public void testEnum2(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); final String drl1 = "import " + Product.class.getCanonicalName() + ";\n" + "import " + CategoryTypeEnum.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/JoinsConcurrentSessionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/JoinsConcurrentSessionsTest.java index e9dad3fb574..d06d16611f6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/JoinsConcurrentSessionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/JoinsConcurrentSessionsTest.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.AnEnum; import org.drools.mvel.integrationtests.facts.ChildFact1; @@ -30,47 +31,47 @@ import org.drools.mvel.integrationtests.facts.ChildFact4WithFirings; import org.drools.mvel.integrationtests.facts.RootFact; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.params.provider.Arguments.arguments; + -@RunWith(Parameterized.class) public class JoinsConcurrentSessionsTest extends AbstractConcurrentTest { private static final Integer NUMBER_OF_THREADS = 10; private static final Integer NUMBER_OF_REPETITIONS = 1; - @Parameterized.Parameters(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") - public static List getTestParameters() { + public static Stream parameters() { List baseParams = Arrays.asList( new Boolean[]{false, false}, new Boolean[]{true, false}, new Boolean[]{false, true}, new Boolean[]{true, true}); - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(true); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(true); // combine - List params = new ArrayList<>(); + List params = new ArrayList<>(); for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam[0] && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[]{baseParam[0], baseParam[1], kbParam[0]}); + params.add(arguments(baseParam[0], baseParam[1], kbParam)); } } } - return params; - } - - public JoinsConcurrentSessionsTest(final boolean enforcedJitting, - final boolean sharedKieBase, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, sharedKieBase, false, kieBaseTestConfiguration); + return params.stream(); } - @Test(timeout = 40000) - public void test5() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(40000) + public void test5(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); final String drlTemplate = " import org.drools.mvel.integrationtests.facts.*;\n" + " rule \"${ruleName}\"\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SharedSessionParallelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SharedSessionParallelTest.java index 6e2a258f7c7..23516200e9b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SharedSessionParallelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SharedSessionParallelTest.java @@ -19,57 +19,53 @@ package org.drools.mvel.integrationtests.concurrency; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.BeanA; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; +import org.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class SharedSessionParallelTest extends AbstractConcurrentTest { - @Parameterized.Parameters(name = "Enforced jitting={0}, KieBase type={1}") - public static List getTestParameters() { - List baseParams = Arrays.asList( - new Boolean[] {false}, - new Boolean[] {true} - ); + public static Stream parameters() { + List baseParams = List.of(false, true); - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(true); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(true); // combine - List params = new ArrayList<>(); - for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + List params = new ArrayList<>(); + for (Boolean baseParam : baseParams) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[] {baseParam[0], kbParam[0]}); + params.add(arguments(baseParam, kbParam)); } } } - return params; + return params.stream(); } - public SharedSessionParallelTest(final boolean enforcedJitting, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, false, false, kieBaseTestConfiguration); - } - - @Test(timeout = 120000) - public void testNoExceptions() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(120000) + public void testNoExceptions(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final String drl = "rule R1 when String() then end"; final int repetitions = 100; @@ -96,8 +92,11 @@ public void testNoExceptions() throws InterruptedException { } } - @Test(timeout = 40000) - public void testCheckOneThreadOnly() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testCheckOneThreadOnly(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final List list = Collections.synchronizedList(new ArrayList<>()); @@ -139,8 +138,11 @@ public void testCheckOneThreadOnly() throws InterruptedException { } } - @Test(timeout = 40000) - public void testCorrectFirings() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testCorrectFirings(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final String drl = "import " + BeanA.class.getCanonicalName() + ";\n" + @@ -168,8 +170,11 @@ public void testCorrectFirings() throws InterruptedException { checkList(threadCount, list); } - @Test(timeout = 40000) - public void testCorrectFirings2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testCorrectFirings2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final String drl = "import " + BeanA.class.getCanonicalName() + ";\n" + @@ -199,8 +204,11 @@ public void testCorrectFirings2() throws InterruptedException { assertThat(list).hasSize(expectedListSize); } - @Test(timeout = 40000) - public void testLongRunningRule() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testLongRunningRule(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final int seed = threadCount + 200; final int objectCount = 1000; @@ -257,8 +265,11 @@ public void testLongRunningRule() throws InterruptedException { checkList(1, threadCount, list2, (threadCount - 1) * objectCount); } - @Test(timeout = 40000) - public void testLongRunningRule2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testLongRunningRule2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final int seed = 1000; @@ -308,8 +319,11 @@ public void testLongRunningRule2() throws InterruptedException { checkList(0, seed, list, seed * threadCount); } - @Test(timeout = 40000) - public void testLongRunningRule3() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testLongRunningRule3(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 10; final int seed = threadCount + 50; final int objectCount = 1000; @@ -374,8 +388,11 @@ public void testLongRunningRule3() throws InterruptedException { assertThat(list2).hasSize(list2ExpectedSize); } - @Test(timeout = 40000) - public void testCountdownBean() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testCountdownBean(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final int seed = 1000; @@ -414,8 +431,11 @@ public void testCountdownBean() throws InterruptedException { assertThat(bean).hasFieldOrPropertyWithValue("seed", 0); } - @Test(timeout = 40000) - public void testCountdownBean2() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(40000) + public void testCountdownBean2(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 100; final int seed = 1000; @@ -455,8 +475,11 @@ public void testCountdownBean2() throws InterruptedException { } } - @Test(timeout = 60000) - public void testOneRulePerThread() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, KieBase type={1}") + @MethodSource("parameters") + @Timeout(60000) + public void testOneRulePerThread(boolean enforcedJitting, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, false, false, kieBaseTestConfiguration); final int threadCount = 1000; final String[] drls = new String[threadCount]; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SubnetworkConcurrentSessionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SubnetworkConcurrentSessionsTest.java index 559dd6405e5..344374446ea 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SubnetworkConcurrentSessionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/concurrency/SubnetworkConcurrentSessionsTest.java @@ -22,22 +22,24 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.Product; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.params.provider.Arguments.arguments; -@RunWith(Parameterized.class) public class SubnetworkConcurrentSessionsTest extends AbstractConcurrentTest { private static final Integer NUMBER_OF_THREADS = 10; private static final Integer NUMBER_OF_REPETITIONS = 1; - @Parameterized.Parameters(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") - public static List getTestParameters() { + public static Stream parameters() { List baseParams = Arrays.asList( new Boolean[]{false, false}, new Boolean[]{true, false}, @@ -45,28 +47,26 @@ public static List getTestParameters() { new Boolean[]{true, true} ); - Collection kbParams = TestParametersUtil.getKieBaseCloudConfigurations(true); + Collection kbParams = TestParametersUtil2.getKieBaseCloudConfigurations(true); // combine - List params = new ArrayList<>(); + List params = new ArrayList<>(); for (Boolean[] baseParam : baseParams) { - for (Object[] kbParam : kbParams) { - if (baseParam[0] == true && ((KieBaseTestConfiguration) kbParam[0]).isExecutableModel()) { + for (KieBaseTestConfiguration kbParam : kbParams) { + if (baseParam[0] && kbParam.isExecutableModel()) { // jitting & exec-model test is not required } else { - params.add(new Object[] {baseParam[0], baseParam[1], kbParam[0]}); + params.add(arguments(baseParam[0], baseParam[1], kbParam)); } } } - return params; - } - - public SubnetworkConcurrentSessionsTest(final boolean enforcedJitting, - final boolean sharedKieBase, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(enforcedJitting, false, sharedKieBase, false, kieBaseTestConfiguration); + return params.stream(); } - @Test(timeout = 80000) - public void test1() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test1(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); final String drl = "rule R when String() then end"; parallelTest(NUMBER_OF_REPETITIONS, NUMBER_OF_THREADS, (kieSession, counter) -> { @@ -75,14 +75,20 @@ public void test1() throws InterruptedException { }, null, null, drl ); } - @Test(timeout = 80000) - public void test2NoSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test2NoSubnetwork(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test2(getRule("R1", "this == \"odd\"", false, false, "Number( intValue > 0 )"), getRule("R2", "this == \"pair\"", false, false, "Number( intValue < 10000 )")); } - @Test(timeout = 80000) - public void test2WithSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test2WithSubnetwork(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test2(getRule("R1", "this == \"odd\"", false, true, "Number( intValue > 0 )"), getRule("R2", "this == \"pair\"", false, true, "Number( intValue < 10000 )")); } @@ -111,20 +117,29 @@ private void test2(final String... drls) throws InterruptedException { }, null, null, drls ); } - @Test(timeout = 80000) - public void test3NoSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test3NoSubnetwork(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test3(getRule("R1", "this == \"odd\"", false, false, "Number( intValue > 0 )"), getRule("R2", "this == \"pair\"", false, false, "Number( intValue < 10000 )")); } - @Test(timeout = 80000) - public void test3WithSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test3WithSubnetwork(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test3(getRule("R1", "this == \"odd\"", false, true, "Number( intValue > 0 )"), getRule("R2", "this == \"pair\"", false, true, "Number( intValue < 10000 )")); } - @Test(timeout = 80000) - public void test3WithSharedSubnetwork() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(80000) + public void test3WithSharedSubnetwork(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); final String ruleTemplate = "import " + Product.class.getCanonicalName() + ";\n" + "rule ${ruleName} when\n" + " $s : String()\n" + @@ -185,14 +200,20 @@ private void test3(final String... drls) throws InterruptedException { }, null, null, drls ); } - @Test(timeout = 20000) - public void test4NoSharing() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(20000) + public void test4NoSharing(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test4(getRule("R1", "", false, true, "Number( intValue > 5 )"), getRule("R2", "", false, true, "Number( intValue < 5 )")); } - @Test(timeout = 20000) - public void test4WithSharing() throws InterruptedException { + @ParameterizedTest(name = "Enforced jitting={0}, Share KieBase={1}, KieBase type={2}") + @MethodSource("parameters") + @Timeout(20000) + public void test4WithSharing(boolean enforcedJitting, boolean isKieBaseShared, KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initTest(enforcedJitting, false, isKieBaseShared, false, kieBaseTestConfiguration); test4(getRule("R1", "", true, true, "Number( intValue > 5 )"), getRule("R2", "", true, true, "Number( intValue < 5 )")); } 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; diff --git a/drools-test-coverage/test-suite/pom.xml b/drools-test-coverage/test-suite/pom.xml index 1e56254af0b..9947867730f 100644 --- a/drools-test-coverage/test-suite/pom.xml +++ b/drools-test-coverage/test-suite/pom.xml @@ -170,10 +170,10 @@ - junit - junit + org.junit.jupiter + junit-jupiter test - + org.mockito mockito-core diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/KieSessionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/KieSessionTest.java index 403ba5ae61a..bf47781778f 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/KieSessionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/KieSessionTest.java @@ -20,29 +20,17 @@ import org.drools.testcoverage.common.listener.TrackingAgendaEventListener; import org.drools.testcoverage.common.util.*; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; import org.kie.api.io.Resource; -@RunWith(Parameterized.class) public abstract class KieSessionTest { - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - protected final KieSessionTestConfiguration kieSessionTestConfiguration; - protected Session session; protected TrackingAgendaEventListener firedRules; - public KieSessionTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - this.kieSessionTestConfiguration = kieSessionTestConfiguration; - } - @Before - public void createKieSession() { + public void createKieSession(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { Resource[] resources = createResources(); if (resources == null) { session = KieSessionUtil.getKieSessionFromKieBaseModel(TestConstants.PACKAGE_REGRESSION, @@ -55,7 +43,7 @@ public void createKieSession() { session.addEventListener(firedRules); } - @After + @AfterEach public void disposeKieSession() { if (session != null) { session.dispose(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtil2.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtil2.java index 46011c70122..69674624ba4 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtil2.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtil2.java @@ -27,6 +27,9 @@ import java.util.stream.Collectors; import org.drools.model.codegen.ExecutableModelProject; +import org.junit.jupiter.params.provider.Arguments; + +import static org.junit.jupiter.params.provider.Arguments.arguments; /** * Utility class that holds default tests parameters. @@ -229,13 +232,13 @@ public static Collection getKieBaseAndKieSessionConfigurations() { * Use only stateful kie sessions. * @return Collection of combinations for parameterized tests. */ - public static Collection getKieBaseAndStatefulKieSessionConfigurations() { - final Collection parameters = new ArrayList<>(); + public static Collection getKieBaseAndStatefulKieSessionConfigurations() { + final Collection parameters = new ArrayList<>(); final Collection kieBaseConfigurations = getKieBaseConfigurations(); for (final KieBaseTestConfiguration kieBaseConfigWrapped : kieBaseConfigurations) { - parameters.add(new Object[]{kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_REALTIME}); + parameters.add(arguments(kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_REALTIME)); if ((kieBaseConfigWrapped).isStreamMode()) { - parameters.add(new Object[]{kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_PSEUDO}); + parameters.add(arguments(kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_PSEUDO)); } } @@ -247,12 +250,12 @@ public static Collection getKieBaseAndStatefulKieSessionConfigurations * Use only stream kie bases and stateful kie sessions. * @return Collection of combinations for parameterized tests. */ - public static Collection getStreamKieBaseAndStatefulKieSessionConfigurations() { - final Collection parameters = new ArrayList<>(); + public static Collection getStreamKieBaseAndStatefulKieSessionConfigurations() { + final Collection parameters = new ArrayList<>(); final Collection kieBaseConfigurations = getKieBaseStreamConfigurations(true); for (final KieBaseTestConfiguration kieBaseConfigWrapped : kieBaseConfigurations) { - parameters.add(new Object[]{kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_REALTIME}); - parameters.add(new Object[]{kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_PSEUDO}); + parameters.add(arguments(kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_REALTIME)); + parameters.add(arguments(kieBaseConfigWrapped, KieSessionTestConfiguration.STATEFUL_PSEUDO)); } return parameters; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtilTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtilTest.java index 0f467c2fdf0..4d0d2d9cbde 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtilTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/common/util/TestParametersUtilTest.java @@ -18,7 +18,7 @@ */ package org.drools.testcoverage.common.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.drools.testcoverage.common.util.KieBaseTestConfiguration.CLOUD_EQUALITY; @@ -34,41 +34,42 @@ import static org.drools.testcoverage.common.util.KieBaseTestConfiguration.STREAM_IDENTITY_MODEL_PATTERN; import static org.drools.testcoverage.common.util.KieBaseTestConfiguration.STREAM_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK; + public class TestParametersUtilTest { @Test public void testGetEqualityInstanceOf() { - assertThat(TestParametersUtil.getEqualityInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_EQUALITY); - assertThat(TestParametersUtil.getEqualityInstanceOf(CLOUD_EQUALITY)).isEqualTo(CLOUD_EQUALITY); - assertThat(TestParametersUtil.getEqualityInstanceOf(CLOUD_IDENTITY_ALPHA_NETWORK)).isEqualTo(CLOUD_EQUALITY_ALPHA_NETWORK); - assertThat(TestParametersUtil.getEqualityInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN)).isEqualTo(CLOUD_EQUALITY_MODEL_PATTERN); - assertThat(TestParametersUtil.getEqualityInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_EQUALITY_MODEL_PATTERN_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getEqualityInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_EQUALITY); + assertThat(TestParametersUtil2.getEqualityInstanceOf(CLOUD_EQUALITY)).isEqualTo(CLOUD_EQUALITY); + assertThat(TestParametersUtil2.getEqualityInstanceOf(CLOUD_IDENTITY_ALPHA_NETWORK)).isEqualTo(CLOUD_EQUALITY_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getEqualityInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN)).isEqualTo(CLOUD_EQUALITY_MODEL_PATTERN); + assertThat(TestParametersUtil2.getEqualityInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_EQUALITY_MODEL_PATTERN_ALPHA_NETWORK); } @Test public void testGetIdentityInstanceOf() { - assertThat(TestParametersUtil.getIdentityInstanceOf(CLOUD_EQUALITY)).isEqualTo(CLOUD_IDENTITY); - assertThat(TestParametersUtil.getIdentityInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_IDENTITY); - assertThat(TestParametersUtil.getIdentityInstanceOf(CLOUD_EQUALITY_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_ALPHA_NETWORK); - assertThat(TestParametersUtil.getIdentityInstanceOf(CLOUD_EQUALITY_MODEL_PATTERN)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN); - assertThat(TestParametersUtil.getIdentityInstanceOf(CLOUD_EQUALITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getIdentityInstanceOf(CLOUD_EQUALITY)).isEqualTo(CLOUD_IDENTITY); + assertThat(TestParametersUtil2.getIdentityInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_IDENTITY); + assertThat(TestParametersUtil2.getIdentityInstanceOf(CLOUD_EQUALITY_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getIdentityInstanceOf(CLOUD_EQUALITY_MODEL_PATTERN)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN); + assertThat(TestParametersUtil2.getIdentityInstanceOf(CLOUD_EQUALITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); } @Test public void testGetStreamInstanceOf() { - assertThat(TestParametersUtil.getStreamInstanceOf(CLOUD_IDENTITY)).isEqualTo(STREAM_IDENTITY); - assertThat(TestParametersUtil.getStreamInstanceOf(STREAM_IDENTITY)).isEqualTo(STREAM_IDENTITY); - assertThat(TestParametersUtil.getStreamInstanceOf(CLOUD_IDENTITY_ALPHA_NETWORK)).isEqualTo(STREAM_IDENTITY_ALPHA_NETWORK); - assertThat(TestParametersUtil.getStreamInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN)).isEqualTo(STREAM_IDENTITY_MODEL_PATTERN); - assertThat(TestParametersUtil.getStreamInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(STREAM_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getStreamInstanceOf(CLOUD_IDENTITY)).isEqualTo(STREAM_IDENTITY); + assertThat(TestParametersUtil2.getStreamInstanceOf(STREAM_IDENTITY)).isEqualTo(STREAM_IDENTITY); + assertThat(TestParametersUtil2.getStreamInstanceOf(CLOUD_IDENTITY_ALPHA_NETWORK)).isEqualTo(STREAM_IDENTITY_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getStreamInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN)).isEqualTo(STREAM_IDENTITY_MODEL_PATTERN); + assertThat(TestParametersUtil2.getStreamInstanceOf(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(STREAM_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); } @Test public void testGetCloudInstanceOf() { - assertThat(TestParametersUtil.getCloudInstanceOf(STREAM_IDENTITY)).isEqualTo(CLOUD_IDENTITY); - assertThat(TestParametersUtil.getCloudInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_IDENTITY); - assertThat(TestParametersUtil.getCloudInstanceOf(STREAM_IDENTITY_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_ALPHA_NETWORK); - assertThat(TestParametersUtil.getCloudInstanceOf(STREAM_IDENTITY_MODEL_PATTERN)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN); - assertThat(TestParametersUtil.getCloudInstanceOf(STREAM_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getCloudInstanceOf(STREAM_IDENTITY)).isEqualTo(CLOUD_IDENTITY); + assertThat(TestParametersUtil2.getCloudInstanceOf(CLOUD_IDENTITY)).isEqualTo(CLOUD_IDENTITY); + assertThat(TestParametersUtil2.getCloudInstanceOf(STREAM_IDENTITY_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_ALPHA_NETWORK); + assertThat(TestParametersUtil2.getCloudInstanceOf(STREAM_IDENTITY_MODEL_PATTERN)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN); + assertThat(TestParametersUtil2.getCloudInstanceOf(STREAM_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK)).isEqualTo(CLOUD_IDENTITY_MODEL_PATTERN_ALPHA_NETWORK); } } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DecisionTableTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DecisionTableTest.java index 369338df410..973e9464049 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DecisionTableTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DecisionTableTest.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.stream.Stream; import org.drools.template.parser.DecisionTableParseException; import org.drools.testcoverage.common.listener.OrderListener; @@ -34,11 +35,10 @@ import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.ResourceUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.BeforeClass; -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.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.KiePackage; import org.kie.api.definition.type.FactType; @@ -48,22 +48,15 @@ import org.kie.internal.builder.DecisionTableInputType; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * Tests all features which can be used in decision tables. */ -@RunWith(Parameterized.class) public class DecisionTableTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DecisionTableTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } private static Resource sampleXlsDecisionTable; @@ -92,7 +85,7 @@ public static Collection getParameters() { private static Resource sampleDateXLSXDecisionTable; - @BeforeClass + @BeforeAll public static void loadDecisionTablesToAvoidLoadingThemForEachKieBaseConfiguration() { sampleXlsDecisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("sample.drl.xls", DecisionTableTest.class, @@ -148,17 +141,19 @@ public static void loadDecisionTablesToAvoidLoadingThemForEachKieBaseConfigurati } - @Test - public void testSimpleXLS() { - testSimpleDecisionTable(sampleXlsDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSimpleXLS(KieBaseTestConfiguration kieBaseTestConfiguration) { + testSimpleDecisionTable(kieBaseTestConfiguration, sampleXlsDecisionTable); } - @Test - public void testSimpleCSV() { - testSimpleDecisionTable(sampleCsvDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSimpleCSV(KieBaseTestConfiguration kieBaseTestConfiguration) { + testSimpleDecisionTable(kieBaseTestConfiguration, sampleCsvDecisionTable); } - private void testSimpleDecisionTable(final Resource decisionTable) { + private void testSimpleDecisionTable(KieBaseTestConfiguration kieBaseTestConfiguration, final Resource decisionTable) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable); final KieSession session = kbase.newKieSession(); @@ -177,8 +172,9 @@ private void testSimpleDecisionTable(final Resource decisionTable) { session.dispose(); } - @Test - public void testMultipleTableXLS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleTableXLS(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, multipleTablesDecisionTable); assertThat(2).isEqualTo(kbase.getKiePackages().size()); @@ -214,8 +210,9 @@ public void testMultipleTableXLS() { * test for various evaluations, file sample_eval_dt.xls need to rewrite xls * table and maybe add some classes to be able to do the test */ - @Test - public void testEvalTable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalTable(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, evalDecisionTable); assertThat(2).isEqualTo(kbase.getKiePackages().size()); @@ -316,8 +313,9 @@ public void testEvalTable() { * covers also bugfix for Bug724257 (agenda group not added from dtable to * .drl) */ - @Test - public void testAdvancedTable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAdvancedTable(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, advancedDecisionTable); KieSession session = kbase.newKieSession(); @@ -343,8 +341,9 @@ public void testAdvancedTable() { session.dispose(); } - @Test - public void testPushQueryWithFactDeclaration() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPushQueryWithFactDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, queriesDecisionTable); final FactType locationType = kbase.getFactType(TestConstants.PACKAGE_FUNCTIONAL, "Location"); @@ -401,8 +400,9 @@ public void testPushQueryWithFactDeclaration() throws IllegalAccessException, In ksession.dispose(); } - @Test - public void testPullQueryWithFactDeclaration() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPullQueryWithFactDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, queriesDecisionTable); final FactType locationType = kbase.getFactType(TestConstants.PACKAGE_FUNCTIONAL, "Location"); @@ -462,8 +462,9 @@ public void testPullQueryWithFactDeclaration() throws IllegalAccessException, In /** * Test sequential turned on, it overrides all user defined saliences. */ - @Test - public void testSequential() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSequential(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, sequentialDecisionTable); final KieSession ksession = kbase.newKieSession(); @@ -479,8 +480,9 @@ public void testSequential() { ksession.dispose(); } - @Test - public void testLockOnActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActive(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, agendaGroupDecisionTable); final KieSession ksession = kbase.newKieSession(); final OrderListener listener = new OrderListener(); @@ -499,8 +501,9 @@ public void testLockOnActive() { * Agenda group rule with auto focus can fire a give focus to agenda group * without focus set on whole agenda group. */ - @Test - public void testAutoFocus() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAutoFocus(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, agendaGroupDecisionTable); final KieSession ksession = kbase.newKieSession(); final OrderListener listener = new OrderListener(); @@ -527,8 +530,9 @@ public void testAutoFocus() { ksession.dispose(); } - @Test - public void testActivationGroup() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivationGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, agendaGroupDecisionTable); final KieSession ksession = kbase.newKieSession(); final TrackingAgendaEventListener listener = new TrackingAgendaEventListener(); @@ -543,27 +547,33 @@ public void testActivationGroup() { ksession.dispose(); } - @Test(expected = DecisionTableParseException.class) - public void testEmptyConditionInXLS() { - KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, emptyConditionDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyConditionInXLS(KieBaseTestConfiguration kieBaseTestConfiguration) { + assertThatExceptionOfType(DecisionTableParseException.class).isThrownBy(() -> + KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, emptyConditionDecisionTable)); } - @Test(expected = DecisionTableParseException.class) - public void testEmptyActionInCSV() { - KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, emptyActionDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyActionInCSV(KieBaseTestConfiguration kieBaseTestConfiguration) { + assertThatExceptionOfType(DecisionTableParseException.class).isThrownBy(() -> + KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, emptyActionDecisionTable)); } - @Test - public void testCSVWithDateAttributes() { - testDecisionTableWithDateAttributes(sampleDatesCsvDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCSVWithDateAttributes(KieBaseTestConfiguration kieBaseTestConfiguration) { + testDecisionTableWithDateAttributes(kieBaseTestConfiguration, sampleDatesCsvDecisionTable); } - @Test - public void testXLSWithDateAttributes() { - testDecisionTableWithDateAttributes(sampleDatesXlsDecisionTable); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testXLSWithDateAttributes(KieBaseTestConfiguration kieBaseTestConfiguration) { + testDecisionTableWithDateAttributes(kieBaseTestConfiguration, sampleDatesXlsDecisionTable); } - private void testDecisionTableWithDateAttributes(final Resource decisionTable) { + private void testDecisionTableWithDateAttributes(KieBaseTestConfiguration kieBaseTestConfiguration, final Resource decisionTable) { final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable); final ArrayList names = new ArrayList<>(); @@ -595,8 +605,9 @@ public void setDate(Date date) { } - @Test - public void testXLSXComparingDates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testXLSXComparingDates(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6820 KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, sampleDateXLSXDecisionTable); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DeclarativeAgendaTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DeclarativeAgendaTest.java index a49b4e7f995..4ce2e9298c8 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DeclarativeAgendaTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DeclarativeAgendaTest.java @@ -25,7 +25,8 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.kie.api.KieBase; import org.kie.api.KieBaseConfiguration; import org.kie.api.KieServices; @@ -46,7 +47,8 @@ public class DeclarativeAgendaTest { // rule activation is blocked and after several iterations (fireAllRules) it // is unblocked and the rule fires - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testSimpleActivationBlock() { final KieBase kbase = buildKieBase("declarative-agenda-simple-block.drl"); final KieSession ksession = kbase.newKieSession(); @@ -107,7 +109,8 @@ public void testSimpleActivationBlock() { // test activation block together with agenda group // BZ 999360 - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testActivationBlock() { final KieBase kbase = buildKieBase("declarative-agenda-block.drl"); final KieSession ksession = kbase.newKieSession(); @@ -144,7 +147,8 @@ public void testActivationBlock() { } // test activation count, test case from doc - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testActivationCount() { final KieBase kbase = buildKieBase("declarative-agenda-count.drl"); final KieSession ksession = kbase.newKieSession(); @@ -171,7 +175,8 @@ public void testActivationCount() { } // testing unblockall command - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testUnblockAll() { final KieBase kbase = buildKieBase("declarative-agenda-unblockall.drl"); final KieSession ksession = kbase.newKieSession(); @@ -202,7 +207,8 @@ public void testUnblockAll() { ksession.dispose(); } - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testSimpleCancel() { final KieBase kbase = buildKieBase("declarative-agenda-cancel.drl"); final KieSession ksession = kbase.newKieSession(); @@ -229,7 +235,8 @@ public void testSimpleCancel() { // working memory // but activationListener('direct') annotation should guarantee priority to // fire - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testCancelWithUpdatingFacts() { final KieBase kbase = buildKieBase("declarative-agenda-cancel.drl"); final KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DuplicityTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DuplicityTest.java index 9807d06c6ea..e9b4730a2e5 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DuplicityTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/DuplicityTest.java @@ -18,14 +18,13 @@ */ package org.drools.testcoverage.functional; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.KieServices; import org.kie.api.io.Resource; import org.slf4j.LoggerFactory; @@ -36,22 +35,15 @@ * Testing of duplicities in rule files. * https://bugzilla.redhat.com/show_bug.cgi?id=724753 */ -@RunWith(Parameterized.class) public class DuplicityTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DuplicityTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testTwoRulesWithSameNameInOneFile() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTwoRulesWithSameNameInOneFile(KieBaseTestConfiguration kieBaseTestConfiguration) { try { final Resource resource = KieServices.Factory.get().getResources().newClassPathResource("rule-name.drl", getClass()); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/FactHandleTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/FactHandleTest.java index 34248d39c77..44e2ad34572 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/FactHandleTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/FactHandleTest.java @@ -19,42 +19,32 @@ package org.drools.testcoverage.functional; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.InternalFactHandle; import org.drools.core.event.DefaultRuleRuntimeEventListener; import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -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.event.rule.ObjectInsertedEvent; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FactHandleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FactHandleTest(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 testFactHandleSequence() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFactHandleSequence(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drlString = "package org.jboss.brms\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "rule \"FactHandleId\"\n" + diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/InternalMatchGroupTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/InternalMatchGroupTest.java index eb8752ac038..da3bd9d57b4 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/InternalMatchGroupTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/InternalMatchGroupTest.java @@ -19,17 +19,16 @@ package org.drools.testcoverage.functional; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.listener.TrackingAgendaEventListener; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.command.Command; @@ -38,59 +37,56 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class InternalMatchGroupTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - public InternalMatchGroupTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } /** * Only one rule from activation group fires. */ - @Test - public void basicTestActivationGroup() { - TrackingAgendaEventListener listener = prepareKSession("basicActivationGroup"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void basicTestActivationGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { + TrackingAgendaEventListener listener = prepareKSession(kieBaseTestConfiguration, "basicActivationGroup"); assertThat(listener.isRuleFired("basic1")).isFalse(); assertThat(listener.isRuleFired("basic2")).isTrue(); assertThat(listener.isRuleFired("basic3")).isFalse(); } - @Test - public void recursiveTestActivationGroup() { - TrackingAgendaEventListener listener = prepareKSession("recursiveActivationGroup"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void recursiveTestActivationGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { + TrackingAgendaEventListener listener = prepareKSession(kieBaseTestConfiguration, "recursiveActivationGroup"); assertThat(listener.isRuleFired("simplyRecursive1")).isFalse(); assertThat(listener.isRuleFired("simplyRecursive2")).isTrue(); assertThat(listener.isRuleFired("simplyRecursive3")).isTrue(); } - @Test - public void testActivationGroupWithDefaultSalience() { - TrackingAgendaEventListener listener = prepareKSession("defaultSalienceActivationGroup"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivationGroupWithDefaultSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { + TrackingAgendaEventListener listener = prepareKSession(kieBaseTestConfiguration, "defaultSalienceActivationGroup"); assertThat(listener.rulesCount()).isEqualTo(1); } - @Test - public void testActivationGroupRecursivelyWithDefaultSalience() { - TrackingAgendaEventListener listener = prepareKSession("defaultSalienceWithRecursion"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivationGroupRecursivelyWithDefaultSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { + TrackingAgendaEventListener listener = prepareKSession(kieBaseTestConfiguration, "defaultSalienceWithRecursion"); assertThat(listener.rulesCount()).isEqualTo(2); } - private TrackingAgendaEventListener prepareKSession(String startingRule) { + private TrackingAgendaEventListener prepareKSession(KieBaseTestConfiguration kieBaseTestConfiguration, String startingRule) { List> commands = new ArrayList>(); TrackingAgendaEventListener listener = new TrackingAgendaEventListener(); - final KieSession ksession = getKieBaseForTest().newKieSession(); + final KieSession ksession = getKieBaseForTest(kieBaseTestConfiguration).newKieSession(); try { ksession.addEventListener(listener); @@ -102,7 +98,7 @@ private TrackingAgendaEventListener prepareKSession(String startingRule) { return listener; } - private KieBase getKieBaseForTest() { + private KieBase getKieBaseForTest(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource drlResource = KieServices.Factory.get().getResources().newClassPathResource("activation-group.drl", getClass()); return KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_FUNCTIONAL, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerDefaultsTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerDefaultsTest.java index ac8069390d9..a17ebb12d69 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerDefaultsTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerDefaultsTest.java @@ -22,8 +22,8 @@ import org.drools.core.impl.InternalKieContainer; import org.drools.testcoverage.common.util.TestConstants; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -53,7 +53,7 @@ public class KieContainerDefaultsTest { private KieServices kieServices; - @Before + @BeforeEach public void initialize() throws IOException { kieServices = KieServices.Factory.get(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerTest.java index 70fa0601986..529f23283fd 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieContainerTest.java @@ -23,8 +23,8 @@ import java.util.Collection; import org.drools.testcoverage.common.util.TestConstants; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieBaseConfiguration; import org.kie.api.KieServices; @@ -58,7 +58,7 @@ public class KieContainerTest { private KieServices kieServices; - @Before + @BeforeEach public void initialize() throws IOException { kieServices = KieServices.Factory.get(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieRepositoryTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieRepositoryTest.java index 970bfaf245e..5da18a0b326 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieRepositoryTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/KieRepositoryTest.java @@ -21,8 +21,8 @@ import java.io.IOException; import org.drools.testcoverage.common.util.TestConstants; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -45,7 +45,7 @@ public class KieRepositoryTest { private static final String DRL = "package defaultKBase;\n rule testRule when then end\n"; - @Before + @BeforeEach public void initialize() throws IOException { kieServices = KieServices.Factory.get(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LiveQueriesBadResultTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LiveQueriesBadResultTest.java index 8a1636bd831..da0ea75919c 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LiveQueriesBadResultTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LiveQueriesBadResultTest.java @@ -19,17 +19,16 @@ package org.drools.testcoverage.functional; import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Before; -import org.junit.Ignore; -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.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.Row; @@ -40,32 +39,25 @@ /** * Tests bad using and accessing to livequeries. */ -@RunWith(Parameterized.class) public class LiveQueriesBadResultTest { private ArrayList inserted, updated, deleted; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LiveQueriesBadResultTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Before + @BeforeEach public void initialize() { inserted = new ArrayList<>(); updated = new ArrayList<>(); deleted = new ArrayList<>(); } - @Ignore("TODO - check correct exception in this test when DROOLS-2186 is fixed.") - @Test - public void testCallingLiveQueryWithoutParametersButItHasParams() { + @Disabled("TODO - check correct exception in this test when DROOLS-2186 is fixed.") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCallingLiveQueryWithoutParametersButItHasParams(KieBaseTestConfiguration kieBaseTestConfiguration) { final ViewChangedEventListener listener = new ViewChangedEventListener() { @@ -93,8 +85,9 @@ public void rowDeleted(Row row) { ksession.openLiveQuery("queryWithParams", new Object[] {}, listener); } - @Test - public void testAccessToNotExistingVariable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccessToNotExistingVariable(KieBaseTestConfiguration kieBaseTestConfiguration) { ViewChangedEventListener listener = new ViewChangedEventListener() { @@ -125,9 +118,10 @@ public void rowDeleted(Row row) { .hasMessage("The identifier 'bad' does not exist as a bound variable for this query"); } - @Ignore("TODO - check correct exception in this test when DROOLS-2187 is fixed.") - @Test - public void testOfBadParameters() { + @Disabled("TODO - check correct exception in this test when DROOLS-2187 is fixed.") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOfBadParameters(KieBaseTestConfiguration kieBaseTestConfiguration) { ViewChangedEventListener listener = new ViewChangedEventListener() { diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LogicalInsertFromCollectionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LogicalInsertFromCollectionTest.java index eeb15d1c0ed..302db8067d3 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LogicalInsertFromCollectionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/LogicalInsertFromCollectionTest.java @@ -20,16 +20,15 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.SimplePerson; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.KieServices; import org.kie.api.io.Resource; @@ -43,23 +42,16 @@ * its elements, than changes the collection in program and checks the correct * changes. */ -@RunWith(Parameterized.class) public class LogicalInsertFromCollectionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LogicalInsertFromCollectionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testRemoveElement() { - final KieSession ksession = getKieBaseForTest().newKieSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveElement(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession ksession = getKieBaseForTest(kieBaseTestConfiguration).newKieSession(); final Collection collection = new ArrayList(); for (int i = 0; i < 4; i++) { @@ -83,9 +75,10 @@ public void testRemoveElement() { } - @Test - public void testAddElement() { - final KieSession ksession = getKieBaseForTest().newKieSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddElement(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession ksession = getKieBaseForTest(kieBaseTestConfiguration).newKieSession(); final Collection collection = new ArrayList(); @@ -107,9 +100,10 @@ public void testAddElement() { assertThat(ksession.getFactCount()).isEqualTo(6); } - @Test - public void testChangeElement() { - final KieSession ksession = getKieBaseForTest().newKieSession(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChangeElement(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession ksession = getKieBaseForTest(kieBaseTestConfiguration).newKieSession(); final Collection collection = new ArrayList<>(); @@ -138,7 +132,7 @@ public void testChangeElement() { } - private KieBase getKieBaseForTest() { + private KieBase getKieBaseForTest(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource drlResource = KieServices.Factory.get().getResources().newClassPathResource("logicalInsertFromCollectionTest.drl", getClass()); return KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_REGRESSION, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/QueryBadResultTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/QueryBadResultTest.java index 55958bf9bc1..7fa6b7aac4f 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/QueryBadResultTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/QueryBadResultTest.java @@ -18,16 +18,15 @@ */ package org.drools.testcoverage.functional; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Person; 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.Level; @@ -35,34 +34,29 @@ import org.kie.api.runtime.rule.QueryResults; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.fail; /** * Tests bad using and accessing to queries. */ -@RunWith(Parameterized.class) public class QueryBadResultTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryBadResultTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testQueriesWithSameNameInOneFile() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueriesWithSameNameInOneFile(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "query-two-same-names.drl"); assertThat(kieBuilder.getResults().getMessages(Level.ERROR).isEmpty()).isFalse(); } - @Test - public void testQueriesWithSameNameInTwoFiles() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueriesWithSameNameInTwoFiles(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources( kieBaseTestConfiguration, @@ -74,15 +68,17 @@ public void testQueriesWithSameNameInTwoFiles() { assertThat(kieBuilder.getResults().getMessages(Level.ERROR).isEmpty()).isFalse(); } - @Test - public void testQueryWithoutName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithoutName(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "query-without-name.drl"); assertThat(kieBuilder.getResults().getMessages(Level.ERROR).isEmpty()).isFalse(); } - @Test - public void testQueryCalledWithoutParamsButItHasParams() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryCalledWithoutParamsButItHasParams(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "query.drl"); final KieSession ksession = kieBase.newKieSession(); ksession.insert(new Person("Petr")); @@ -95,13 +91,14 @@ public void testQueryCalledWithoutParamsButItHasParams() { } } - @Test(expected = IllegalArgumentException.class) - public void testAccessToNotExistingVariable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccessToNotExistingVariable(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration,"query.drl"); final KieSession ksession = kieBase.newKieSession(); ksession.insert(new Person("Petr")); final QueryResults results = ksession.getQueryResults("simple query with no parameters"); - results.iterator().next().get("bad"); + assertThatIllegalArgumentException().isThrownBy(() -> results.iterator().next().get("bad")); } } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java index cf8603c11e4..a042326508b 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/ResourcesTest.java @@ -19,17 +19,16 @@ package org.drools.testcoverage.functional; import java.io.StringReader; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.decisiontable.ExternalSpreadsheetCompiler; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.ResourceUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.definition.KiePackage; @@ -43,22 +42,15 @@ * Tests loading of different types of resources (DRL, DSL, DRF, BPMN2, DTABLE). * Packages are loaded and built using KnowledgeBuilder. */ -@RunWith(Parameterized.class) public class ResourcesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ResourcesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testDRL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDRL(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "aggregation.drl"); @@ -70,8 +62,9 @@ public void testDRL() { verifyPackageWithImports(kbase, TestConstants.PACKAGE_TESTCOVERAGE_MODEL); } - @Test - public void testDSL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSL(KieBaseTestConfiguration kieBaseTestConfiguration) { // DSL must go before rules otherwise error is thrown during building final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "sample.dsl", "sample.dslr"); @@ -80,8 +73,9 @@ public void testDSL() { verifyPackageWithRules(kbase, TestConstants.PACKAGE_FUNCTIONAL, 1); } - @Test - public void testXLS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testXLS(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "sample.drl.xls"); @@ -91,8 +85,9 @@ public void testXLS() { verifyPackageWithImports(kbase, TestConstants.PACKAGE_TESTCOVERAGE_MODEL); } - @Test - public void testCSV() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCSV(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("sample.drl.csv", getClass(), DecisionTableInputType.CSV); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable); @@ -103,8 +98,9 @@ public void testCSV() { verifyPackageWithImports(kbase, TestConstants.PACKAGE_TESTCOVERAGE_MODEL); } - @Test - public void testRuleTemplate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleTemplate(KieBaseTestConfiguration kieBaseTestConfiguration) { // first we compile the decision table into a whole lot of rules. final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler(); @@ -124,8 +120,9 @@ public void testRuleTemplate() { verifyPackageWithImports(kbase, TestConstants.PACKAGE_TESTCOVERAGE_MODEL); } - @Test - public void testWrongExtension() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongExtension(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.testcoverage.functional\n" + "import org.drools.testcoverage.common.model.Message\n" + "rule sampleRule\n" + diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/RuleTemplateTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/RuleTemplateTest.java index 79235ccaaa9..277e9967eb1 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/RuleTemplateTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/RuleTemplateTest.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.decisiontable.ExternalSpreadsheetCompiler; import org.drools.testcoverage.common.model.Cheese; @@ -30,10 +31,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.definition.KiePackage; @@ -44,24 +44,17 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RuleTemplateTest { private static final Logger LOGGER = LoggerFactory.getLogger(RuleTemplateTest.class); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleTemplateTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testSampleCheese() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSampleCheese(KieBaseTestConfiguration kieBaseTestConfiguration) { // first we compile the decision table into a whole lot of rules. final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/TemplatesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/TemplatesTest.java index b94e49e572b..d08eaecd1af 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/TemplatesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/TemplatesTest.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.decisiontable.ExternalSpreadsheetCompiler; import org.drools.template.DataProviderCompiler; @@ -35,10 +36,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.definition.KiePackage; @@ -52,21 +53,13 @@ /** * Tests templates - providers, generating rules, performance. */ -@RunWith(Parameterized.class) public class TemplatesTest { private static final Logger LOGGER = LoggerFactory.getLogger(TemplatesTest.class); private static final StringBuffer EXPECTED_RULES = new StringBuffer(); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TemplatesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } static { @@ -98,8 +91,9 @@ public static Collection getParameters() { EXPECTED_RULES.append(rule2_when).append(rule2_then); } - @Test - public void loadingFromDLRObjsCorrectnessCheck() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void loadingFromDLRObjsCorrectnessCheck(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final Collection cfl = new ArrayList(); cfl.add(new ParamSet("tomato", "weight", 200, 1000, 6, EnumSet.of(Taste.GOOD, Taste.EXCELENT))); @@ -115,12 +109,13 @@ public void loadingFromDLRObjsCorrectnessCheck() throws IOException { assertEqualsIgnoreWhitespace(EXPECTED_RULES.toString(), drl); - testCorrectnessCheck(drl); + testCorrectnessCheck(kieBaseTestConfiguration, drl); } } - @Test - public void loadingFromDLRMapsCorrectnessCheck() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void loadingFromDLRMapsCorrectnessCheck(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final ObjectDataCompiler converter = new ObjectDataCompiler(); @@ -132,12 +127,13 @@ public void loadingFromDLRMapsCorrectnessCheck() throws IOException { assertEqualsIgnoreWhitespace(EXPECTED_RULES.toString(), drl); - testCorrectnessCheck(drl); + testCorrectnessCheck(kieBaseTestConfiguration, drl); } } - @Test - public void loadingFromDLRArrayCorrectnessCheck() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void loadingFromDLRArrayCorrectnessCheck(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String[][] rows = new String[3][6]; rows[0] = new String[]{"tomato", "weight", "200", "1000", "6", "== Taste.GOOD || == Taste.EXCELENT"}; rows[1] = new String[]{"cucumber", "length", "20", "40", "15", "== Taste.EXCELENT"}; @@ -154,12 +150,13 @@ public void loadingFromDLRArrayCorrectnessCheck() throws Exception { assertEqualsIgnoreWhitespace(EXPECTED_RULES.toString(), drl); - testCorrectnessCheck(drl); + testCorrectnessCheck(kieBaseTestConfiguration, drl); } } - @Test - public void loadingFromDLRSpreadsheetCorrectnessCheck() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void loadingFromDLRSpreadsheetCorrectnessCheck(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler(); final KieServices kieServices = KieServices.Factory.get(); @@ -174,12 +171,14 @@ public void loadingFromDLRSpreadsheetCorrectnessCheck() throws Exception { assertEqualsIgnoreWhitespace(EXPECTED_RULES.toString(), drl); - testCorrectnessCheck(drl); + testCorrectnessCheck(kieBaseTestConfiguration, drl); } } - @Test(timeout = 30000L) - public void OneRuleManyRows() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(30000L) + public void OneRuleManyRows(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final Collection cfl = new ArrayList(); cfl.add(new ParamSet("tomato", "weight", 200, 1000, 6, EnumSet.of(Taste.GOOD, Taste.EXCELENT))); @@ -191,12 +190,14 @@ public void OneRuleManyRows() throws IOException { // prints rules generated from template LOGGER.debug(drl); - testManyRows(drl, 0, 1); + testManyRows(kieBaseTestConfiguration, drl, 0, 1); } } - @Test(timeout = 30000L) - public void TenRulesManyRows() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(30000L) + public void TenRulesManyRows(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final ObjectDataCompiler converter = new ObjectDataCompiler(); @@ -206,12 +207,14 @@ public void TenRulesManyRows() throws IOException { // prints rules generated from template LOGGER.debug(drl); - testManyRows(drl, 500, 10); + testManyRows(kieBaseTestConfiguration, drl, 500, 10); } } - @Test(timeout = 30000L) - public void OneTemplateManyRules() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(30000L) + public void OneTemplateManyRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final ObjectDataCompiler converter = new ObjectDataCompiler(); @@ -221,12 +224,14 @@ public void OneTemplateManyRules() throws IOException { // prints rules generated from template LOGGER.debug(drl); - testManyRules(drl, 50); + testManyRules(kieBaseTestConfiguration, drl, 50); } } - @Test(timeout = 30000L) - public void TenTemplatesManyRules() throws IOException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(30000L) + public void TenTemplatesManyRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException { final KieServices kieServices = KieServices.Factory.get(); final ObjectDataCompiler converter = new ObjectDataCompiler(); try (InputStream resourceStream = kieServices.getResources().newClassPathResource("template_2.drl", getClass()).getInputStream()) { @@ -237,11 +242,11 @@ public void TenTemplatesManyRules() throws IOException { // prints rules generated from template LOGGER.debug(drl); - testManyRules(drl, 500); + testManyRules(kieBaseTestConfiguration, drl, 500); } } - private void testCorrectnessCheck(final String drl) { + private void testCorrectnessCheck(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final Resource drlResource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); drlResource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, drlResource); @@ -278,7 +283,7 @@ private void testCorrectnessCheck(final String drl) { assertThat(pkg.getRules().size()).isEqualTo(3); } - private void testManyRows(final String drl, final int expectedResultListSize, final int expectedRulesCount) { + private void testManyRows(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl, final int expectedResultListSize, final int expectedRulesCount) { final Resource drlResource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); drlResource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, drlResource); @@ -309,7 +314,7 @@ private void testManyRows(final String drl, final int expectedResultListSize, fi assertThat(pkg.getRules().size()).isEqualTo(expectedRulesCount); } - private void testManyRules(final String drl, final int expectedRulesCount) { + private void testManyRules(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl, final int expectedRulesCount) { final Resource drlResource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); drlResource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, drlResource); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/UnicodeTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/UnicodeTest.java index 6fb00f80f52..fdb4803402d 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/UnicodeTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/UnicodeTest.java @@ -20,18 +20,17 @@ import java.io.FileNotFoundException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; +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.ResourceUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.command.Command; @@ -52,22 +51,15 @@ * Tests Drools engine capabilities regarding Unicode characters * */ -@RunWith(Parameterized.class) public class UnicodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public UnicodeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testJapanese() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJapanese(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.Factory.get(); final Resource resource = kieServices.getResources().newClassPathResource("unicode.drl", getClass()); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, @@ -94,8 +86,9 @@ public void testJapanese() { assertThat(一覧.iterator().next().getの名前()).isEqualTo("横綱"); } - @Test - public void testCzech() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCzech(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.Factory.get(); final Resource resource = kieServices.getResources().newClassPathResource("unicode.drl", getClass()); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource); @@ -122,8 +115,9 @@ public void testCzech() { assertThat(lidé.get(1).getJméno()).isEqualTo("Oldřiška"); } - @Test - public void testCzechDomainSpecificLanguage() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCzechDomainSpecificLanguage(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.Factory.get(); final Resource dsl = kieServices.getResources().newClassPathResource("unicode.dsl", getClass()); final Resource dslr = kieServices.getResources().newClassPathResource("unicode.dslr", getClass()); @@ -146,8 +140,9 @@ public void testCzechDomainSpecificLanguage() { assertThat(dospělí.iterator().next().getJméno()).isEqualTo("Řehoř"); } - @Test - public void testCzechXLSDecisionTable() throws FileNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCzechXLSDecisionTable(KieBaseTestConfiguration kieBaseTestConfiguration) throws FileNotFoundException { final KieServices kieServices = KieServices.Factory.get(); final Resource resource = kieServices.getResources().newClassPathResource("unicode.drl.xls", getClass()); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource); @@ -169,8 +164,9 @@ public void testCzechXLSDecisionTable() throws FileNotFoundException { assertThat(dospělí.iterator().next().getJméno()).isEqualTo("Řehoř"); } - @Test - public void testCzechCSVDecisionTable() throws FileNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCzechCSVDecisionTable(KieBaseTestConfiguration kieBaseTestConfiguration) throws FileNotFoundException { final KieServices kieServices = KieServices.Factory.get(); final Resource decisionTable = @@ -196,8 +192,9 @@ public void testCzechCSVDecisionTable() throws FileNotFoundException { } // test queries in Czech language - @Test - public void testQueryCallFromJava() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryCallFromJava(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { final KieServices kieServices = KieServices.Factory.get(); final Resource resource = kieServices.getResources().newClassPathResource("unicode.drl", getClass()); final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource); @@ -318,7 +315,8 @@ public static class Člověk { } } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testMutibyteJavaDialect() { // DROOLS-1200 final String drl = diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/decisiontable/DecisionTableKieContainerTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/decisiontable/DecisionTableKieContainerTest.java index e74058b61c0..895e1c7cfec 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/decisiontable/DecisionTableKieContainerTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/decisiontable/DecisionTableKieContainerTest.java @@ -19,7 +19,7 @@ package org.drools.testcoverage.functional.decisiontable; import org.drools.testcoverage.common.model.Record; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/model/RulesWithInTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/model/RulesWithInTest.java index d1bfdee0246..95254e37221 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/model/RulesWithInTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/model/RulesWithInTest.java @@ -20,7 +20,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.io.Resource; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathCepTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathCepTest.java index ee09fdaaacf..cfb349c0600 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathCepTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathCepTest.java @@ -19,20 +19,19 @@ package org.drools.testcoverage.functional.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Message; import org.drools.testcoverage.common.model.MessageEvent; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieSessionUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; @@ -46,7 +45,6 @@ /** * Tests usage of OOPath expressions with CEP (events, event windows, event streams). */ -@RunWith(Parameterized.class) public class OOPathCepTest { private static final String MODULE_GROUP_ID = "oopath-cep-test"; @@ -58,18 +56,11 @@ public class OOPathCepTest { private List events; private List messages; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathCepTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @After + @AfterEach public void disposeKieSession() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -80,8 +71,9 @@ public void disposeKieSession() { } } - @Test - public void testEventWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -102,8 +94,9 @@ public void testEventWithOOPath() { this.populateAndVerifyEventCase(this.kieSession); } - @Test - public void testEntryPointWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEntryPointWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -136,8 +129,9 @@ private void populateAndVerifyEventCase(final EntryPoint entryPoint) { assertThat(this.messages).containsExactlyInAnyOrder(helloMessage); } - @Test - public void testTemporalOperatorAfterWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorAfterWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -169,8 +163,9 @@ public void testTemporalOperatorAfterWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorBeforeWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorBeforeWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -202,8 +197,9 @@ public void testTemporalOperatorBeforeWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorCoincidesWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorCoincidesWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -235,8 +231,9 @@ public void testTemporalOperatorCoincidesWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorDuringWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorDuringWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -269,8 +266,9 @@ public void testTemporalOperatorDuringWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorFinishesWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorFinishesWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -303,8 +301,9 @@ public void testTemporalOperatorFinishesWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorFinishedByWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorFinishedByWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -337,8 +336,9 @@ public void testTemporalOperatorFinishedByWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorIncludesWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorIncludesWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -371,8 +371,9 @@ public void testTemporalOperatorIncludesWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorMeetsWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorMeetsWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -404,8 +405,9 @@ public void testTemporalOperatorMeetsWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorMetByWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorMetByWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -437,8 +439,9 @@ public void testTemporalOperatorMetByWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorOverlapsWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorOverlapsWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -472,8 +475,9 @@ public void testTemporalOperatorOverlapsWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorOverlappedByWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorOverlappedByWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -506,8 +510,9 @@ public void testTemporalOperatorOverlappedByWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorStartsWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorStartsWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -540,8 +545,9 @@ public void testTemporalOperatorStartsWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testTemporalOperatorStartedByWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorStartedByWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -574,8 +580,9 @@ public void testTemporalOperatorStartedByWithOOPath() { assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage); } - @Test - public void testLengthWindowWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLengthWindowWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -595,8 +602,9 @@ public void testLengthWindowWithOOPath() { this.populateAndVerifyLengthWindowCase(kieBase); } - @Test - public void testDeclaredLengthWindowWithOOPathInRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredLengthWindowWithOOPathInRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -620,8 +628,9 @@ public void testDeclaredLengthWindowWithOOPathInRule() { this.populateAndVerifyLengthWindowCase(kieBase); } - @Test - public void testOOPathNotAllowedInDeclaredWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathNotAllowedInDeclaredWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -670,8 +679,9 @@ private void populateAndVerifyLengthWindowCase(final KieBase kieBase) { assertThat(this.events).as("The rule should have fired for ping event only").contains(ping4Event); } - @Test - public void testTimeWindowWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTimeWindowWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -691,8 +701,9 @@ public void testTimeWindowWithOOPath() { this.populateAndVerifyTimeWindowCase(kieBase); } - @Test - public void testDeclaredTimeWindowWithOOPathInRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTimeWindowWithOOPathInRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + @@ -749,8 +760,9 @@ private void populateAndVerifyTimeWindowCase(final KieBase kieBase) { assertThat(this.events).as("The rule should have fired for ping event only").contains(ping4Event); } - @Test - public void testEventExplicitExpirationWithOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventExplicitExpirationWithOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDslTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDslTest.java index 244f25c17da..a3a3eb8de4a 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDslTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDslTest.java @@ -20,7 +20,7 @@ import org.drools.testcoverage.common.model.InternationalAddress; import org.drools.testcoverage.common.model.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; import org.kie.internal.utils.KieHelper; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDtablesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDtablesTest.java index a84ecd548a3..f77e2112fc8 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDtablesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathDtablesTest.java @@ -19,8 +19,8 @@ package org.drools.testcoverage.functional.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Address; import org.drools.testcoverage.common.model.InternationalAddress; @@ -28,10 +28,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.ResourceUtil; -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.io.Resource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.QueryResults; @@ -44,35 +43,30 @@ * Test basic OOPath expressions used in Decision tables (*.xls, *.xlsx, *.csv) * in both RuleTable and Queries as well. */ -@RunWith(Parameterized.class) public class OOPathDtablesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathDtablesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void xlsWithOOPathTest() { - final KieSession kieSession = getKieSessionFromXls("oopath.drl.xls"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void xlsWithOOPathTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession kieSession = getKieSessionFromXls(kieBaseTestConfiguration, "oopath.drl.xls"); testOOPathWithDTable(kieSession); } - @Test - public void xlsxWithOOPathTest() { - final KieSession kieSession = getKieSessionFromXlsx("oopath.drl.xlsx"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void xlsxWithOOPathTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession kieSession = getKieSessionFromXlsx(kieBaseTestConfiguration, "oopath.drl.xlsx"); testOOPathWithDTable(kieSession); } - @Test - public void csvWithOOPathTest() { - final KieSession kieSession = getKieSessionFromCsv("oopath.drl.csv"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void csvWithOOPathTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieSession kieSession = getKieSessionFromCsv(kieBaseTestConfiguration, "oopath.drl.csv"); testOOPathWithDTable(kieSession); } @@ -87,22 +81,22 @@ private void testOOPathWithDTable(final KieSession kieSession) { verifyQueryResults(kieSession.getQueryResults("listSafeCities")); } - private KieSession getKieSessionFromCsv(final String csvFile) { + private KieSession getKieSessionFromCsv(KieBaseTestConfiguration kieBaseTestConfiguration, final String csvFile) { final Resource resource = ResourceUtil.getDecisionTableResourceFromClasspath(csvFile, getClass(), DecisionTableInputType.CSV); return KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource).newKieSession(); } - private KieSession getKieSessionFromXls(final String xlsFile) { - return getKieSessionFromExcel(xlsFile, DecisionTableInputType.XLS); + private KieSession getKieSessionFromXls(KieBaseTestConfiguration kieBaseTestConfiguration, final String xlsFile) { + return getKieSessionFromExcel(kieBaseTestConfiguration, xlsFile, DecisionTableInputType.XLS); } - private KieSession getKieSessionFromXlsx(final String xlsxFile) { - return getKieSessionFromExcel(xlsxFile, DecisionTableInputType.XLSX); + private KieSession getKieSessionFromXlsx(KieBaseTestConfiguration kieBaseTestConfiguration, final String xlsxFile) { + return getKieSessionFromExcel(kieBaseTestConfiguration, xlsxFile, DecisionTableInputType.XLSX); } - private KieSession getKieSessionFromExcel(final String file, final DecisionTableInputType fileType) { + private KieSession getKieSessionFromExcel(KieBaseTestConfiguration kieBaseTestConfiguration, final String file, final DecisionTableInputType fileType) { final Resource resource = ResourceUtil.getDecisionTableResourceFromClasspath(file, getClass(), fileType); return KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource).newKieSession(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathLogicalBranchesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathLogicalBranchesTest.java index dc76b246e0a..045f9a8ef9e 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathLogicalBranchesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathLogicalBranchesTest.java @@ -19,18 +19,17 @@ package org.drools.testcoverage.functional.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Address; import org.drools.testcoverage.common.model.Employee; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieSession; @@ -41,7 +40,6 @@ /** * Tests usage of OOPath expressions resulting in multiple conditional branches (e.g. OR operator). */ -@RunWith(Parameterized.class) public class OOPathLogicalBranchesTest { private static final KieServices KIE_SERVICES = KieServices.Factory.get(); @@ -49,18 +47,11 @@ public class OOPathLogicalBranchesTest { private KieSession kieSession; private List results; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathLogicalBranchesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @After + @AfterEach public void disposeKieSession() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -69,8 +60,9 @@ public void disposeKieSession() { } } - @Test - public void testBasicOrCondition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBasicOrCondition(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -90,8 +82,9 @@ public void testBasicOrCondition() { assertThat(this.results).containsExactlyInAnyOrder("Big City", "Small City"); } - @Test - public void testOrConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -112,8 +105,9 @@ public void testOrConstraint() { assertThat(this.results).containsExactlyInAnyOrder("Big City", "Small City"); } - @Test - public void testOrConstraintWithJoin() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrConstraintWithJoin(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -134,8 +128,9 @@ public void testOrConstraintWithJoin() { assertThat(this.results).containsExactlyInAnyOrder("Big City", "Small City"); } - @Test - public void testOrConstraintNoBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrConstraintNoBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -156,8 +151,9 @@ public void testOrConstraintNoBinding() { assertThat(this.results).containsExactlyInAnyOrder("Bruno", "Alice"); } - @Test - public void testOrConditionalElement() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrConditionalElement(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -179,8 +175,9 @@ public void testOrConditionalElement() { assertThat(this.results).containsExactlyInAnyOrder("Big City", "Small City"); } - @Test - public void testOrConditionalElementNoBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrConditionalElementNoBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -204,8 +201,9 @@ public void testOrConditionalElementNoBinding() { assertThat(this.results).containsExactlyInAnyOrder("Bruno", "Alice"); } - @Test - public void testBasicAndCondition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBasicAndCondition(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -225,8 +223,9 @@ public void testBasicAndCondition() { assertThat(this.results).containsExactly("Big City"); } - @Test - public void testAndConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAndConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -247,8 +246,9 @@ public void testAndConstraint() { assertThat(this.results).containsExactlyInAnyOrder("Big City"); } - @Test - public void testAndConstraintNoBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAndConstraintNoBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -269,8 +269,9 @@ public void testAndConstraintNoBinding() { assertThat(this.results).containsExactlyInAnyOrder("Alice"); } - @Test - public void testAndConditionalElement() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAndConditionalElement(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + @@ -292,8 +293,9 @@ public void testAndConditionalElement() { assertThat(this.results).containsExactlyInAnyOrder("Big City"); } - @Test - public void testAndConditionalElementWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAndConditionalElementWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathSmokeTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathSmokeTest.java index c19bb1b8ddc..09f4abd0462 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathSmokeTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/oopath/OOPathSmokeTest.java @@ -18,18 +18,17 @@ */ package org.drools.testcoverage.functional.oopath; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Address; import org.drools.testcoverage.common.model.Person; 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.After; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.ReleaseId; @@ -42,25 +41,17 @@ /** * Tests basic usage of OOPath expressions. */ -@RunWith(Parameterized.class) public class OOPathSmokeTest { private static final KieServices KIE_SERVICES = KieServices.Factory.get(); private static final ReleaseId RELEASE_ID = KIE_SERVICES.newReleaseId("org.drools.testcoverage.oopath", "marshalling-test", "1.0"); private KieSession kieSession; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathSmokeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @After + @AfterEach public void disposeKieSession() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -68,14 +59,16 @@ public void disposeKieSession() { } } - @Test - public void testBuildKieBase() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuildKieBase(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "oopath.drl"); assertThat(kieBase).isNotNull(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testBuildTwoKieBases() { final Resource drlResource = KIE_SERVICES.getResources().newClassPathResource("oopath.drl", this.getClass()); KieUtil.getKieModuleFromResources(RELEASE_ID, KieBaseTestConfiguration.CLOUD_IDENTITY, drlResource); @@ -88,8 +81,9 @@ public void testBuildTwoKieBases() { } } - @Test - public void testFireRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "oopath.drl"); this.kieSession = kieBase.newKieSession(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DrlParserTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DrlParserTest.java index 9aa85201e2a..22fd5520ef6 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DrlParserTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DrlParserTest.java @@ -19,28 +19,28 @@ package org.drools.testcoverage.functional.parser; import java.io.File; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.runners.Parameterized.Parameters; import org.kie.api.KieServices; import org.kie.api.io.Resource; public class DrlParserTest extends ParserTest { - public DrlParserTest(final File file, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(file, kieBaseTestConfiguration); - } @Parameters(name = "{index}: {0}, {1}") - public static Collection getParameters() { - return getTestParamsFromFiles(getFiles("drl")); + public static Stream parameters() { + return getTestParamsFromFiles(getFiles("drl")).stream(); } - @Test - public void testParserSmoke() { + @ParameterizedTest(name = "{index}: {0}, {1}") + @MethodSource("parameters") + public void testParserSmoke(File file, KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource fileResource = KieServices.Factory.get().getResources().newFileSystemResource(file); KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, fileResource); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DslParserTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DslParserTest.java index 7c0001b40aa..b2d0335a9ef 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DslParserTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/DslParserTest.java @@ -22,47 +22,48 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.runners.Parameterized.Parameters; import org.kie.api.KieServices; import org.kie.api.io.Resource; -public class DslParserTest extends ParserTest { - private final File dsl; +import static org.junit.jupiter.params.provider.Arguments.arguments; - public DslParserTest(final File dslr, final File dsl, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(dslr, kieBaseTestConfiguration); - this.dsl = dsl; - } +public class DslParserTest extends ParserTest { @Parameters - public static Collection getParameters() { - final Set set = new HashSet<>(); + public static Stream parameters() { + final Set set = new HashSet<>(); for (File f : getFiles("dsl", "dslr")) { final String dslPath = f.getAbsolutePath(); final File dsl = new File(dslPath.substring(0, dslPath.length() - 1)); - set.add(new Object[] {dsl, f, KieBaseTestConfiguration.CLOUD_EQUALITY}); - set.add(new Object[]{dsl, f, KieBaseTestConfiguration.CLOUD_EQUALITY_MODEL_PATTERN}); + set.add(arguments(dsl, f, KieBaseTestConfiguration.CLOUD_EQUALITY)); + set.add(arguments(dsl, f, KieBaseTestConfiguration.CLOUD_EQUALITY_MODEL_PATTERN)); } - return set; + return set.stream(); } - @Test - public void testParserDsl() { + @ParameterizedTest + @MethodSource("parameters") + public void testParserDsl(File dslr, File dsl, KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource dslResource = KieServices.Factory.get().getResources().newFileSystemResource(dsl); - final Resource dslrResource = KieServices.Factory.get().getResources().newFileSystemResource(file); + final Resource dslrResource = KieServices.Factory.get().getResources().newFileSystemResource(dslr); KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, dslResource, dslrResource); } - @Test - public void testParserDsl2() { + @ParameterizedTest + @MethodSource("parameters") + public void testParserDsl2(File dslr, File dsl, KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource dslResource = KieServices.Factory.get().getResources().newFileSystemResource(dsl); - final Resource dslrResource = KieServices.Factory.get().getResources().newFileSystemResource(file); + final Resource dslrResource = KieServices.Factory.get().getResources().newFileSystemResource(dslr); KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, dslrResource, dslResource); } } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/ParserTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/ParserTest.java index 73433ea58f3..acc977b85d6 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/ParserTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/ParserTest.java @@ -26,8 +26,9 @@ import java.util.Set; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.provider.Arguments; + +import static org.junit.jupiter.params.provider.Arguments.arguments; /** * Tests ability to parse resources. To add a test to this class simply add a @@ -40,20 +41,10 @@ * new folder can be added * */ -@RunWith(Parameterized.class) public abstract class ParserTest { private static final String PARSER_RESOURCES_DIR_PATH = "src/test/resources/org/drools/testcoverage/functional/parser"; private static final File PARSER_RESOURCES_DIR = new File(PARSER_RESOURCES_DIR_PATH); - protected final File file; - - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ParserTest(final File file, final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.file = file; - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - protected static List getFiles(final String directory) { return getFiles(directory, null); } @@ -73,12 +64,12 @@ protected static List getFiles(final String directory, final String extens return result; } - protected static Collection getTestParamsFromFiles(Collection files) { - final Set set = new HashSet<>(); + protected static Collection getTestParamsFromFiles(Collection files) { + final Set set = new HashSet<>(); for (File file : files) { - set.add(new Object[] {file, KieBaseTestConfiguration.CLOUD_EQUALITY}); - set.add(new Object[]{file, KieBaseTestConfiguration.CLOUD_EQUALITY_MODEL_PATTERN}); + set.add(arguments(file, KieBaseTestConfiguration.CLOUD_EQUALITY)); + set.add(arguments(file, KieBaseTestConfiguration.CLOUD_EQUALITY_MODEL_PATTERN)); } return set; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/SmokeParserTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/SmokeParserTest.java index a323631bb89..014e154f464 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/SmokeParserTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/functional/parser/SmokeParserTest.java @@ -19,12 +19,13 @@ package org.drools.testcoverage.functional.parser; import java.io.File; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.io.Resource; import org.slf4j.Logger; @@ -36,17 +37,13 @@ public class SmokeParserTest extends ParserTest { private static int count = 0; - public SmokeParserTest(final File file, final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(file, kieBaseTestConfiguration); + public static Stream parameters() { + return getTestParamsFromFiles(getFiles("smoke")).stream(); } - @Parameters - public static Collection getParameters() { - return getTestParamsFromFiles(getFiles("smoke")); - } - - @Test - public void testParserSmoke() { + @ParameterizedTest + @MethodSource("parameters") + public void testParserSmoke(File file, KieBaseTestConfiguration kieBaseTestConfiguration) { LOGGER.warn(count++ + " : " + file.getName()); final Resource fileResource = KieServices.Factory.get().getResources().newFileSystemResource(file); KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, fileResource); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/memory/KieScannerMemoryTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/memory/KieScannerMemoryTest.java index 6ab640b74a5..05dc3fde95d 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/memory/KieScannerMemoryTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/memory/KieScannerMemoryTest.java @@ -28,38 +28,35 @@ import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.MavenUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.Ignore; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; import org.kie.api.builder.KieScanner; import org.kie.api.builder.ReleaseId; import org.kie.api.runtime.KieContainer; import org.kie.scanner.KieMavenRepository; -import org.kie.test.testcategory.TurtleTestCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; -@Ignore("DROOLS-3628 Ignoring, because it can be useful when run locally, however due to unpredictable GC behaviour, unstable in automation.") -@Category(TurtleTestCategory.class) +@Disabled("DROOLS-3628 Ignoring, because it can be useful when run locally, however due to unpredictable GC behaviour, unstable in automation.") public class KieScannerMemoryTest { private static final Logger logger = LoggerFactory.getLogger(KieScannerMemoryTest.class); private FileManager fileManager; - @Before + @BeforeEach public void setUp() throws Exception { this.fileManager = new FileManager(); this.fileManager.setUp(); } - @After + @AfterEach public void tearDown() throws Exception { this.fileManager.tearDown(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AbstractCompositeRestrictionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AbstractCompositeRestrictionTest.java index 7b00490e119..9454031c660 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AbstractCompositeRestrictionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AbstractCompositeRestrictionTest.java @@ -18,15 +18,14 @@ */ package org.drools.testcoverage.regression; -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.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.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -37,22 +36,15 @@ * Bugfix test for bz#724655 'NPE in AbstractCompositionRestriction when using * unbound variables' */ -@RunWith(Parameterized.class) public class AbstractCompositeRestrictionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbstractCompositeRestrictionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder builder = KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, false, KieServices.Factory.get().getResources().newClassPathResource("abstractCompositeRestrictionTest.drl", getClass())); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AccumulateRecalculationTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AccumulateRecalculationTest.java index 37aa30b0be2..2d307bc9c90 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AccumulateRecalculationTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AccumulateRecalculationTest.java @@ -19,7 +19,7 @@ package org.drools.testcoverage.regression; import org.drools.testcoverage.common.model.MyFact; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AmbiguousExceptionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AmbiguousExceptionTest.java index 41239cfd089..69fce23b084 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AmbiguousExceptionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/AmbiguousExceptionTest.java @@ -19,19 +19,17 @@ package org.drools.testcoverage.regression; import java.io.StringReader; +import java.util.stream.Stream; -import java.util.Collection; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.builder.KieFileSystem; -@RunWith(Parameterized.class) public class AmbiguousExceptionTest { private static final String DRL = " package " + TestConstants.PACKAGE_REGRESSION + "\n\n " @@ -41,19 +39,13 @@ public class AmbiguousExceptionTest { + " then\n" + " end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AmbiguousExceptionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testCompilation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilation(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieFileSystem fileSystem = KieServices.Factory.get().newKieFileSystem(); fileSystem.write( TestConstants.DRL_TEST_TARGET_PATH, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/BetaMemoryLeakOnDeleteTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/BetaMemoryLeakOnDeleteTest.java index 6ea368db35d..c8285a98927 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/BetaMemoryLeakOnDeleteTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/BetaMemoryLeakOnDeleteTest.java @@ -21,9 +21,8 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.Memory; import org.drools.core.common.NodeMemories; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.TupleImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DateExtendingFactTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DateExtendingFactTest.java index 54a594eb4aa..f4707ea295e 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DateExtendingFactTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DateExtendingFactTest.java @@ -18,15 +18,14 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; import java.util.Date; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.builder.KieBuilder; import org.kie.api.builder.Message; @@ -35,7 +34,6 @@ /** * Tests compilation of facts extending java.util.Date (BZ 1072629). */ -@RunWith(Parameterized.class) public class DateExtendingFactTest { private static final String FACT_CLASS_NAME = MyDate.class.getCanonicalName(); @@ -49,22 +47,16 @@ public class DateExtendingFactTest { "$date.setDescription(\"test\");\n" + "end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DateExtendingFactTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } /** * Tests compiling DRL with a fact extending java.util.Date. */ - @Test - public void testDateExtendingFact() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateExtendingFact(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); assertThat(kbuilder.getResults().getMessages(Message.Level.ERROR)).isEmpty(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeclarationWithOrTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeclarationWithOrTest.java index bb3cd845864..a3db14e497e 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeclarationWithOrTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeclarationWithOrTest.java @@ -19,16 +19,15 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -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.builder.KieBuilder; import org.kie.api.runtime.KieSession; @@ -37,7 +36,6 @@ /** * Tests handling a variable binding in LHS with OR (BZ 1136424). */ -@RunWith(Parameterized.class) public class DeclarationWithOrTest { private static final String FACT = "working"; @@ -52,22 +50,16 @@ public class DeclarationWithOrTest { " list.add(\"" + FACT + "\");\n" + "end"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DeclarationWithOrTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } /** * Verifies that the rule with binding and OR in LHS compiles and works as expected. */ - @Test - public void testBindingWithOrInLHS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingWithOrInLHS(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); final KieSession ksession = KieBaseUtil.getDefaultKieBaseFromKieBuilder(kbuilder).newKieSession(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeserializationWithCompositeTriggerTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeserializationWithCompositeTriggerTest.java index 6257071f715..3d0dc37700b 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeserializationWithCompositeTriggerTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DeserializationWithCompositeTriggerTest.java @@ -18,18 +18,16 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.StockTick; import org.drools.mvel.integrationtests.SerializationHelper; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieBaseConfiguration; import org.kie.api.KieServices; @@ -45,7 +43,6 @@ /** * Verifies that serialization and de-serialization of a composite trigger succeeds (BZ 1142914). */ -@RunWith(Parameterized.class) public class DeserializationWithCompositeTriggerTest { private static final String DRL = @@ -68,19 +65,12 @@ public class DeserializationWithCompositeTriggerTest { private KieSession ksession; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DeserializationWithCompositeTriggerTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); - } - @Before - public void prepare() { + public void prepare(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); final KieContainer kcontainer = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()); @@ -94,7 +84,7 @@ public void prepare() { this.ksession = kbase.newKieSession(kieSessionConfiguration, null); } - @After + @AfterEach public void cleanup() { if (this.ksession != null) { this.ksession.dispose(); @@ -105,8 +95,10 @@ public void cleanup() { * Verifies that serialization of a rule with composite trigger does not fail on * org.drools.core.time.impl.CompositeMaxDurationTrigger class serialization. */ - @Test - public void testSerializationAndDeserialization() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializationAndDeserialization(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + prepare(kieBaseTestConfiguration); this.ksession.insert(new StockTick(2, "AAA", 1.0, 0)); this.ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true, false); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DroolsGcCausesNPETest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DroolsGcCausesNPETest.java index cf918036098..89fff39cdcc 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DroolsGcCausesNPETest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/DroolsGcCausesNPETest.java @@ -22,10 +22,9 @@ import java.util.Random; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -40,7 +39,6 @@ import org.kie.api.runtime.KieSessionConfiguration; import org.kie.api.runtime.conf.ClockTypeOption; import org.kie.api.time.SessionPseudoClock; -import org.kie.test.testcategory.TurtleTestCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,7 +64,7 @@ public class DroolsGcCausesNPETest { private SessionPseudoClock clock; private FactType eventFactType; - @BeforeClass + @BeforeAll public static void beforeClass() throws Exception { final KieModuleModel module = SERVICES.newKieModuleModel(); @@ -88,7 +86,7 @@ public static void beforeClass() throws Exception { SERVICES.getRepository().addKieModule(builder.getKieModule()); } - @Before + @BeforeEach public void setUp() throws Exception { final KieSessionConfiguration conf = SERVICES.newKieSessionConfiguration(); conf.setOption(ClockTypeOption.PSEUDO); @@ -105,7 +103,6 @@ public void setUp() throws Exception { * BZ 1181584 */ @Test - @Category(TurtleTestCategory.class) public void testMoreTimesRepeated() throws Exception { final Random r = new Random(1); int i = 0; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EqualityKeyOverrideTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EqualityKeyOverrideTest.java index e9249f8b4f5..6be29743c6d 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EqualityKeyOverrideTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EqualityKeyOverrideTest.java @@ -18,15 +18,16 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.io.Resource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -56,18 +57,15 @@ public class EqualityKeyOverrideTest extends KieSessionTest { " insertLogical(new Superclass());\n" + "end\n"; - public EqualityKeyOverrideTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndStatefulKieSessionConfigurations(); - } - - @Test - public void testEqualityOverride() { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testEqualityOverride(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); FactHandle string = ksession.insert("testString"); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EscapesInMetadataTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EscapesInMetadataTest.java index b1ab477b5ff..eaa192f70ca 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EscapesInMetadataTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EscapesInMetadataTest.java @@ -18,17 +18,15 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; import java.util.Map; +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.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +37,6 @@ * Test to verify BRMS-312 (Allow escaping characters in metadata value) is * fixed */ -@RunWith(Parameterized.class) public class EscapesInMetadataTest { private static final Logger LOGGER = LoggerFactory.getLogger(EscapesInMetadataTest.class); @@ -48,19 +45,13 @@ public class EscapesInMetadataTest { private static final String RULE_KEY = "output"; private static final String RULE_VALUE = "Hello world!"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EscapesInMetadataTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testMetadataEscapes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMetadataEscapes(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule = "package " + TestConstants.PACKAGE_REGRESSION + "\n" + " rule \"" + RULE_NAME + "\"\n" + " @" + RULE_KEY + "(\"\\\""+ RULE_VALUE + "\\\"\")\n" diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventDeserializationInPastTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventDeserializationInPastTest.java index 6772d48e886..eb36ad6c289 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventDeserializationInPastTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventDeserializationInPastTest.java @@ -26,7 +26,7 @@ import org.drools.core.ClockType; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.time.impl.PseudoClockScheduler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.conf.EventProcessingOption; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventFactHandleDeserializationTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventFactHandleDeserializationTest.java index 269b4b20e99..0738cfd8f12 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventFactHandleDeserializationTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/EventFactHandleDeserializationTest.java @@ -20,8 +20,8 @@ import org.assertj.core.api.SoftAssertions; import org.drools.core.common.DefaultFactHandle; +import org.junit.jupiter.api.Test; import org.drools.core.common.DefaultEventHandle; -import org.junit.Test; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FixedPatternTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FixedPatternTest.java index 326dc004c05..2ae5e7f56dc 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FixedPatternTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FixedPatternTest.java @@ -19,17 +19,16 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -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.After; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.io.Resource; @@ -40,23 +39,15 @@ /** * Test for BZ 1150308. */ -@RunWith(Parameterized.class) public class FixedPatternTest { private KieSession ksession; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FixedPatternTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @After + @AfterEach public void cleanup() { if (this.ksession != null) { this.ksession.dispose(); @@ -66,8 +57,9 @@ public void cleanup() { /** * Tests fixed pattern without constraint in Decision table (BZ 1150308). */ - @Test - public void testFixedPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFixedPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource resource = KieServices.Factory.get().getResources().newClassPathResource("fixedPattern.drl.xls", getClass()); final KieBuilder kbuilder = KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, resource); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FromGenericCollectionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FromGenericCollectionTest.java index fcb1b32925b..d05020b503e 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FromGenericCollectionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FromGenericCollectionTest.java @@ -18,41 +18,32 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +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.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.runtime.ClassObjectFilter; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FromGenericCollectionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FromGenericCollectionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testGenerics() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGenerics(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package " + TestConstants.PACKAGE_REGRESSION + "\n" + " import java.util.Map.Entry\n" diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FusionAfterBeforeTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FusionAfterBeforeTest.java index 65fed9548a2..8409a4ecb50 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FusionAfterBeforeTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/FusionAfterBeforeTest.java @@ -18,10 +18,10 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.impl.RuleBaseFactory; import org.drools.testcoverage.common.listener.TrackingAgendaEventListener; @@ -33,11 +33,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.io.Resource; @@ -55,22 +54,15 @@ * Test to verify BRMS-582 (use of 'after' and 'before' operators ends with NPE) * is fixed. */ -@RunWith(Parameterized.class) public class FusionAfterBeforeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FusionAfterBeforeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Test - public void testAfterBeforeOperators() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterBeforeOperators(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource drlResource = KieServices.Factory.get().getResources().newClassPathResource("fusionAfterBeforeTest.drl", getClass()); final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_REGRESSION, @@ -112,8 +104,10 @@ public void testAfterBeforeOperators() { + firedCount + " time(s)!").isEqualTo(actuallyFired); } - @Test(timeout = 10000) - public void testExpireEventsWhenSharingAllRules() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testExpireEventsWhenSharingAllRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { final StringBuilder drlBuilder = new StringBuilder(); for (int i = 0; i < 64; i++) { drlBuilder.append(" import " + EventA.class.getCanonicalName() + ";\n"); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GenericsWithModifyTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GenericsWithModifyTest.java index 8a49cee936a..05b4981c4db 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GenericsWithModifyTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GenericsWithModifyTest.java @@ -18,16 +18,14 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.runtime.KieContainer; @@ -36,7 +34,6 @@ /** * Tests generics in RHS with modify - BZ 1142886. */ -@RunWith(Parameterized.class) public class GenericsWithModifyTest { private static final String DRL = @@ -52,26 +49,11 @@ public class GenericsWithModifyTest { private KieSession kieSession; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public GenericsWithModifyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Before - public void initialize() { - final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); - - final KieContainer kieContainer = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()); - this.kieSession = kieContainer.newKieSession(); - } - - @After + @AfterEach public void dispose() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -81,8 +63,13 @@ public void dispose() { /** * Tests generics on rule's RHS with modify. */ - @Test - public void testModifyWithGenericsOnRHS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithGenericsOnRHS(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); + + final KieContainer kieContainer = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()); + this.kieSession = kieContainer.newKieSession(); this.kieSession.insert("1"); this.kieSession.fireAllRules(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GlobalOnLHSTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GlobalOnLHSTest.java index d2c514d50ec..084ed5b3762 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GlobalOnLHSTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/GlobalOnLHSTest.java @@ -19,17 +19,18 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.io.Resource; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -44,19 +45,15 @@ public class GlobalOnLHSTest extends KieSessionTest { private static final String DRL_FILE = "bz1019473.drl"; - public GlobalOnLHSTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndStatefulKieSessionConfigurations(); - } - - @Test - public void testNPEOnMutableGlobal() throws Exception { - + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testNPEOnMutableGlobal(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); List context = new ArrayList(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/ImportReplaceTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/ImportReplaceTest.java index 70264fa75ab..ed44e60bbb1 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/ImportReplaceTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/ImportReplaceTest.java @@ -20,18 +20,17 @@ import java.io.StringReader; -import java.util.Collection; +import java.util.stream.Stream; + import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -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.KieServices; import org.kie.api.io.Resource; -@RunWith(Parameterized.class) public class ImportReplaceTest { private static final String declares = @@ -59,19 +58,13 @@ public class ImportReplaceTest { + " insert(new Holder(person));\n" + "end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ImportReplaceTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource declaresResource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(declares)); declaresResource.setTargetPath("src/main/resources/declares.drl"); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InaccurateComparisonTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InaccurateComparisonTest.java index d03f8026d66..fbd41ddd06a 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InaccurateComparisonTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InaccurateComparisonTest.java @@ -18,17 +18,15 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.runtime.KieSession; @@ -37,22 +35,15 @@ /** * Tests problems with large numbers to String conversion. See DROOLS-167. */ -@RunWith(Parameterized.class) public class InaccurateComparisonTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public InaccurateComparisonTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testStringCoercionComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStringCoercionComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule = "package " + TestConstants.PACKAGE_REGRESSION + "\n" + " import " + TestConstants.PACKAGE_TESTCOVERAGE_MODEL + ".Message;\n" + " rule \"string coercion\" \n" + diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InternalMatchTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InternalMatchTest.java index cbd4ce061e7..0a984d1edb5 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InternalMatchTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/InternalMatchTest.java @@ -22,8 +22,9 @@ import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.*; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; @@ -33,8 +34,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import static org.drools.testcoverage.common.util.KieUtil.getCommands; import static org.mockito.Mockito.*; @@ -64,22 +65,19 @@ public class InternalMatchTest extends KieSessionTest { " LOGGER.debug(\"noop\");\n" + "end\n"; - public InternalMatchTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); - } - - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndKieSessionConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } /** * Tests improper deactivation of already activated rule on the agenda. See * BZ 862325. */ - @Test - public void noDormantCheckOnModifies() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void noDormantCheckOnModifies(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); AgendaEventListener ael = mock(AgendaEventListener.class); session.addEventListener(ael); session.setGlobal("LOGGER", LOGGER); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/LogicalInsertionsSerializationTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/LogicalInsertionsSerializationTest.java index 82aa28cd3f7..7c9bf00f604 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/LogicalInsertionsSerializationTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/LogicalInsertionsSerializationTest.java @@ -23,18 +23,18 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.Promotion; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.io.Resource; import org.kie.api.marshalling.Marshaller; @@ -47,23 +47,20 @@ public class LogicalInsertionsSerializationTest extends KieSessionTest { private static final String DRL_FILE = "logical-insertion.drl"; - public LogicalInsertionsSerializationTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); - } - - @Rule - public TestName name = new TestName(); + @TempDir + public File name; - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndStatefulKieSessionConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Test - public void testSerializeAndDeserializeSession() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testSerializeAndDeserializeSession(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); - File tempFile = File.createTempFile(name.getMethodName(), null); + File tempFile = File.createTempFile("Junit5", "serializeAndDeserializeSession", name); ksession.fireAllRules(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultiRestrictionPatternTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultiRestrictionPatternTest.java index b4c96864cb4..01fcb74a43c 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultiRestrictionPatternTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultiRestrictionPatternTest.java @@ -19,17 +19,18 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.io.Resource; @@ -41,21 +42,18 @@ * fixed */ public class MultiRestrictionPatternTest extends KieSessionTest { - + private static final String DRL_FILE = "BRMS-364.drl"; - public MultiRestrictionPatternTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); - } - - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndStatefulKieSessionConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Test - public void multiRestriction1() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void multiRestriction1(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); List> commands = new ArrayList>(); commands.add(getCommands().newInsert(new Person("multi"))); commands.add(getCommands().newFireAllRules()); @@ -65,9 +63,12 @@ public void multiRestriction1() throws Exception { assertThat(firedRules.isRuleFired("or1")).isTrue(); } - @Test - public void multiRestriction2() throws Exception { - List> commands = new ArrayList>(); + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void multiRestriction2(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); + List> commands = new ArrayList>(); commands.add(getCommands().newInsert(new Person("MULTIRESTRICTION"))); commands.add(getCommands().newFireAllRules()); @@ -76,9 +77,12 @@ public void multiRestriction2() throws Exception { assertThat(firedRules.isRuleFired("or2")).isTrue(); } - @Test - public void multiRestriction3() throws Exception { - List> commands = new ArrayList>(); + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void multiRestriction3(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); + List> commands = new ArrayList>(); Person p = new Person(); p.setId(3); commands.add(getCommands().newInsert(p)); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleKieBaseListenersTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleKieBaseListenersTest.java index f2161255955..15c795e3cdd 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleKieBaseListenersTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleKieBaseListenersTest.java @@ -18,38 +18,29 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +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.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.event.kiebase.DefaultKieBaseEventListener; import org.kie.api.event.kiebase.KieBaseEventListener; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MultipleKieBaseListenersTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MultipleKieBaseListenersTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testKnowledgeBaseEventSupportLeak() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeBaseEventSupportLeak(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl(TestConstants.PACKAGE_REGRESSION, kieBaseTestConfiguration, ""); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSalienceUpdateFactTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSalienceUpdateFactTest.java index dc8d078fdda..717db29662a 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSalienceUpdateFactTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSalienceUpdateFactTest.java @@ -20,8 +20,8 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.ListHolder; @@ -29,9 +29,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.io.Resource; import org.slf4j.Logger; @@ -50,18 +51,15 @@ public class MultipleSalienceUpdateFactTest extends KieSessionTest { private static final String DRL_FILE = "BRMS-580.drl"; - public MultipleSalienceUpdateFactTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndStatefulKieSessionConfigurations(); - } - - @Test - public void test() { + + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); session.setGlobal("LOGGER", LOGGER); List> commands = new ArrayList>(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSheetsLoadingTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSheetsLoadingTest.java index 8efc92fc519..2e17eb0319b 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSheetsLoadingTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MultipleSheetsLoadingTest.java @@ -21,15 +21,15 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.stream.Stream; import org.drools.compiler.builder.conf.DecisionTableConfigurationImpl; 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.KieServices; import org.kie.api.builder.KieBuilder; @@ -48,18 +48,10 @@ /** * Tests loading decision tables from several worksheets in a XLS file. */ -@RunWith(Parameterized.class) public class MultipleSheetsLoadingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MultipleSheetsLoadingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } private static final Logger LOGGER = LoggerFactory.getLogger(MultipleSheetsLoadingTest.class); @@ -71,9 +63,10 @@ public static Collection getParameters() { private static final String WORKSHEET_1_NAME = "first"; private static final String WORKSHEET_2_NAME = "second"; - @Test - public void test() { - final KieBuilder kbuilder = this.buildResources(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieBuilder kbuilder = this.buildResources(kieBaseTestConfiguration); final Collection results = kbuilder.getResults().getMessages(Level.ERROR, Level.WARNING); if (results.size() > 0) { @@ -93,7 +86,7 @@ public void test() { } } - private KieBuilder buildResources() { + private KieBuilder buildResources(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource resourceXlsFirst = this.createResourceWithConfig(WORKSHEET_1_NAME); final Resource resourceXlsSecond = this.createResourceWithConfig(WORKSHEET_2_NAME); return KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, false, resourceXlsFirst, resourceXlsSecond); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MvelOverloadedMethodsUsageTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MvelOverloadedMethodsUsageTest.java index 862c4d080fe..16d8ce8a25c 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MvelOverloadedMethodsUsageTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/MvelOverloadedMethodsUsageTest.java @@ -19,17 +19,18 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.Overloaded; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.io.Resource; import org.kie.internal.command.CommandFactory; @@ -64,18 +65,15 @@ public class MvelOverloadedMethodsUsageTest extends KieSessionTest { " then\n" + "end\n"; - public MvelOverloadedMethodsUsageTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndKieSessionConfigurations(); - } - - @Test - public void testMvelOverloadedMethodsUsage() { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testMvelOverloadedMethodsUsage(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert(new Overloaded())); commands.add(CommandFactory.newFireAllRules()); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NonStringCompareTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NonStringCompareTest.java index 34851e4380f..91eb88684a6 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NonStringCompareTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NonStringCompareTest.java @@ -18,16 +18,15 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +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.TestConstants; -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.Level; @@ -36,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NonStringCompareTest { private static final String genericDrl = @@ -51,37 +49,33 @@ public class NonStringCompareTest { + " // consequence\n" + "end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NonStringCompareTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testStringCompare() throws Exception { - testScenario("\"someString\"", "someString"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStringCompare(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + testScenario(kieBaseTestConfiguration, "\"someString\"", "someString"); } - @Test - public void testNonQuotedStringComapre() { - final KieBuilder kbuilder = build("someString"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonQuotedStringComapre(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieBuilder kbuilder = build(kieBaseTestConfiguration, "someString"); assertThat(kbuilder.getResults().getMessages(Level.ERROR).size()).isEqualTo(1); } - @Test - public void testIntCompare() throws Exception { - testScenario("13", "13"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntCompare(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + testScenario(kieBaseTestConfiguration, "13", "13"); } - private void testScenario(final String factFieldValueForDrl, final String factFieldValueForTest) + private void testScenario(KieBaseTestConfiguration kieBaseTestConfiguration, final String factFieldValueForDrl, final String factFieldValueForTest) throws IllegalAccessException, InstantiationException { - final KieBuilder kbuilder = build(factFieldValueForDrl); + final KieBuilder kbuilder = build(kieBaseTestConfiguration, factFieldValueForDrl); assertThat(kbuilder.getResults().getMessages(Level.ERROR)).isEmpty(); final KieBase kbase = KieBaseUtil.getDefaultKieBaseFromKieBuilder(kbuilder); @@ -100,7 +94,7 @@ private void testScenario(final String factFieldValueForDrl, final String factFi } } - private KieBuilder build(final String replacement) { + private KieBuilder build(KieBaseTestConfiguration kieBaseTestConfiguration, final String replacement) { final String drl = String.format(genericDrl, replacement); return KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NotInFusionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NotInFusionTest.java index 31d946e21d3..c367d6740c4 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NotInFusionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NotInFusionTest.java @@ -18,15 +18,16 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.definition.type.FactType; import org.kie.api.io.Resource; import org.kie.api.runtime.KieSession; @@ -42,26 +43,27 @@ public class NotInFusionTest extends KieSessionTest { private static final String RULE2 = "not equal 2"; private static final String RULE3 = "different"; - public NotInFusionTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); - } - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getStreamKieBaseAndStatefulKieSessionConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getStreamKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Test - public void testNoEvent() { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testNoEvent(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); ksession.fireAllRules(); assertThat(firedRules.isRuleFired(RULE1)).as(RULE1).isTrue(); } - @Test - public void testInsertFirst() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testInsertFirst(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); insertNotEvent(ksession); @@ -70,8 +72,11 @@ public void testInsertFirst() throws Exception { assertThat(firedRules.isRuleFired(RULE1)).as(RULE1).isFalse(); } - @Test - public void testInsertFirstAndAdd() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testInsertFirstAndAdd(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); insertNotEvent(ksession); @@ -87,8 +92,11 @@ public void testInsertFirstAndAdd() throws Exception { assertThat(firedRules.isRuleFired(RULE1)).as(RULE1).isTrue(); } - @Test - public void testInsertFirstAndAdd2() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testInsertFirstAndAdd2(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); insertNotEvent(ksession); @@ -105,8 +113,11 @@ public void testInsertFirstAndAdd2() throws Exception { assertThat(firedRules.isRuleFired(RULE1)).as(RULE1).isTrue(); } - @Test - public void testInsertFirstAndAdd3() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testInsertFirstAndAdd3(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); insertNotEvent(ksession); @@ -124,8 +135,11 @@ public void testInsertFirstAndAdd3() throws Exception { assertThat(firedRules.isRuleFired(RULE1)).as(RULE1).isTrue(); } - @Test - public void testNoEntryPoint() throws Exception { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testNoEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); KieSession ksession = session.getStateful(); ksession.insert(createNotEvent(ksession, "value")); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NullInListInFromTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NullInListInFromTest.java index 4924f758fb9..3d2f84f8f2e 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NullInListInFromTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/NullInListInFromTest.java @@ -19,16 +19,15 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -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.runtime.KieSession; @@ -36,7 +35,6 @@ /** * Tests handling a null value in a list used in FROM (BZ 1093174). */ -@RunWith(Parameterized.class) public class NullInListInFromTest { private static final String DRL = @@ -48,19 +46,13 @@ public class NullInListInFromTest { "then\n" + "end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NullInListInFromTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testNullValueInFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullValueInFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBuilder kbuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, DRL); final KieBase kbase = KieBaseUtil.getDefaultKieBaseFromKieBuilder(kbuilder); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/POJOAnnotationMergeTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/POJOAnnotationMergeTest.java index c6055f0a674..2ac5ec81d7f 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/POJOAnnotationMergeTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/POJOAnnotationMergeTest.java @@ -18,34 +18,25 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; 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.definition.type.Position; /** * Tests merging the POJO annotations (e.g. @Position) with fact declaration in * DRL. */ -@RunWith(Parameterized.class) public class POJOAnnotationMergeTest { private static final String EVENT_CLASS_NAME = PositionAnnotatedEvent.class.getCanonicalName(); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public POJOAnnotationMergeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } // should add metadata to metadata already defined in POJO @@ -63,8 +54,9 @@ public static Collection getParameters() { /** * Tests adding metadata in DRL to the metadata already declared in a POJO. */ - @Test - public void testPositionFromPOJOIgnored() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPositionFromPOJOIgnored(KieBaseTestConfiguration kieBaseTestConfiguration) { KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration,true, DRL); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/PropertyListenerTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/PropertyListenerTest.java index 9bf56450f60..d114fcc7e4d 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/PropertyListenerTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/PropertyListenerTest.java @@ -23,15 +23,14 @@ import java.util.ArrayList; 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.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.KieServices; import org.kie.api.command.Command; @@ -47,23 +46,16 @@ * https://bugzilla.redhat.com/show_bug.cgi?id=746887 * https://issues.jboss.org/browse/JBRULES-3256 */ -@RunWith(Parameterized.class) public class PropertyListenerTest { private static final Logger LOGGER = LoggerFactory.getLogger(PropertyListenerTest.class); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PropertyListenerTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void runTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void runTest(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices kieServices = KieServices.Factory.get(); final Resource drlResource = kieServices.getResources().newClassPathResource("propertyListenerTest.drl", getClass()); final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_REGRESSION, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableGeneratedTypesTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableGeneratedTypesTest.java index c592c6a3182..89ad0f8f3c8 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableGeneratedTypesTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableGeneratedTypesTest.java @@ -18,16 +18,14 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +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.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.KieServices; import org.kie.api.definition.type.FactType; @@ -38,22 +36,15 @@ /** * Test to verify BRMS-360 (Generated types should be serializable) is fixed */ -@RunWith(Parameterized.class) public class SerializableGeneratedTypesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SerializableGeneratedTypesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testSerializability() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializability(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource drlResource = KieServices.Factory.get().getResources().newClassPathResource("serializableGeneratedTypesTest.drl", getClass()); final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_REGRESSION, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableInstantiationTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableInstantiationTest.java index b5a8c9c2f64..81b254416f4 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableInstantiationTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializableInstantiationTest.java @@ -20,17 +20,18 @@ import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.util.*; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.io.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; -import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.stream.Stream; import static org.drools.testcoverage.common.util.KieUtil.getCommands; @@ -49,18 +50,15 @@ public class SerializableInstantiationTest extends KieSessionTest { "// LOGGER.info(\"Works like a charm!\");\n" + "end\n"; - public SerializableInstantiationTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndKieSessionConfigurations(); - } - - @Test - public void testSerializableInstantiation() { + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void testSerializableInstantiation(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); session.setGlobal("LOGGER", LOGGER); List> commands = new LinkedList>(); commands.add(getCommands().newInsert(new SerializableWrapper("hello"))); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializationWithCollectTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializationWithCollectTest.java index 440e889df2f..f171707ae51 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializationWithCollectTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SerializationWithCollectTest.java @@ -21,9 +21,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -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.KieBase; import org.kie.api.io.ResourceType; import org.kie.api.marshalling.Marshaller; @@ -50,13 +50,13 @@ public class SerializationWithCollectTest { private KieBase kbase; private KieSession ksession; - @Before + @BeforeEach public void setup() { this.kbase = new KieHelper().addContent(DRL, ResourceType.DRL).build(); this.ksession = kbase.newKieSession(); } - @After + @AfterEach public void cleanup() { if (this.ksession != null) { this.ksession.dispose(); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SessionInsertMultiThreadingTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SessionInsertMultiThreadingTest.java index 4e52b9447e6..55fe2abdb4f 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SessionInsertMultiThreadingTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/SessionInsertMultiThreadingTest.java @@ -19,23 +19,21 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Message; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -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.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.command.Command; @@ -52,7 +50,6 @@ * Test to verify BRMS-532 (Drools Session insert * ConcurrentModificationException in Multithreading Environment) is fixed */ -@RunWith(Parameterized.class) public class SessionInsertMultiThreadingTest { private static final Logger LOGGER = LoggerFactory.getLogger(SessionInsertMultiThreadingTest.class); @@ -63,19 +60,11 @@ public class SessionInsertMultiThreadingTest { private KieBase kbase; private ExecutorService executor; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SessionInsertMultiThreadingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Before - public void createExecutor() { + public void createExecutor(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource resource = KieServices.Factory.get().getResources().newClassPathResource( "sessionInsertMultithreadingTest.drl", SessionInsertMultiThreadingTest.class); @@ -85,7 +74,7 @@ public void createExecutor() { executor = Executors.newFixedThreadPool(THREADS); } - @After + @AfterEach public void shutdownExecutor() throws Exception { if (kbase != null) { for (KieSession ksession : kbase.getKieSessions()) { @@ -101,8 +90,10 @@ public void shutdownExecutor() throws Exception { executor = null; } - @Test - public void testCommonBase() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCommonBase(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createExecutor(kieBaseTestConfiguration); final List> futures = new ArrayList>(); for (int i = 0; i < RUNS_PER_THREAD; i++) { @@ -114,8 +105,10 @@ public void testCommonBase() throws Exception { waitForCompletion(futures); } - @Test - public void testCommonSession() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCommonSession(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createExecutor(kieBaseTestConfiguration); for (int i = 0; i < RUNS_PER_THREAD; i++) { testSingleCommonSession(); } @@ -138,8 +131,10 @@ private void testSingleCommonSession() throws Exception { /** * Reproducer for BZ 1187070. */ - @Test - public void testCommonStatelessSessionBZ1187070() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCommonStatelessSessionBZ1187070(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createExecutor(kieBaseTestConfiguration); for (int i = 0; i < RUNS_PER_THREAD; i++) { testSingleCommonStatelessSession(); } diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/StarImportTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/StarImportTest.java index 0944a3b3c31..f5269f5d3f2 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/StarImportTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/StarImportTest.java @@ -19,17 +19,18 @@ package org.drools.testcoverage.regression; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.KieSessionTest; import org.drools.testcoverage.common.model.TestEvent; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.command.Command; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; @@ -55,24 +56,21 @@ public class StarImportTest extends KieSessionTest { private static final String DRL_FILE = "star_import.drl"; - public StarImportTest(final KieBaseTestConfiguration kieBaseTestConfiguration, - final KieSessionTestConfiguration kieSessionTestConfiguration) { - super(kieBaseTestConfiguration, kieSessionTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseAndStatefulKieSessionConfigurations().stream(); } - - @Parameterized.Parameters(name = "{1}" + " (from " + "{0}" + ")") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseAndKieSessionConfigurations(); - } - /** * Tests that rule fires if supplied with a fact that is imported using * "star" import. * * See BZ 973264. */ - @Test - public void starImportedFactAlsoDeclaredInDRL() throws Exception { + + @ParameterizedTest(name = "{1}" + " (from " + "{0}" + ")") + @MethodSource("parameters") + public void starImportedFactAlsoDeclaredInDRL(KieBaseTestConfiguration kieBaseTestConfiguration, + KieSessionTestConfiguration kieSessionTestConfiguration) throws Exception { + createKieSession(kieBaseTestConfiguration, kieSessionTestConfiguration); session.setGlobal("LOGGER", LOGGER); AgendaEventListener ael = mock(AgendaEventListener.class); session.addEventListener(ael); diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/TruthMaintenanceSystemConcurrencyTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/TruthMaintenanceSystemConcurrencyTest.java index 83ee2daddb2..5f0b9f9b0df 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/TruthMaintenanceSystemConcurrencyTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/TruthMaintenanceSystemConcurrencyTest.java @@ -29,7 +29,7 @@ import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; import org.drools.mvel.compiler.Cheese; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.io.ResourceType; import org.kie.api.runtime.ClassObjectFilter; diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/UnwantedStringConversionTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/UnwantedStringConversionTest.java index 8e6e206ee91..e30919d5604 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/UnwantedStringConversionTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/UnwantedStringConversionTest.java @@ -18,17 +18,15 @@ */ package org.drools.testcoverage.regression; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.listener.TrackingAgendaEventListener; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +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.KieServices; import org.kie.api.io.Resource; @@ -38,23 +36,16 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class UnwantedStringConversionTest { private static final Logger LOGGER = LoggerFactory.getLogger(UnwantedStringConversionTest.class); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public UnwantedStringConversionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameters - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations().stream(); } - @Test - public void testStringToDecimalConversion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStringToDecimalConversion(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource drlResource = KieServices.Factory.get().getResources().newClassPathResource("unwantedStringConversionTest.drl", getClass()); final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromResources(TestConstants.PACKAGE_REGRESSION, diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/XSDResourceTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/XSDResourceTest.java index 3818ecd5e8c..62efcb7181d 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/XSDResourceTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/XSDResourceTest.java @@ -18,12 +18,13 @@ */ package org.drools.testcoverage.regression; -import org.junit.Test; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.Test; + /** * Tests KIE package compilation when there is a XSD resource (BZ 1120972). */ diff --git a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/mvel/MvelLinkageErrorTest.java b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/mvel/MvelLinkageErrorTest.java index 1bf15cce662..65b06e34867 100644 --- a/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/mvel/MvelLinkageErrorTest.java +++ b/drools-test-coverage/test-suite/src/test/java/org/drools/testcoverage/regression/mvel/MvelLinkageErrorTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieFileSystem; import org.kie.api.runtime.KieSession; From 6b9edfd47b1f84899093418cf453120cee6c24b0 Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Fri, 22 Nov 2024 18:30:01 +0100 Subject: [PATCH 6/7] [incubator-kie-drools-6136] Migrate drools kie manve plugin tests to JUnit5 - #6 (#6170) * More tests migrated * Migrated tests to Junit5 * Migrated module to JUnit5 * Migrated kie-ci module --- kie-ci/pom.xml | 6 ++--- ...duleDeploymentHelperLoadResourcesTest.java | 2 +- .../helper/KieModuleDeploymentHelperTest.java | 6 ++--- .../JavaBeansEventRoleTest.java | 2 +- .../scanner/DependentScopeNamedBeanTest.java | 2 +- .../org/kie/scanner/KieModuleBuilderTest.java | 10 ++++---- .../KieModuleIncrementalCompilationTest.java | 2 +- .../org/kie/scanner/KieModuleMavenTest.java | 2 +- .../scanner/KieModuleMetaDataImplTest.java | 2 +- .../kie/scanner/KieModuleMetaDataTest.java | 2 +- .../KieRepositoryScannerNexusTest.java | 14 +++++------ .../kie/scanner/KieRepositoryScannerTest.java | 24 +++++++++++-------- .../KieScannerIncrementalCompilationTest.java | 6 ++--- .../concurrent/ConcurrentBuildTest.java | 14 ++++++----- .../kie/scanner/embedder/MavenDeployTest.java | 2 +- .../management/KieScannerMBeanTest.java | 10 ++++---- kie-maven-plugin/pom.xml | 5 ---- .../ittests/ExecModelParameterTestIT.java | 7 ++---- .../ittests/ExecModelParameterTestIT.java | 7 ++---- .../ittests/ExecModelParameterTestIT.java | 5 ++-- .../ittests/ExecModelParameterTestIT.java | 7 ++---- .../plugin/ittests/BuildPMMLTrustyTestIT.java | 13 +++++----- .../ittests/AlphaNetworkCompilerTestIT.java | 14 +++++------ .../org/drools/ruleunit/example/LoanTest.java | 10 ++++---- .../kie/maven/plugin/ittests/YamlTestIT.java | 21 +++++++--------- ...AdditionalPropertiesIntegrationTestIT.java | 8 +++---- .../ittests/KJarWithDMNIntegrationTestIT.java | 3 +-- .../ittests/KJarWithDMNIntegrationTestIT.java | 5 ++-- .../plugin/ittests/MultiModuleTestIT.java | 7 ++---- .../plugin/ittests/MultiModuleTestIT.java | 5 ++-- .../plugin/ittests/DeclaredTypesTestIT.java | 12 ++++------ .../plugin/ittests/DeclaredTypesTestIT.java | 12 +++++----- .../kie-maven-plugin-test-kjar-common/pom.xml | 9 +++---- .../maven/plugin/ittests/ITTestsUtils.java | 18 +++++++------- .../kie-maven-plugin-test-kjar-parent/pom.xml | 9 +++---- 35 files changed, 131 insertions(+), 152 deletions(-) diff --git a/kie-ci/pom.xml b/kie-ci/pom.xml index 4e5c85613ba..3aee239da18 100644 --- a/kie-ci/pom.xml +++ b/kie-ci/pom.xml @@ -150,10 +150,10 @@ - junit - junit + org.junit.jupiter + junit-jupiter test - + org.assertj diff --git a/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperLoadResourcesTest.java b/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperLoadResourcesTest.java index 4f4ae25e5b6..e5fee8b3dad 100644 --- a/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperLoadResourcesTest.java +++ b/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperLoadResourcesTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.helper.KieModuleDeploymentHelperImpl.KJarResource; import static org.assertj.core.api.Assertions.assertThat; diff --git a/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperTest.java b/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperTest.java index def9532ac34..005054d8442 100644 --- a/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperTest.java +++ b/kie-ci/src/test/java/org/kie/api/builder/helper/KieModuleDeploymentHelperTest.java @@ -30,8 +30,8 @@ import org.drools.core.impl.EnvironmentImpl; import org.drools.core.test.model.Cheese; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.kie.api.builder.KieModule; import org.kie.api.builder.model.KieBaseModel; import org.kie.api.conf.EqualityBehaviorOption; @@ -49,7 +49,7 @@ public class KieModuleDeploymentHelperTest { private ZipInputStream zip; - @After + @AfterEach public void cleanUp() { if (zip != null) { try { diff --git a/kie-ci/src/test/java/org/kie/declarativetypes/JavaBeansEventRoleTest.java b/kie-ci/src/test/java/org/kie/declarativetypes/JavaBeansEventRoleTest.java index a196274469f..35a4c7c4396 100644 --- a/kie-ci/src/test/java/org/kie/declarativetypes/JavaBeansEventRoleTest.java +++ b/kie-ci/src/test/java/org/kie/declarativetypes/JavaBeansEventRoleTest.java @@ -20,7 +20,7 @@ import org.drools.base.rule.TypeMetaInfo; import org.drools.mvel.CommonTestMethodBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; diff --git a/kie-ci/src/test/java/org/kie/scanner/DependentScopeNamedBeanTest.java b/kie-ci/src/test/java/org/kie/scanner/DependentScopeNamedBeanTest.java index 8a7b98370fc..9ee8df1bee2 100644 --- a/kie-ci/src/test/java/org/kie/scanner/DependentScopeNamedBeanTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/DependentScopeNamedBeanTest.java @@ -20,7 +20,7 @@ import java.io.InputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.maven.integration.MavenPomModelGenerator; import org.kie.util.maven.support.PomModel; import org.kie.util.maven.support.PomModelGenerator; diff --git a/kie-ci/src/test/java/org/kie/scanner/KieModuleBuilderTest.java b/kie-ci/src/test/java/org/kie/scanner/KieModuleBuilderTest.java index bc7e0ad68c1..aa5c97d5832 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieModuleBuilderTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieModuleBuilderTest.java @@ -26,9 +26,9 @@ import org.drools.compiler.kie.builder.impl.InternalKieModule; import org.drools.core.util.FileManager; -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.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -44,13 +44,13 @@ public class KieModuleBuilderTest extends AbstractKieCiTest { private FileManager fileManager; - @Before + @BeforeEach public void setUp() throws Exception { this.fileManager = new FileManager(); this.fileManager.setUp(); } - @After + @AfterEach public void tearDown() throws Exception { this.fileManager.tearDown(); } diff --git a/kie-ci/src/test/java/org/kie/scanner/KieModuleIncrementalCompilationTest.java b/kie-ci/src/test/java/org/kie/scanner/KieModuleIncrementalCompilationTest.java index 6f4d6e53be9..7b98d52502e 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieModuleIncrementalCompilationTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieModuleIncrementalCompilationTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import org.drools.drl.parser.MessageImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; diff --git a/kie-ci/src/test/java/org/kie/scanner/KieModuleMavenTest.java b/kie-ci/src/test/java/org/kie/scanner/KieModuleMavenTest.java index 2d66e152fb9..b3fb5961521 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieModuleMavenTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieModuleMavenTest.java @@ -34,7 +34,7 @@ import org.drools.compiler.kie.builder.impl.KieRepositoryImpl; import org.drools.compiler.kie.builder.impl.KieServicesImpl; import org.drools.mvel.asm.DefaultBeanClassBuilder; -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.KieBuilder; diff --git a/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataImplTest.java b/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataImplTest.java index 830e851cb25..35c244e560e 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataImplTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataImplTest.java @@ -18,7 +18,7 @@ */ package org.kie.scanner; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataTest.java b/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataTest.java index 8188a23e8ae..7f031a7231f 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieModuleMetaDataTest.java @@ -19,8 +19,8 @@ package org.kie.scanner; import org.drools.compiler.kie.builder.impl.InternalKieModule; +import org.junit.jupiter.api.Test; import org.drools.base.rule.TypeMetaInfo; -import org.junit.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; diff --git a/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerNexusTest.java b/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerNexusTest.java index 6855bb248b8..a180ab7ca3b 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerNexusTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerNexusTest.java @@ -23,10 +23,10 @@ import org.drools.compiler.kie.builder.impl.InternalKieModule; import org.drools.core.util.FileManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; import org.kie.api.builder.ReleaseId; @@ -48,13 +48,13 @@ * 3. Note that this test uses 'http://localhost:8081' as nexus target, with the default nexus user name 'admin' and password 'admin123' * */ -@Ignore("ignored because it needs a running nexus server") +@Disabled("ignored because it needs a running nexus server") public class KieRepositoryScannerNexusTest extends AbstractKieCiTest { private static final Logger LOG = LoggerFactory.getLogger(KieRepositoryScannerNexusTest.class); private FileManager fileManager; - @Before + @BeforeEach public void setUp() throws Exception { System.setProperty("kie.maven.settings.custom", new File("target/test-classes/org/kie/scanner/settings_nexus.xml").getAbsolutePath()); this.fileManager = new FileManager(); @@ -62,7 +62,7 @@ public void setUp() throws Exception { ReleaseId releaseId = KieServices.Factory.get().newReleaseId("org.kie", "scanner-test", "1.0-SNAPSHOT"); } - @After + @AfterEach public void tearDown() throws Exception { this.fileManager.tearDown(); } diff --git a/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerTest.java b/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerTest.java index b06a6228339..240caa36d60 100644 --- a/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerTest.java +++ b/kie-ci/src/test/java/org/kie/scanner/KieRepositoryScannerTest.java @@ -31,10 +31,10 @@ import org.drools.compiler.kie.builder.impl.event.KieScannerStatusChangeEventImpl; import org.drools.compiler.kie.builder.impl.event.KieScannerUpdateResultsEventImpl; import org.drools.core.util.FileManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -63,14 +63,14 @@ public class KieRepositoryScannerTest extends AbstractKieCiTest { private FileManager fileManager; - @Before + @BeforeEach public void setUp() throws Exception { this.fileManager = new FileManager(); this.fileManager.setUp(); ReleaseId releaseId = KieServices.Factory.get().newReleaseId("org.kie", "scanner-test", "1.0-SNAPSHOT"); } - @After + @AfterEach public void tearDown() throws Exception { this.fileManager.tearDown(); } @@ -115,7 +115,8 @@ public void testKScanner() throws Exception { ks.getRepository().removeKieModule(releaseId); } - @Test @Ignore("used only for check performances") + @Test + @Disabled("used only for check performances") public void testKScannerWithDependencies() throws Exception { KieServices ks = KieServices.Factory.get(); ReleaseId releaseIdNoDep = ks.newReleaseId( "org.kie", "test-no-dep", "1.0-SNAPSHOT" ); @@ -136,7 +137,8 @@ public void testKScannerWithDependencies() throws Exception { System.out.println("done in " + (System.nanoTime() - start)); } - @Test @Ignore("avoid use external dependency") + @Test + @Disabled("avoid use external dependency") public void testKScannerWithTransitiveInclusion() throws Exception { String pom = "\n" + "\n" + "assertj-core test - - junit - junit - test - org.junit.jupiter junit-jupiter-engine diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java index c9a0de4cf98..4042783e456 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java @@ -20,16 +20,13 @@ import java.net.URL; -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; public class ExecModelParameterTestIT { @@ -43,7 +40,7 @@ public class ExecModelParameterTestIT { public void testWithoutDroolsModelCompilerOnClassPathDoNotRunExecModel() throws Exception { KieModule kieModule = fireRule(); assertThat(kieModule).isNotNull(); - assertFalse(kieModule.getClass().getCanonicalName().equals(CANONICAL_KIE_MODULE)); + assertThat(kieModule.getClass().getCanonicalName()).isNotEqualTo(CANONICAL_KIE_MODULE); } private KieModule fireRule() throws Exception { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java index 1436b809703..21bf6041e3b 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-10-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java @@ -20,16 +20,13 @@ import java.net.URL; -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; public class ExecModelParameterTestIT { @@ -43,7 +40,7 @@ public class ExecModelParameterTestIT { public void testWithoutDroolsModelCompilerOnClassPathDoNotRunExecModel() throws Exception { KieModule kieModule = fireRule(); assertThat(kieModule).isNotNull(); - assertFalse(kieModule.getClass().getCanonicalName().equals(CANONICAL_KIE_MODULE)); + assertThat(kieModule.getClass().getCanonicalName()).isNotEqualTo(CANONICAL_KIE_MODULE); } private KieModule fireRule() throws Exception { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java index 6a05bd465d2..83c22a90917 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-default/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java @@ -21,11 +21,10 @@ import java.net.URL; import org.drools.modelcompiler.CanonicalKieModule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.KieModule; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertTrue; public class ExecModelParameterTestIT { @@ -38,7 +37,7 @@ public class ExecModelParameterTestIT { public void testWithoutDroolsModelCompilerOnClassPathDoNotRunExecModel() throws Exception { KieModule kieModule = fireRule(); assertThat(kieModule).isNotNull(); - assertTrue(kieModule instanceof CanonicalKieModule); + assertThat(kieModule).isInstanceOf(CanonicalKieModule.class); } private KieModule fireRule() throws Exception { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java index 8afd4f2090f..88fbad464b2 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-11-yes-generate/src/test/java-filtered/org/kie/maven/plugin/ittests/ExecModelParameterTestIT.java @@ -20,17 +20,14 @@ import java.net.URL; -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.drools.modelcompiler.CanonicalKieModule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; public class ExecModelParameterTestIT { @@ -43,7 +40,7 @@ public class ExecModelParameterTestIT { public void testWithoutDroolsModelCompilerOnClassPathDoNotRunExecModel() throws Exception { KieModule kieModule = fireRule(); assertThat(kieModule).isNotNull(); - assertTrue(kieModule instanceof CanonicalKieModule); + assertThat(kieModule).isInstanceOf(CanonicalKieModule.class); } private KieModule fireRule() throws Exception { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-12/src/test/java-filtered/org/kie/maven/plugin/ittests/BuildPMMLTrustyTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-12/src/test/java-filtered/org/kie/maven/plugin/ittests/BuildPMMLTrustyTestIT.java index 287b2d65342..742fc12a2f3 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-12/src/test/java-filtered/org/kie/maven/plugin/ittests/BuildPMMLTrustyTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-12/src/test/java-filtered/org/kie/maven/plugin/ittests/BuildPMMLTrustyTestIT.java @@ -28,8 +28,9 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; -import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; public class BuildPMMLTrustyTestIT { @@ -54,9 +55,9 @@ public void testContentKjarWithPMML() throws Exception { jarContent.add(entryName); } - Assertions.assertThat(jarContent).isNotEmpty(); - Assertions.assertThat(jarContent).contains(PMML_FILE_NAME); - Assertions.assertThat(jarContent).contains(INDEX_FILE_NAME); - EXAMPLE_PMML_CLASSES.forEach(examplePMMLClass -> Assertions.assertThat(jarContent).contains(examplePMMLClass)); + assertThat(jarContent).isNotEmpty(); + assertThat(jarContent).contains(PMML_FILE_NAME); + assertThat(jarContent).contains(INDEX_FILE_NAME); + EXAMPLE_PMML_CLASSES.forEach(examplePMMLClass -> assertThat(jarContent).contains(examplePMMLClass)); } } \ No newline at end of file diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-13/src/test/java-filtered/org/kie/maven/plugin/ittests/AlphaNetworkCompilerTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-13/src/test/java-filtered/org/kie/maven/plugin/ittests/AlphaNetworkCompilerTestIT.java index 08613bff8ff..5ec89001201 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-13/src/test/java-filtered/org/kie/maven/plugin/ittests/AlphaNetworkCompilerTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-13/src/test/java-filtered/org/kie/maven/plugin/ittests/AlphaNetworkCompilerTestIT.java @@ -22,20 +22,18 @@ import java.net.URL; import java.util.List; -import org.assertj.core.api.Assertions; import org.drools.ancompiler.CompiledNetwork; import org.drools.ancompiler.ObjectTypeNodeCompiler; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.core.reteoo.ObjectSinkPropagator; import org.drools.core.reteoo.ObjectTypeNode; import org.drools.core.reteoo.Rete; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class AlphaNetworkCompilerTestIT { @@ -48,12 +46,12 @@ public void testAlphaNetworkCompiler() throws Exception { final URL targetLocation = AlphaNetworkCompilerTestIT.class.getProtectionDomain().getCodeSource().getLocation(); final KieContainer kieContainer = ITTestsUtils.getKieContainer(targetLocation, GAV_ARTIFACT_ID, GAV_VERSION); final KieBase kieBase = kieContainer.getKieBase(KBASE_NAME); - Assertions.assertThat(kieBase).isNotNull(); + assertThat(kieBase).isNotNull(); KieSession kSession = null; try { kSession = kieBase.newKieSession(); - Assertions.assertThat(kSession).isNotNull(); + assertThat(kSession).isNotNull(); ClassLoader classLoader = kieContainer.getClassLoader(); Class aClass = Class.forName("org.compiledalphanetwork.Person", true, classLoader); @@ -64,7 +62,7 @@ public void testAlphaNetworkCompiler() throws Exception { int rulesFired = kSession.fireAllRules(); kSession.dispose(); - assertEquals(1, rulesFired); + assertThat(rulesFired).isEqualTo(1); assertReteIsAlphaNetworkCompiled(kSession); @@ -79,7 +77,7 @@ protected void assertReteIsAlphaNetworkCompiled(KieSession ksession) { for(ObjectTypeNode otn : objectTypeNodes) { ObjectSinkPropagator objectSinkPropagator = otn.getObjectSinkPropagator(); System.out.println(objectSinkPropagator.getClass().getCanonicalName()); - assertTrue(objectSinkPropagator instanceof CompiledNetwork); + assertThat(objectSinkPropagator).isInstanceOf(CompiledNetwork.class); } } } \ No newline at end of file diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-14-ruleunits/src/test/java/org/drools/ruleunit/example/LoanTest.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-14-ruleunits/src/test/java/org/drools/ruleunit/example/LoanTest.java index c973178b15b..3c6b0bc6aae 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-14-ruleunits/src/test/java/org/drools/ruleunit/example/LoanTest.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-14-ruleunits/src/test/java/org/drools/ruleunit/example/LoanTest.java @@ -23,10 +23,10 @@ import org.drools.ruleunits.api.RuleUnitInstance; import org.drools.ruleunits.api.RuleUnitProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static java.util.stream.Collectors.toList; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class LoanTest { @@ -43,8 +43,8 @@ public void test() { List results = instance.executeQuery("FindApproved").toList("$l"); - assertEquals(1, results.size()); - assertEquals("ABC10001", results.get(0).getId()); - assertEquals("John", results.get(0).getApplicant().getName()); + assertThat(results).hasSize(1); + assertThat(results.get(0).getId()).isEqualTo("ABC10001"); + assertThat(results.get(0).getApplicant().getName()).isEqualTo("John"); } } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-15-yaml/src/test/java-filtered/org/kie/maven/plugin/ittests/YamlTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-15-yaml/src/test/java-filtered/org/kie/maven/plugin/ittests/YamlTestIT.java index ded38386ade..d95c193fb0e 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-15-yaml/src/test/java-filtered/org/kie/maven/plugin/ittests/YamlTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-15-yaml/src/test/java-filtered/org/kie/maven/plugin/ittests/YamlTestIT.java @@ -27,15 +27,11 @@ import org.kie.api.KieBase; import org.kie.api.runtime.KieContainer; - -import org.assertj.core.api.Assertions; -import org.junit.Test; import org.kie.api.runtime.KieSession; - +import org.junit.jupiter.api.Test; import org.yaml.Measurement; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class YamlTestIT { @@ -50,12 +46,12 @@ public void testYamlRules() throws Exception { final URL targetLocation = YamlTestIT.class.getProtectionDomain().getCodeSource().getLocation(); final KieContainer kieContainer = ITTestsUtils.getKieContainer(targetLocation, GAV_ARTIFACT_ID, GAV_VERSION); final KieBase kieBase = kieContainer.getKieBase(KBASE_NAME); - Assertions.assertThat(kieBase).isNotNull(); + assertThat(kieBase).isNotNull(); KieSession kSession = null; try { kSession = kieBase.newKieSession(); - Assertions.assertThat(kSession).isNotNull(); + assertThat(kSession).isNotNull(); Set check = new HashSet(); kSession.setGlobal("controlSet", check); @@ -72,11 +68,10 @@ public void testYamlRules() throws Exception { kSession.insert(mBlue); kSession.fireAllRules(); - assertEquals("Size of object in Working Memory is 3", 3, kSession.getObjects().size()); - assertTrue("contains red", check.contains("red")); - assertTrue("contains green", check.contains("green")); - assertTrue("contains blue", check.contains("blue")); - + assertThat(kSession.getObjects()).as("Size of object in Working Memory is 3").hasSize(3); + assertThat(check).as("contains red").contains("red"); + assertThat(check).as("contains green").contains("green"); + assertThat(check).as("contains blue").contains("blue"); } finally { kSession.dispose(); } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-3/src/test/java/org/kie/maven/plugin/ittests/AdditionalPropertiesIntegrationTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-3/src/test/java/org/kie/maven/plugin/ittests/AdditionalPropertiesIntegrationTestIT.java index 8456c262680..1c24a20ddb0 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-3/src/test/java/org/kie/maven/plugin/ittests/AdditionalPropertiesIntegrationTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-3/src/test/java/org/kie/maven/plugin/ittests/AdditionalPropertiesIntegrationTestIT.java @@ -23,9 +23,9 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class AdditionalPropertiesIntegrationTestIT { @@ -38,7 +38,7 @@ public void testAdditionalPropertiesCorrectlySet() throws Exception { final File basedir = new File(targetLocation.getFile().replace("/target/test-classes/", "")); final File buildLog = new File(basedir, "build.log"); final String expected = "Additional system properties: {drools.dialect.java.compiler.lnglevel=1.8, my.property=some-value}"; - assertTrue(Files.lines(buildLog.toPath(), StandardCharsets.UTF_8) - .anyMatch(line -> line.contains(expected))); + assertThat(Files.lines(buildLog.toPath(), StandardCharsets.UTF_8) + .anyMatch(line -> line.contains(expected))).isTrue(); } } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java index e4b4c55e3a6..7226cea4d3f 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java @@ -27,8 +27,7 @@ import java.util.Map; import java.util.Set; -import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java index cd4e188ded9..e3f4da553dd 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-7-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/KJarWithDMNIntegrationTestIT.java @@ -27,8 +27,7 @@ import java.util.Map; import java.util.Set; -import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; @@ -38,8 +37,8 @@ import org.kie.dmn.api.core.DMNResult; import org.kie.dmn.api.core.DMNRuntime; import org.kie.dmn.core.api.DMNFactory; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; public class KJarWithDMNIntegrationTestIT { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-exec-model/kie-maven-plugin-test-kjar-8-modA-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-exec-model/kie-maven-plugin-test-kjar-8-modA-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java index 1e6526ad737..3c832527c7f 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-exec-model/kie-maven-plugin-test-kjar-8-modA-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-exec-model/kie-maven-plugin-test-kjar-8-modA-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java @@ -26,11 +26,8 @@ import java.util.List; import java.util.Set; - - -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.definition.KiePackage; import org.kie.api.definition.type.FactType; @@ -38,7 +35,7 @@ import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class MultiModuleTestIT { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-no-exec-model/kie-maven-plugin-test-kjar-8-modA-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-no-exec-model/kie-maven-plugin-test-kjar-8-modA-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java index 8c59f02e6d5..496e302d52c 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-no-exec-model/kie-maven-plugin-test-kjar-8-modA-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-8-no-exec-model/kie-maven-plugin-test-kjar-8-modA-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/MultiModuleTestIT.java @@ -26,9 +26,8 @@ import java.util.List; import java.util.Set; -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.definition.KiePackage; import org.kie.api.definition.type.FactType; @@ -36,7 +35,7 @@ import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class MultiModuleTestIT { diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java index cfdda1d8a45..acd96b7eaeb 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java @@ -25,15 +25,13 @@ import java.util.HashSet; import java.util.Set; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; - -import org.assertj.core.api.Assertions; -import org.junit.Test; import org.kie.api.runtime.KieSession; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class DeclaredTypesTestIT { @@ -48,12 +46,12 @@ public void testDeclaredTypeWithJavaField() throws Exception { final URL targetLocation = DeclaredTypesTestIT.class.getProtectionDomain().getCodeSource().getLocation(); final KieContainer kieContainer = ITTestsUtils.getKieContainer(targetLocation, GAV_ARTIFACT_ID, GAV_VERSION); final KieBase kieBase = kieContainer.getKieBase(KBASE_NAME); - Assertions.assertThat(kieBase).isNotNull(); + assertThat(kieBase).isNotNull(); KieSession kSession = null; try { kSession = kieBase.newKieSession(); - Assertions.assertThat(kSession).isNotNull(); + assertThat(kSession).isNotNull(); ClassLoader classLoader = kieContainer.getClassLoader(); Class aClass = Class.forName("org.declaredtype.FactA", true, classLoader); @@ -64,7 +62,7 @@ public void testDeclaredTypeWithJavaField() throws Exception { int rulesFired = kSession.fireAllRules(); kSession.dispose(); - assertEquals(1, rulesFired); + assertThat(rulesFired).isEqualTo(1); } finally { kSession.dispose(); } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java index 15d5533cbac..6bdeb02f47e 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-9-no-exec-model/src/test/java-filtered/org/kie/maven/plugin/ittests/DeclaredTypesTestIT.java @@ -27,11 +27,11 @@ import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; -import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; + public class DeclaredTypesTestIT { @@ -45,12 +45,12 @@ public void testDeclaredTypeWithJavaField() throws Exception { final URL targetLocation = DeclaredTypesTestIT.class.getProtectionDomain().getCodeSource().getLocation(); final KieContainer kieContainer = ITTestsUtils.getKieContainer(targetLocation, GAV_ARTIFACT_ID, GAV_VERSION); final KieBase kieBase = kieContainer.getKieBase(KBASE_NAME); - Assertions.assertThat(kieBase).isNotNull(); + assertThat(kieBase).isNotNull(); KieSession kSession = null; try { kSession = kieBase.newKieSession(); - Assertions.assertThat(kSession).isNotNull(); + assertThat(kSession).isNotNull(); ClassLoader classLoader = kieContainer.getClassLoader(); Class aClass = Class.forName("org.declaredtype.FactA", true, classLoader); @@ -61,7 +61,7 @@ public void testDeclaredTypeWithJavaField() throws Exception { int rulesFired = kSession.fireAllRules(); kSession.dispose(); - assertEquals(1, rulesFired); + assertThat(rulesFired).isEqualTo(1); } finally { kSession.dispose(); } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/pom.xml b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/pom.xml index 66518508a89..a90120b9199 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/pom.xml +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/pom.xml @@ -42,10 +42,11 @@ @org.kie.version@ - junit - junit - ${junit.version} - + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} + test + org.assertj assertj-core diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/src/main/java/org/kie/maven/plugin/ittests/ITTestsUtils.java b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/src/main/java/org/kie/maven/plugin/ittests/ITTestsUtils.java index 98b427469ba..9afae835fbb 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/src/main/java/org/kie/maven/plugin/ittests/ITTestsUtils.java +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-common/src/main/java/org/kie/maven/plugin/ittests/ITTestsUtils.java @@ -24,7 +24,6 @@ import java.util.HashSet; import java.util.Set; -import org.assertj.core.api.Assertions; import org.drools.compiler.kie.builder.impl.KieContainerImpl; import org.kie.api.KieBase; import org.kie.api.KieServices; @@ -32,7 +31,8 @@ import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; + public class ITTestsUtils { @@ -43,7 +43,7 @@ private ITTestsUtils() { public static File getKjarFile(final URL targetLocation, final String gavArtifactId, final String gavVersion) throws Exception { final File basedir = new File(targetLocation.getFile().replace("/test-classes/", "")); final File toReturn = new File(basedir, gavArtifactId + "-" + gavVersion + ".jar"); - Assertions.assertThat(toReturn).exists(); + assertThat(toReturn).exists(); return toReturn; } @@ -55,28 +55,28 @@ public static KieContainer getKieContainer(final URL targetLocation, final Strin final KieServices kieServices = KieServices.get(); final KieContainer toReturn = kieServices.getKieClasspathContainer(projectClassLoader); - Assertions.assertThat(toReturn).isNotNull(); + assertThat(toReturn).isNotNull(); return toReturn; } public static KieBase getKieBase(final URL targetLocation, final String gavArtifactId, final String gavVersion, final String kieBaseName) throws Exception { final KieContainer kieContainer = getKieContainer(targetLocation, gavArtifactId, gavVersion); KieBase toReturn = kieContainer.getKieBase(kieBaseName); - Assertions.assertThat(toReturn).isNotNull(); + assertThat(toReturn).isNotNull(); return toReturn; } public static KieSession getKieSession(final URL targetLocation, final String gavArtifactId, final String gavVersion, final String kieBaseName) throws Exception { final KieBase kieBase = getKieBase(targetLocation, gavArtifactId, gavVersion, kieBaseName); KieSession toReturn = kieBase.newKieSession(); - Assertions.assertThat(toReturn).isNotNull(); + assertThat(toReturn).isNotNull(); return toReturn; } public static KieModule fireRule(final URL targetLocation, final String gavArtifactId, final String gavVersion, final String kieBaseName, final String ruleName) throws Exception { final KieContainer kieContainer = getKieContainer(targetLocation, gavArtifactId, gavVersion); final KieBase kieBase = kieContainer.getKieBase(kieBaseName); - Assertions.assertThat(kieBase).isNotNull(); + assertThat(kieBase).isNotNull(); KieSession kSession = null; try { @@ -87,14 +87,14 @@ public static KieModule fireRule(final URL targetLocation, final String gavArtif int rulesFired = kSession.fireAllRules(); kSession.dispose(); - assertEquals(1, rulesFired); + assertThat(rulesFired).isEqualTo(1); } finally { if (kSession != null) { kSession.dispose(); } } KieModule toReturn = ((KieContainerImpl) kieContainer).getKieModuleForKBase(kieBaseName); - Assertions.assertThat(toReturn).isNotNull(); + assertThat(toReturn).isNotNull(); return toReturn; } diff --git a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-parent/pom.xml b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-parent/pom.xml index 85d496c9447..0f5a7199b36 100644 --- a/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-parent/pom.xml +++ b/kie-maven-plugin/src/it/kie-maven-plugin-test-kjar-setup/kie-maven-plugin-test-kjar-parent/pom.xml @@ -35,6 +35,7 @@ UTF-8 11 4.13.1 + 5.10.2 3.14.0 3.11.0 3.1.0 @@ -48,11 +49,11 @@ ${org.kie.version} - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} test - + org.assertj assertj-core From bfbb2400fed054ba5f1638143cdfc92368d66662 Mon Sep 17 00:00:00 2001 From: Roberto Oliveira Date: Mon, 25 Nov 2024 08:56:38 -0500 Subject: [PATCH 7/7] [NO-ISSUE] List single files in .rat-excludes aligning with other repos (#6169) * [NO-ISSUE] List single files in .rat-excludes aligning with other repos * fixed license headers # Conflicts: # .rat-excludes --- .../TroubleTicketWithDSL.dslr | 19 ++++++++++++++++++ .../mvel/compiler/lang/ErrorsParserTest.java | 4 ++-- .../compiler/lang/dsl/test_expansion.dslr | 20 ++++++++++++++++++- .../compiler/lang/expander_line_errors.dslr | 19 ++++++++++++++++++ .../lang/expander_multiple_constraints.dslr | 19 ++++++++++++++++++ .../expander_multiple_constraints_flush.dslr | 18 +++++++++++++++++ .../compiler/lang/expander_post_errors.dslr | 18 +++++++++++++++++ .../compiler/lang/expander_spread_lines.dslr | 18 +++++++++++++++++ .../rule_with_expander_dsl.dslr | 18 +++++++++++++++++ .../rule_with_expander_dsl_more.dslr | 18 +++++++++++++++++ .../rule_with_expander_multiline.dslr | 18 +++++++++++++++++ .../test_dslWithIndividualConstraints.dslr | 18 +++++++++++++++++ 12 files changed, 204 insertions(+), 3 deletions(-) diff --git a/drools-examples/src/main/resources/org/drools/examples/troubleticketWithDSL/TroubleTicketWithDSL.dslr b/drools-examples/src/main/resources/org/drools/examples/troubleticketWithDSL/TroubleTicketWithDSL.dslr index 0724162fb72..3d3a6d66dec 100644 --- a/drools-examples/src/main/resources/org/drools/examples/troubleticketWithDSL/TroubleTicketWithDSL.dslr +++ b/drools-examples/src/main/resources/org/drools/examples/troubleticketWithDSL/TroubleTicketWithDSL.dslr @@ -1,3 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.drools.examples.troubleticket expander ticketing.dsl diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/ErrorsParserTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/ErrorsParserTest.java index 3296e941654..397dc192bdf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/ErrorsParserTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/ErrorsParserTest.java @@ -48,14 +48,14 @@ public void testExpanderErrorsAfterExpansion() throws Exception { String name = "expander_post_errors.dslr"; Expander expander = new DefaultExpander(); String expanded = expander.expand( this.getReader( name ) ); - + DRLParser parser = parse( name, expanded ); parser.compilationUnit(); assertThat(parser.hasErrors()).isTrue(); assertThat(parser.getErrors().size()).isEqualTo(1); DroolsParserException err = parser.getErrors().get(0); - assertThat(err.getLineNumber()).isEqualTo(6); + assertThat(err.getLineNumber()).isEqualTo(7); } @Test diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/dsl/test_expansion.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/dsl/test_expansion.dslr index a2a7d74a9d6..bea217a6aa3 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/dsl/test_expansion.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/dsl/test_expansion.dslr @@ -1,4 +1,22 @@ -# Example DRL with expansion +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +# Example DRL with expansion # (ie "domain specific language") # declare expanders for domain specific and natural language extensions diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_line_errors.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_line_errors.dslr index 23eb4caf3fd..d6f5e7ddf10 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_line_errors.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_line_errors.dslr @@ -1,3 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + #this will show error line numbers due to failure to expand package expanderFoo diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints.dslr index cfb3bdf78b9..3d520dd6eef 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints.dslr @@ -1,3 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + //created on: 13/04/2006 package mydsl diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints_flush.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints_flush.dslr index f352d9196fa..329f3b1addc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints_flush.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_multiple_constraints_flush.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ //created on: 13/04/2006 package mydsl diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_post_errors.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_post_errors.dslr index e57ce42eccc..ccc97d2d9d5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_post_errors.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_post_errors.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ //this will show error line numbers post expansion expander foo.dsl diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_spread_lines.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_spread_lines.dslr index 02ae6b5bcca..4e2ccc15ac1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_spread_lines.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/compiler/lang/expander_spread_lines.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ //created on: 13/04/2006 package mydsl diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl.dslr index d38e5dfcd19..6045cc2a5a2 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 test // must be in the following order. diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl_more.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl_more.dslr index 6e58f5c977a..be3ef2d8bdd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl_more.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_dsl_more.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 test // must be in the following order. diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_multiline.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_multiline.dslr index 287f88821f0..3e76a7dcd07 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_multiline.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/rule_with_expander_multiline.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ Add 2 percent to all Red cars diff --git a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_dslWithIndividualConstraints.dslr b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_dslWithIndividualConstraints.dslr index f0248a49998..f42217a3838 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_dslWithIndividualConstraints.dslr +++ b/drools-test-coverage/test-compiler-integration/src/test/resources/org/drools/mvel/integrationtests/test_dslWithIndividualConstraints.dslr @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.drools.mvel.compiler global java.util.List results