From 241966d3d6bf9cad79683b20b3123f8d33365aeb Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Mon, 28 Oct 2024 18:53:24 +0100 Subject: [PATCH 1/3] [incubator-kie-drools #6136] Migrate tests to Junit5 (#6138) * Migrated drools-examples-api * Migrated drools-fastutil * Migrated drools-kiesession * Migrated drools-compiler * Migrated drools-legacy-test-util * Migrated drools-metric * Migrated drools-mvel * Migrated drools-templates * Migrated drools-tms * Migrated drools-wiring * Fixed issue with tests * Better solution to migrate test --- drools-compiler/pom.xml | 5 + .../org/drools/compiler/CompilerTest.java | 2 +- .../lang/descr/CompositePackageDescrTest.java | 13 +- .../compiler/lang/descr/PackageDescrTest.java | 2 +- .../default-kiesession-from-file/pom.xml | 11 +- ...ultKieSessionFromByteArrayExampleTest.java | 4 +- .../DefaultKieSessionFromFileExampleTest.java | 6 +- .../default-kiesession/pom.xml | 11 +- .../DefaultKieSessionExampleTest.java | 6 +- .../DefaultKieSessionFromFSExampleTest.java | 6 +- .../kie-module-from-multiple-files/pom.xml | 11 +- ...KieModuleFromMultipleFilesExampleTest.java | 6 +- drools-examples-api/kiebase-inclusion/pom.xml | 10 +- .../KieBaseInclusionExampleTest.java | 6 +- .../kiecontainer-from-kierepo/pom.xml | 11 +- .../KieContainerFromKieRepoExampleTest.java | 6 +- .../kiefilesystem-example/pom.xml | 10 +- .../KieFileSystemExampleTest.java | 6 +- .../kiemodulemodel-example/pom.xml | 11 +- .../KieModuleModelExampleTest.java | 6 +- drools-examples-api/multiple-kbases/pom.xml | 10 +- .../MultipleKbasesExampleTest.java | 22 +- .../named-kiesession-from-file/pom.xml | 11 +- .../NamedKieSessionFromFileExampleTest.java | 6 +- drools-examples-api/named-kiesession/pom.xml | 10 +- .../NamedKieSessionExampleTest.java | 6 +- drools-examples-api/pom.xml | 2 - .../reactive-kiesession/pom.xml | 10 +- .../ReactiveKieSessionExampleTest.java | 6 +- drools-fastutil/pom.xml | 11 +- .../fastutil/FastUtilTreeMemoryTest.java | 2 +- drools-kiesession/pom.xml | 12 +- ...BetaConstraintsPositionalIndexingTest.java | 14 +- .../org/drools/kiesession/AddRemoveTest.java | 2 +- .../drools/kiesession/CrossProductTest.java | 6 +- .../InternalRuleBaseConfigurationTest.java | 2 +- .../kiesession/NodeSegmentUnlinkingTest.java | 2 +- .../PropertyChangeListenerTest.java | 6 +- .../kiesession/QueryElementNodeTest.java | 6 +- .../java/org/drools/kiesession/ReteTest.java | 12 +- .../ReteooRuleBaseMultiThreadedTest.java | 10 +- .../kiesession/ReteooWorkingMemoryTest.java | 8 +- .../RuleRuntimeEventSupportTest.java | 2 +- .../drools/kiesession/RuleUnlinkingTest.java | 2 +- .../RuleUnlinkingWithSegmentMemoryTest.java | 2 +- drools-legacy-test-util/pom.xml | 11 +- .../command/MoreBatchExecutionTest.java | 6 +- .../command/SimpleBatchExecutionTest.java | 10 +- drools-metric/pom.xml | 12 +- .../org/drools/metric/AbstractMetricTest.java | 8 +- .../java/org/drools/metric/CloneTest.java | 2 +- .../org/drools/metric/ConstraintsTest.java | 2 +- .../org/drools/metric/MetricLogUtilsTest.java | 2 +- drools-mvel/pom.xml | 10 +- .../java/org/drools/mvel/BuildUtilsTest.java | 6 +- .../drools/mvel/MVELCalendarCoercionTest.java | 2 +- .../org/drools/mvel/MVELDateCoercionTest.java | 2 +- .../mvel/asm/ClassFieldInspectorTest.java | 2 +- .../mvel/asm/KnowledgeHelperFixerTest.java | 2 +- .../mvel/asm/LambdaIntrospectorTest.java | 2 +- .../drools/mvel/asm/MethodComparerTest.java | 2 +- .../dialect/asm/ClassGeneratorTest.java | 2 +- .../dialect/asm/InvokerGeneratorTest.java | 2 +- .../java/JavaAccumulateBuilderTest.java | 6 +- .../JavaConsequenceBuilderPRAlwaysTest.java | 2 +- .../java/JavaConsequenceBuilderTest.java | 2 +- .../dialect/java/JavaExprAnalyzerTest.java | 2 +- .../JavaForMvelDialectConfigurationTest.java | 2 +- .../mvel/MVELAccumulateBuilderTest.java | 2 +- .../mvel/MVELConsequenceBuilderTest.java | 2 +- .../builder/dialect/mvel/MVELDebugTest.java | 2 +- .../dialect/mvel/MVELEvalBuilderTest.java | 6 +- .../dialect/mvel/MVELExprAnalyzerTest.java | 6 +- .../dialect/mvel/MVELSalienceBuilderTest.java | 6 +- .../TemporalEvaluatorFactoryTest.java | 2 +- .../drools/mvel/field/FieldFactoryTest.java | 2 +- .../org/drools/mvel/field/FieldValueTest.java | 6 +- .../LogicTransformerTest.java | 2 +- .../MoreBatchExecutionPersistenceTest.java | 99 +++++++- .../SimpleBatchExecutionPersistenceTest.java | 213 +++++++++++++++++- drools-templates/pom.xml | 8 +- .../template/DataProviderCompilerTest.java | 6 +- .../template/jdbc/ResultSetGeneratorTest.java | 2 +- .../template/model/FunctionsRenderTest.java | 2 +- .../template/model/PackageRenderTest.java | 2 +- .../template/model/QueriesRenderTest.java | 2 +- .../drools/template/model/RuleRenderTest.java | 2 +- .../template/model/SnippetBuilderTest.java | 2 +- .../template/parser/ColumnFactoryTest.java | 2 +- .../template/parser/DefaultGeneratorTest.java | 6 +- .../parser/DefaultTemplateContainerTest.java | 2 +- .../parser/ExternalSheetListenerTest.java | 6 +- .../template/parser/RuleTemplateTest.java | 2 +- drools-tms/pom.xml | 12 +- .../java/org/drools/tms/EqualityKeyTest.java | 2 +- .../org/drools/tms/LazyTMSEnablingTest.java | 6 +- drools-wiring/drools-wiring-api/pom.xml | 10 +- .../classloader/ProjectClassLoaderTest.java | 2 +- drools-wiring/drools-wiring-dynamic/pom.xml | 10 +- .../org/drools/dynamic/ClassLoaderTest.java | 7 +- drools-wiring/drools-wiring-static/pom.xml | 10 +- .../DummyByteArrayClassLoaderTest.java | 2 +- 102 files changed, 589 insertions(+), 294 deletions(-) diff --git a/drools-compiler/pom.xml b/drools-compiler/pom.xml index 557640fdfbb..cfa70e99f13 100644 --- a/drools-compiler/pom.xml +++ b/drools-compiler/pom.xml @@ -144,6 +144,11 @@ drools-wiring-dynamic test + + org.junit.jupiter + junit-jupiter + test + org.kie diff --git a/drools-compiler/src/test/java/org/drools/compiler/CompilerTest.java b/drools-compiler/src/test/java/org/drools/compiler/CompilerTest.java index f637cbe3b53..1650e04e3a7 100644 --- a/drools-compiler/src/test/java/org/drools/compiler/CompilerTest.java +++ b/drools-compiler/src/test/java/org/drools/compiler/CompilerTest.java @@ -18,7 +18,7 @@ */ package org.drools.compiler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.ResourceType; import org.kie.internal.utils.KieHelper; diff --git a/drools-compiler/src/test/java/org/drools/compiler/lang/descr/CompositePackageDescrTest.java b/drools-compiler/src/test/java/org/drools/compiler/lang/descr/CompositePackageDescrTest.java index c39dc3789a7..8db4b817aca 100644 --- a/drools-compiler/src/test/java/org/drools/compiler/lang/descr/CompositePackageDescrTest.java +++ b/drools-compiler/src/test/java/org/drools/compiler/lang/descr/CompositePackageDescrTest.java @@ -20,10 +20,11 @@ import org.drools.drl.ast.descr.PackageDescr; import org.drools.io.ByteArrayResource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.drools.util.StringUtils.generateUUID; public class CompositePackageDescrTest { @@ -31,7 +32,7 @@ public class CompositePackageDescrTest { private static final String NAMESPACE = "namespace"; private CompositePackageDescr compositePackageDescr; - @Before + @BeforeEach public void setup() { compositePackageDescr = new CompositePackageDescr(new ByteArrayResource(), new PackageDescr(NAMESPACE)); } @@ -50,7 +51,7 @@ public void addPackageDescrSamePkgUUID() { assertThat(compositePackageDescr.getPreferredPkgUUID().get()).isEqualTo(pkgUUID); } - @Test(expected = RuntimeException.class) + @Test public void addPackageDescrDifferentPkgUUID() { String pkgUUID = generateUUID(); PackageDescr first = new PackageDescr(NAMESPACE); @@ -64,6 +65,8 @@ public void addPackageDescrDifferentPkgUUID() { second.setPreferredPkgUUID(pkgUUID); assertThat(second.getPreferredPkgUUID().isPresent()).isTrue(); assertThat(second.getPreferredPkgUUID().get()).isNotEqualTo(first.getPreferredPkgUUID().get()); - compositePackageDescr.addPackageDescr(new ByteArrayResource(), second); + assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> { + compositePackageDescr.addPackageDescr(new ByteArrayResource(), second); + }); } } \ No newline at end of file diff --git a/drools-compiler/src/test/java/org/drools/compiler/lang/descr/PackageDescrTest.java b/drools-compiler/src/test/java/org/drools/compiler/lang/descr/PackageDescrTest.java index b5e7cee1202..c79c2c556c8 100644 --- a/drools-compiler/src/test/java/org/drools/compiler/lang/descr/PackageDescrTest.java +++ b/drools-compiler/src/test/java/org/drools/compiler/lang/descr/PackageDescrTest.java @@ -27,7 +27,7 @@ import org.drools.drl.ast.descr.PackageDescr; import org.drools.drl.ast.dsl.PackageDescrBuilder; import org.drools.drl.ast.dsl.impl.PackageDescrBuilderImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-examples-api/default-kiesession-from-file/pom.xml b/drools-examples-api/default-kiesession-from-file/pom.xml index c9155eafa17..1d2625481b1 100644 --- a/drools-examples-api/default-kiesession-from-file/pom.xml +++ b/drools-examples-api/default-kiesession-from-file/pom.xml @@ -41,12 +41,11 @@ org.drools drools-engine-classic - - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromByteArrayExampleTest.java b/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromByteArrayExampleTest.java index 76093b9989c..5735e26adbb 100644 --- a/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromByteArrayExampleTest.java +++ b/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromByteArrayExampleTest.java @@ -26,14 +26,14 @@ import java.io.PrintStream; import java.util.Arrays; -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; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DefaultKieSessionFromByteArrayExampleTest { diff --git a/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromFileExampleTest.java b/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromFileExampleTest.java index 4c5256c239e..b3ab286bad3 100644 --- a/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromFileExampleTest.java +++ b/drools-examples-api/default-kiesession-from-file/src/test/java/org/drools/example/api/defaultkiesessionfromfile/DefaultKieSessionFromFileExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.defaultkiesessionfromfile; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class DefaultKieSessionFromFileExampleTest { diff --git a/drools-examples-api/default-kiesession/pom.xml b/drools-examples-api/default-kiesession/pom.xml index ba5b8452f3c..9b40e312282 100644 --- a/drools-examples-api/default-kiesession/pom.xml +++ b/drools-examples-api/default-kiesession/pom.xml @@ -41,12 +41,11 @@ org.drools drools-engine-classic - - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionExampleTest.java b/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionExampleTest.java index c319068dab2..1767b87961b 100644 --- a/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionExampleTest.java +++ b/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.defaultkiesession; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class DefaultKieSessionExampleTest { diff --git a/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionFromFSExampleTest.java b/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionFromFSExampleTest.java index 985c3eaaa80..edaf89ea336 100644 --- a/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionFromFSExampleTest.java +++ b/drools-examples-api/default-kiesession/src/test/java/org/drools/example/api/defaultkiesession/DefaultKieSessionFromFSExampleTest.java @@ -18,18 +18,18 @@ */ package org.drools.example.api.defaultkiesession; -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.runtime.KieSession; import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.File; import java.io.IOException; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; - public class DefaultKieSessionFromFSExampleTest { private static final String NL = System.getProperty("line.separator"); diff --git a/drools-examples-api/kie-module-from-multiple-files/pom.xml b/drools-examples-api/kie-module-from-multiple-files/pom.xml index 7cc5e54f7c6..ea3cf74a873 100644 --- a/drools-examples-api/kie-module-from-multiple-files/pom.xml +++ b/drools-examples-api/kie-module-from-multiple-files/pom.xml @@ -42,18 +42,17 @@ drools-engine-classic - - junit - junit - test - - org.drools kiebase-inclusion runtime + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/kie-module-from-multiple-files/src/test/java/org/drools/example/api/kiemodulefrommultiplefiles/KieModuleFromMultipleFilesExampleTest.java b/drools-examples-api/kie-module-from-multiple-files/src/test/java/org/drools/example/api/kiemodulefrommultiplefiles/KieModuleFromMultipleFilesExampleTest.java index 403cd9392fb..8245690dd23 100644 --- a/drools-examples-api/kie-module-from-multiple-files/src/test/java/org/drools/example/api/kiemodulefrommultiplefiles/KieModuleFromMultipleFilesExampleTest.java +++ b/drools-examples-api/kie-module-from-multiple-files/src/test/java/org/drools/example/api/kiemodulefrommultiplefiles/KieModuleFromMultipleFilesExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.kiemodulefrommultiplefiles; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class KieModuleFromMultipleFilesExampleTest { diff --git a/drools-examples-api/kiebase-inclusion/pom.xml b/drools-examples-api/kiebase-inclusion/pom.xml index 05ae135c261..25a20d14ea0 100644 --- a/drools-examples-api/kiebase-inclusion/pom.xml +++ b/drools-examples-api/kiebase-inclusion/pom.xml @@ -45,11 +45,11 @@ org.drools named-kiesession - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/kiebase-inclusion/src/test/java/org/drools/example/api/kiebaseinclusion/KieBaseInclusionExampleTest.java b/drools-examples-api/kiebase-inclusion/src/test/java/org/drools/example/api/kiebaseinclusion/KieBaseInclusionExampleTest.java index 77804c46fb1..9c779cedc03 100644 --- a/drools-examples-api/kiebase-inclusion/src/test/java/org/drools/example/api/kiebaseinclusion/KieBaseInclusionExampleTest.java +++ b/drools-examples-api/kiebase-inclusion/src/test/java/org/drools/example/api/kiebaseinclusion/KieBaseInclusionExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.kiebaseinclusion; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class KieBaseInclusionExampleTest { diff --git a/drools-examples-api/kiecontainer-from-kierepo/pom.xml b/drools-examples-api/kiecontainer-from-kierepo/pom.xml index d55279a5cc4..b0156e4958c 100644 --- a/drools-examples-api/kiecontainer-from-kierepo/pom.xml +++ b/drools-examples-api/kiecontainer-from-kierepo/pom.xml @@ -41,6 +41,11 @@ org.kie kie-ci + + org.junit.jupiter + junit-jupiter + test + org.drools drools-engine-classic @@ -49,12 +54,6 @@ org.drools named-kiesession - - - junit - junit - test - diff --git a/drools-examples-api/kiecontainer-from-kierepo/src/test/java/org/drools/example/api/kiecontainerfromkierepo/KieContainerFromKieRepoExampleTest.java b/drools-examples-api/kiecontainer-from-kierepo/src/test/java/org/drools/example/api/kiecontainerfromkierepo/KieContainerFromKieRepoExampleTest.java index 70da1110b7b..3e24f8b0844 100644 --- a/drools-examples-api/kiecontainer-from-kierepo/src/test/java/org/drools/example/api/kiecontainerfromkierepo/KieContainerFromKieRepoExampleTest.java +++ b/drools-examples-api/kiecontainer-from-kierepo/src/test/java/org/drools/example/api/kiecontainerfromkierepo/KieContainerFromKieRepoExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.kiecontainerfromkierepo; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class KieContainerFromKieRepoExampleTest { diff --git a/drools-examples-api/kiefilesystem-example/pom.xml b/drools-examples-api/kiefilesystem-example/pom.xml index d3537b51834..382e65cb7fe 100644 --- a/drools-examples-api/kiefilesystem-example/pom.xml +++ b/drools-examples-api/kiefilesystem-example/pom.xml @@ -49,11 +49,11 @@ org.kie kie-api - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/kiefilesystem-example/src/test/java/org/drools/example/api/kiefilesystem/KieFileSystemExampleTest.java b/drools-examples-api/kiefilesystem-example/src/test/java/org/drools/example/api/kiefilesystem/KieFileSystemExampleTest.java index bc55c5dc4b1..ca973ed355e 100644 --- a/drools-examples-api/kiefilesystem-example/src/test/java/org/drools/example/api/kiefilesystem/KieFileSystemExampleTest.java +++ b/drools-examples-api/kiefilesystem-example/src/test/java/org/drools/example/api/kiefilesystem/KieFileSystemExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.kiefilesystem; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class KieFileSystemExampleTest { diff --git a/drools-examples-api/kiemodulemodel-example/pom.xml b/drools-examples-api/kiemodulemodel-example/pom.xml index fc6b6c3eb4f..6fb2269d926 100644 --- a/drools-examples-api/kiemodulemodel-example/pom.xml +++ b/drools-examples-api/kiemodulemodel-example/pom.xml @@ -54,18 +54,17 @@ kie-api - - junit - junit - test - - org.drools named-kiesession runtime + + org.junit.jupiter + junit-jupiter + test + org.drools kiebase-inclusion diff --git a/drools-examples-api/kiemodulemodel-example/src/test/java/org/drools/example/api/kiemodulemodel/KieModuleModelExampleTest.java b/drools-examples-api/kiemodulemodel-example/src/test/java/org/drools/example/api/kiemodulemodel/KieModuleModelExampleTest.java index 979a2baa9b4..7974d2f6ee0 100644 --- a/drools-examples-api/kiemodulemodel-example/src/test/java/org/drools/example/api/kiemodulemodel/KieModuleModelExampleTest.java +++ b/drools-examples-api/kiemodulemodel-example/src/test/java/org/drools/example/api/kiemodulemodel/KieModuleModelExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.kiemodulemodel; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class KieModuleModelExampleTest { diff --git a/drools-examples-api/multiple-kbases/pom.xml b/drools-examples-api/multiple-kbases/pom.xml index ad3aa3926c7..f5a8217c42f 100644 --- a/drools-examples-api/multiple-kbases/pom.xml +++ b/drools-examples-api/multiple-kbases/pom.xml @@ -41,11 +41,11 @@ org.drools drools-engine-classic - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/multiple-kbases/src/test/java/org/drools/example/api/multiplekbases/MultipleKbasesExampleTest.java b/drools-examples-api/multiple-kbases/src/test/java/org/drools/example/api/multiplekbases/MultipleKbasesExampleTest.java index a7faa33f89c..8eb9b808743 100644 --- a/drools-examples-api/multiple-kbases/src/test/java/org/drools/example/api/multiplekbases/MultipleKbasesExampleTest.java +++ b/drools-examples-api/multiple-kbases/src/test/java/org/drools/example/api/multiplekbases/MultipleKbasesExampleTest.java @@ -23,8 +23,8 @@ import org.drools.core.time.impl.JDKTimerService; import org.drools.core.time.impl.PseudoClockScheduler; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.model.KieSessionModel; import org.kie.api.runtime.KieContainer; @@ -33,8 +33,8 @@ import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MultipleKbasesExampleTest { @@ -110,15 +110,15 @@ public void testEditSessionModel() { ClockTypeOption clockType = kieSessionModel.getClockType(); // clockType realtime - Assert.assertNotEquals(clockType, pseudoClock); + Assertions.assertNotEquals(clockType, pseudoClock); // change model to pseudo kieSessionModel.setClockType(pseudoClock); - Assert.assertEquals(kieSessionModel.getClockType(), pseudoClock); + Assertions.assertEquals(kieSessionModel.getClockType(), pseudoClock); // new pseudo session KieSession kSession = kContainer.newKieSession(name); - Assert.assertEquals(kSession.getSessionClock().getClass(), PseudoClockScheduler.class); + Assertions.assertEquals(kSession.getSessionClock().getClass(), PseudoClockScheduler.class); } @Test @@ -132,18 +132,18 @@ public void testEditSessionModelAfterFirstCreatedKieSession() { ClockTypeOption clockType = kieSessionModel.getClockType(); // clockType realtime - Assert.assertEquals(clockType, ClockTypeOption.REALTIME); - Assert.assertNotEquals(clockType, pseudoClock); + Assertions.assertEquals(clockType, ClockTypeOption.REALTIME); + Assertions.assertNotEquals(clockType, pseudoClock); // session is realtime KieSession kSession = kContainer.newKieSession(name); - Assert.assertEquals(kSession.getSessionClock().getClass(), JDKTimerService.class); + Assertions.assertEquals(kSession.getSessionClock().getClass(), JDKTimerService.class); // change model to pseudo kieSessionModel.setClockType(pseudoClock); // new session still realtime KieSession kSessionPseudo = kContainer.newKieSession(name); - Assert.assertEquals(kSessionPseudo.getSessionClock().getClass(), PseudoClockScheduler.class); + Assertions.assertEquals(kSessionPseudo.getSessionClock().getClass(), PseudoClockScheduler.class); } } \ No newline at end of file diff --git a/drools-examples-api/named-kiesession-from-file/pom.xml b/drools-examples-api/named-kiesession-from-file/pom.xml index ab0c04a8e78..68f963fa155 100644 --- a/drools-examples-api/named-kiesession-from-file/pom.xml +++ b/drools-examples-api/named-kiesession-from-file/pom.xml @@ -42,18 +42,17 @@ drools-engine-classic - - junit - junit - test - - org.drools named-kiesession runtime + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/named-kiesession-from-file/src/test/java/org/drools/example/api/namedkiesessionfromfile/NamedKieSessionFromFileExampleTest.java b/drools-examples-api/named-kiesession-from-file/src/test/java/org/drools/example/api/namedkiesessionfromfile/NamedKieSessionFromFileExampleTest.java index e2cd2afe1de..db5dec84573 100644 --- a/drools-examples-api/named-kiesession-from-file/src/test/java/org/drools/example/api/namedkiesessionfromfile/NamedKieSessionFromFileExampleTest.java +++ b/drools-examples-api/named-kiesession-from-file/src/test/java/org/drools/example/api/namedkiesessionfromfile/NamedKieSessionFromFileExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.namedkiesessionfromfile; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class NamedKieSessionFromFileExampleTest { private static final String NL = System.getProperty("line.separator"); diff --git a/drools-examples-api/named-kiesession/pom.xml b/drools-examples-api/named-kiesession/pom.xml index ff558c4a6e1..84860d54ad3 100644 --- a/drools-examples-api/named-kiesession/pom.xml +++ b/drools-examples-api/named-kiesession/pom.xml @@ -41,11 +41,11 @@ org.drools drools-engine-classic - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/named-kiesession/src/test/java/org/drools/example/api/namedkiesession/NamedKieSessionExampleTest.java b/drools-examples-api/named-kiesession/src/test/java/org/drools/example/api/namedkiesession/NamedKieSessionExampleTest.java index 4c22b893351..b5ec7fdda21 100644 --- a/drools-examples-api/named-kiesession/src/test/java/org/drools/example/api/namedkiesession/NamedKieSessionExampleTest.java +++ b/drools-examples-api/named-kiesession/src/test/java/org/drools/example/api/namedkiesession/NamedKieSessionExampleTest.java @@ -18,12 +18,12 @@ */ package org.drools.example.api.namedkiesession; -import org.junit.Test; - import java.io.ByteArrayOutputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class NamedKieSessionExampleTest { private static final String NL = System.getProperty("line.separator"); diff --git a/drools-examples-api/pom.xml b/drools-examples-api/pom.xml index 68742076319..c7b3cef3796 100644 --- a/drools-examples-api/pom.xml +++ b/drools-examples-api/pom.xml @@ -59,6 +59,4 @@ multiple-kbases reactive-kiesession - - diff --git a/drools-examples-api/reactive-kiesession/pom.xml b/drools-examples-api/reactive-kiesession/pom.xml index b532d6ae6d4..eaa8cae2215 100644 --- a/drools-examples-api/reactive-kiesession/pom.xml +++ b/drools-examples-api/reactive-kiesession/pom.xml @@ -41,11 +41,11 @@ org.drools drools-engine-classic - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-examples-api/reactive-kiesession/src/test/java/org/drools/example/api/reactivekiesession/ReactiveKieSessionExampleTest.java b/drools-examples-api/reactive-kiesession/src/test/java/org/drools/example/api/reactivekiesession/ReactiveKieSessionExampleTest.java index 75044ac5f26..0b362777283 100644 --- a/drools-examples-api/reactive-kiesession/src/test/java/org/drools/example/api/reactivekiesession/ReactiveKieSessionExampleTest.java +++ b/drools-examples-api/reactive-kiesession/src/test/java/org/drools/example/api/reactivekiesession/ReactiveKieSessionExampleTest.java @@ -18,7 +18,7 @@ */ package org.drools.example.api.reactivekiesession; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ReactiveKieSessionExampleTest { diff --git a/drools-fastutil/pom.xml b/drools-fastutil/pom.xml index 5e453e09b5d..eab48e87ee3 100644 --- a/drools-fastutil/pom.xml +++ b/drools-fastutil/pom.xml @@ -49,16 +49,15 @@ org.drools drools-core - - - junit - junit - test - org.assertj assertj-core test + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-fastutil/src/test/java/org/drools/fastutil/FastUtilTreeMemoryTest.java b/drools-fastutil/src/test/java/org/drools/fastutil/FastUtilTreeMemoryTest.java index bd42b7a9e69..000131b9da7 100644 --- a/drools-fastutil/src/test/java/org/drools/fastutil/FastUtilTreeMemoryTest.java +++ b/drools-fastutil/src/test/java/org/drools/fastutil/FastUtilTreeMemoryTest.java @@ -33,8 +33,8 @@ import org.drools.core.util.FastIterator; import org.drools.base.util.IndexedValueReader; import org.drools.fastutil.FastUtilTreeMemory.TreeFastIterator; +import org.junit.jupiter.api.Test; import org.drools.base.util.index.ConstraintTypeOperator; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-kiesession/pom.xml b/drools-kiesession/pom.xml index 31c361a1500..e9c29a0961f 100644 --- a/drools-kiesession/pom.xml +++ b/drools-kiesession/pom.xml @@ -87,12 +87,11 @@ drools-wiring-dynamic test - - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + org.assertj assertj-core @@ -104,5 +103,4 @@ test - diff --git a/drools-kiesession/src/test/java/org/drools/core/positional/BetaConstraintsPositionalIndexingTest.java b/drools-kiesession/src/test/java/org/drools/core/positional/BetaConstraintsPositionalIndexingTest.java index 3ae6dd13cfa..71116f22db3 100644 --- a/drools-kiesession/src/test/java/org/drools/core/positional/BetaConstraintsPositionalIndexingTest.java +++ b/drools-kiesession/src/test/java/org/drools/core/positional/BetaConstraintsPositionalIndexingTest.java @@ -43,7 +43,7 @@ import org.drools.core.test.model.Person; import org.drools.core.util.index.IndexSpec; import org.drools.kiesession.rulebase.SessionsAwareKnowledgeBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; import org.kie.internal.conf.CompositeBaseConfiguration; import static org.assertj.core.api.Assertions.assertThat; @@ -105,9 +105,8 @@ public void testSingleInputEqualityIndexExpressions() { }; List results = new ArrayList<>(); - VoidFunction1> f2 = (c) -> { + VoidFunction1> f2 = (c) -> c.setFunction((VoidFunction2) (s, p) -> {results.add(new Object[] {s, p}); System.out.println(p.getName() + " lives in " + s);}); - }; testBody(null, f1, f2, false); @@ -129,9 +128,8 @@ public void testDoubleInputEqualityIndexExpressions() { }; List results = new ArrayList<>(); - VoidFunction1> f2 = (c) -> { + VoidFunction1> f2 = (c) -> c.setFunction((VoidFunction3) (s, i, p) -> {results.add(new Object[] {s, i, p}); System.out.println(p.getName() + " lives in " + s);}); - }; Person p1 = new Person("yoda", 300); p1.setCity("London"); @@ -173,9 +171,8 @@ public void testSingleInputRangeIndexExpressions() { }; List results = new ArrayList<>(); - VoidFunction1> f2 = (c) -> { + VoidFunction1> f2 = (c) -> c.setFunction((VoidFunction2) (s, p) -> {results.add(new Object[] {s, p}); System.out.println(p.getName() + " is younger than " + s);}); - }; testBody(f0, f1, f2, false); @@ -210,9 +207,8 @@ public void testDoubleInputRangeIndexExpressions() { }; List results = new ArrayList<>(); - VoidFunction1> f2 = (c) -> { + VoidFunction1> f2 = (c) -> c.setFunction((VoidFunction3) (s, i, p) -> {results.add(new Object[] {s, i, p}); System.out.println(p.getName() + " is younger than " + s);}); - }; testBody(f0, f1, f2, true); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/AddRemoveTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/AddRemoveTest.java index c07a6b9a9a4..0a131a2ab86 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/AddRemoveTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/AddRemoveTest.java @@ -29,7 +29,7 @@ import org.drools.core.reteoo.builder.NodeFactory; import org.drools.core.reteoo.builder.PhreakNodeFactory; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AddRemoveTest { @Test diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/CrossProductTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/CrossProductTest.java index e36af3b1881..042a4c9d201 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/CrossProductTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/CrossProductTest.java @@ -36,8 +36,8 @@ import org.drools.base.base.ObjectType; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; @@ -47,7 +47,7 @@ public class CrossProductTest { private KieSession ksession; private List values; - @Before + @BeforeEach public void setUp() throws Exception { final ObjectType list1ObjectType = new ClassObjectType( String.class ); final ObjectType list2ObjectType = new ClassObjectType( String.class ); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/InternalRuleBaseConfigurationTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/InternalRuleBaseConfigurationTest.java index b984e51f806..2d111a94581 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/InternalRuleBaseConfigurationTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/InternalRuleBaseConfigurationTest.java @@ -25,7 +25,7 @@ import org.drools.core.RuleBaseConfiguration.SequentialAgenda; import org.drools.core.common.PriorityQueueAgendaGroupFactory; import org.drools.core.reteoo.RuntimeComponentFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.conf.CompositeConfiguration; import org.kie.internal.utils.ChainedProperties; diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java index 9693d65b11c..b7bfef34041 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java @@ -52,7 +52,7 @@ import org.drools.core.common.PropagationContext; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/PropertyChangeListenerTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/PropertyChangeListenerTest.java index 8038fb61f05..9d62fd52b89 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/PropertyChangeListenerTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/PropertyChangeListenerTest.java @@ -29,8 +29,8 @@ import org.drools.core.reteoo.builder.BuildContext; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -39,7 +39,7 @@ public class PropertyChangeListenerTest { private BuildContext buildContext; private EntryPointNode entryPoint; - @Before + @BeforeEach public void setUp() throws Exception { this.kBase = KnowledgeBaseFactory.newKnowledgeBase(); this.buildContext = new BuildContext( kBase, Collections.emptyList() ); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/QueryElementNodeTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/QueryElementNodeTest.java index 52cff7781e6..a75b98ee050 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/QueryElementNodeTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/QueryElementNodeTest.java @@ -32,8 +32,8 @@ import org.drools.core.common.PropagationContext; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -43,7 +43,7 @@ public class QueryElementNodeTest { private InternalKnowledgeBase kBase; private BuildContext buildContext; - @Before + @BeforeEach public void setUp() { this.kBase = KnowledgeBaseFactory.newKnowledgeBase(); this.buildContext = new BuildContext( kBase, Collections.emptyList() ); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/ReteTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/ReteTest.java index f9e927484dd..30a4c2abe07 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/ReteTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/ReteTest.java @@ -44,9 +44,9 @@ import org.drools.core.test.model.Cheese; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.rule.FactHandle; import org.kie.internal.conf.CompositeConfiguration; import org.kie.internal.utils.ChainedProperties; @@ -59,7 +59,7 @@ public class ReteTest { private BuildContext buildContext; private EntryPointNode entryPoint; - @Before + @BeforeEach public void setUp() throws Exception { this.kBase = KnowledgeBaseFactory.newKnowledgeBase(); @@ -234,7 +234,7 @@ public void testAssertObjectWithNoMatchingObjectTypeNode() { } @Test - @Ignore + @Disabled public void testHierarchy() { StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); @@ -400,7 +400,7 @@ public void testIsShadowed() { final Object[] results = (Object[]) sink1.getAsserted().get(0); } - @Test @Ignore + @Test @Disabled public void testNotShadowed() { Properties properties = new Properties(); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooRuleBaseMultiThreadedTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooRuleBaseMultiThreadedTest.java index 68509629fbb..440e16c73b4 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooRuleBaseMultiThreadedTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooRuleBaseMultiThreadedTest.java @@ -27,9 +27,9 @@ import org.drools.core.rule.consequence.KnowledgeHelper; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; @@ -44,7 +44,7 @@ public class ReteooRuleBaseMultiThreadedTest { RuleImpl rule; InternalKnowledgePackage pkg; - @Before + @BeforeEach public void setUp() { this.kBase = KnowledgeBaseFactory.newKnowledgeBase(); @@ -72,7 +72,7 @@ public String getName() { kBase.addPackage(pkg); } - @Test @Ignore + @Test @Disabled public void testNewSessionWhileModifyingRuleBase() throws InterruptedException { PackageModifier modifier = new PackageModifier(); SessionCreator creator = new SessionCreator(); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java index c59f1f773ac..0d5b5d78205 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java @@ -42,8 +42,8 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.EntryPoint; import org.kie.api.runtime.rule.FactHandle; @@ -56,7 +56,7 @@ public class ReteooWorkingMemoryTest { * @see JBRULES-356 */ @Test - @Ignore + @Disabled public void testBasicWorkingMemoryActions() { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); @@ -149,7 +149,7 @@ public void testObjectIterator() { } } - @Test @Ignore + @Test @Disabled public void testExecuteQueueActions() { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/RuleRuntimeEventSupportTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/RuleRuntimeEventSupportTest.java index d3395665cc5..67cdfe0e773 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/RuleRuntimeEventSupportTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/RuleRuntimeEventSupportTest.java @@ -25,7 +25,7 @@ import org.drools.core.event.RuleRuntimeEventSupport; import org.drools.core.test.model.Cheese; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.event.rule.ObjectDeletedEvent; import org.kie.api.event.rule.ObjectInsertedEvent; diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java index 9fbafbdcdff..29a61892498 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java @@ -53,7 +53,7 @@ import org.drools.core.common.PropagationContext; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java index fcd51e7d00c..88e9a965f07 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java @@ -53,7 +53,7 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBaseConfiguration; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-legacy-test-util/pom.xml b/drools-legacy-test-util/pom.xml index e8d1fef3e1e..e90a66d21ea 100644 --- a/drools-legacy-test-util/pom.xml +++ b/drools-legacy-test-util/pom.xml @@ -78,11 +78,11 @@ test-jar test - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + @@ -95,5 +95,4 @@ test - diff --git a/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java b/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java index 82805ece038..46aa81be59b 100644 --- a/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java +++ b/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java @@ -25,8 +25,8 @@ import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.mvel.CommonTestMethodBase; import org.drools.mvel.compiler.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.command.Command; import org.kie.api.io.ResourceType; import org.kie.api.runtime.ExecutionResults; @@ -44,7 +44,7 @@ public class MoreBatchExecutionTest extends CommonTestMethodBase { private KieSession ksession = null; - @After + @AfterEach public void disposeKSession() { if( ksession != null ) { ksession.dispose(); diff --git a/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java b/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java index 7bda60daf17..3cdd0ab39e4 100644 --- a/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java +++ b/drools-legacy-test-util/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java @@ -26,9 +26,9 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.mvel.CommonTestMethodBase; -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.command.Command; import org.kie.api.io.ResourceType; import org.kie.api.runtime.ExecutionResults; @@ -53,7 +53,7 @@ public class SimpleBatchExecutionTest extends CommonTestMethodBase { + " then\n" + "end\n"; - @Before + @BeforeEach public void createKSession() throws Exception { final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( ResourceFactory.newByteArrayResource(ruleString.getBytes()), ResourceType.DRL ); @@ -64,7 +64,7 @@ public void createKSession() throws Exception { ksession = createKnowledgeSession(kbase); } - @After + @AfterEach public void disposeKSession() throws Exception { if( ksession != null ) { ksession.dispose(); diff --git a/drools-metric/pom.xml b/drools-metric/pom.xml index 2f946343221..3e66126705d 100644 --- a/drools-metric/pom.xml +++ b/drools-metric/pom.xml @@ -62,6 +62,11 @@ drools-mvel test + + org.junit.jupiter + junit-jupiter + test + org.drools drools-legacy-test-util @@ -83,12 +88,5 @@ logback-classic test - - - junit - junit - test - - diff --git a/drools-metric/src/test/java/org/drools/metric/AbstractMetricTest.java b/drools-metric/src/test/java/org/drools/metric/AbstractMetricTest.java index 94afb25f899..36ce7233029 100644 --- a/drools-metric/src/test/java/org/drools/metric/AbstractMetricTest.java +++ b/drools-metric/src/test/java/org/drools/metric/AbstractMetricTest.java @@ -24,21 +24,21 @@ import org.drools.metric.util.MetricLogUtils; import org.drools.metric.util.MicrometerUtils; import org.drools.mvel.CommonTestMethodBase; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; abstract class AbstractMetricTest extends CommonTestMethodBase { protected MeterRegistry registry; - @Before + @BeforeEach public void setup() { System.setProperty(MetricLogUtils.METRIC_LOGGER_ENABLED, "true"); System.setProperty(MetricLogUtils.METRIC_LOGGER_THRESHOLD, "-1"); this.registry = Metrics.globalRegistry; } - @After + @AfterEach public void clearMeters() { // Remove meters we inserted without affecting those that may have already been there. Search.in(registry) .name(name -> name.startsWith("org.drools.metric")) diff --git a/drools-metric/src/test/java/org/drools/metric/CloneTest.java b/drools-metric/src/test/java/org/drools/metric/CloneTest.java index 7ac097eaadd..abc068694f3 100644 --- a/drools-metric/src/test/java/org/drools/metric/CloneTest.java +++ b/drools-metric/src/test/java/org/drools/metric/CloneTest.java @@ -18,7 +18,7 @@ */ package org.drools.metric; -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-metric/src/test/java/org/drools/metric/ConstraintsTest.java b/drools-metric/src/test/java/org/drools/metric/ConstraintsTest.java index 4c7a8c25d7f..697132134ae 100644 --- a/drools-metric/src/test/java/org/drools/metric/ConstraintsTest.java +++ b/drools-metric/src/test/java/org/drools/metric/ConstraintsTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.drools.mvel.compiler.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; diff --git a/drools-metric/src/test/java/org/drools/metric/MetricLogUtilsTest.java b/drools-metric/src/test/java/org/drools/metric/MetricLogUtilsTest.java index 3262031bbec..5b11c16bee2 100644 --- a/drools-metric/src/test/java/org/drools/metric/MetricLogUtilsTest.java +++ b/drools-metric/src/test/java/org/drools/metric/MetricLogUtilsTest.java @@ -29,7 +29,7 @@ import org.drools.metric.util.MetricLogUtils; import org.drools.mvel.compiler.Address; import org.drools.mvel.compiler.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; diff --git a/drools-mvel/pom.xml b/drools-mvel/pom.xml index df99d589db3..3bd052b2358 100644 --- a/drools-mvel/pom.xml +++ b/drools-mvel/pom.xml @@ -106,6 +106,11 @@ drools-tms test + + org.junit.jupiter + junit-jupiter + test + org.assertj @@ -127,11 +132,6 @@ commons-io test - - junit - junit - test - diff --git a/drools-mvel/src/test/java/org/drools/mvel/BuildUtilsTest.java b/drools-mvel/src/test/java/org/drools/mvel/BuildUtilsTest.java index 692c6450246..387fdaee286 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/BuildUtilsTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/BuildUtilsTest.java @@ -30,8 +30,8 @@ import org.drools.base.time.Interval; import org.drools.core.time.TemporalDependencyMatrix; import org.drools.mvel.evaluators.AfterEvaluatorDefinition; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.drools.base.time.Interval.MAX; @@ -41,7 +41,7 @@ public class BuildUtilsTest { private BuildUtils utils; - @Before + @BeforeEach public void setUp() throws Exception { utils = new BuildUtils(); } diff --git a/drools-mvel/src/test/java/org/drools/mvel/MVELCalendarCoercionTest.java b/drools-mvel/src/test/java/org/drools/mvel/MVELCalendarCoercionTest.java index 748dcaa7eef..f7b420d40f9 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/MVELCalendarCoercionTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/MVELCalendarCoercionTest.java @@ -24,8 +24,8 @@ import java.util.Locale; import org.drools.util.DateUtils; +import org.junit.jupiter.api.Test; import org.drools.mvel.expr.MVELCalendarCoercion; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/MVELDateCoercionTest.java b/drools-mvel/src/test/java/org/drools/mvel/MVELDateCoercionTest.java index 9e06729024a..67f314e4ca5 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/MVELDateCoercionTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/MVELDateCoercionTest.java @@ -27,8 +27,8 @@ import org.drools.mvel.MVELConstraintBuilder.StringCoercionCompatibilityEvaluator; import org.drools.util.DateUtils; +import org.junit.jupiter.api.Test; import org.drools.mvel.expr.MVELDateCoercion; -import org.junit.Test; import org.mvel2.DataConversion; import org.mvel2.MVEL; import org.mvel2.ParserContext; diff --git a/drools-mvel/src/test/java/org/drools/mvel/asm/ClassFieldInspectorTest.java b/drools-mvel/src/test/java/org/drools/mvel/asm/ClassFieldInspectorTest.java index ed6aaee232c..419a78505fc 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/asm/ClassFieldInspectorTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/asm/ClassFieldInspectorTest.java @@ -28,7 +28,7 @@ import org.drools.core.util.asm.InterfaceChildImpl; import org.drools.core.util.asm.TestAbstract; import org.drools.core.util.asm.TestInterface; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-mvel/src/test/java/org/drools/mvel/asm/KnowledgeHelperFixerTest.java b/drools-mvel/src/test/java/org/drools/mvel/asm/KnowledgeHelperFixerTest.java index 7f134ae42ed..dd51cb2e5ec 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/asm/KnowledgeHelperFixerTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/asm/KnowledgeHelperFixerTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.asm; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/asm/LambdaIntrospectorTest.java b/drools-mvel/src/test/java/org/drools/mvel/asm/LambdaIntrospectorTest.java index 75323f6476c..a77018dcec5 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/asm/LambdaIntrospectorTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/asm/LambdaIntrospectorTest.java @@ -23,7 +23,7 @@ import java.util.function.Supplier; import org.drools.mvel.compiler.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/asm/MethodComparerTest.java b/drools-mvel/src/test/java/org/drools/mvel/asm/MethodComparerTest.java index 955e5134e54..853c71e49e9 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/asm/MethodComparerTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/asm/MethodComparerTest.java @@ -22,7 +22,7 @@ import org.drools.core.util.asm.MethodCompareA; import org.drools.core.util.asm.MethodCompareB; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mvel2.asm.ClassReader; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/ClassGeneratorTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/ClassGeneratorTest.java index da95070e0d3..04d2fb4940e 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/ClassGeneratorTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/ClassGeneratorTest.java @@ -19,7 +19,7 @@ package org.drools.mvel.compiler.rule.builder.dialect.asm; import org.drools.mvel.asm.ClassGenerator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mvel2.asm.MethodVisitor; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/InvokerGeneratorTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/InvokerGeneratorTest.java index 49e2435e3de..d805db0561f 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/InvokerGeneratorTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/asm/InvokerGeneratorTest.java @@ -30,7 +30,7 @@ import org.drools.mvel.asm.InvokerContext; import org.drools.mvel.asm.InvokerGenerator; import org.drools.mvel.asm.InvokerStub; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaAccumulateBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaAccumulateBuilderTest.java index a9d787379fa..f060800c117 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaAccumulateBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaAccumulateBuilderTest.java @@ -37,8 +37,8 @@ import org.drools.mvel.java.JavaAccumulateBuilder; import org.drools.mvel.java.JavaAnalysisResult; import org.drools.mvel.java.JavaExprAnalyzer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ public class JavaAccumulateBuilderTest { private JavaAccumulateBuilder builder; - @Before + @BeforeEach public void setUp() throws Exception { builder = new JavaAccumulateBuilder(); } diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderPRAlwaysTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderPRAlwaysTest.java index 9df48d8dcdc..17dc1b27f5b 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderPRAlwaysTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderPRAlwaysTest.java @@ -46,7 +46,7 @@ import org.drools.mvel.compiler.Person; import org.drools.mvel.java.JavaAnalysisResult; import org.drools.mvel.java.JavaExprAnalyzer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.conf.PropertySpecificOption; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java index 47f439c985a..48a77803420 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java @@ -46,7 +46,7 @@ import org.drools.mvel.compiler.Person; import org.drools.mvel.java.JavaAnalysisResult; import org.drools.mvel.java.JavaExprAnalyzer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.conf.PropertySpecificOption; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaExprAnalyzerTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaExprAnalyzerTest.java index 4b116b27dde..11d00674978 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaExprAnalyzerTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaExprAnalyzerTest.java @@ -25,7 +25,7 @@ import org.drools.compiler.compiler.BoundIdentifiers; import org.drools.mvel.java.JavaAnalysisResult; import org.drools.mvel.java.JavaExprAnalyzer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaForMvelDialectConfigurationTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaForMvelDialectConfigurationTest.java index f00ff3c2ae2..654ecb2175d 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaForMvelDialectConfigurationTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/JavaForMvelDialectConfigurationTest.java @@ -19,7 +19,7 @@ package org.drools.mvel.compiler.rule.builder.dialect.java; import org.drools.mvel.java.JavaForMvelDialectConfiguration; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JavaForMvelDialectConfigurationTest { diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELAccumulateBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELAccumulateBuilderTest.java index 5aefec89e3d..3bd1fd86a4b 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELAccumulateBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELAccumulateBuilderTest.java @@ -45,7 +45,7 @@ import org.drools.mvel.builder.MVELDialect; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.expr.MVELCompileable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java index 6e63fa9aac5..84597f88715 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java @@ -83,7 +83,7 @@ import org.drools.mvel.compiler.Cheese; import org.drools.mvel.expr.MVELConsequence; import org.drools.mvel.expr.MVELDebugHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.conf.LanguageLevelOption; import org.mvel2.ParserContext; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELDebugTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELDebugTest.java index def1708a344..a5206c26fb0 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELDebugTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELDebugTest.java @@ -24,7 +24,7 @@ import org.drools.drl.ast.descr.RuleDescr; import org.drools.base.definitions.InternalKnowledgePackage; import org.drools.mvel.expr.MVELConsequence; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELEvalBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELEvalBuilderTest.java index 09a5ae8ab70..a91477920d9 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELEvalBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELEvalBuilderTest.java @@ -50,8 +50,8 @@ import org.drools.mvel.builder.MVELEvalBuilder; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.expr.MVELEvalExpression; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -59,7 +59,7 @@ public class MVELEvalBuilderTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELExprAnalyzerTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELExprAnalyzerTest.java index 919a07b1953..ce2274e5fef 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELExprAnalyzerTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELExprAnalyzerTest.java @@ -19,14 +19,14 @@ package org.drools.mvel.compiler.rule.builder.dialect.mvel; import org.drools.mvel.builder.MVELExprAnalyzer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MVELExprAnalyzerTest { private MVELExprAnalyzer analyzer; - @Before + @BeforeEach public void setUp() throws Exception { analyzer = new MVELExprAnalyzer(); } diff --git a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java index 584439f953e..247c79eb123 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java @@ -55,8 +55,8 @@ import org.drools.mvel.builder.MVELSalienceBuilder; import org.drools.mvel.compiler.Person; import org.drools.mvel.expr.MVELSalienceExpression; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.definition.rule.Rule; import static org.assertj.core.api.Assertions.assertThat; @@ -66,7 +66,7 @@ public class MVELSalienceBuilderTest { private InternalKnowledgeBase kBase ; private BuildContext buildContext; - @Before + @BeforeEach public void setUp() throws Exception { InternalKnowledgePackage pkg = CoreComponentFactory.get().createKnowledgePackage( "pkg1" ); final RuleDescr ruleDescr = new RuleDescr( "rule 1" ); diff --git a/drools-mvel/src/test/java/org/drools/mvel/evaluators/TemporalEvaluatorFactoryTest.java b/drools-mvel/src/test/java/org/drools/mvel/evaluators/TemporalEvaluatorFactoryTest.java index d22c95224f8..c99fb7ea1d2 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/evaluators/TemporalEvaluatorFactoryTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/evaluators/TemporalEvaluatorFactoryTest.java @@ -25,6 +25,7 @@ import org.drools.base.base.ValueResolver; import org.drools.mvel.field.FieldFactory; +import org.junit.jupiter.api.Test; import org.drools.base.base.ValueType; import org.drools.compiler.rule.builder.EvaluatorDefinition; import org.drools.compiler.builder.impl.EvaluatorRegistry; @@ -34,7 +35,6 @@ import org.drools.base.rule.accessor.Evaluator; import org.drools.base.rule.accessor.FieldValue; import org.drools.base.rule.accessor.ReadAccessor; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/field/FieldFactoryTest.java b/drools-mvel/src/test/java/org/drools/mvel/field/FieldFactoryTest.java index 1d62ec02953..4072d922304 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/field/FieldFactoryTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/field/FieldFactoryTest.java @@ -26,7 +26,7 @@ import org.drools.base.base.ValueType; import org.drools.base.rule.accessor.FieldValue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-mvel/src/test/java/org/drools/mvel/field/FieldValueTest.java b/drools-mvel/src/test/java/org/drools/mvel/field/FieldValueTest.java index d1722a22f8f..cf6241b9ec7 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/field/FieldValueTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/field/FieldValueTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.field; import org.drools.base.rule.accessor.FieldValue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -31,7 +31,7 @@ public class FieldValueTest { FieldValue field4; FieldValue field5; - @Before + @BeforeEach public void setUp() throws Exception { this.field1 = FieldFactory.getInstance().getFieldValue( null ); this.field2 = FieldFactory.getInstance().getFieldValue( null ); diff --git a/drools-mvel/src/test/java/org/drools/mvel/integrationtests/LogicTransformerTest.java b/drools-mvel/src/test/java/org/drools/mvel/integrationtests/LogicTransformerTest.java index ec98c674545..85a53153e8c 100644 --- a/drools-mvel/src/test/java/org/drools/mvel/integrationtests/LogicTransformerTest.java +++ b/drools-mvel/src/test/java/org/drools/mvel/integrationtests/LogicTransformerTest.java @@ -33,7 +33,7 @@ import org.drools.base.rule.LogicTransformer; import org.drools.base.rule.Pattern; import org.drools.core.util.DroolsStreamUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/MoreBatchExecutionPersistenceTest.java b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/MoreBatchExecutionPersistenceTest.java index 1610d0563c6..a0864484736 100644 --- a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/MoreBatchExecutionPersistenceTest.java +++ b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/MoreBatchExecutionPersistenceTest.java @@ -18,24 +18,41 @@ */ package org.drools.persistence.command; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Map; import org.drools.core.impl.RuleBaseFactory; -import org.drools.mvel.compiler.command.MoreBatchExecutionTest; +import org.drools.kiesession.rulebase.InternalKnowledgeBase; +import org.drools.kiesession.rulebase.KnowledgeBaseFactory; +import org.drools.mvel.CommonTestMethodBase; +import org.drools.mvel.compiler.Cheese; import org.drools.persistence.util.DroolsPersistenceUtil; import org.junit.After; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.kie.api.KieBase; +import org.kie.api.command.Command; +import org.kie.api.io.ResourceType; import org.kie.api.runtime.Environment; import org.kie.api.runtime.EnvironmentName; +import org.kie.api.runtime.ExecutionResults; +import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; +import org.kie.api.runtime.rule.QueryResults; +import org.kie.internal.builder.KnowledgeBuilder; +import org.kie.internal.builder.KnowledgeBuilderFactory; +import org.kie.internal.command.CommandFactory; +import org.kie.internal.io.ResourceFactory; import org.kie.internal.persistence.jpa.JPAKnowledgeService; import org.kie.internal.runtime.StatefulKnowledgeSession; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.drools.persistence.util.DroolsPersistenceUtil.DROOLS_PERSISTENCE_UNIT_NAME; import static org.drools.persistence.util.DroolsPersistenceUtil.OPTIMISTIC_LOCKING; import static org.drools.persistence.util.DroolsPersistenceUtil.PESSIMISTIC_LOCKING; @@ -43,7 +60,10 @@ import static org.drools.persistence.util.DroolsPersistenceUtil.createEnvironment; @RunWith(Parameterized.class) -public class MoreBatchExecutionPersistenceTest extends MoreBatchExecutionTest { +public class MoreBatchExecutionPersistenceTest extends CommonTestMethodBase { + + + private KieSession ksession = null; private Map context; private boolean locking; @@ -67,6 +87,13 @@ public void cleanUpPersistence() throws Exception { cleanUp(context); context = null; } + + public void disposeKSession() { + if( ksession != null ) { + ksession.dispose(); + ksession = null; + } + } protected StatefulKnowledgeSession createKnowledgeSession(KieBase kbase) { if( context == null ) { @@ -77,6 +104,72 @@ protected StatefulKnowledgeSession createKnowledgeSession(KieBase kbase) { if( this.locking ) { env.set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true); } - return JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env); } + return JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env); + + } + + @Test + public void testFireAllRules() { + KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); + kbuilder.add(ResourceFactory.newClassPathResource("org/drools/mvel/integrationtests/drl/test_ImportFunctions.drl"), ResourceType.DRL); + if (kbuilder.hasErrors()) { + fail(kbuilder.getErrors().toString()); + } + InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); + kbase.addPackages(kbuilder.getKnowledgePackages()); + ksession = createKnowledgeSession(kbase); + + final Cheese cheese = new Cheese("stilton", 15); + ksession.insert(cheese); + List list = new ArrayList(); + ksession.setGlobal("list", list); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newFireAllRules("fired")); + Command cmds = CommandFactory.newBatchExecution(commands); + ExecutionResults result = (ExecutionResults) ksession.execute(cmds); + assertThat(result).as("Batch execution result is null!").isNotNull(); + + Object firedObject = result.getValue("fired"); + assertThat(firedObject instanceof Integer).as("Retrieved object is null or incorrect!").isTrue(); + assertThat(firedObject).isEqualTo(4); + + list = (List) ksession.getGlobal("list"); + assertThat(list.size()).isEqualTo(4); + + assertThat(list.get(0)).isEqualTo("rule1"); + assertThat(list.get(1)).isEqualTo("rule2"); + assertThat(list.get(2)).isEqualTo("rule3"); + assertThat(list.get(3)).isEqualTo("rule4"); + } + + @Test + public void testQuery() { + KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); + kbuilder.add(ResourceFactory.newClassPathResource("org/drools/mvel/integrationtests/simple_query_test.drl"), ResourceType.DRL); + if (kbuilder.hasErrors()) { + fail(kbuilder.getErrors().toString()); + } + InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); + kbase.addPackages(kbuilder.getKnowledgePackages()); + ksession = createKnowledgeSession(kbase); + + ksession.insert( new Cheese( "stinky", 5 ) ); + ksession.insert( new Cheese( "smelly", 7 ) ); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newQuery("numStinkyCheeses", "simple query")); + Command cmds = CommandFactory.newBatchExecution(commands); + ExecutionResults result = (ExecutionResults) ksession.execute(cmds); + assertThat(result).as("Batch execution result is null!").isNotNull(); + + Object queryResultsObject = result.getValue("numStinkyCheeses"); + assertThat(queryResultsObject instanceof QueryResults).as("Retrieved object is null or incorrect!").isTrue(); + + assertThat(((QueryResults) queryResultsObject).size()).isEqualTo(1); + } + + + } diff --git a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/SimpleBatchExecutionPersistenceTest.java b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/SimpleBatchExecutionPersistenceTest.java index c419dc07242..bdce54ea33d 100644 --- a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/SimpleBatchExecutionPersistenceTest.java +++ b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/command/SimpleBatchExecutionPersistenceTest.java @@ -18,26 +18,44 @@ */ package org.drools.persistence.command; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Map; import org.drools.core.impl.RuleBaseFactory; +import org.drools.kiesession.rulebase.InternalKnowledgeBase; +import org.drools.kiesession.rulebase.KnowledgeBaseFactory; +import org.drools.mvel.CommonTestMethodBase; import org.drools.mvel.compiler.command.SimpleBatchExecutionTest; import org.drools.persistence.util.DroolsPersistenceUtil; import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.kie.api.KieBase; +import org.kie.api.command.Command; +import org.kie.api.io.ResourceType; import org.kie.api.runtime.Environment; import org.kie.api.runtime.EnvironmentName; +import org.kie.api.runtime.ExecutionResults; +import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; +import org.kie.api.runtime.rule.FactHandle; +import org.kie.internal.builder.KnowledgeBuilder; +import org.kie.internal.builder.KnowledgeBuilderFactory; +import org.kie.internal.command.CommandFactory; +import org.kie.internal.io.ResourceFactory; import org.kie.internal.persistence.jpa.JPAKnowledgeService; import org.kie.internal.runtime.StatefulKnowledgeSession; @RunWith(Parameterized.class) -public class SimpleBatchExecutionPersistenceTest extends SimpleBatchExecutionTest { +public class SimpleBatchExecutionPersistenceTest extends CommonTestMethodBase { private Map context; private boolean locking; @@ -73,4 +91,197 @@ protected StatefulKnowledgeSession createKnowledgeSession(KieBase kbase) { } return JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env); } + + private KieSession ksession; + protected final static String ruleString = "" + + "package org.kie.api.persistence \n" + + "global String globalCheeseCountry\n" + + "\n" + + "rule 'EmptyRule' \n" + + " when\n" + + " then\n" + + "end\n"; + + @Before + public void createKSession() throws Exception { + final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); + kbuilder.add( ResourceFactory.newByteArrayResource(ruleString.getBytes()), ResourceType.DRL ); + InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); + assertThat(kbuilder.hasErrors()).isFalse(); + kbase.addPackages( kbuilder.getKnowledgePackages() ); + + ksession = createKnowledgeSession(kbase); + } + + @After + public void disposeKSession() throws Exception { + if( ksession != null ) { + ksession.dispose(); + ksession = null; + } + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testInsertObjectCommand() throws Exception { + + String expected_1 = "expected_1"; + String expected_2 = "expected_2"; + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newInsert(expected_1, "out_1")); + commands.add(CommandFactory.newInsert(expected_2, "out_2")); + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + + Object fact_1 = result.getValue("out_1"); + assertThat(fact_1).isNotNull(); + Object fact_2 = result.getValue("out_2"); + assertThat(fact_2).isNotNull(); + ksession.fireAllRules(); + + Object [] expectedArr = {expected_1, expected_2}; + List expectedList = new ArrayList(Arrays.asList(expectedArr)); + + Collection factList = ksession.getObjects(); + assertThat(factList.size() == expectedList.size()).as("Expected " + expectedList.size() + " objects but retrieved " + factList.size()).isTrue(); + for( Object fact : factList ) { + expectedList.remove(fact); + } + assertThat(expectedList.isEmpty()).as("Retrieved object list did not contain expected objects.").isTrue(); + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testInsertElementsCommand() throws Exception { + + String expected_1 = "expected_1"; + String expected_2 = "expected_2"; + Object [] expectedArr = {expected_1, expected_2}; + Collection factCollection = Arrays.asList(expectedArr); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newInsertElements(factCollection, "out_list", true, null)); + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + + Collection outList = (Collection) result.getValue("out_list"); + assertThat(outList).isNotNull(); + ksession.fireAllRules(); + + List expectedList = new ArrayList(Arrays.asList(expectedArr)); + + Collection factList = ksession.getObjects(); + assertThat(factList.size() == expectedList.size()).as("Expected " + expectedList.size() + " objects but retrieved " + factList.size()).isTrue(); + for( Object fact : factList ) { + expectedList.remove(fact); + } + assertThat(expectedList.isEmpty()).as("Retrieved object list did not contain expected objects.").isTrue(); + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testSetGlobalCommand() throws Exception { + + ksession.insert(new Integer(5)); + ksession.insert(new Integer(7)); + ksession.fireAllRules(); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newSetGlobal( "globalCheeseCountry", "France", true )); + + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + assertThat(result).isNotNull(); + Object global = result.getValue("globalCheeseCountry"); + assertThat(global).isNotNull(); + assertThat(global).isEqualTo("France"); + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testGetGlobalCommand() throws Exception { + + ksession.insert(new Integer(5)); + ksession.insert(new Integer(7)); + ksession.fireAllRules(); + ksession.setGlobal("globalCheeseCountry", "France"); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newGetGlobal( "globalCheeseCountry", "cheeseCountry" )); + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + assertThat(result).as("GetGlobalCommand result is null!").isNotNull(); + Object global = result.getValue("cheeseCountry"); + assertThat(global).as("Retrieved global fact is null!").isNotNull(); + assertThat(global).as("Retrieved global is not equal to 'France'.").isEqualTo("France"); + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testGetObjectCommand() throws Exception { + + String expected_1 = "expected_1"; + String expected_2 = "expected_2"; + FactHandle handle_1 = ksession.insert( expected_1 ); + FactHandle handle_2 = ksession.insert( expected_2 ); + ksession.fireAllRules(); + + Object fact = ksession.getObject(handle_1); + assertThat(fact).isNotNull(); + assertThat(fact).isEqualTo(expected_1); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newGetObject(handle_1, "out_1")); + commands.add(CommandFactory.newGetObject(handle_2, "out_2")); + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + assertThat(result).as("GetObjectCommand result is null!").isNotNull(); + + assertThat(result.getValue("out_1")).isEqualTo(expected_1); + assertThat(result.getValue("out_2")).isEqualTo(expected_2); + } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testGetObjectsCommand() throws Exception { + + String expected_1 = "expected_1"; + String expected_2 = "expected_2"; + FactHandle handle_1 = ksession.insert( expected_1 ); + FactHandle handle_2 = ksession.insert( expected_2 ); + ksession.fireAllRules(); + + Object object = ksession.getObject(handle_1); + assertThat(object).isNotNull(); + assertThat(object).isEqualTo(expected_1); + object = ksession.getObject(handle_2); + assertThat(object).isNotNull(); + assertThat(object).isEqualTo(expected_2); + + List> commands = new ArrayList>(); + commands.add(CommandFactory.newGetObjects("out_list")); + Command cmds = CommandFactory.newBatchExecution( commands ); + + ExecutionResults result = (ExecutionResults) ksession.execute( cmds ); + assertThat(result).as("GetObjectsCommand result is null!").isNotNull(); + + List objectList = (List) result.getValue("out_list"); + assertThat(objectList != null && !objectList.isEmpty()).as("Retrieved object list is null or empty!").isTrue(); + + Collection factList = ksession.getObjects(); + Object [] expectedArr = {expected_1, expected_2}; + List expectedList = new ArrayList(Arrays.asList(expectedArr)); + assertThat(factList.size() == expectedList.size()).as("Expected " + expectedList.size() + " objects but retrieved " + factList.size()).isTrue(); + for( Object fact : factList ) { + expectedList.remove(fact); + } + assertThat(expectedList.isEmpty()).as("Retrieved object list did not contain expected objects.").isTrue(); + } + } diff --git a/drools-templates/pom.xml b/drools-templates/pom.xml index 9194b46c1d4..286ae1e329c 100644 --- a/drools-templates/pom.xml +++ b/drools-templates/pom.xml @@ -79,13 +79,13 @@ test - org.assertj - assertj-core + org.junit.jupiter + junit-jupiter test - junit - junit + org.assertj + assertj-core test diff --git a/drools-templates/src/test/java/org/drools/template/DataProviderCompilerTest.java b/drools-templates/src/test/java/org/drools/template/DataProviderCompilerTest.java index b95278bf3fa..83eb143b444 100644 --- a/drools-templates/src/test/java/org/drools/template/DataProviderCompilerTest.java +++ b/drools-templates/src/test/java/org/drools/template/DataProviderCompilerTest.java @@ -29,8 +29,8 @@ import org.drools.template.parser.Column; import org.drools.template.parser.DefaultTemplateContainer; import org.drools.template.parser.TemplateContainer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +83,7 @@ public String[] next() { private ArrayList rows = new ArrayList(); - @Before + @BeforeEach public void setUp() { rows.add(new String[]{"1", "STANDARD", diff --git a/drools-templates/src/test/java/org/drools/template/jdbc/ResultSetGeneratorTest.java b/drools-templates/src/test/java/org/drools/template/jdbc/ResultSetGeneratorTest.java index 7c91b775bcd..734d24af853 100644 --- a/drools-templates/src/test/java/org/drools/template/jdbc/ResultSetGeneratorTest.java +++ b/drools-templates/src/test/java/org/drools/template/jdbc/ResultSetGeneratorTest.java @@ -29,7 +29,7 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -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.builder.KnowledgeBuilder; diff --git a/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java b/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java index 0430fe73ce3..6fe6dc6de55 100644 --- a/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java +++ b/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java b/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java index f9740107474..9f67e1b11a3 100644 --- a/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java +++ b/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-templates/src/test/java/org/drools/template/model/QueriesRenderTest.java b/drools-templates/src/test/java/org/drools/template/model/QueriesRenderTest.java index 65bf5da351f..e8747074b8d 100644 --- a/drools-templates/src/test/java/org/drools/template/model/QueriesRenderTest.java +++ b/drools-templates/src/test/java/org/drools/template/model/QueriesRenderTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java b/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java index 352156512d9..f1f1629dadf 100644 --- a/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java +++ b/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java b/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java index 4c30ec31e82..945d496d794 100644 --- a/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java +++ b/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java b/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java index 1a42ef0c864..cd9c2566025 100644 --- a/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java +++ b/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java @@ -18,7 +18,7 @@ */ package org.drools.template.parser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java b/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java index d9d6e3cd7e2..98f2028bef0 100644 --- a/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java +++ b/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java @@ -18,8 +18,8 @@ */ package org.drools.template.parser; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; @@ -29,7 +29,7 @@ public class DefaultGeneratorTest { private DefaultGenerator g; - @Before + @BeforeEach public void setUp() throws Exception { Map t = new HashMap(); TemplateContainer tc = new TemplateContainer() { diff --git a/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java b/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java index c2fe0d302d0..1c7379e24c5 100644 --- a/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java +++ b/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java b/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java index b605305d2d1..66af096e4a3 100644 --- a/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java +++ b/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; -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.command.Command; import org.kie.api.event.process.ProcessEventListener; @@ -54,7 +54,7 @@ public class ExternalSheetListenerTest { private List assertedRows = new ArrayList<>(); - @Before + @BeforeEach public void setUp() throws Exception { esl = new TemplateDataListener(2, 2, new TestTemplateContainer(), new TestGenerator()); } diff --git a/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java b/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java index ea62ee85729..344ff92377f 100644 --- a/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java +++ b/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java @@ -19,7 +19,7 @@ package org.drools.template.parser; import org.drools.util.StringUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; diff --git a/drools-tms/pom.xml b/drools-tms/pom.xml index a04ae00e2a1..a454a1b2d92 100644 --- a/drools-tms/pom.xml +++ b/drools-tms/pom.xml @@ -97,12 +97,11 @@ drools-wiring-dynamic test - - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + org.assertj assertj-core @@ -115,5 +114,4 @@ - diff --git a/drools-tms/src/test/java/org/drools/tms/EqualityKeyTest.java b/drools-tms/src/test/java/org/drools/tms/EqualityKeyTest.java index c584a4a2bae..0e869e8e9b2 100644 --- a/drools-tms/src/test/java/org/drools/tms/EqualityKeyTest.java +++ b/drools-tms/src/test/java/org/drools/tms/EqualityKeyTest.java @@ -22,7 +22,7 @@ import org.drools.core.common.InternalFactHandle; import org.drools.core.reteoo.ReteooFactHandleFactory; import org.drools.core.test.model.Cheese; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-tms/src/test/java/org/drools/tms/LazyTMSEnablingTest.java b/drools-tms/src/test/java/org/drools/tms/LazyTMSEnablingTest.java index 089d154546e..12389353de3 100644 --- a/drools-tms/src/test/java/org/drools/tms/LazyTMSEnablingTest.java +++ b/drools-tms/src/test/java/org/drools/tms/LazyTMSEnablingTest.java @@ -24,8 +24,8 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ public class LazyTMSEnablingTest { private StatefulKnowledgeSessionImpl ksession; private TruthMaintenanceSystem tms; - @Before + @BeforeEach public void setUp() { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); diff --git a/drools-wiring/drools-wiring-api/pom.xml b/drools-wiring/drools-wiring-api/pom.xml index ae3a1228f74..cb88a2d26d4 100755 --- a/drools-wiring/drools-wiring-api/pom.xml +++ b/drools-wiring/drools-wiring-api/pom.xml @@ -61,11 +61,11 @@ assertj-core test - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-wiring/drools-wiring-api/src/test/java/org/drools/wiring/api/classloader/ProjectClassLoaderTest.java b/drools-wiring/drools-wiring-api/src/test/java/org/drools/wiring/api/classloader/ProjectClassLoaderTest.java index 15f7cfbd800..a90c8739e12 100644 --- a/drools-wiring/drools-wiring-api/src/test/java/org/drools/wiring/api/classloader/ProjectClassLoaderTest.java +++ b/drools-wiring/drools-wiring-api/src/test/java/org/drools/wiring/api/classloader/ProjectClassLoaderTest.java @@ -18,7 +18,7 @@ */ package org.drools.wiring.api.classloader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-wiring/drools-wiring-dynamic/pom.xml b/drools-wiring/drools-wiring-dynamic/pom.xml index 355a9d666df..58d833d294a 100755 --- a/drools-wiring/drools-wiring-dynamic/pom.xml +++ b/drools-wiring/drools-wiring-dynamic/pom.xml @@ -83,11 +83,11 @@ logback-classic test - - junit - junit - test - + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-wiring/drools-wiring-dynamic/src/test/java/org/drools/dynamic/ClassLoaderTest.java b/drools-wiring/drools-wiring-dynamic/src/test/java/org/drools/dynamic/ClassLoaderTest.java index a120c4f390e..dd92b9d5188 100755 --- a/drools-wiring/drools-wiring-dynamic/src/test/java/org/drools/dynamic/ClassLoaderTest.java +++ b/drools-wiring/drools-wiring-dynamic/src/test/java/org/drools/dynamic/ClassLoaderTest.java @@ -24,13 +24,16 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import org.drools.wiring.api.classloader.ProjectClassLoader; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; public class ClassLoaderTest { - @Test(timeout = 20000) + @Test + @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS) public void testParallelClassLoading() { final int THREAD_COUNT = 100; diff --git a/drools-wiring/drools-wiring-static/pom.xml b/drools-wiring/drools-wiring-static/pom.xml index 07bd2d42bdb..8f56b762329 100755 --- a/drools-wiring/drools-wiring-static/pom.xml +++ b/drools-wiring/drools-wiring-static/pom.xml @@ -62,16 +62,16 @@ logback-classic test - - junit - junit - test - org.assertj assertj-core test + + org.junit.jupiter + junit-jupiter + test + diff --git a/drools-wiring/drools-wiring-static/src/test/java/org/drools/wiring/statics/DummyByteArrayClassLoaderTest.java b/drools-wiring/drools-wiring-static/src/test/java/org/drools/wiring/statics/DummyByteArrayClassLoaderTest.java index 0c7eafc483a..024f6d2b695 100644 --- a/drools-wiring/drools-wiring-static/src/test/java/org/drools/wiring/statics/DummyByteArrayClassLoaderTest.java +++ b/drools-wiring/drools-wiring-static/src/test/java/org/drools/wiring/statics/DummyByteArrayClassLoaderTest.java @@ -18,7 +18,7 @@ */ package org.drools.wiring.statics; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; From af01c000d3bed6b80ce9a670dcef282fb84cc0ae Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Thu, 31 Oct 2024 08:25:03 +0100 Subject: [PATCH 2/3] [incubator-kie-drools-6136] Migrate droos test coverage module to JUnit5 - #2 (#6139) * More tests migrated to JUnit5 * More tests migrated * More unit tests migrated to JUnit5 --- .../AbstractBackwardChainingTest.java | 36 +- .../integrationtests/AbstractCellTest.java | 14 +- .../integrationtests/AbstractCepEspTest.java | 22 +- .../integrationtests/AccumulateCepTest.java | 4 +- .../AccumulateMvelDialectTest.java | 55 +- .../integrationtests/AccumulateTest.java | 579 +++++++++------ .../ActivateAndDeleteOnListenerTest.java | 116 +-- .../AlphaNetworkModifyTest.java | 36 +- .../AlphaNodeRangeIndexingTest.java | 262 +++---- ...phaNodeSharingWithDiffPackageNameTest.java | 28 +- .../compiler/integrationtests/AlphaTest.java | 46 +- .../BackwardChainingTest.java | 162 ++-- .../compiler/integrationtests/CellTest.java | 24 +- .../CepEspNegativeCloudTest.java | 6 +- .../compiler/integrationtests/CepEspTest.java | 691 +++++++++++------- .../CepFireUntilHaltTimerTest.java | 6 +- .../integrationtests/CepJavaTypeTest.java | 1 - .../integrationtests/CepQueryTest.java | 50 +- .../integrationtests/CompositeAgendaTest.java | 11 +- .../QueryConcurrencyTest.java | 28 +- .../TimerAndCalendarExceptionTest.java | 69 +- .../TimerAndCalendarFireUntilHaltTest.java | 59 +- .../TimerAndCalendarWithPseudoTimeTest.java | 237 +++--- .../TimerAndCalendarWithRealTimeTest.java | 60 +- .../AccumulateFunctionConcurrencyTest.java | 16 +- .../concurrency/BaseConcurrencyTest.java | 15 +- .../ConsequenceConcurrencyTest.java | 18 +- .../ConsequenceWithAndOrConcurrencyTest.java | 16 +- .../ConstraintConcurrencyTest.java | 18 +- .../ConstraintWithAndOrConcurrencyTest.java | 16 +- ...traintWithAndOrJittingConcurrencyTest.java | 16 +- .../concurrency/EvalConcurrencyTest.java | 16 +- .../FromAccumulateConcurrencyTest.java | 16 +- .../concurrency/GlobalConcurrencyTest.java | 25 +- ...ELDateClassFieldReaderConcurrencyTest.java | 16 +- ...NumberClassFieldReaderConcurrencyTest.java | 16 +- ...ObjectClassFieldReaderConcurrencyTest.java | 16 +- .../drl/AbstractDeclareTest.java | 13 +- .../integrationtests/drl/BindTest.java | 52 +- .../integrationtests/drl/CommentTest.java | 31 +- .../integrationtests/drl/ConsequenceTest.java | 46 +- .../integrationtests/drl/DRLCepTest.java | 26 +- .../integrationtests/drl/DRLTest.java | 76 +- .../integrationtests/drl/DeclareTest.java | 69 +- .../drl/DrlSpecificFeaturesTest.java | 51 +- .../integrationtests/drl/ExceptionTest.java | 26 +- .../integrationtests/drl/GlobalTest.java | 36 +- .../integrationtests/drl/ImportsTest.java | 80 +- .../integrationtests/drl/LiteralTest.java | 46 +- .../integrationtests/drl/NestingTest.java | 31 +- .../integrationtests/drl/PatternTest.java | 136 ++-- .../integrationtests/drl/RHSTest.java | 36 +- .../drl/RuleFlowGroupTest.java | 26 +- .../integrationtests/drl/VariableTest.java | 26 +- .../AccumulateCepEqualityModeTest.java | 28 +- .../BackwardChainingEqualityModeTest.java | 17 +- .../equalitymode/CellEqualityModeTest.java | 18 +- .../equalitymode/CepEspEqualityModeTest.java | 18 +- .../equalitymode/DeclareEqualityModeTest.java | 18 +- .../equalitymode/EqualityModeTest.java | 33 +- .../operators/FromOnlyExecModelTest.java | 2 +- .../ExplicitCanonicalModelCompilerTest.java | 2 +- .../phases/ExplicitCompilerTest.java | 2 +- 63 files changed, 1963 insertions(+), 1804 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractBackwardChainingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractBackwardChainingTest.java index c7a4516ec5f..898cddeeeb6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractBackwardChainingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractBackwardChainingTest.java @@ -24,7 +24,9 @@ import org.drools.testcoverage.common.model.Person; 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; @@ -32,14 +34,10 @@ public abstract class AbstractBackwardChainingTest { - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbstractBackwardChainingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test(timeout = 10000) - public void testQueryPositional() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryPositional(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = getQueryHeader(); drl += "rule x1\n" + @@ -81,11 +79,13 @@ public void testQueryPositional() { " list.add( $name1 + \" : \" + $age1 );\n" + "end \n"; - testQuery(drl); + testQuery(kieBaseTestConfiguration, drl); } - @Test(timeout = 10000) - public void testQueryNamed() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryNamed(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = getQueryHeader(); drl += "rule x1\n" + @@ -127,11 +127,13 @@ public void testQueryNamed() { " list.add( $name1 + \" : \" + $age1 );\n" + "end \n"; - testQuery(drl); + testQuery(kieBaseTestConfiguration, drl); } - @Test(timeout = 10000) - public void testQueryMixed() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryMixed(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = getQueryHeader(); drl += "rule x1\n" + @@ -173,10 +175,10 @@ public void testQueryMixed() { " list.add( $name1 + \" : \" + $age1 );\n" + "end \n"; - testQuery(drl); + testQuery(kieBaseTestConfiguration, drl); } - private void testQuery(final String drl) { + private void testQuery(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("backward-chaining-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCellTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCellTest.java index 9bc81fd8184..d2d491f7b87 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCellTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCellTest.java @@ -28,7 +28,8 @@ import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.SerializationHelper; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.marshalling.ObjectMarshallingStrategy; import org.kie.api.runtime.Environment; @@ -39,14 +40,9 @@ public abstract class AbstractCellTest { - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbstractCellTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test - public void testCell() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCell(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { final String drl = "package evalmodify;\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCepEspTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCepEspTest.java index 0c16e17ee98..6c1ec6836eb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCepEspTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AbstractCepEspTest.java @@ -26,7 +26,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieSessionTestConfiguration; -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.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; @@ -43,14 +45,10 @@ public abstract class AbstractCepEspTest { - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbstractCepEspTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test(timeout = 10000) - public void testAssertBehaviorOnEntryPoints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAssertBehaviorOnEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_AssertBehaviorOnEntryPoints.drl"); final KieSession ksession = kbase.newKieSession(); @@ -91,8 +89,10 @@ public void testAssertBehaviorOnEntryPoints() { } } - @Test(timeout = 10000L) - public void testDuplicateFiring2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDuplicateFiring2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.test;\n" + "import " + StockTick.class.getCanonicalName() + ";\n " + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateCepTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateCepTest.java index 00f7fa2f8cc..bd165edb63f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateCepTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateCepTest.java @@ -74,7 +74,7 @@ public static Stream parameters() { return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") public void testAccumulatesExpireVsCancel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3201 @@ -126,7 +126,7 @@ public void testAccumulatesExpireVsCancel(KieBaseTestConfiguration kieBaseTestCo } } - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") public void testManySlidingWindows(KieBaseTestConfiguration kieBaseTestConfiguration) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateMvelDialectTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateMvelDialectTest.java index 654e28c72c0..db15d5d2bbe 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateMvelDialectTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateMvelDialectTest.java @@ -19,11 +19,11 @@ package org.drools.compiler.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTupleSink; @@ -36,10 +36,10 @@ 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.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; @@ -51,23 +51,17 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AccumulateMvelDialectTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AccumulateMvelDialectTest( 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(); } // See https://issues.jboss.org/browse/DROOLS-2733 - @Test(timeout = 10000) - public void testMVELAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMVELAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMVEL.drl"); final KieSession wm = kbase.newKieSession(); @@ -101,8 +95,10 @@ public void testMVELAccumulate() { } // See https://issues.jboss.org/browse/DROOLS-2733 - @Test(timeout = 10000) - public void testMVELAccumulate2WM() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMVELAccumulate2WM(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMVEL.drl"); @@ -167,20 +163,22 @@ public void testMVELAccumulate2WM() { } - @Test - public void testAccFunctionOpaqueJoins() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccFunctionOpaqueJoins(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-661 - testAccFunctionOpaqueJoins(PropertySpecificOption.ALLOWED); + testAccFunctionOpaqueJoins(kieBaseTestConfiguration, PropertySpecificOption.ALLOWED); } - @Test - public void testAccFunctionOpaqueJoinsWithPropertyReactivity() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccFunctionOpaqueJoinsWithPropertyReactivity(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1445 - testAccFunctionOpaqueJoins(PropertySpecificOption.ALWAYS); + testAccFunctionOpaqueJoins(kieBaseTestConfiguration, PropertySpecificOption.ALWAYS); } // This is unsupported as the declared type Data is loosely typed - private void testAccFunctionOpaqueJoins(final PropertySpecificOption propertySpecificOption) { + private void testAccFunctionOpaqueJoins(KieBaseTestConfiguration kieBaseTestConfiguration, final PropertySpecificOption propertySpecificOption) { final String drl = "package org.test; " + "import java.util.*; " + "global List list; " + @@ -273,8 +271,9 @@ private void testAccFunctionOpaqueJoins(final PropertySpecificOption propertySpe } } - @Test - public void testAccumulateWithSameSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithSameSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "import " + Person.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java index bce20cc5af3..53b1c746f18 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.incrementalcompilation.TestUtil; import org.drools.core.RuleSessionConfiguration; @@ -46,10 +47,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.KieBuilder; @@ -76,22 +77,16 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class AccumulateTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AccumulateTest(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 = 10000) - public void testAccumulateModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateModify(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests;\n" + "\n" + @@ -171,8 +166,10 @@ public void testAccumulateModify() { } } - @Test(timeout = 10000) - public void testAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_Accumulate.drl"); final KieSession wm = kbase.newKieSession(); @@ -209,8 +206,10 @@ public void testAccumulate() { } } - @Test(timeout = 10000) - public void testAccumulateModifyMVEL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateModifyMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -293,8 +292,9 @@ public void testAccumulateModifyMVEL() { } - @Test() - public void testAccumulateReverseModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateReverseModify(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -382,8 +382,10 @@ public void testAccumulateReverseModify() { } } - @Test(timeout = 10000) - public void testAccumulateReverseModify2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateReverseModify2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -471,8 +473,10 @@ public void testAccumulateReverseModify2() { } } - @Test(timeout = 10000) - public void testAccumulateReverseModifyInsertLogical2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateReverseModifyInsertLogical2(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateReverseModifyInsertLogical2.drl"); @@ -517,8 +521,10 @@ public void testAccumulateReverseModifyInsertLogical2() { } } - @Test(timeout = 10000) - public void testAccumulateReverseModifyMVEL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateReverseModifyMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -604,8 +610,10 @@ public void testAccumulateReverseModifyMVEL() { } } - @Test(timeout = 10000) - public void testAccumulateReverseModifyMVEL2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateReverseModifyMVEL2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -691,8 +699,10 @@ public void testAccumulateReverseModifyMVEL2() { } } - @Test(timeout = 10000) - public void testAccumulateWithFromChaining() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithFromChaining(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + @@ -788,8 +798,10 @@ public void testAccumulateWithFromChaining() { } } - @Test(timeout = 10000) - public void testAccumulateInnerClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateInnerClass(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + @@ -828,8 +840,10 @@ public void testAccumulateInnerClass() { } } - @Test(timeout = 10000) - public void testAccumulateReturningNull() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateReturningNull(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + @@ -861,108 +875,150 @@ public void testAccumulateReturningNull() { } } - @Test(timeout = 10000) - public void testAccumulateSumJava() { - execTestAccumulateSum("org/drools/compiler/integrationtests/test_AccumulateSum.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateSumJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateSum(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateSum.drl"); } - @Test(timeout = 10000) - public void testAccumulateSumMVEL() { - execTestAccumulateSum("org/drools/compiler/integrationtests/test_AccumulateSumMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateSumMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateSum(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateSumMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultiPatternWithFunctionJava() { - execTestAccumulateSum("org/drools/compiler/integrationtests/test_AccumulateMultiPatternFunctionJava.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultiPatternWithFunctionJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateSum(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultiPatternFunctionJava.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultiPatternWithFunctionMVEL() { - execTestAccumulateSum("org/drools/compiler/integrationtests/test_AccumulateMultiPatternFunctionMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultiPatternWithFunctionMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateSum(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultiPatternFunctionMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateCountJava() { - execTestAccumulateCount("org/drools/compiler/integrationtests/test_AccumulateCount.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCountJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCount(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCount.drl"); } - @Test(timeout = 10000) - public void testAccumulateCountMVEL() { - execTestAccumulateCount("org/drools/compiler/integrationtests/test_AccumulateCountMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCountMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCount(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCountMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateAverageJava() { - execTestAccumulateAverage("org/drools/compiler/integrationtests/test_AccumulateAverage.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateAverageJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateAverage(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateAverage.drl"); } - @Test(timeout = 10000) - public void testAccumulateAverageMVEL() { - execTestAccumulateAverage("org/drools/compiler/integrationtests/test_AccumulateAverageMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateAverageMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateAverage(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateAverageMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMinJava() { - execTestAccumulateMin("org/drools/compiler/integrationtests/test_AccumulateMin.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMinJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMin(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMin.drl"); } - @Test(timeout = 10000) - public void testAccumulateMinMVEL() { - execTestAccumulateMin("org/drools/compiler/integrationtests/test_AccumulateMinMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMinMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMin(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMinMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMaxJava() { - execTestAccumulateMax("org/drools/compiler/integrationtests/test_AccumulateMax.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMaxJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMax(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMax.drl"); } - @Test(timeout = 10000) - public void testAccumulateMaxMVEL() { - execTestAccumulateMax("org/drools/compiler/integrationtests/test_AccumulateMaxMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMaxMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMax(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMaxMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultiPatternJava() { - execTestAccumulateReverseModifyMultiPattern("org/drools/compiler/integrationtests/test_AccumulateMultiPattern.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultiPatternJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateReverseModifyMultiPattern(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultiPattern.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultiPatternMVEL() { - execTestAccumulateReverseModifyMultiPattern("org/drools/compiler/integrationtests/test_AccumulateMultiPatternMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultiPatternMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateReverseModifyMultiPattern(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultiPatternMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateCollectListJava() { - execTestAccumulateCollectList("org/drools/compiler/integrationtests/test_AccumulateCollectList.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCollectListJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCollectList(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCollectList.drl"); } - @Test(timeout = 10000) - public void testAccumulateCollectListMVEL() { - execTestAccumulateCollectList("org/drools/compiler/integrationtests/test_AccumulateCollectListMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCollectListMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCollectList(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCollectListMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateCollectSetJava() { - execTestAccumulateCollectSet("org/drools/compiler/integrationtests/test_AccumulateCollectSet.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCollectSetJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCollectSet(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCollectSet.drl"); } - @Test(timeout = 10000) - public void testAccumulateCollectSetMVEL() { - execTestAccumulateCollectSet("org/drools/compiler/integrationtests/test_AccumulateCollectSetMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCollectSetMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateCollectSet(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateCollectSetMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultipleFunctionsJava() { - execTestAccumulateMultipleFunctions("org/drools/compiler/integrationtests/test_AccumulateMultipleFunctions.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultipleFunctionsJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMultipleFunctions(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultipleFunctions.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultipleFunctionsMVEL() { - execTestAccumulateMultipleFunctions("org/drools/compiler/integrationtests/test_AccumulateMultipleFunctionsMVEL.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultipleFunctionsMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + execTestAccumulateMultipleFunctions(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultipleFunctionsMVEL.drl"); } - @Test(timeout = 10000) - public void testAccumulateMultipleFunctionsConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMultipleFunctionsConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_AccumulateMultipleFunctionsConstraint.drl"); final KieSession ksession = kbase.newKieSession(); @@ -1025,8 +1081,10 @@ public void testAccumulateMultipleFunctionsConstraint() { } } - @Test(timeout = 10000) - public void testAccumulateWithAndOrCombinations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithAndOrCombinations(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3482 // once this compils, update it to actually assert on correct outputs. @@ -1055,7 +1113,7 @@ public void testAccumulateWithAndOrCombinations() { } } - private void execTestAccumulateSum(final String fileName) { + private void execTestAccumulateSum(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1137,7 +1195,7 @@ private void updateReferences(final KieSession session, } } - private void execTestAccumulateCount(final String fileName) { + private void execTestAccumulateCount(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1202,7 +1260,7 @@ private void execTestAccumulateCount(final String fileName) { } } - private void execTestAccumulateAverage(final String fileName) { + private void execTestAccumulateAverage(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1267,7 +1325,7 @@ private void execTestAccumulateAverage(final String fileName) { } } - private void execTestAccumulateMin(final String fileName) { + private void execTestAccumulateMin(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1332,7 +1390,7 @@ private void execTestAccumulateMin(final String fileName) { } } - private void execTestAccumulateMax(final String fileName) { + private void execTestAccumulateMax(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1397,7 +1455,7 @@ private void execTestAccumulateMax(final String fileName) { } } - private void execTestAccumulateCollectList(final String fileName) { + private void execTestAccumulateCollectList(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1448,7 +1506,7 @@ private void execTestAccumulateCollectList(final String fileName) { } } - private void execTestAccumulateCollectSet(final String fileName) { + private void execTestAccumulateCollectSet(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1505,7 +1563,7 @@ private void execTestAccumulateCollectSet(final String fileName) { } } - private void execTestAccumulateReverseModifyMultiPattern(final String fileName) { + private void execTestAccumulateReverseModifyMultiPattern(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1572,8 +1630,10 @@ private void execTestAccumulateReverseModifyMultiPattern(final String fileName) } } - @Test(timeout = 10000) - public void testAccumulateWithPreviouslyBoundVariables() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithPreviouslyBoundVariables(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + @@ -1621,8 +1681,10 @@ public void testAccumulateWithPreviouslyBoundVariables() { } } - @Test(timeout = 10000) - public void testAccumulateMVELWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMVELWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + @@ -1679,8 +1741,10 @@ public void testAccumulateMVELWithModify() { } } - @Test(timeout = 10000) - public void testAccumulateGlobals() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateGlobals(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List results;\n" + @@ -1726,8 +1790,10 @@ public void testAccumulateGlobals() { } } - @Test(timeout = 10000) - public void testAccumulateNonExistingFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateNonExistingFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -1759,8 +1825,10 @@ public void testAccumulateNonExistingFunction() { .anySatisfy(text -> assertThat(text).contains("Unknown accumulate function: 'nonExistingFunction' on rule 'Accumulate non existing function - MVEL'.")); } - @Test(timeout = 10000) - public void testAccumulateZeroParams() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateZeroParams(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.List list;\n" + "rule fromIt\n" + "when\n" + @@ -1789,7 +1857,7 @@ public void testAccumulateZeroParams() { } } - private void execTestAccumulateMultipleFunctions(final String fileName) { + private void execTestAccumulateMultipleFunctions(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration, fileName); @@ -1879,8 +1947,10 @@ public static class DataSet { public List results; } - @Test(timeout = 10000) - public void testAccumulateMinMax() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateMinMax(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test \n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List results \n " + @@ -1919,8 +1989,10 @@ public void testAccumulateMinMax() { } } - @Test(timeout = 10000) - public void testAccumulateCE() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateCE(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List results\n" + @@ -1958,8 +2030,10 @@ public void testAccumulateCE() { } } - @Test(timeout = 10000) - public void testAccumulateAndRetract() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateAndRetract(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler;\n" + "\n" + "import java.util.ArrayList;\n" + @@ -2018,8 +2092,10 @@ public void testAccumulateAndRetract() { } } - @Test(timeout = 10000) - public void testAccumulateWithNull() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithNull(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule foo\n" + "when\n" + "Object() from accumulate( Object(),\n" + @@ -2061,8 +2137,10 @@ public NestedObj getNestedObj() { } } - @Test(timeout = 10000) - public void testAccumulateWithBoundExpression() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithBoundExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler;\n" + "import " + MyObj.class.getCanonicalName() + ";\n" + "global java.util.List results\n" + @@ -2097,8 +2175,10 @@ public void testAccumulateWithBoundExpression() { } } - @Test(timeout = 10000) - public void testInfiniteLoopAddingPkgAfterSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testInfiniteLoopAddingPkgAfterSession(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3488 final String drl = "package org.drools.compiler.test;\n" + "import " + Triple.class.getCanonicalName() + ";\n" + @@ -2160,8 +2240,10 @@ public String getObject() { } } - @Test(timeout = 10000) - public void testAccumulateWithVarsOutOfHashOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithVarsOutOfHashOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3494 final String drl = "package com.sample;\n" + "\n" + @@ -2203,8 +2285,10 @@ public void testAccumulateWithVarsOutOfHashOrder() { } } - @Test(timeout = 10000) - public void testAccumulateWithWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.Map map;\n" + " \n" + "declare Double\n" + @@ -2226,11 +2310,13 @@ public void testAccumulateWithWindow() { " System.out.println( \"We have a sum \" + $a );\n" + "end\n"; - testAccumulateEntryPointWindow(drl, null); + testAccumulateEntryPointWindow(kieBaseTestConfiguration, drl, null); } - @Test(timeout = 10000) - public void testAccumulateWithEntryPoint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.Map map;\n" + " \n" + "declare Double\n" + @@ -2248,11 +2334,13 @@ public void testAccumulateWithEntryPoint() { " System.out.println( \"We have a sum \" + $a );\n" + "end\n"; - testAccumulateEntryPointWindow(drl, "data"); + testAccumulateEntryPointWindow(kieBaseTestConfiguration, drl, "data"); } - @Test(timeout = 10000) - public void testAccumulateWithWindowAndEntryPoint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAccumulateWithWindowAndEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.Map map;\n" + " \n" + "declare Double\n" + @@ -2274,10 +2362,10 @@ public void testAccumulateWithWindowAndEntryPoint() { " System.out.println( \"We have a sum \" + $a );\n" + "end\n"; - testAccumulateEntryPointWindow(drl, "data"); + testAccumulateEntryPointWindow(kieBaseTestConfiguration, drl, "data"); } - private void testAccumulateEntryPointWindow(final String drl, final String entryPointName) { + private void testAccumulateEntryPointWindow(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl, final String entryPointName) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); @@ -2299,8 +2387,10 @@ private void testAccumulateEntryPointWindow(final String drl, final String entry } } - @Test(timeout = 10000) - public void test2AccumulatesWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void test2AccumulatesWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3538 final String drl = "import java.util.*;\n" + @@ -2463,8 +2553,9 @@ public void setDay(final int day) { } } - @Test - public void testAccumulateWithExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithExists(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + Course.class.getCanonicalName() + "\n" + "import " + Lecture.class.getCanonicalName() + "\n" + @@ -2517,8 +2608,9 @@ public void testAccumulateWithExists() { } } - @Test - public void testImportAccumulateFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportAccumulateFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.foo.bar\n" + "import accumulate " + TestFunction.class.getCanonicalName() + " f\n" + "rule X when\n" @@ -2526,11 +2618,12 @@ public void testImportAccumulateFunction() { + " $v : f( $s ) )\n" + "then\n" + "end\n"; - testImportAccumulateFunction(drl); + testImportAccumulateFunction(kieBaseTestConfiguration, drl); } - @Test - public void testImportAccumulateFunctionWithDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportAccumulateFunctionWithDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-750 final String drl = "package org.foo.bar\n" + "import accumulate " + TestFunction.class.getCanonicalName() + " f;\n" @@ -2544,10 +2637,10 @@ public void testImportAccumulateFunctionWithDeclaration() { + "then\n" + "end\n"; - testImportAccumulateFunction(drl); + testImportAccumulateFunction(kieBaseTestConfiguration, drl); } - private void testImportAccumulateFunction(final String drl) { + private void testImportAccumulateFunction(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final ReleaseId releaseId = new ReleaseIdImpl("foo", "bar", "1.0"); KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration, drl); final KieContainer kc = KieServices.get().newKieContainer(releaseId); @@ -2611,8 +2704,9 @@ public Class getResultType() { } } - @Test - public void testAccumulateWithSharedNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithSharedNode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-594 final String drl = "rule A when" + @@ -2650,8 +2744,9 @@ public void testAccumulateWithSharedNode() { } } - @Test - public void testEmptyAccumulateInSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyAccumulateInSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-598 final String drl = "global java.util.List list;\n" + @@ -2682,8 +2777,9 @@ public void testEmptyAccumulateInSubnetwork() { } } - @Test - public void testEmptyAccumulateInSubnetworkFollwedByPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyAccumulateInSubnetworkFollwedByPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-627 final String drl = "global java.util.List list;\n" + @@ -2716,8 +2812,9 @@ public void testEmptyAccumulateInSubnetworkFollwedByPattern() { } } - @Test - public void testAccumulateWithoutSeparator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithoutSeparator(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-602 final String drl = "package org.drools.compiler\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -2738,8 +2835,9 @@ public void testAccumulateWithoutSeparator() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testFromAccumulateWithoutSeparator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromAccumulateWithoutSeparator(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-602 final String drl = "rule R when\n" + " $count : Number( ) from accumulate (\n" + @@ -2794,8 +2892,9 @@ public void setRegistered(final boolean registered) { } } - @Test - public void testReaccumulateForLeftTuple() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReaccumulateForLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + ExpectedMessage.class.getCanonicalName() + ";\n" @@ -2835,8 +2934,9 @@ public void testReaccumulateForLeftTuple() { } } - @Test - public void testNoLoopAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoLoopAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-694 final String drl = "import " + AtomicInteger.class.getCanonicalName() + ";\n" + @@ -2870,8 +2970,9 @@ public void testNoLoopAccumulate() { } } - @Test - public void testAccumulateWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-839 final String drl = "import " + Converter.class.getCanonicalName() + ";\n" + @@ -2887,11 +2988,12 @@ public void testAccumulateWithOr() { " list.add($result);\n" + "end"; - testAccumulateWithOr(drl); + testAccumulateWithOr(kieBaseTestConfiguration, drl); } - @Test - public void testMvelAccumulateWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelAccumulateWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-839 final String drl = "import " + Converter.class.getCanonicalName() + ";\n" + @@ -2907,10 +3009,10 @@ public void testMvelAccumulateWithOr() { " list.add($result);\n" + "end"; - testAccumulateWithOr(drl); + testAccumulateWithOr(kieBaseTestConfiguration, drl); } - private void testAccumulateWithOr(final String drl) { + private void testAccumulateWithOr(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); @@ -2937,8 +3039,9 @@ public static int convert(final int i) { } } - @Test - public void testNormalizeStagedTuplesInAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNormalizeStagedTuplesInAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-998 final String drl = "global java.util.List list;\n" + @@ -2968,8 +3071,9 @@ public void testNormalizeStagedTuplesInAccumulate() { } } - @Test - public void testIncompatibleTypeOnAccumulateFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncompatibleTypeOnAccumulateFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1243 final String drl = "import " + MyPerson.class.getCanonicalName() + ";\n" + @@ -2986,8 +3090,9 @@ public void testIncompatibleTypeOnAccumulateFunction() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testIncompatibleListOnAccumulateFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncompatibleListOnAccumulateFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1243 final String drl = "import " + MyPerson.class.getCanonicalName() + ";\n" + @@ -3004,8 +3109,9 @@ public void testIncompatibleListOnAccumulateFunction() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testTypedSumOnAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypedSumOnAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1175 final String drl = "global java.util.List list;\n" + @@ -3035,8 +3141,9 @@ public void testTypedSumOnAccumulate() { } } - @Test - public void testSumAccumulateOnNullValue() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSumAccumulateOnNullValue(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1242 final String drl = "import " + PersonWithBoxedAge.class.getCanonicalName() + ";\n" + @@ -3066,17 +3173,19 @@ public void testSumAccumulateOnNullValue() { } } - @Test - public void testMinAccumulateOnComparable() { - testMinMaxAccumulateOnComparable("min", "she"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMinAccumulateOnComparable(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMinMaxAccumulateOnComparable(kieBaseTestConfiguration, "min", "she"); } - @Test - public void testMaxAccumulateOnComparable() { - testMinMaxAccumulateOnComparable("max", "you"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMaxAccumulateOnComparable(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMinMaxAccumulateOnComparable(kieBaseTestConfiguration, "max", "you"); } - private void testMinMaxAccumulateOnComparable(final String minMaxFunction, final String expectedResult) { + private void testMinMaxAccumulateOnComparable(KieBaseTestConfiguration kieBaseTestConfiguration, final String minMaxFunction, final String expectedResult) { final String drl = "import " + PersonWithBoxedAge.class.getCanonicalName() + ";\n" + @@ -3130,8 +3239,9 @@ public int compareTo(final PersonWithBoxedAge other) { } } - @Test - public void testTypedMaxOnAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypedMaxOnAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1175 final String drl = "global java.util.List list;\n" + @@ -3161,8 +3271,9 @@ public void testTypedMaxOnAccumulate() { } } - @Test - public void testVarianceDouble() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testVarianceDouble(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -3190,8 +3301,9 @@ public void testVarianceDouble() { assertThat(cheeseInsertsFunction(kieBase, 15, 0, 0, 0, 0)).isCloseTo(36.00, within(0.01)); } - @Test - public void testStandardDeviationDouble() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStandardDeviationDouble(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -3242,8 +3354,9 @@ private double cheeseInsertsFunction(final KieBase kieBase, final int... prices) } } - @Test - public void testConcurrentLeftAndRightUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConcurrentLeftAndRightUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1517 final String drl = "package P;\n" + "import " + Visit.class.getCanonicalName() + ";\n" @@ -3347,8 +3460,9 @@ private boolean containsExactlyAndClear(final List list, final T... value return list.isEmpty(); } - @Test - public void testDoubleAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1530 final String drl = "package P;" + "import " + BusStop.class.getCanonicalName() + ";\n" @@ -3503,8 +3617,9 @@ public String toString() { } } - @Test - public void testCompileFailureOnMissingImport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompileFailureOnMissingImport(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1714 final String drl = "import " + BusStop.class.getCanonicalName() + ";\n" + "rule \"sample rule\"\n" + @@ -3524,8 +3639,9 @@ public void testCompileFailureOnMissingImport() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testAccumulateWithFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List persons;\n" + @@ -3555,8 +3671,9 @@ public void testAccumulateWithFrom() { } } - @Test - public void testAccumulateWith2EntryPoints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWith2EntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -3587,19 +3704,21 @@ public void testAccumulateWith2EntryPoints() { } } - @Test - public void testNumericMax() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNumericMax(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2519 - assertThat((int) testMax("age")).isEqualTo(44); + assertThat((int) testMax(kieBaseTestConfiguration, "age")).isEqualTo(44); } - @Test - public void testComparableMax() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComparableMax(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2519 - assertThat(testMax("name")).isEqualTo("Sofia"); + assertThat(testMax(kieBaseTestConfiguration, "name")).isEqualTo("Sofia"); } - private Object testMax(final String fieldToUse) { + private Object testMax(KieBaseTestConfiguration kieBaseTestConfiguration, final String fieldToUse) { final String drl = "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -3629,8 +3748,9 @@ private Object testMax(final String fieldToUse) { } } - @Test - public void testAccumlateResultCannotBeUsedInFunctions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumlateResultCannotBeUsedInFunctions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import java.util.*;" + "rule \"Rule X\" when\n" + @@ -3648,8 +3768,9 @@ public void testAccumlateResultCannotBeUsedInFunctions() { .anySatisfy(text -> assertThat(text).contains("openAlarms")); } - @Test - public void testAverageWithNoFacts() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAverageWithNoFacts(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2595 final String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -3687,8 +3808,9 @@ public void testAverageWithNoFacts() throws Exception { } } - @Test - public void testAverageFunctionRounding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAverageFunctionRounding(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import java.math.BigDecimal; \n" + "import java.util.List; \n" + @@ -3719,8 +3841,9 @@ public void testAverageFunctionRounding() { } } - @Test - public void testNestedAccumulateWithPrefixAnd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccumulateWithPrefixAnd(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule R when\n" + " String($l: length)\n" + @@ -3748,8 +3871,9 @@ public void testNestedAccumulateWithPrefixAnd() { } } - @Test - public void testNestedAccumulateWithInfixAnd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccumulateWithInfixAnd(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule R when\n" + " String($l: length)\n" + @@ -3786,8 +3910,9 @@ public List getPersons() { } } - @Test - public void testPeerCollectWithEager() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPeerCollectWithEager(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6768 final String drl = "import " + PersonsContainer.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ActivateAndDeleteOnListenerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ActivateAndDeleteOnListenerTest.java index 4e295008cd9..e629685b64d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ActivateAndDeleteOnListenerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ActivateAndDeleteOnListenerTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.event.DefaultAgendaEventListener; import org.drools.core.impl.RuleBaseFactory; @@ -29,10 +30,10 @@ import org.drools.testcoverage.common.model.Sensor; 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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.event.rule.AgendaEventListener; import org.kie.api.event.rule.MatchCancelledEvent; @@ -49,23 +50,16 @@ /** * see JBPM-4764 */ -@RunWith(Parameterized.class) public class ActivateAndDeleteOnListenerTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ActivateAndDeleteOnListenerTest(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 testActivateOnMatchAndDelete() { - testActivateOnMatch(new DefaultAgendaEventListener(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivateOnMatchAndDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { + testActivateOnMatch(kieBaseTestConfiguration, new DefaultAgendaEventListener(){ @Override public void matchCreated(final MatchCreatedEvent event) { final Collection alarms = event.getKieRuntime().getFactHandles(new ClassObjectFilter(Alarm.class)); @@ -76,9 +70,10 @@ public void matchCreated(final MatchCreatedEvent event) { }); } - @Test - public void testActivateOnMatchAndUpdate() { - testActivateOnMatch(new DefaultAgendaEventListener(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivateOnMatchAndUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + testActivateOnMatch(kieBaseTestConfiguration, new DefaultAgendaEventListener(){ @Override public void matchCreated(final MatchCreatedEvent event) { final Collection alarms = event.getKieRuntime().getFactHandles(new ClassObjectFilter(Alarm.class)); @@ -89,7 +84,7 @@ public void matchCreated(final MatchCreatedEvent event) { }); } - private void testActivateOnMatch(final AgendaEventListener listener) { + private void testActivateOnMatch(KieBaseTestConfiguration kieBaseTestConfiguration, final AgendaEventListener listener) { final String drl = "package org.drools.compiler.integrationtests \n" + "import " + Alarm.class.getCanonicalName() + " \n" + @@ -101,7 +96,7 @@ private void testActivateOnMatch(final AgendaEventListener listener) { " then \n" + "end \n"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { ksession.addEventListener(listener); @@ -122,8 +117,9 @@ private void testActivateOnMatch(final AgendaEventListener listener) { } } - @Test - public void testEagerEvaluationWith2Paths() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEagerEvaluationWith2Paths(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -139,7 +135,7 @@ public void testEagerEvaluationWith2Paths() { "then \n" + "end \n"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); @@ -174,8 +170,9 @@ public void matchCancelled(final MatchCancelledEvent event ) { } } - @Test - public void testEagerEvaluationWith2SubPaths() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEagerEvaluationWith2SubPaths(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -191,7 +188,7 @@ public void testEagerEvaluationWith2SubPaths() { "then \n" + "end \n"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); @@ -212,8 +209,9 @@ public void matchCreated(final org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test - public void testOneLinkedAndOneUnlinkedPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOneLinkedAndOneUnlinkedPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -231,7 +229,7 @@ public void testOneLinkedAndOneUnlinkedPath() { "then \n" + "end \n"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); @@ -256,8 +254,9 @@ public void matchCreated(final org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test - public void testOneLazyAndOneImmediateSubPathFromLia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOneLazyAndOneImmediateSubPathFromLia(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -330,8 +329,9 @@ public void matchCreated(final org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test - public void testOneLazyAndOneImmediateSubPathAfterLia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOneLazyAndOneImmediateSubPathAfterLia(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "global java.util.List list; \n" + @@ -413,8 +413,9 @@ public void matchCreated(final org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test - public void testOrPropagatesThroughSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrPropagatesThroughSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "global java.util.List list; \n" + @@ -504,8 +505,9 @@ public void matchCancelled(final org.kie.api.event.rule.MatchCancelledEvent even } } - @Test - public void testEagerEvaluationWithSubSubPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEagerEvaluationWithSubSubPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -515,7 +517,7 @@ public void testEagerEvaluationWithSubSubPath() { "then \n" + "end \n"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); @@ -539,8 +541,10 @@ public void matchCreated(final org.kie.api.event.rule.MatchCreatedEvent event) { } } - @Test(timeout = 10000L) - public void testSegMemInitializationWithForceEagerActivation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSegMemInitializationWithForceEagerActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1247 final String drl = "global java.util.List list\n" + "declare SimpleFact end\n" + @@ -571,7 +575,7 @@ public void testSegMemInitializationWithForceEagerActivation() { " list.add(\"2\");\n" + "end"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); ksession.setGlobal( "list", list ); @@ -586,8 +590,10 @@ public void testSegMemInitializationWithForceEagerActivation() { } } - @Test(timeout = 10000L) - public void testSegMemInitializationWithForceEagerActivationAndAcc() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSegMemInitializationWithForceEagerActivationAndAcc(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1247 final String drl = "global java.util.List list\n" + "declare SimpleFact end\n" + @@ -618,7 +624,7 @@ public void testSegMemInitializationWithForceEagerActivationAndAcc() { " list.add(\"2\");\n" + "end"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); ksession.setGlobal( "list", list ); @@ -633,8 +639,10 @@ public void testSegMemInitializationWithForceEagerActivationAndAcc() { } } - @Test(timeout = 10000L) - public void testSegMemInitializationWithForceEagerActivationAndExistsWithNots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSegMemInitializationWithForceEagerActivationAndExistsWithNots(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1247 final String drl = "global java.util.List list\n" + "declare SimpleFact end\n" + @@ -665,7 +673,7 @@ public void testSegMemInitializationWithForceEagerActivationAndExistsWithNots() " list.add(\"2\");\n" + "end"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final List list = new ArrayList<>(); ksession.setGlobal( "list", list ); @@ -680,8 +688,10 @@ public void testSegMemInitializationWithForceEagerActivationAndExistsWithNots() } } - @Test(timeout = 10000L) - public void testNoLoopWithForceEagerActivation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testNoLoopWithForceEagerActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1349 final String drl = "import " + Person.class.getCanonicalName() + "\n" + "\n" + @@ -691,7 +701,7 @@ public void testNoLoopWithForceEagerActivation() { " modify($p) { setAge($p.getAge()+1) };\n" + "end"; - final KieSession ksession = getSessionWithEagerActivation(drl); + final KieSession ksession = getSessionWithEagerActivation(kieBaseTestConfiguration, drl); try { final Person mario = new Person("mario", 42); @@ -704,7 +714,7 @@ public void testNoLoopWithForceEagerActivation() { } } - private KieSession getSessionWithEagerActivation(final String drl) { + private KieSession getSessionWithEagerActivation(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("activate-delete-test", kieBaseTestConfiguration, drl); final KieSessionConfiguration conf = RuleBaseFactory.newKnowledgeSessionConfiguration(); conf.setOption( ForceEagerActivationOption.YES ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNetworkModifyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNetworkModifyTest.java index 95779125b12..d21ede7ac67 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNetworkModifyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNetworkModifyTest.java @@ -18,8 +18,8 @@ */ package org.drools.compiler.integrationtests; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.impl.InternalRuleBase; @@ -31,27 +31,18 @@ import org.drools.testcoverage.common.model.Pet; 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 AlphaNetworkModifyTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AlphaNetworkModifyTest(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 ObjectTypeNode getObjectTypeNode(final KieBase kbase, final String nodeName) { @@ -64,8 +55,9 @@ private ObjectTypeNode getObjectTypeNode(final KieBase kbase, final String nodeN return null; } - @Test - public void testModifyWithLiaToEval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithLiaToEval(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -125,8 +117,9 @@ public void testModifyWithLiaToEval() { } } - @Test - public void testModifyWithLiaToFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithLiaToFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { // technically you can't have a modify with InitialFactImpl // But added test for completeness @@ -176,8 +169,9 @@ public void testModifyWithLiaToFrom() { } } - @Test - public void testModifyWithLiaToAcc() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithLiaToAcc(KieBaseTestConfiguration kieBaseTestConfiguration) { // technically you can't have a modify with InitialFactImpl // But added test for completeness diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeRangeIndexingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeRangeIndexingTest.java index fd8fca1ca01..42820e0ee03 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeRangeIndexingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeRangeIndexingTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.ancompiler.CompiledNetwork; import org.drools.core.reteoo.CompositeObjectSinkAdapter; @@ -37,12 +38,11 @@ import org.drools.testcoverage.common.model.Primitives; 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.util.DateUtils; -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.KieBaseConfiguration; import org.kie.api.KieServices; @@ -54,11 +54,8 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AlphaNodeRangeIndexingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - private static final String BASIC_DRL = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -81,24 +78,20 @@ public class AlphaNodeRangeIndexingTest { " Person( age <= 4 )\n" + "then\n end\n"; - public AlphaNodeRangeIndexingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { //System.setProperty("alphanetworkCompilerEnabled", "true"); - return TestParametersUtil.getKieBaseCloudConfigurations(true); + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testInteger() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInteger(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = BASIC_DRL; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 6, 6, 0, 6); // sinksLength = 6, sinkAdapterSize = 6, rangeIndexableSinks is null, Size of RangeIndexed nodes = 6 + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 6); // sinksLength = 6, sinkAdapterSize = 6, rangeIndexableSinks is null, Size of RangeIndexed nodes = 6 ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); @@ -109,7 +102,7 @@ public void testInteger() { assertThat(fired).isEqualTo(3); } - private KieBase createKieBaseWithRangeIndexThresholdValue(String drl, int rangeIndexThresholdValue) { + private KieBase createKieBaseWithRangeIndexThresholdValue(KieBaseTestConfiguration kieBaseTestConfiguration, String drl, int rangeIndexThresholdValue) { final KieModule kieModule = KieUtil.getKieModuleFromDrls("indexing-test", kieBaseTestConfiguration, drl); final KieContainer kieContainer = KieServices.get().newKieContainer(kieModule.getReleaseId()); final KieBaseConfiguration kieBaseConfiguration = kieBaseTestConfiguration.getKieBaseConfiguration(); @@ -117,12 +110,13 @@ private KieBase createKieBaseWithRangeIndexThresholdValue(String drl, int rangeI return kieContainer.newKieBase(kieBaseConfiguration); } - private void assertSinks(KieBase kbase, Class factClass, int sinksLength, int sinkAdapterSize, int rangeIndexableSinksSize, int rangeIndexSize) { + private void assertSinks(KieBaseTestConfiguration kieBaseTestConfiguration, KieBase kbase, Class factClass, int sinksLength, int sinkAdapterSize, int rangeIndexableSinksSize, int rangeIndexSize + ) { final ObjectTypeNode otn = KieUtil.getObjectTypeNode(kbase, factClass); assertThat(otn).isNotNull(); ObjectSinkPropagator objectSinkPropagator = otn.getObjectSinkPropagator(); - if (this.kieBaseTestConfiguration.useAlphaNetworkCompiler()) { + if (kieBaseTestConfiguration.useAlphaNetworkCompiler()) { objectSinkPropagator = ((CompiledNetwork) objectSinkPropagator).getOriginalSinkPropagator(); } CompositeObjectSinkAdapter sinkAdapter = (CompositeObjectSinkAdapter) objectSinkPropagator; @@ -143,8 +137,9 @@ private void assertSinks(KieBase kbase, Class factClass, int sinksLength, int } } - @Test - public void testNoMatch() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoMatch(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -167,10 +162,10 @@ public void testNoMatch() { " Person( age >= 50 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 6); ksession.insert(new Person("John", 30)); int fired = ksession.fireAllRules(); @@ -181,8 +176,9 @@ public void testNoMatch() { assertThat(fired).isEqualTo(1); } - @Test - public void testDouble() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDouble(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Order.class.getCanonicalName() + "\n" + @@ -205,10 +201,10 @@ public void testDouble() { " Order( total <= 4.0 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Order.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Order.class, 6, 6, 0, 6); Order o1 = new Order(); o1.setTotal(18.0); @@ -223,8 +219,9 @@ public void testDouble() { assertThat(fired).isEqualTo(3); } - @Test - public void testString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testString(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -247,10 +244,10 @@ public void testString() { " Person( name <= \"Paul\" )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 6); ksession.insert(new Person("John")); int fired = ksession.fireAllRules(); @@ -261,8 +258,9 @@ public void testString() { assertThat(fired).isEqualTo(5); } - @Test - public void testBigDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Primitives.class.getCanonicalName() + "\n" + @@ -285,10 +283,10 @@ public void testBigDecimal() { " Primitives( bigDecimal <= 4.0 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Primitives.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Primitives.class, 6, 6, 0, 6); Primitives p1 = new Primitives(); p1.setBigDecimal(new BigDecimal("18.0")); @@ -303,8 +301,9 @@ public void testBigDecimal() { assertThat(fired).isEqualTo(3); } - @Test - public void testNull() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNull(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Primitives.class.getCanonicalName() + "\n" + @@ -327,10 +326,10 @@ public void testNull() { " Primitives( bigDecimal <= 4.0 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Primitives.class, 6, 6, 0, 5); // [bigDecimal >= null] is in OtherSinks + assertSinks(kieBaseTestConfiguration, kbase, Primitives.class, 6, 6, 0, 5); // [bigDecimal >= null] is in OtherSinks Primitives p1 = new Primitives(); p1.setBigDecimal(new BigDecimal("18.0")); @@ -345,8 +344,9 @@ public void testNull() { assertThat(fired).isEqualTo(0); // bigDecimal >= null is false } - @Test - public void testEmpty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmpty(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -369,10 +369,10 @@ public void testEmpty() { " Person( name <= \"Paul\" )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 6); ksession.insert(new Person("John")); int fired = ksession.fireAllRules(); @@ -383,8 +383,9 @@ public void testEmpty() { assertThat(fired).isEqualTo(3); } - @Test - public void testDate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDate(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Order.class.getCanonicalName() + "\n" + @@ -420,10 +421,10 @@ public void testDate() { " results.add(drools.getRule().getName());" + "end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Order.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Order.class, 6, 6, 0, 6); List results = new ArrayList<>(); ksession.setGlobal("results", results); @@ -444,8 +445,9 @@ public void testDate() { assertThat(results).containsOnly("test2", "test3", "test4", "test6"); } - @Test - public void testUnderThreshold() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnderThreshold(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -456,10 +458,10 @@ public void testUnderThreshold() { " Person( age < 25 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 2, 2, 2, 0); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 2, 2, 2, 0); ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); @@ -470,8 +472,9 @@ public void testUnderThreshold() { assertThat(fired).isEqualTo(1); } - @Test - public void testSurroundingRange() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSurroundingRange(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -485,10 +488,10 @@ public void testSurroundingRange() { " Person( age >= 40 && < 60 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 3, 3, 0, 3); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 3, 3, 0, 3); ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); @@ -499,11 +502,12 @@ public void testSurroundingRange() { assertThat(fired).isEqualTo(0); } - @Test - public void testRemoveObjectSink() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveObjectSink(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = BASIC_DRL; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession1 = kbase.newKieSession(); ksession1.insert(new Person("John", 18)); @@ -519,12 +523,12 @@ public void testRemoveObjectSink() { kbase.removeRule("org.drools.compiler.test", "test2"); kbase.removeRule("org.drools.compiler.test", "test3"); - if (this.kieBaseTestConfiguration.useAlphaNetworkCompiler()) { + if (kieBaseTestConfiguration.useAlphaNetworkCompiler()) { // after removeRule, ANC is not recreated return; } - assertSinks(kbase, Person.class, 4, 4, 0, 4); // still above threshold + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 4, 4, 0, 4); // still above threshold final KieSession ksession2 = kbase.newKieSession(); @@ -541,7 +545,7 @@ public void testRemoveObjectSink() { kbase.removeRule("org.drools.compiler.test", "test4"); kbase.removeRule("org.drools.compiler.test", "test5"); - assertSinks(kbase, Person.class, 2, 2, 2, 0); // now under threshold so put back from rangeIndex + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 2, 2, 2, 0); // now under threshold so put back from rangeIndex final KieSession ksession3 = kbase.newKieSession(); @@ -555,8 +559,9 @@ public void testRemoveObjectSink() { ksession3.dispose(); } - @Test - public void testCustomComparable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCustomComparable(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + MyComparableHolder.class.getCanonicalName() + "\n" + @@ -580,11 +585,11 @@ public void testCustomComparable() { " MyComparableHolder( myComparable <= MyComparable.PQR )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); // Doesn't support Object type for range index. See CompositeObjectSinkAdapter.isRangeIndexable() - assertSinks(kbase, MyComparableHolder.class, 6, 6, 0, 0); + assertSinks(kieBaseTestConfiguration, kbase, MyComparableHolder.class, 6, 6, 0, 0); MyComparable abc = new MyComparable("ABC", 1); ksession.insert(new MyComparableHolder(abc)); @@ -597,8 +602,9 @@ public void testCustomComparable() { assertThat(fired).isEqualTo(3); } - @Test - public void testNestedProps() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedProps(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -621,11 +627,11 @@ public void testNestedProps() { " Person( address.number <= 4 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); // Doesn't support nested prop for range index. See CompositeObjectSinkAdapter.isRangeIndexable() - assertSinks(kbase, Person.class, 6, 6, 0, 0); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 0); Person person1 = new Person("John", 18); person1.setAddress(new Address("ABC street", 18, "London")); @@ -640,8 +646,9 @@ public void testNestedProps() { assertThat(fired).isEqualTo(3); } - @Test - public void testMultipleProps() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleProps(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -682,13 +689,13 @@ public void testMultipleProps() { " Person( name <= \"Paul\" )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); final ObjectTypeNode otn = KieUtil.getObjectTypeNode(kbase, Person.class); assertThat(otn).isNotNull(); ObjectSinkPropagator objectSinkPropagator = otn.getObjectSinkPropagator(); - if (this.kieBaseTestConfiguration.useAlphaNetworkCompiler()) { + if (kieBaseTestConfiguration.useAlphaNetworkCompiler()) { objectSinkPropagator = ((CompiledNetwork) objectSinkPropagator).getOriginalSinkPropagator(); } CompositeObjectSinkAdapter sinkAdapter = (CompositeObjectSinkAdapter) objectSinkPropagator; @@ -711,8 +718,9 @@ public void testMultipleProps() { assertThat(fired).isEqualTo(8); } - @Test - public void testModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModify(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -737,10 +745,10 @@ public void testModify() { " modify($p) { setAge(90) }\n" + "end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 6, 6, 0, 6); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 6, 6, 0, 6); ksession.insert(new Person("John", 0)); int fired = ksession.fireAllRules(); @@ -748,8 +756,9 @@ public void testModify() { } - @Test - public void testIncrementalCompilation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementalCompilation(KieBaseTestConfiguration kieBaseTestConfiguration) { // 2 rules under threshold final String drl1 = @@ -809,7 +818,7 @@ public void testIncrementalCompilation() { KieBase kbase = kc.newKieBase(kieBaseConfiguration); KieSession ksession = kbase.newKieSession(); - assertSinks(ksession.getKieBase(), Person.class, 2, 2, 2, 0); + assertSinks(kieBaseTestConfiguration, ksession.getKieBase(), Person.class, 2, 2, 2, 0); ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); @@ -829,7 +838,7 @@ public void testIncrementalCompilation() { kbase = kc.newKieBase(kieBaseConfiguration); ksession = kbase.newKieSession(); - assertSinks(ksession.getKieBase(), Person.class, 6, 6, 0, 6); // now fully indexed + assertSinks(kieBaseTestConfiguration, ksession.getKieBase(), Person.class, 6, 6, 0, 6); // now fully indexed ksession.insert(new Person("Paul", 18)); fired = ksession.fireAllRules(); @@ -849,7 +858,7 @@ public void testIncrementalCompilation() { kbase = kc.newKieBase(kieBaseConfiguration); ksession = kbase.newKieSession(); - assertSinks(ksession.getKieBase(), Person.class, 2, 2, 2, 0); // under threshold so back to rangeIndexableSinks + assertSinks(kieBaseTestConfiguration, ksession.getKieBase(), Person.class, 2, 2, 2, 0); // under threshold so back to rangeIndexableSinks ksession.insert(new Person("George", 18)); fired = ksession.fireAllRules(); @@ -857,8 +866,9 @@ public void testIncrementalCompilation() { ksession.dispose(); } - @Test - public void testDefaultThreshold() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDefaultThreshold(KieBaseTestConfiguration kieBaseTestConfiguration) { // Assuming AlphaRangeIndexThresholdOption.DEFAULT_VALUE == 9 final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -894,16 +904,16 @@ public void testDefaultThreshold() { final KieContainer kieContainer = KieServices.get().newKieContainer(kieModule.getReleaseId()); final KieBase kbase = kieContainer.getKieBase(); - assertSinks(kbase, Person.class, 9, 9, 0, 9); // indexed + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 9, 9, 0, 9); // indexed kbase.removeRule("org.drools.compiler.test", "test9"); - if (this.kieBaseTestConfiguration.useAlphaNetworkCompiler()) { + if (kieBaseTestConfiguration.useAlphaNetworkCompiler()) { // after removeRule, ANC is not recreated return; } - assertSinks(kbase, Person.class, 8, 8, 8, 0); // under threshold so not indexed + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 8, 8, 8, 0); // under threshold so not indexed final KieSession ksession = kbase.newKieSession(); @@ -916,8 +926,9 @@ public void testDefaultThreshold() { assertThat(fired).isEqualTo(3); } - @Test - public void testMixedRangeHashAndOther() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMixedRangeHashAndOther(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List results;\n" + @@ -957,13 +968,13 @@ public void testMixedRangeHashAndOther() { " results.add(drools.getRule().getName());" + "end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); final ObjectTypeNode otn = KieUtil.getObjectTypeNode(kbase, Person.class); assertThat(otn).isNotNull(); ObjectSinkPropagator objectSinkPropagator = otn.getObjectSinkPropagator(); - if (this.kieBaseTestConfiguration.useAlphaNetworkCompiler()) { + if (kieBaseTestConfiguration.useAlphaNetworkCompiler()) { objectSinkPropagator = ((CompiledNetwork) objectSinkPropagator).getOriginalSinkPropagator(); } CompositeObjectSinkAdapter sinkAdapter = (CompositeObjectSinkAdapter) objectSinkPropagator; @@ -988,9 +999,10 @@ public void testMixedRangeHashAndOther() { assertThat(results).containsOnly("test1", "test3", "test4", "test7"); } - @Ignore("No need to test. Fails with standard-drl") - @Test - public void testCoercionStringToNumber() { + @Disabled("No need to test. Fails with standard-drl") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCoercionStringToNumber(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -1004,10 +1016,10 @@ public void testCoercionStringToNumber() { " Person( name > 50 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 3, 3, 0, 0); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 3, 3, 0, 0); ksession.insert(new Person("30")); int fired = ksession.fireAllRules(); @@ -1018,15 +1030,16 @@ public void testCoercionStringToNumber() { assertThat(fired).isEqualTo(1); } - @Test - public void testDifferentNumberOfDigitsInDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentNumberOfDigitsInDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6313 - checkDifferentNumberOfDigitsInDecimal("10"); - checkDifferentNumberOfDigitsInDecimal("10.00"); - checkDifferentNumberOfDigitsInDecimal("10B"); + checkDifferentNumberOfDigitsInDecimal(kieBaseTestConfiguration, "10"); + checkDifferentNumberOfDigitsInDecimal(kieBaseTestConfiguration, "10.00"); + checkDifferentNumberOfDigitsInDecimal(kieBaseTestConfiguration, "10B"); } - private void checkDifferentNumberOfDigitsInDecimal(String value) { + private void checkDifferentNumberOfDigitsInDecimal(KieBaseTestConfiguration kieBaseTestConfiguration, String value) { String drl = "import " + Factor.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -1048,7 +1061,7 @@ private void checkDifferentNumberOfDigitsInDecimal(String value) { " Factor( factorAmt > 10.0 )\n" + "then end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); ksession.insert(new Factor(25.0)); @@ -1068,8 +1081,9 @@ public double getFactorAmt() { } } - @Test - public void testIntegerWithStaticMethodAddedBeforeThreshold() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntegerWithStaticMethodAddedBeforeThreshold(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + StaticUtil.class.getCanonicalName() + "\n" + @@ -1088,21 +1102,22 @@ public void testIntegerWithStaticMethodAddedBeforeThreshold() { final KieBase kbase; - kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); - final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 4, 4, 0, 3); // "age < StaticUtil.getThirty()" is not range indexable + kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); + final KieSession ksession = kbase.newKieSession(); + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 4, 4, 0, 3); // "age < StaticUtil.getThirty()" is not range indexable - ksession.insert(new Person("John", 18)); - int fired = ksession.fireAllRules(); + ksession.insert(new Person("John", 18)); + int fired = ksession.fireAllRules(); assertThat(fired).isEqualTo(4); - ksession.insert(new Person("Paul", 60)); - fired = ksession.fireAllRules(); + ksession.insert(new Person("Paul", 60)); + fired = ksession.fireAllRules(); assertThat(fired).isEqualTo(2); } - @Test - public void testIntegerWithStaticMethodAddedAfterThreshold() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntegerWithStaticMethodAddedAfterThreshold(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + StaticUtil.class.getCanonicalName() + "\n" + @@ -1121,9 +1136,9 @@ public void testIntegerWithStaticMethodAddedAfterThreshold() { final KieBase kbase; - kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 4, 4, 0, 3); // "age < StaticUtil.getThirty()" is not range indexable + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 4, 4, 0, 3); // "age < StaticUtil.getThirty()" is not range indexable ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); @@ -1141,8 +1156,9 @@ public static int getThirty() { } } - @Test - public void testSharedAlpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Person.class.getCanonicalName() + "\n" + "rule test1\n when\n" + @@ -1158,10 +1174,10 @@ public void testSharedAlpha() { " Person( age < 30 )\n" + "then\n end\n"; - final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3); + final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(kieBaseTestConfiguration, drl, 3); final KieSession ksession = kbase.newKieSession(); - assertSinks(kbase, Person.class, 3, 3, 0, 3); // sinksLength = 3, sinkAdapterSize = 3, rangeIndexableSinks is null, Size of RangeIndexed nodes = 3 + assertSinks(kieBaseTestConfiguration, kbase, Person.class, 3, 3, 0, 3); // sinksLength = 3, sinkAdapterSize = 3, rangeIndexableSinks is null, Size of RangeIndexed nodes = 3 ksession.insert(new Person("John", 18)); int fired = ksession.fireAllRules(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeSharingWithDiffPackageNameTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeSharingWithDiffPackageNameTest.java index e18420490b0..fcad9bb8929 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeSharingWithDiffPackageNameTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaNodeSharingWithDiffPackageNameTest.java @@ -1,5 +1,5 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one +3 * 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 @@ -18,33 +18,24 @@ */ package org.drools.compiler.integrationtests; -import java.util.Collection; import java.util.HashSet; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import static org.assertj.core.api.Assertions.assertThat; 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; // DROOLS-1010 -@RunWith(Parameterized.class) public class AlphaNodeSharingWithDiffPackageNameTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AlphaNodeSharingWithDiffPackageNameTest(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(); } public static class TypeA { @@ -200,8 +191,9 @@ public static class TypeE { " update($a);\r\n" + "end;"; - @Test - public void testAlphaNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaNode(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("alpha-node-sharing-test", kieBaseTestConfiguration, rule1, rule2, rule3, rule4); final KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaTest.java index ba9b198931a..1e1c5bcb84e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AlphaTest.java @@ -19,18 +19,17 @@ package org.drools.compiler.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.model.Cheesery; 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.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; @@ -38,22 +37,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AlphaTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AlphaTest(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 testAlphaExpression() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Person.class.getCanonicalName() + ";\n" + "rule \"alpha\"\n" + @@ -73,8 +65,9 @@ public void testAlphaExpression() { } } - @Test - public void testAlphaNodeSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -116,8 +109,9 @@ public void testAlphaNodeSharing() { } } - @Test - public void testAlphaCompositeConstraints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaCompositeConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -147,8 +141,9 @@ public void testAlphaCompositeConstraints() { } } - @Test - public void testAlphaHashingWithConstants() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaHashingWithConstants(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3658 final String drl = "import " + Person.class.getName() + ";\n" + "rule R1 when\n" + @@ -171,8 +166,9 @@ public void testAlphaHashingWithConstants() { } } - @Test - public void testNPEOnMVELAlphaPredicates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNPEOnMVELAlphaPredicates(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/BackwardChainingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/BackwardChainingTest.java index a0fd4c1212f..d8655c94ac1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/BackwardChainingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/BackwardChainingTest.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.incrementalcompilation.TestUtil; import org.drools.base.InitialFact; @@ -54,10 +55,10 @@ import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.SerializationHelper; -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; @@ -81,20 +82,16 @@ import static org.assertj.core.api.Assertions.fail; import static org.kie.api.runtime.rule.Variable.v; -@RunWith(Parameterized.class) public class BackwardChainingTest extends AbstractBackwardChainingTest { - public BackwardChainingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(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(timeout = 10000) - public void testQueryPatternBindingAsResult() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryPatternBindingAsResult(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { String str = "" + "package org.drools.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -172,8 +169,10 @@ public void testQueryPatternBindingAsResult() throws IOException, ClassNotFoundE } } - @Test(timeout = 10000) - public void testQueriesWithNestedAccessorsAllOutputs() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueriesWithNestedAccessorsAllOutputs(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { String drl = "" + "package org.drools.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -221,8 +220,10 @@ public void testQueriesWithNestedAccessorsAllOutputs() throws IOException, Class } } - @Test(timeout = 10000) - public void testQueriesWithNestedAcecssorsMixedArgs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueriesWithNestedAcecssorsMixedArgs(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "" + "package org.drools.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -274,8 +275,10 @@ public void testQueriesWithNestedAcecssorsMixedArgs() { } } - @Test(timeout = 10000) - public void testQueryWithDynamicData() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithDynamicData(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { String drl = "" + "package org.drools.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -326,8 +329,10 @@ public void testQueryWithDynamicData() throws IOException, ClassNotFoundExceptio } } - @Test(timeout = 10000) - public void testQueryWithDyanmicInsert() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithDyanmicInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { String drl = "" + "package org.drools.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -376,8 +381,10 @@ public void testQueryWithDyanmicInsert() throws IOException, ClassNotFoundExcept } } - @Test(timeout = 10000) - public void testQueryWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.compiler.test \n" + @@ -494,8 +501,10 @@ public void testQueryWithOr() { } } - @Test(timeout = 10000) - public void testGeneology() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testGeneology(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { // from http://kti.mff.cuni.cz/~bartak/prolog/genealogy.html final String drl = "" + @@ -795,8 +804,10 @@ public void testGeneology() throws IOException, ClassNotFoundException { } } - @Test(timeout = 10000) - public void testDynamicRulesWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRulesWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "" + "package org.drools.compiler.test1 \n" + "\n" + @@ -942,8 +953,10 @@ public void testDynamicRulesWithSharing() { } } - @Test(timeout = 10000) - public void testOpenBackwardChain() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testOpenBackwardChain(KieBaseTestConfiguration kieBaseTestConfiguration) { // http://www.amzi.com/AdventureInProlog/advtop.php final String drl = "" + @@ -1124,8 +1137,10 @@ public void testOpenBackwardChain() { } } - @Test(timeout = 10000) - public void testCompile() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCompile(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "declare Location\n" + "thing : String\n" + "location : String\n" @@ -1139,8 +1154,10 @@ public void testCompile() { KieBaseUtil.getKieBaseFromKieModuleFromDrl("backward-chaining-test", kieBaseTestConfiguration, drl); } - @Test(timeout = 10000) - public void testInsertionOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testInsertionOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.compiler.integrationtests \n" + @@ -1245,15 +1262,17 @@ public void testInsertionOrder() { } } - @Test(timeout = 10000) - public void testQueryFindAll() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryFindAll(KieBaseTestConfiguration kieBaseTestConfiguration) { final Object[] objects = new Object[]{42, "a String", 100}; final int oCount = objects.length; final List queryList = new ArrayList<>(); final List ruleList = new ArrayList<>(); // expect all inserted objects + InitialFact - runTestQueryFindAll(0, queryList, ruleList, objects); + runTestQueryFindAll(kieBaseTestConfiguration, 0, queryList, ruleList, objects); assertThat(queryList.size()).isEqualTo(oCount); assertContains(objects, queryList); @@ -1261,16 +1280,17 @@ public void testQueryFindAll() { // expect inserted objects + InitialFact queryList.clear(); ruleList.clear(); - runTestQueryFindAll(1, queryList, ruleList, objects); + runTestQueryFindAll(kieBaseTestConfiguration, 1, queryList, ruleList, objects); assertThat(queryList.size()).isEqualTo(oCount * oCount); queryList.clear(); ruleList.clear(); - runTestQueryFindAll(2, queryList, ruleList, objects); + runTestQueryFindAll(kieBaseTestConfiguration, 2, queryList, ruleList, objects); assertThat(queryList.size()).isEqualTo(oCount * oCount); } - private void runTestQueryFindAll(final int iCase, + private void runTestQueryFindAll(KieBaseTestConfiguration kieBaseTestConfiguration, + final int iCase, final List queryList, final List ruleList, final Object[] objects) { @@ -1326,8 +1346,10 @@ private void runTestQueryFindAll(final int iCase, } } - @Test(timeout = 10000) - public void testQueryWithObject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithObject(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.compiler.test \n" + @@ -1653,8 +1675,10 @@ public boolean equals(final Object obj) { } } - @Test(timeout = 10000) - public void testQueryWithClassLiterals() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithClassLiterals(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.test \n" + @@ -1701,8 +1725,10 @@ public void testQueryWithClassLiterals() { } } - @Test(timeout = 10000) - public void testQueryIndexingWithUnification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryIndexingWithUnification(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.test \n" + @@ -1753,8 +1779,10 @@ public void testQueryIndexingWithUnification() { } } - @Test(timeout = 10000) - public void testQueryWithEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testQueryWithEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.List list; " + "" + "declare Inner\n" + @@ -1792,8 +1820,10 @@ public void testQueryWithEvents() { } } - @Test(timeout = 10000) - public void testNpeOnQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testNpeOnQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.List list; " + "query foo( Integer $i ) " + @@ -1844,8 +1874,9 @@ public void testNpeOnQuery() { } } - @Test - public void testQueryWithEvalAndTypeBoxingUnboxing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithEvalAndTypeBoxingUnboxing(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.test;\n" + "\n" + "global java.util.List list \n;" + @@ -1908,18 +1939,20 @@ public void testQueryWithEvalAndTypeBoxingUnboxing() { ksession.dispose(); } } - @Test - public void testNaniSearchsNoPropReactivity() throws IOException, ClassNotFoundException { - testNaniSearchs( PropertySpecificOption.ALLOWED); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNaniSearchsNoPropReactivity(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { + testNaniSearchs(kieBaseTestConfiguration, PropertySpecificOption.ALLOWED); } - @Test - public void testNaniSearchsWithPropReactivity() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNaniSearchsWithPropReactivity(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { // DROOLS-1453 - testNaniSearchs(PropertySpecificOption.ALWAYS); + testNaniSearchs(kieBaseTestConfiguration, PropertySpecificOption.ALWAYS); } - private void testNaniSearchs(final PropertySpecificOption propertySpecificOption) throws IOException, ClassNotFoundException { + private void testNaniSearchs(KieBaseTestConfiguration kieBaseTestConfiguration, final PropertySpecificOption propertySpecificOption) throws IOException, ClassNotFoundException { // http://www.amzi.com/AdventureInProlog/advtop.php final String drl = "" + @@ -2168,8 +2201,9 @@ private void testNaniSearchs(final PropertySpecificOption propertySpecificOption } } - @Test //(timeout = 10000) - public void testSubNetworksAndQueries() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworksAndQueries(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "" + "package org.drools.compiler.test \n" + @@ -2358,8 +2392,10 @@ public void rowInserted(final Row row) { } } - @Test(timeout = 10000) - public void testInsertionOrderTwo() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testInsertionOrderTwo(KieBaseTestConfiguration kieBaseTestConfiguration) { final StringBuilder drlBuilder = new StringBuilder("" + "package org.drools.compiler.test \n" + "import java.util.List \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CellTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CellTest.java index 84f45b99538..c5d5cc51854 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CellTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CellTest.java @@ -18,34 +18,28 @@ */ package org.drools.compiler.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Cell; 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 CellTest extends AbstractCellTest { - public CellTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(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 testFreeFormExpressions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFreeFormExpressions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + Cell.class.getCanonicalName() + "\n" + "rule r1\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspNegativeCloudTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspNegativeCloudTest.java index e5d497cebc4..3fd9a12878e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspNegativeCloudTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspNegativeCloudTest.java @@ -45,7 +45,7 @@ public static Stream parameters() { return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") @Timeout(10000) public void testCloudModeExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException, InterruptedException { @@ -99,7 +99,7 @@ public void testCloudModeExpiration(KieBaseTestConfiguration kieBaseTestConfigur } } - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") public void testThrowsWhenCreatingKieBaseUsingWindowsInCloudMode(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = @@ -121,7 +121,7 @@ public void testThrowsWhenCreatingKieBaseUsingWindowsInCloudMode(KieBaseTestConf } } - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") public void testTemporalQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-967441 diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java index 9e5795baf7c..5d4c5e8be0c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -43,6 +42,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.core.WorkingMemory; import org.drools.base.base.ClassObjectType; @@ -71,13 +71,13 @@ import org.drools.testcoverage.common.util.KieSessionTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.SerializationHelper; -import org.drools.testcoverage.common.util.TestParametersUtil; +import org.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.testcoverage.common.util.TimeUtil; import org.drools.util.DateUtils; -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.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; @@ -106,20 +106,16 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class CepEspTest extends AbstractCepEspTest { - public CepEspTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); - } - - @Test(timeout=10000) - public void testComplexTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testComplexTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package " + Message.class.getPackage().getName() + "\n" + "declare " + Message.class.getCanonicalName() + "\n" + " @role( event ) \n" + @@ -144,8 +140,10 @@ public void testComplexTimestamp() { } } - @Test(timeout=10000) - public void testJavaSqlTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testJavaSqlTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package " + Message.class.getPackage().getName() + "\n" + "declare " + Message.class.getCanonicalName() + "\n" + " @role( event ) \n" + @@ -168,8 +166,10 @@ public void testJavaSqlTimestamp() { } } - @Test(timeout=10000) - public void testEventAssertion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventAssertion(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleEventAssertion.drl"); final KieSession session = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -212,8 +212,10 @@ public void testEventAssertion() { } } - @Test(timeout=10000) - public void testAnnotatedEventAssertion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAnnotatedEventAssertion(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test;\n" + "\n" + @@ -270,8 +272,10 @@ public void testAnnotatedEventAssertion() { } @SuppressWarnings("unchecked") - @Test(timeout=10000) - public void testPackageSerializationWithEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPackageSerializationWithEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleEventAssertion.drl"); final KieSession session = kbase.newKieSession(); @@ -301,8 +305,10 @@ public void testPackageSerializationWithEvents() { } } - @Test(timeout=10000) - public void testEventAssertionWithDuration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventAssertionWithDuration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -372,8 +378,10 @@ public void testEventAssertionWithDuration() { } } - @Test(timeout=10000) - public void testEventAssertionWithDateTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventAssertionWithDateTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -437,8 +445,10 @@ public void testEventAssertionWithDateTimestamp() { } } - @Test(timeout = 10000) - public void testEventExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List results;\n" + @@ -462,17 +472,21 @@ public void testEventExpiration() { assertThat(factType.getExpirationOffset()).isEqualTo(TimeIntervalParser.parse("1h30m")[0]); } - @Test(timeout = 10000) - public void testEventExpiration2() { - testEventExpiration("15m", "15m"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpiration2(KieBaseTestConfiguration kieBaseTestConfiguration) { + testEventExpiration(kieBaseTestConfiguration, "15m", "15m"); } - @Test(timeout = 10000) - public void testEventExpiration3() { - testEventExpiration("5m", "5m"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpiration3(KieBaseTestConfiguration kieBaseTestConfiguration) { + testEventExpiration(kieBaseTestConfiguration, "5m", "5m"); } - private void testEventExpiration(final String afterBoundary, final String windowTime) { + private void testEventExpiration(KieBaseTestConfiguration kieBaseTestConfiguration, final String afterBoundary, final String windowTime) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List results;\n" + @@ -510,8 +524,10 @@ private void testEventExpiration(final String afterBoundary, final String window assertThat(node.getExpirationOffset()).isEqualTo(TimeIntervalParser.parse("10m")[0] + 1); } - @Test(timeout = 10000) - public void testEventExpiration4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpiration4(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List results;\n" + @@ -558,8 +574,10 @@ public void testEventExpiration4() { } } - @Test(timeout = 10000) - public void testTimeRelationalOperators() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimeRelationalOperators(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_TimeRelationalOperators.drl"); final KieSession wm = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -683,8 +701,10 @@ public void testTimeRelationalOperators() { } } - @Test(timeout = 10000) - public void testBeforeOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testBeforeOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_BeforeOperator.drl"); final KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -729,8 +749,10 @@ public void testBeforeOperator() { } } - @Test(timeout = 10000) - public void testMetByOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMetByOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_MetByOperator.drl"); final KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -775,8 +797,10 @@ public void testMetByOperator() { } } - @Test(timeout = 10000) - public void testComplexOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testComplexOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_ComplexOperator.drl"); final KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -819,22 +843,28 @@ public void testComplexOperator() { } } - @Test(timeout = 10000) - public void testAfterOnArbitraryDates() { - testArbitraryDates("org/drools/compiler/integrationtests/test_CEP_AfterOperatorDates.drl", 100000, 104000); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAfterOnArbitraryDates(KieBaseTestConfiguration kieBaseTestConfiguration) { + testArbitraryDates(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_AfterOperatorDates.drl", 100000, 104000); } - @Test(timeout = 10000) - public void testBeforeOnArbitraryDates() { - testArbitraryDates("org/drools/compiler/integrationtests/test_CEP_BeforeOperatorDates.drl", 104000, 100000); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testBeforeOnArbitraryDates(KieBaseTestConfiguration kieBaseTestConfiguration) { + testArbitraryDates(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_BeforeOperatorDates.drl", 104000, 100000); } - @Test(timeout = 10000) - public void testCoincidesOnArbitraryDates() { - testArbitraryDates("org/drools/compiler/integrationtests/test_CEP_CoincidesOperatorDates.drl", 100000, 100050); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCoincidesOnArbitraryDates(KieBaseTestConfiguration kieBaseTestConfiguration) { + testArbitraryDates(kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_CoincidesOperatorDates.drl", 100000, 100050); } - private void testArbitraryDates(final String drlClasspathResource, final long tick1Time, final long tick2Time) { + private void testArbitraryDates(KieBaseTestConfiguration kieBaseTestConfiguration, final String drlClasspathResource, final long tick1Time, final long tick2Time) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, drlClasspathResource); final KieSession wm = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); try { @@ -866,8 +896,10 @@ private void testArbitraryDates(final String drlClasspathResource, final long ti } } - @Test(timeout = 10000) - public void testSimpleTimeWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSimpleTimeWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleTimeWindow.drl"); final KieSession wm = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -947,8 +979,10 @@ public void testSimpleTimeWindow() { } } - @Test(timeout = 10000) - public void testSimpleLengthWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSimpleLengthWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleLengthWindow.drl"); final KieSession wm = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -1001,8 +1035,10 @@ public void testSimpleLengthWindow() { } } - @Test(timeout = 10000) - public void testDelayingNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDelayingNot(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List results;\n" + @@ -1062,8 +1098,10 @@ public void testDelayingNot() { } } - @Test(timeout = 10000) - public void testSimpleLengthWindowWithQueue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSimpleLengthWindowWithQueue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleLengthWindow.drl"); KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -1109,8 +1147,10 @@ public void testSimpleLengthWindowWithQueue() throws Exception { } } - @Test(timeout=10000) - public void testDelayingNot2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDelayingNot2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "declare A @role(event) symbol : String end\n" + "declare B @role(event) symbol : String end\n" + @@ -1136,8 +1176,10 @@ public void testDelayingNot2() { } - @Test(timeout=10000) - public void testDelayingNotWithPreEpochClock() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDelayingNotWithPreEpochClock(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "declare A @role(event) symbol : String end\n" + "declare B @role(event) symbol : String end\n" + @@ -1170,8 +1212,10 @@ public void testDelayingNotWithPreEpochClock() { } } - @Test(timeout = 10000) - public void testIdleTime() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIdleTime(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleEventAssertion.drl"); final KieSession session = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -1223,8 +1267,10 @@ public void testIdleTime() { } } - @Test(timeout = 10000) - public void testIdleTimeAndTimeToNextJob() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIdleTimeAndTimeToNextJob(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_SimpleTimeWindow.drl"); final StatefulKnowledgeSessionImpl wm = @@ -1306,8 +1352,10 @@ public void testIdleTimeAndTimeToNextJob() { } } - @Test(timeout = 10000) - public void testCollectWithWindows() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCollectWithWindows(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration, "org/drools/compiler/integrationtests/test_CEP_CollectWithWindows.drl"); final KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); @@ -1385,8 +1433,10 @@ public void testCollectWithWindows() { } } - @Test(timeout = 10000) - public void testPseudoSchedulerRemoveJobTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPseudoSchedulerRemoveJobTest(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + CepEspTest.class.getName() + ".A\n" + "declare A\n" + " @role( event )\n" + @@ -1443,8 +1493,10 @@ public void setDuration(final Long duration) { } } - @Test(timeout = 10000) - public void testEventDeclarationForInterfaces() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventDeclarationForInterfaces(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + "\n" + "declare StockTick \n" + @@ -1480,8 +1532,10 @@ public void testEventDeclarationForInterfaces() { } } - @Test(timeout = 10000) - public void testTemporalOperators() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTemporalOperators(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "declare StockTick \n" + @@ -1507,8 +1561,10 @@ public void testTemporalOperators() { } } - @Test(timeout = 10000) - public void testTemporalOperators2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTemporalOperators2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -1552,8 +1608,10 @@ public void testTemporalOperators2() { } } - @Test(timeout = 10000) - public void testTemporalOperatorsInfinity() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTemporalOperatorsInfinity(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -1597,8 +1655,10 @@ public void testTemporalOperatorsInfinity() { } } - @Test (timeout=10000) - public void testMultipleSlidingWindows() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMultipleSlidingWindows(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "declare A\n" + " @role( event )\n" + " id : int\n" + @@ -1663,8 +1723,10 @@ public void testMultipleSlidingWindows() { } } - @Test(timeout=10000) - public void testSalienceWithEventsPseudoClock() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSalienceWithEventsPseudoClock(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getName() + "\n" + "declare StockTick\n" + @@ -1721,8 +1783,10 @@ public void testSalienceWithEventsPseudoClock() { } } - @Test(timeout=10000) - public void testSalienceWithEventsRealtimeClock() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSalienceWithEventsRealtimeClock(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.compiler\n" + "import " + StockTick.class.getName() + "\n" + "declare StockTick\n" + @@ -1777,8 +1841,10 @@ public void testSalienceWithEventsRealtimeClock() throws InterruptedException { } } - @Test(timeout=10000) - public void testExpireEventOnEndTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testExpireEventOnEndTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-40 final String drl = "package org.drools.compiler;\n" + @@ -1819,8 +1885,10 @@ public void testExpireEventOnEndTimestamp() { } } - @Test(timeout=10000) - public void testEventExpirationDuringAccumulate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpirationDuringAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-70 final String drl = "package org.drools.integrationtests\n" + @@ -1923,8 +1991,10 @@ private Object createDRLStock(final String name, final Double value) } } - @Test(timeout=10000) - public void testEventExpirationInSlidingWindow() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEventExpirationInSlidingWindow(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-70 final String drl = "package org.drools.integrationtests\n" + @@ -1967,8 +2037,10 @@ public void testEventExpirationInSlidingWindow() throws Exception { } } - @Test(timeout=10000) - public void testSlidingWindowsAccumulateExternalJoin() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSlidingWindowsAccumulateExternalJoin(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-106 // The logic may not be optimal, but was used to detect a WM corruption final String drl = @@ -2030,8 +2102,10 @@ public void testSlidingWindowsAccumulateExternalJoin() { } } - @Test (timeout=10000) - public void testTimeAndLengthWindowConflict() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimeAndLengthWindowConflict(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3671 final String drl = "package org.drools.compiler;\n" + "import java.util.List\n" + @@ -2100,8 +2174,9 @@ public void testTimeAndLengthWindowConflict() { } } - @Test - public void testTimeStampOnNonExistingField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTimeStampOnNonExistingField(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-985942 final String drl = "package org.drools.compiler;\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -2114,8 +2189,10 @@ public void testTimeStampOnNonExistingField() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test (timeout=10000) - public void testTimeWindowWithPastEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimeWindowWithPastEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-2258 final String drl = "package org.drools.compiler;\n" + "import java.util.List\n" + @@ -2180,8 +2257,9 @@ public void testTimeWindowWithPastEvents() { } } - @Test - public void testLeakingActivationsWithDetachedExpiredNonCancelling() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLeakingActivationsWithDetachedExpiredNonCancelling(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3558 - DROOLS 311 // TODO: it is still possible to get multiple insertions of the Recording object // if you set the @expires of Motion to 1ms, maybe because the event expires too soon @@ -2235,8 +2313,10 @@ public void testLeakingActivationsWithDetachedExpiredNonCancelling() throws Exce } } - @Test(timeout=10000) - public void testTwoWindowsInsideCEAndOut() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTwoWindowsInsideCEAndOut(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler;\n" + "import java.util.List\n" + "import " + OrderEvent.class.getCanonicalName() + ";\n" + @@ -2271,8 +2351,9 @@ public void testTwoWindowsInsideCEAndOut() { } } - @Test - public void testUpdateEventThroughEntryPoint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateEventThroughEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + CepEspTest.TestEvent.class.getCanonicalName() + "\n" + "\n" + "declare TestEvent\n" + @@ -2326,8 +2407,9 @@ public String toString() { } } - @Test - public void testStreamModeWithSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStreamModeWithSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1009348 final String drl = "package org.drools.compiler.integrationtests\n" + @@ -2405,8 +2487,9 @@ public String toString() { } } - @Test - public void testEventTimestamp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-268 final String drl = "\n" + "import " + CepEspTest.Event.class.getCanonicalName() + "; \n" + @@ -2473,8 +2556,9 @@ public void testEventTimestamp() { } } - @Test - public void testEventTimestamp2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventTimestamp2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-268 final String drl = "\n" + "import " + CepEspTest.Event.class.getCanonicalName() + ";\n" + @@ -2530,8 +2614,9 @@ public void testEventTimestamp2() { } } - @Test - public void testModifyInStreamMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyInStreamMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1012933 final String drl = "import " + CepEspTest.SimpleFact.class.getCanonicalName() + ";\n" + @@ -2565,8 +2650,9 @@ public void testModifyInStreamMode() { } } - @Test - public void testCollectAfterRetract() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAfterRetract(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1015109 final String drl = "import " + CepEspTest.SimpleFact.class.getCanonicalName() + ";\n" + @@ -2611,8 +2697,9 @@ public void testCollectAfterRetract() { } } - @Test - public void testCollectAfterUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAfterUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-295 final String drl = "import " + CepEspTest.SimpleFact.class.getCanonicalName() + ";\n" + @@ -2730,9 +2817,10 @@ public static class ProbeCounter { public void addValue () { total += 1; } } - @Test - @Ignore - public void testExpirationAtHighRates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testExpirationAtHighRates(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-130 final String drl = "package droolsfusioneval\n" + "" + @@ -2790,8 +2878,9 @@ public void testExpirationAtHighRates() { } - @Test - public void AfterOperatorInCEPQueryTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void AfterOperatorInCEPQueryTest(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools;\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -2850,8 +2939,9 @@ public void AfterOperatorInCEPQueryTest() { } } - @Test - public void testFromWithEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromWithEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "\n" + "\n" + "package org.drools.test\n" + @@ -2902,8 +2992,9 @@ public void testFromWithEvents() { } } - @Test - public void testDeserializationWithTrackableTimerJob() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeserializationWithTrackableTimerJob(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.test;\n" + "import " + StockTick.class.getCanonicalName() + "; \n" + "global java.util.List list;\n" + @@ -2959,8 +3050,9 @@ public void testDeserializationWithTrackableTimerJob() throws InterruptedExcepti } } - @Test - public void testDeserializationWithTrackableTimerJobShortExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeserializationWithTrackableTimerJobShortExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.test;\n" + "import " + StockTick.class.getCanonicalName() + "; \n" + "global java.util.List list;\n" + @@ -2994,8 +3086,9 @@ public void testDeserializationWithTrackableTimerJobShortExpiration() { } } - @Test - public void testDeserializationWithExpiringEventAndAccumulate() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeserializationWithExpiringEventAndAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.test;\n" + "import " + StockTick.class.getCanonicalName() + "; \n" + "global java.util.List list;\n" + @@ -3043,8 +3136,9 @@ public void testDeserializationWithExpiringEventAndAccumulate() throws Interrupt } } - @Test - public void testDeserializationWithCompositeTrigger() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeserializationWithCompositeTrigger(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.test;\n" + "import " + StockTick.class.getCanonicalName() + "; \n" + "global java.util.List list;\n" + @@ -3080,8 +3174,9 @@ public void testDeserializationWithCompositeTrigger() { } } - @Test - public void testWindowExpireActionDeserialization() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWindowExpireActionDeserialization(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "package org.drools.test;\n" + "import " + StockTick.class.getCanonicalName() + "; \n" + "global java.util.List list; \n" + @@ -3126,8 +3221,9 @@ public void testWindowExpireActionDeserialization() throws InterruptedException } } - @Test - public void testDuplicateFiring1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateFiring1(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.test;\n" + "import " + StockTick.class.getCanonicalName() + ";\n " + @@ -3185,8 +3281,9 @@ public void testDuplicateFiring1() { } } - @Test - public void testPastEventExipration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPastEventExipration(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-257 final String drl = "package org.test;\n" + "import " + StockTick.class.getCanonicalName() + ";\n " + @@ -3246,8 +3343,9 @@ public static class MyEvent { public String toString() { return "MyEvent{" + "timestamp=" + timestamp + '}'; } } - @Test - public void testEventStreamWithEPsAndDefaultPseudo() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventStreamWithEPsAndDefaultPseudo(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-286 final String drl = "\n" + "import java.util.*;\n" + @@ -3356,8 +3454,9 @@ public void testEventStreamWithEPsAndDefaultPseudo() { } } - @Test - public void testExpirationOnModification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpirationOnModification(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-374 final String drl = "\n" + "import java.util.*;\n" + @@ -3418,8 +3517,9 @@ public void testExpirationOnModification() { } } - @Test - public void testTemporalEvaluatorsWithEventsFromNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalEvaluatorsWithEventsFromNode(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-421 final String drl = "\n" + "import java.util.*; " + @@ -3457,11 +3557,12 @@ public void testTemporalEvaluatorsWithEventsFromNode() { ""; - testTemporalEvaluators(drl); + testTemporalEvaluators(kieBaseTestConfiguration, drl); } - @Test - public void testTemporalEvaluatorsUsingRawDateFields() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalEvaluatorsUsingRawDateFields(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-421 final String drl = "\n" + "import java.util.*; " + @@ -3496,11 +3597,12 @@ public void testTemporalEvaluatorsUsingRawDateFields() { ""; - testTemporalEvaluators(drl); + testTemporalEvaluators(kieBaseTestConfiguration, drl); } - @Test - public void testTemporalEvaluatorsUsingRawDateFieldsFromFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalEvaluatorsUsingRawDateFieldsFromFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-421 final String drl = "\n" + "import java.util.*; " + @@ -3524,11 +3626,12 @@ public void testTemporalEvaluatorsUsingRawDateFieldsFromFrom() { ""; - testTemporalEvaluators(drl); + testTemporalEvaluators(kieBaseTestConfiguration, drl); } - @Test - public void testTemporalEvaluatorsUsingSelfDates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalEvaluatorsUsingSelfDates(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-421 final String drl = "\n" + "import java.util.*; " + @@ -3550,10 +3653,10 @@ public void testTemporalEvaluatorsUsingSelfDates() { ""; - testTemporalEvaluators(drl); + testTemporalEvaluators(kieBaseTestConfiguration, drl); } - private void testTemporalEvaluators(final String drl) { + private void testTemporalEvaluators(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("cep-esp-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); try { @@ -3570,8 +3673,9 @@ private void testTemporalEvaluators(final String drl) { } } - @Test - public void testEventOffsetExpirationOverflow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventOffsetExpirationOverflow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-455 final String drl = "\n" + "import java.util.*; " + @@ -3634,8 +3738,9 @@ public Date getTimestamp() { } } - @Test - public void testExpiredEventModification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpiredEventModification(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1082990 final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "import java.util.Date\n" + @@ -3712,8 +3817,9 @@ public String toString() { } } - @Test - public void testTemporalOperatorWithConstant() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorWithConstant(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1096243 final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "import java.util.Date\n" + @@ -3748,8 +3854,9 @@ public void testTemporalOperatorWithConstant() { } } - @Test - public void testTemporalOperatorWithConstantAndJoin() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorWithConstantAndJoin(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ 1096243 final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "import java.util.Date\n" + @@ -3787,8 +3894,9 @@ public void testTemporalOperatorWithConstantAndJoin() { } } - @Test - public void testDynamicSalienceInStreamMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicSalienceInStreamMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-526 final String drl = "import java.util.concurrent.atomic.AtomicInteger;\n" + @@ -3840,8 +3948,9 @@ public void testDynamicSalienceInStreamMode() { } } - @Test - public void test2NotsWithTemporalConstraints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2NotsWithTemporalConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1122738 DROOLS-479 final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "import java.util.Date\n" + @@ -3882,8 +3991,9 @@ public void test2NotsWithTemporalConstraints() { } } - @Test - public void testRetractFromWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetractFromWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-636 final String drl = "import " + StockTick.class.getCanonicalName() + ";\n " + @@ -3912,8 +4022,9 @@ public void testRetractFromWindow() { } } - @Test - public void testCEPNamedCons() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCEPNamedCons(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools " + @@ -3985,8 +4096,9 @@ public void testCEPNamedCons() { } } - @Test - public void testCEPNamedConsTimers() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCEPNamedConsTimers(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools " + @@ -4037,8 +4149,9 @@ public void testCEPNamedConsTimers() { } } - @Test - public void test2TimersWithNamedCons() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2TimersWithNamedCons(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools " + "global java.util.List list; " + @@ -4065,11 +4178,12 @@ public void test2TimersWithNamedCons() { " list.add( 1 );\n" + "end\n"; - test2Timers(drl); + test2Timers(kieBaseTestConfiguration, drl); } - @Test - public void test2TimersWith2Rules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2TimersWith2Rules(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools " + "global java.util.List list; " + @@ -4100,10 +4214,10 @@ public void test2TimersWith2Rules() { " list.add( 1 );\n" + "end\n"; - test2Timers(drl); + test2Timers(kieBaseTestConfiguration, drl); } - private void test2Timers(final String drl) { + private void test2Timers(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("cep-esp-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(), null); try { @@ -4124,8 +4238,9 @@ private void test2Timers(final String drl) { } } - @Test - public void testCEPWith2NamedConsAndEagerRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCEPWith2NamedConsAndEagerRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools " + "global java.util.List list; " + @@ -4183,8 +4298,9 @@ public void testCEPWith2NamedConsAndEagerRule() { } } - @Test - public void testExpireLogicalEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpireLogicalEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools; " + "declare Foo " + " @role(event) " + @@ -4211,8 +4327,9 @@ public void testExpireLogicalEvent() { } } - @Test - public void testSerializationWithEventInPast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializationWithEventInPast(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-749 final String drl = "import " + Event1.class.getCanonicalName() + "\n" + @@ -4272,8 +4389,9 @@ public String toString() { } } - @Test - public void testUseMapAsEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUseMapAsEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-753 final String drl = "import java.util.Map\n " + @@ -4298,8 +4416,9 @@ public void testUseMapAsEvent() { } } - @Test - public void testDisconnectedEventFactHandle() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDisconnectedEventFactHandle(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-924 final String drl = "declare String \n"+ @@ -4324,8 +4443,10 @@ public void testDisconnectedEventFactHandle() { } } - @Test(timeout = 5000) - public void testEventWithShortExpiration() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testEventWithShortExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-921 final String drl = "declare String\n" + " @expires( 1ms )\n" + @@ -4357,8 +4478,9 @@ public void testEventWithShortExpiration() throws InterruptedException { } } - @Test - public void testDeleteExpiredEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1274696 final String drl = "import " + StockTick.class.getCanonicalName() + "\n" + @@ -4393,8 +4515,9 @@ public void testDeleteExpiredEvent() { } } - @Test - public void testDeleteExpiredEventWithTimestampAndEqualityKey() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteExpiredEventWithTimestampAndEqualityKey(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1017 final String drl = "import " + StockTick.class.getCanonicalName() + "\n" + @@ -4429,8 +4552,9 @@ public void testDeleteExpiredEventWithTimestampAndEqualityKey() { } } - @Test - public void testSerializationWithWindowLength() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializationWithWindowLength(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-953 final String drl = "import " + StockTick.class.getCanonicalName() + "\n" + @@ -4476,8 +4600,9 @@ public void testSerializationWithWindowLength() { } } - @Test - public void testSerializationWithWindowLengthAndLiaSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializationWithWindowLengthAndLiaSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-953 final String drl = "import " + StockTick.class.getCanonicalName() + "\n" + @@ -4529,8 +4654,9 @@ public void testSerializationWithWindowLengthAndLiaSharing() { } } - @Test - public void testSerializationBeforeFireWithWindowLength() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSerializationBeforeFireWithWindowLength(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-953 final String drl = "import " + StockTick.class.getCanonicalName() + "\n" + @@ -4573,8 +4699,9 @@ public void testSerializationBeforeFireWithWindowLength() { } } - @Test - public void testSubclassWithLongerExpirationThanSuper() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubclassWithLongerExpirationThanSuper(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-983 final String drl = "import " + SuperClass.class.getCanonicalName() + "\n" + @@ -4612,8 +4739,9 @@ public void testSubclassWithLongerExpirationThanSuper() { } } - @Test - public void testSubclassWithLongerExpirationThanSuperWithSerialization() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubclassWithLongerExpirationThanSuperWithSerialization(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-983 final String drl = "import " + SuperClass.class.getCanonicalName() + "\n" + @@ -4666,8 +4794,9 @@ public static class SuperClass implements Serializable { } @Expires( "20s" ) public static class SubClass extends SuperClass { } - @Test - public void testTemporalOperatorWithGlobal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTemporalOperatorWithGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-993 final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -4704,26 +4833,29 @@ public void testTemporalOperatorWithGlobal() { } } - @Test - public void testNoExpirationWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoExpirationWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-984 - checkNoExpiration("$s: SimpleEvent ()\n" + + checkNoExpiration(kieBaseTestConfiguration, "$s: SimpleEvent ()\n" + "not SimpleEvent (this != $s, this after[0, 30s] $s)\n" ); } - @Test - public void testNoExpirationWithSlidingWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoExpirationWithSlidingWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-984 - checkNoExpiration("SimpleEvent( ) over window:time(30s)\n" ); + checkNoExpiration(kieBaseTestConfiguration, "SimpleEvent( ) over window:time(30s)\n" ); } - @Test - public void testNoExpirationWithNoTemporalConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoExpirationWithNoTemporalConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-984 - checkNoExpiration("SimpleEvent( )\n" ); + checkNoExpiration(kieBaseTestConfiguration, "SimpleEvent( )\n" ); } - private void checkNoExpiration(final String lhs) { + private void checkNoExpiration(KieBaseTestConfiguration kieBaseTestConfiguration, final String lhs) { final String drl = "import " + SimpleEvent.class.getCanonicalName() + "\n" + "declare SimpleEvent\n" + " @role( event )\n" + @@ -4758,8 +4890,9 @@ private void checkNoExpiration(final String lhs) { } } - @Test - public void testCancelActivationWithExpiredEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCancelActivationWithExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2463 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "import " + AtomicInteger.class.getCanonicalName() + "\n" + @@ -4810,8 +4943,9 @@ public void testCancelActivationWithExpiredEvent() { } } - @Test - public void testRightTupleExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRightTupleExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2463 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "import " + AtomicInteger.class.getCanonicalName() + "\n" + @@ -4858,8 +4992,9 @@ public void testRightTupleExpiration() { } } - @Test - public void testLeftTupleExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLeftTupleExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2463 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "import " + AtomicInteger.class.getCanonicalName() + "\n" + @@ -4904,8 +5039,9 @@ public void testLeftTupleExpiration() { } } - @Test - public void testLeftTupleExpirationWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLeftTupleExpirationWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2463 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "import " + AtomicInteger.class.getCanonicalName() + "\n" + @@ -4951,8 +5087,9 @@ public void testLeftTupleExpirationWithNot() { } } - @Test - public void testExpireLogicallyInsertedEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpireLogicallyInsertedEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2515 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "declare MyEvent\n" + @@ -4987,8 +5124,9 @@ public void testExpireLogicallyInsertedEvent() { } } - @Test - public void testExpiredEventWithPendingActivations() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpiredEventWithPendingActivations(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.drools_usage_pZB7GRxZp64;\n" + "\n" + "declare time_Var\n" + @@ -5098,8 +5236,9 @@ public void testExpiredEventWithPendingActivations() throws Exception { } } - @Test - public void testTimerWithMillisPrecision() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTimerWithMillisPrecision(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2627 final String drl = "import " + MyEvent.class.getCanonicalName() + "\n" + "import " + AtomicInteger.class.getCanonicalName() + "\n" + @@ -5150,8 +5289,10 @@ public void testTimerWithMillisPrecision() { } } - @Test(timeout=10000) - public void testSerializationDeserliaizationWithRectractedExpireFact() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSerializationDeserliaizationWithRectractedExpireFact(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1328 final String drl = "package " + TestEvent.class.getPackage().getName() + "\n" + @@ -5188,8 +5329,9 @@ public void testSerializationDeserliaizationWithRectractedExpireFact() { } } - @Test - public void testConflictingRightTuplesUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConflictingRightTuplesUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1338 final String drl = "declare Integer @role(event) end\n" + @@ -5219,8 +5361,9 @@ public void testConflictingRightTuplesUpdate() { } } - @Test - public void testModifyEventOverWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyEventOverWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1346 final String drl = "import " + AtomicBoolean.class.getCanonicalName() + "\n" + @@ -5259,8 +5402,9 @@ public void testModifyEventOverWindow() { } } - @Test - public void testExpirationOnAfter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpirationOnAfter(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1227 final String drl = "declare String @role( event ) end\n" + "declare Integer @role( event ) end\n" + @@ -5292,8 +5436,9 @@ public void testExpirationOnAfter() { } } - @Test - public void testExpirationOnBefore() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpirationOnBefore(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1227 final String drl = "declare String @role( event ) end\n" + "declare Integer @role( event ) end\n" + @@ -5324,8 +5469,9 @@ public void testExpirationOnBefore() { } } - @Test - public void testFireExpiredEventOnInactiveGroup() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireExpiredEventOnInactiveGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1523 final String drl = "global java.util.List list;\n" + "declare String @role(event) @expires( 6d ) end\n" + @@ -5388,8 +5534,9 @@ public void agendaGroupPopped(final AgendaGroupPoppedEvent event) { } } - @Test - public void testExpireUnusedDeclaredTypeEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpireUnusedDeclaredTypeEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1524 final String drl = "declare String @role( event ) @expires( 1s ) end\n" + "\n" + @@ -5416,8 +5563,9 @@ public void testExpireUnusedDeclaredTypeEvent() { } } - @Test - public void testExpireUnusedDeclaredTypeClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpireUnusedDeclaredTypeClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1524 final String drl = "rule R when\n" + "then\n" @@ -5485,8 +5633,9 @@ private static Date parseDate(final String input) { } } - @Test - public void testDeleteOfDeserializedJob() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteOfDeserializedJob(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1660 final String drl = "import " + EventA.class.getCanonicalName() + "\n" + @@ -5595,8 +5744,9 @@ public void testDeleteOfDeserializedJob() { } } - @Test - public void testInvalidWindowPredicate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidWindowPredicate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1723 final String drl = "declare A\n" + " @role( event )\n" + @@ -5615,8 +5765,9 @@ public void testInvalidWindowPredicate() { @Role(Role.Type.EVENT) public static class ExpiringEventD { } - @Test - public void testInsertLogicalNoExpires() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertLogicalNoExpires(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2182 final String drl = "import " + ExpiringEventD.class.getCanonicalName() + "\n" + "rule Insert when then " + @@ -5631,8 +5782,9 @@ public void testInsertLogicalNoExpires() { } } - @Test - public void testPropertyReactiveWithDurationOnRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyReactiveWithDurationOnRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2238 final String drl = "package org.drools.test " + " " + @@ -5673,8 +5825,9 @@ public void testPropertyReactiveWithDurationOnRule() { } } - @Test - public void testNPERiaPathMemWithEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNPERiaPathMemWithEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2241 final String drl = "package org.drools " + @@ -5702,8 +5855,9 @@ public void testNPERiaPathMemWithEvent() { } } - @Test - public void testCollectExpiredEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4393 final String drl = "import java.util.Collection\n" + @@ -5742,8 +5896,9 @@ public void testCollectExpiredEvent() { } } - @Test - public void testSlidingWindowExpire() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSlidingWindowExpire(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-4805 final String drl = "package org.drools.compiler\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepFireUntilHaltTimerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepFireUntilHaltTimerTest.java index 79075002622..3140a643d90 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepFireUntilHaltTimerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepFireUntilHaltTimerTest.java @@ -28,8 +28,8 @@ import java.util.concurrent.TimeUnit; import org.drools.testcoverage.common.util.TimeUtil; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.builder.KieFileSystem; import org.kie.api.builder.model.KieBaseModel; @@ -45,7 +45,7 @@ * Tests proper timer firing using accumulate and fireUntilHalt() mode. * BZ-981270 */ -@Ignore +@Disabled public class CepFireUntilHaltTimerTest { private KieSession ksession; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepJavaTypeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepJavaTypeTest.java index 8213c074f0a..bf465636b20 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepJavaTypeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepJavaTypeTest.java @@ -18,7 +18,6 @@ */ package org.drools.compiler.integrationtests; -import java.util.Collection; import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepQueryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepQueryTest.java index cd781f9cfb0..afadf0b6608 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepQueryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CepQueryTest.java @@ -18,18 +18,16 @@ */ package org.drools.compiler.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.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.runtime.KieSession; import org.kie.api.runtime.rule.EntryPoint; @@ -41,28 +39,28 @@ /** * Tests queries using temporal operators on events from two entry points. */ -@RunWith(Parameterized.class) public class CepQueryTest { - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - private final KieBaseTestConfiguration kieBaseTestConfiguration; - private KieSession ksession; private SessionPseudoClock clock; private EntryPoint firstEntryPoint, secondEntryPoint; - public CepQueryTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - @Before - public void prepare() { + + @AfterEach + public void cleanup() { + if (ksession != null) { + ksession.dispose(); + } + } + + private void prepare(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests\n" + "import " + CepQueryTest.TestEvent.class.getCanonicalName() + ";\n" + "declare TestEvent\n" + @@ -81,13 +79,7 @@ public void prepare() { secondEntryPoint = ksession.getEntryPoint("SecondStream"); } - @After - public void cleanup() { - if (ksession != null) { - ksession.dispose(); - } - } - + private void eventsInitialization() { secondEntryPoint.insert(new TestEvent("minusOne")); clock.advanceTime(5, TimeUnit.SECONDS); @@ -99,9 +91,11 @@ private void eventsInitialization() { /** * Tests query using temporal operator 'after' on events from two entry points. */ - @Test - public void testQueryWithAfter() { - this.eventsInitialization(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithAfter(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); + eventsInitialization(); final QueryResults results = ksession.getQueryResults("EventsAfterZeroToNineSeconds"); assertThat(results.size()).as("Unexpected query result length").isEqualTo(1); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CompositeAgendaTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CompositeAgendaTest.java index fee0df07833..fd05e83dabf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CompositeAgendaTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/CompositeAgendaTest.java @@ -20,9 +20,10 @@ import org.drools.testcoverage.common.model.A; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; -import org.junit.Ignore; -import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Disabled; +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.io.ResourceType; @@ -41,7 +42,8 @@ @Category(TurtleTestCategory.class) public class CompositeAgendaTest { - @Test @Ignore + @Test + @Disabled public void testInALoop() { for (int i = 0; i < 100; i++) { testCreateHaltDisposeAgenda(); @@ -49,7 +51,8 @@ public void testInALoop() { } } - @Test(timeout = 600_000) + @Test + @Timeout(600000) public void testCreateHaltDisposeAgenda() { final String drl = " import " + A.class.getCanonicalName() + ";\n" + " declare A @role( event ) end\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/QueryConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/QueryConcurrencyTest.java index 1466191487f..ef227dd4c74 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/QueryConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/QueryConcurrencyTest.java @@ -20,7 +20,6 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -29,22 +28,22 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.mvel.expr.MvelEvaluator; 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.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.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class QueryConcurrencyTest { @@ -53,19 +52,14 @@ public class QueryConcurrencyTest { private static int THREADS = 32; private static int REQUESTS = 32; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test(timeout = 300000) - public void testConstraintConcurrency() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(300000) + public void testConstraintConcurrency(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package com.example.reproducer\n" + "import " + Bus.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarExceptionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarExceptionTest.java index b5635a34f46..2445d96ac5a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarExceptionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarExceptionTest.java @@ -18,16 +18,16 @@ */ package org.drools.compiler.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.core.base.UndefinedCalendarExcption; 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.builder.KieBuilder; import org.kie.api.runtime.KieSession; @@ -35,46 +35,48 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class TimerAndCalendarExceptionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TimerAndCalendarExceptionTest(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(); } - @Test(timeout = 10000) - public void testUnknownProtocol() { - wrongTimerExpression("xyz:30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testUnknownProtocol(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "xyz:30"); } - @Test(timeout = 10000) - public void testMissingColon() { - wrongTimerExpression("int 30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMissingColon(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "int 30"); } - @Test(timeout = 10000) - public void testMalformedExpression() { - wrongTimerExpression("30s s30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "30s s30"); } - @Test(timeout = 10000) - public void testMalformedIntExpression() { - wrongTimerExpression("int 30s"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedIntExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "int 30s"); } - @Test(timeout = 10000) - public void testMalformedCronExpression() { - wrongTimerExpression("cron: 0/30 * * * * *"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedCronExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "cron: 0/30 * * * * *"); } - private void wrongTimerExpression(final String timer) { + private void wrongTimerExpression(KieBaseTestConfiguration kieBaseTestConfiguration, final String timer) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -91,8 +93,9 @@ private void wrongTimerExpression(final String timer) { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testUndefinedCalendar() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUndefinedCalendar(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule xxx \n" + " calendars \"cal1\"\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarFireUntilHaltTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarFireUntilHaltTest.java index 5022ae79916..046d857bce8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarFireUntilHaltTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarFireUntilHaltTest.java @@ -19,22 +19,22 @@ package org.drools.compiler.integrationtests; import java.time.Duration; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.time.impl.PseudoClockScheduler; 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.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.Timeout; +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; @@ -44,7 +44,6 @@ import static org.awaitility.Awaitility.await; -@RunWith(Parameterized.class) public class TimerAndCalendarFireUntilHaltTest { private final class RecordingRulesListener extends DefaultAgendaEventListener { @@ -70,7 +69,6 @@ public void afterMatchFired(AfterMatchFiredEvent event) { } } - private final KieBaseTestConfiguration kieBaseTestConfiguration; private KieSession ksession; private KieBase kbase; private CountDownLatch stoppedLatch; @@ -79,24 +77,21 @@ public void afterMatchFired(AfterMatchFiredEvent event) { private CountDownLatch startingLatch; private FactHandle triggerHandle; - public TimerAndCalendarFireUntilHaltTest(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 after() throws Exception { if (ksession != null) { ksession.dispose(); } } - @Test(timeout = 10000) - public void testTimerRuleFires() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerRuleFires(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "// fire once, for a String, create an Integer\n" + "rule TimerRule\n" + "timer(int:0 1000)\n" + @@ -105,7 +100,7 @@ public void testTimerRuleFires() throws Exception { "then\n" + " insert( new Integer(1) );\n" + "end"; - setupKSessionFor(drl); + setupKSessionFor(kieBaseTestConfiguration, drl); startEngine(); activateRule(); @@ -117,8 +112,10 @@ public void testTimerRuleFires() throws Exception { stopEngine(); } - @Test(timeout = 10000) - public void testTimerRuleHaltStopsFiring() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerRuleHaltStopsFiring(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "// fire once, for a String, create an Integer\n" + "rule TimerRule\n" + "timer(int:0 1000)\n" + @@ -127,7 +124,7 @@ public void testTimerRuleHaltStopsFiring() throws Exception { "then\n" + " insert( new Integer(1) );\n" + "end"; - setupKSessionFor(drl); + setupKSessionFor(kieBaseTestConfiguration, drl); startEngine(); activateRule(); @@ -142,8 +139,10 @@ public void testTimerRuleHaltStopsFiring() throws Exception { await().during(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(2)).until(ruleHasFired("TimerRule", 2)); } - @Test(timeout = 10000) - public void testTimerRuleRestartsAfterStop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerRuleRestartsAfterStop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "// fire once, for a String, create an Integer\n" + "rule TimerRule\n" + "timer(int:0 1000)\n" + @@ -152,7 +151,7 @@ public void testTimerRuleRestartsAfterStop() throws Exception { "then\n" + " insert( new Integer(1) );\n" + "end"; - setupKSessionFor(drl); + setupKSessionFor(kieBaseTestConfiguration, drl); startEngine(); activateRule(); @@ -170,8 +169,10 @@ public void testTimerRuleRestartsAfterStop() throws Exception { stopEngine(); } - @Test(timeout = 10000) - public void testTimerRuleDoesRestartsIfNoLongerHolds() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerRuleDoesRestartsIfNoLongerHolds(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "// fire once, for a String, create an Integer\n" + "rule TimerRule\n" + "timer(int:0 1000)\n" + @@ -180,7 +181,7 @@ public void testTimerRuleDoesRestartsIfNoLongerHolds() throws Exception { "then\n" + " insert( new Integer(1) );\n" + "end"; - setupKSessionFor(drl); + setupKSessionFor(kieBaseTestConfiguration, drl); startEngine(); activateRule(); @@ -200,7 +201,7 @@ public void testTimerRuleDoesRestartsIfNoLongerHolds() throws Exception { } - private void setupKSessionFor(final String drl) { + private void setupKSessionFor(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("timer-and-calendar-test", kieBaseTestConfiguration, drl); KieSessionConfiguration kieSessionConfiguration = KieSessionTestConfiguration.STATEFUL_PSEUDO.getKieSessionConfiguration(); ksession = kbase.newKieSession(kieSessionConfiguration, null); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithPseudoTimeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithPseudoTimeTest.java index a4649ec7573..716fe449a27 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithPseudoTimeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithPseudoTimeTest.java @@ -21,13 +21,13 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; import org.drools.core.base.UndefinedCalendarExcption; import org.drools.core.time.impl.PseudoClockScheduler; @@ -40,12 +40,12 @@ 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.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.util.DateUtils; -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.api.Timeout; +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.event.rule.AgendaEventListener; @@ -63,22 +63,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class TimerAndCalendarWithPseudoTimeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TimerAndCalendarWithPseudoTimeTest(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(); } - @Test(timeout = 10000) - public void testDurationMemoryLeakonRepeatedUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDurationMemoryLeakonRepeatedUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + Alarm.class.getCanonicalName() + "\n" + @@ -118,17 +112,21 @@ public void testDurationMemoryLeakonRepeatedUpdate() { } } - @Test(timeout = 10000) - public void testNoProtocolIntervalTimer() { - testIntervalTimer(true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testNoProtocolIntervalTimer(KieBaseTestConfiguration kieBaseTestConfiguration) { + testIntervalTimer(kieBaseTestConfiguration, true); } - @Test(timeout = 10000) - public void testIntervalTimer() { - testIntervalTimer(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimer(KieBaseTestConfiguration kieBaseTestConfiguration) { + testIntervalTimer(kieBaseTestConfiguration, false); } - private void testIntervalTimer(final boolean noProtocol) { + private void testIntervalTimer(KieBaseTestConfiguration kieBaseTestConfiguration, final boolean noProtocol) { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -177,8 +175,10 @@ private void testIntervalTimer(final boolean noProtocol) { } } - @Test(timeout = 10000) - public void testIntervalTimerWithoutFire() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithoutFire(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -219,8 +219,10 @@ public void testIntervalTimerWithoutFire() { } } - @Test(timeout = 10000) - public void testExprIntervalTimerRaceCondition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testExprIntervalTimerRaceCondition(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -261,32 +263,42 @@ public void testExprIntervalTimerRaceCondition() { } } - @Test(timeout = 10000) - public void testUnknownProtocol() { - wrongTimerExpression("xyz:30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testUnknownProtocol(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "xyz:30"); } - @Test(timeout = 10000) - public void testMissingColon() { - wrongTimerExpression("int 30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMissingColon(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "int 30"); } - @Test(timeout = 10000) - public void testMalformedExpression() { - wrongTimerExpression("30s s30"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "30s s30"); } - @Test(timeout = 10000) - public void testMalformedIntExpression() { - wrongTimerExpression("int 30s"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedIntExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "int 30s"); } - @Test(timeout = 10000) - public void testMalformedCronExpression() { - wrongTimerExpression("cron: 0/30 * * * * *"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMalformedCronExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { + wrongTimerExpression(kieBaseTestConfiguration, "cron: 0/30 * * * * *"); } - private void wrongTimerExpression(final String timer) { + private void wrongTimerExpression(KieBaseTestConfiguration kieBaseTestConfiguration, final String timer) { final String drl = "package org.simple \n" + "rule xxx \n" + @@ -303,8 +315,10 @@ private void wrongTimerExpression(final String timer) { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test(timeout = 10000) - public void testCronTimer() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCronTimer(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -352,8 +366,10 @@ public void testCronTimer() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarNormalRuleSingleCalendar() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarNormalRuleSingleCalendar(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -407,8 +423,9 @@ public void testCalendarNormalRuleSingleCalendar() throws Exception { } } - @Test - public void testUndefinedCalendar() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUndefinedCalendar(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule xxx \n" + " calendars \"cal1\"\n" + @@ -430,8 +447,10 @@ public void testUndefinedCalendar() { } } - @Test(timeout = 10000) - public void testCalendarNormalRuleMultipleCalendars() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarNormalRuleMultipleCalendars(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -489,8 +508,10 @@ public void testCalendarNormalRuleMultipleCalendars() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithCron() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithCron(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -571,8 +592,10 @@ public void testCalendarsWithCron() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithIntervals() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithIntervals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -653,8 +676,10 @@ public void testCalendarsWithIntervals() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithIntervalsAndStartAndEnd() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithIntervalsAndStartAndEnd(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -710,8 +735,10 @@ public void testCalendarsWithIntervalsAndStartAndEnd() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithIntervalsAndStartAndLimit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithIntervalsAndStartAndLimit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.simple \n" + "global java.util.List list \n" + @@ -767,8 +794,10 @@ public void testCalendarsWithIntervalsAndStartAndLimit() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithCronAndStartAndEnd() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithCronAndStartAndEnd(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Locale defaultLoc = Locale.getDefault(); try { Locale.setDefault(Locale.UK); // Because of the date strings in the DRL, fixable with JBRULES-3444 @@ -832,8 +861,10 @@ public void testCalendarsWithCronAndStartAndEnd() throws Exception { } } - @Test(timeout = 10000) - public void testCalendarsWithCronAndStartAndLimit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCalendarsWithCronAndStartAndLimit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Locale defaultLoc = Locale.getDefault(); try { Locale.setDefault(Locale.UK); // Because of the date strings in the DRL, fixable with JBRULES-3444 @@ -898,8 +929,10 @@ public void testCalendarsWithCronAndStartAndLimit() throws Exception { } } - @Test(timeout = 10000) - public void testIntervalTimerWithLongExpressions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithLongExpressions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.simple;\n" + "global java.util.List list;\n" + "\n" + @@ -962,8 +995,10 @@ public void testIntervalTimerWithLongExpressions() { } } - @Test(timeout = 10000) - public void testIntervalTimerAfterEnd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerAfterEnd(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5908 final String drl = "package org.simple;\n" + "global java.util.List list;\n" + @@ -1007,27 +1042,35 @@ public void testIntervalTimerAfterEnd() { } } - @Test(timeout = 10000) - public void testIntervalTimerWithStringExpressions() { - checkIntervalTimerWithStringExpressions(false, "3-JAN-2010"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithStringExpressions(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkIntervalTimerWithStringExpressions(kieBaseTestConfiguration, false, "3-JAN-2010"); } - @Test(timeout = 10000) - public void testIntervalTimerWithAllExpressions() { - checkIntervalTimerWithStringExpressions(true, "3-JAN-2010"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithAllExpressions(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkIntervalTimerWithStringExpressions(kieBaseTestConfiguration, true, "3-JAN-2010"); } - @Test(timeout = 10000) - public void testIntervalTimerWithStringExpressionsAfterStart() { - checkIntervalTimerWithStringExpressions(false, "3-FEB-2010"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithStringExpressionsAfterStart(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkIntervalTimerWithStringExpressions(kieBaseTestConfiguration, false, "3-FEB-2010"); } - @Test(timeout = 10000) - public void testIntervalTimerWithAllExpressionsAfterStart() { - checkIntervalTimerWithStringExpressions(true, "3-FEB-2010"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerWithAllExpressionsAfterStart(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkIntervalTimerWithStringExpressions(kieBaseTestConfiguration, true, "3-FEB-2010"); } - private void checkIntervalTimerWithStringExpressions(final boolean useExprForStart, final String startTime) { + private void checkIntervalTimerWithStringExpressions(KieBaseTestConfiguration kieBaseTestConfiguration, final boolean useExprForStart, final String startTime) { final String drl = "package org.simple;\n" + "global java.util.List list;\n" + "\n" + @@ -1115,8 +1158,10 @@ private void checkIntervalTimerWithStringExpressions(final boolean useExprForSta } } - @Test(timeout = 10000) - public void testIntervalTimerExpressionWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIntervalTimerExpressionWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.kie.test\n" + "global java.util.List list\n" + "import " + FactA.class.getCanonicalName() + "\n" + "import " + FactB.class.getCanonicalName() + "\n" + "import " + Pet.class.getCanonicalName() + "\n" + @@ -1184,8 +1229,10 @@ public void testIntervalTimerExpressionWithOr() { } } - @Test(timeout = 10000) - public void testExprTimeRescheduled() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testExprTimeRescheduled(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.kie.test\n" + "global java.util.List list\n" + "import " + FactA.class.getCanonicalName() + "\n" + "rule r1 timer (expr: f1.field2, f1.field4)\n" + "when\n" + " f1 : FactA() \n" + "then\n" + " list.add( f1 );\n" + "end\n" + "\n"; @@ -1258,8 +1305,9 @@ public void testExprTimeRescheduled() { } } - @Test - public void testExpiredPropagations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpiredPropagations(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-244 final String drl = "package org.drools.test;\n" + "\n" + @@ -1342,8 +1390,9 @@ public void testExpiredPropagations() { } } - @Test - public void testCronFire() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCronFire(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1059372 final String drl = "package test.drools\n" + "rule TestRule " + @@ -1370,9 +1419,11 @@ public void testCronFire() { } } - @Test(timeout = 10000) - @Ignore("the listener callback holds some locks so blocking in it is not safe") - public void testRaceConditionWithTimedRuleExectionOption() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + @Disabled("the listener callback holds some locks so blocking in it is not safe") + public void testRaceConditionWithTimedRuleExectionOption(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1073880 final String drl = "package org.simple \n" + "global java.util.List list \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithRealTimeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithRealTimeTest.java index 9dd92362d58..5e0d3f6cfeb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithRealTimeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarWithRealTimeTest.java @@ -19,11 +19,11 @@ package org.drools.compiler.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.kiesession.agenda.DefaultAgenda; import org.drools.testcoverage.common.model.Alarm; @@ -32,11 +32,11 @@ 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.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.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; import org.kie.api.runtime.KieSessionConfiguration; @@ -45,31 +45,26 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -@RunWith(Parameterized.class) public class TimerAndCalendarWithRealTimeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; private KieSession ksession; private KieBase kbase; - public TimerAndCalendarWithRealTimeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); - } - - @After + @AfterEach public void after() throws Exception { if (ksession != null) { ksession.dispose(); } } - @Test(timeout = 15000) - public void testDuration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDuration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.test;\n" + "\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -103,8 +98,10 @@ public void testDuration() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test(timeout = 10000) - public void testDurationWithNoLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDurationWithNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.test;\n" + "\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -141,8 +138,10 @@ public void testDurationWithNoLoop() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test(timeout = 10000) - public void testFireRuleAfterDuration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testFireRuleAfterDuration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.test;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -184,8 +183,10 @@ public void testFireRuleAfterDuration() throws Exception { assertThat(list.size()).isEqualTo(2); } - @Test(timeout = 10000) - public void testTimerWithNot() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieBase kbase = KieBaseUtil .getKieBaseFromClasspathResources( @@ -199,8 +200,10 @@ public void testTimerWithNot() throws Exception { assertThat(ksession.getFactCount()).isEqualTo(2); } - @Test(timeout = 10000) - public void testTimerRemoval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testTimerRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.test\n" + "import " + TimeUnit.class.getName() + "\n" + "global java.util.List list \n" + @@ -231,8 +234,9 @@ public void testTimerRemoval() { await().until(ruleIsRemoved()); } - @Test - public void testIntervalRuleInsertion() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntervalRuleInsertion(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-620 // Does not fail when using pseudo clock due to the subsequent call to fireAllRules final String drl = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java index 289579c7f9c..9c7a1fa4733 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/AccumulateFunctionConcurrencyTest.java @@ -18,26 +18,18 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class AccumulateFunctionConcurrencyTest extends BaseConcurrencyTest { - public AccumulateFunctionConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); // fails with exec-model. file JIRA + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); // fails with exec-model. file JIRA } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/BaseConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/BaseConcurrencyTest.java index 9fd8a1c9ff7..78746000e0b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/BaseConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/BaseConcurrencyTest.java @@ -28,7 +28,9 @@ import org.drools.mvel.expr.MvelEvaluator; 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; @@ -39,14 +41,11 @@ public abstract class BaseConcurrencyTest { protected static int LOOP = 500; protected static int THREADS = 32; protected static int REQUESTS = 32; - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - public BaseConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test(timeout = 300000) - public void testConcurrency() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(300000) + public void testConcurrency(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = getDrl(); List exceptions = new ArrayList<>(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java index d9f047ba415..b192f160728 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceConcurrencyTest.java @@ -19,28 +19,20 @@ package org.drools.compiler.integrationtests.concurrency; 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.TestParametersUtil; +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.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class ConsequenceConcurrencyTest extends BaseConcurrencyTest { - - public ConsequenceConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java index 52079684107..e811c70862f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConsequenceWithAndOrConcurrencyTest.java @@ -19,29 +19,21 @@ package org.drools.compiler.integrationtests.concurrency; 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.TestParametersUtil; +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.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class ConsequenceWithAndOrConcurrencyTest extends BaseConcurrencyTest { - public ConsequenceWithAndOrConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); // fails with exec-model. file JIRA + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); // fails with exec-model. file JIRA } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java index 50996882b08..69fd08ccf18 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintConcurrencyTest.java @@ -18,26 +18,18 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class ConstraintConcurrencyTest extends BaseConcurrencyTest { - - public ConstraintConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java index 755be00e1af..50ca5d67a78 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrConcurrencyTest.java @@ -18,28 +18,20 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class ConstraintWithAndOrConcurrencyTest extends BaseConcurrencyTest { - public ConstraintWithAndOrConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java index 1e5bd57647b..af9a55a3469 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/ConstraintWithAndOrJittingConcurrencyTest.java @@ -18,28 +18,20 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class ConstraintWithAndOrJittingConcurrencyTest extends BaseConcurrencyTest { - public ConstraintWithAndOrJittingConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); // only for non-exec-model mvel jitting test + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); // only for non-exec-model mvel jitting test } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java index fe51f4a74c1..09efce8f7e7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/EvalConcurrencyTest.java @@ -18,26 +18,18 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class EvalConcurrencyTest extends BaseConcurrencyTest { - public EvalConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java index cd652c5ce71..339be050d48 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/FromAccumulateConcurrencyTest.java @@ -18,26 +18,18 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class FromAccumulateConcurrencyTest extends BaseConcurrencyTest { - public FromAccumulateConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); // fails with exec-model. file JIRA + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); // fails with exec-model. file JIRA } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java index 317d0501445..0a82bfb97fe 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/GlobalConcurrencyTest.java @@ -19,21 +19,20 @@ package org.drools.compiler.integrationtests.concurrency; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.model.Result; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.junit.Test; import org.junit.experimental.categories.Category; -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.KieBase; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; @@ -42,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class GlobalConcurrencyTest { @@ -50,21 +48,14 @@ public class GlobalConcurrencyTest { protected static int LOOP = 3000; protected static int MAX_THREAD = 30; - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - public GlobalConcurrencyTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return Stream.of(KieBaseTestConfiguration.CLOUD_IDENTITY_MODEL_PATTERN); // DROOLS-6961 : exec-model only } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{KieBaseTestConfiguration.CLOUD_IDENTITY_MODEL_PATTERN}); // DROOLS-6961 : exec-model only - return parameters; - } - - @Test - public void testGlobalConcurrency() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalConcurrency(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.mypkg;" + "import " + Person.class.getCanonicalName() + ";" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java index c4479ef3758..d751b4e4f6c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELDateClassFieldReaderConcurrencyTest.java @@ -18,28 +18,20 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.TestParametersUtil; +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.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class MVELDateClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { - public MVELDateClassFieldReaderConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java index b104a5d4b3a..ea641d9f16d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELNumberClassFieldReaderConcurrencyTest.java @@ -18,27 +18,19 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class MVELNumberClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { - public MVELNumberClassFieldReaderConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java index 129ee86fe8e..93a41e05874 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/concurrency/MVELObjectClassFieldReaderConcurrencyTest.java @@ -18,27 +18,19 @@ */ package org.drools.compiler.integrationtests.concurrency; -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.drools.testcoverage.common.util.TestParametersUtil2; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.runtime.KieSession; import org.kie.test.testcategory.TurtleTestCategory; -@RunWith(Parameterized.class) @Category(TurtleTestCategory.class) public class MVELObjectClassFieldReaderConcurrencyTest extends BaseConcurrencyTest { - public MVELObjectClassFieldReaderConcurrencyTest(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(); } protected String getDrl() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/AbstractDeclareTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/AbstractDeclareTest.java index ae2c73ab465..35a16ed3bdf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/AbstractDeclareTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/AbstractDeclareTest.java @@ -24,21 +24,18 @@ import org.drools.testcoverage.common.model.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.junit.Test; +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; public abstract class AbstractDeclareTest { - protected final KieBaseTestConfiguration kieBaseTestConfiguration; - public AbstractDeclareTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Test - public void testDeclaresWithArrayFields() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaresWithArrayFields(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl; \n" + "import " + Person.class.getName() + ";\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/BindTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/BindTest.java index 274f73616ce..8be5c21dfc3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/BindTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/BindTest.java @@ -19,18 +19,17 @@ package org.drools.compiler.integrationtests.drl; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Cheese; 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.event.rule.ObjectUpdatedEvent; @@ -45,22 +44,15 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class BindTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public BindTest(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 testFactBindings() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFactBindings(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -105,8 +97,9 @@ public void testFactBindings() { } } - @Test - public void testBindingToMissingField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingToMissingField(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3047 final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "rule rule1\n" + @@ -122,8 +115,9 @@ public void testBindingToMissingField() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testFieldBindingOnWrongFieldName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFieldBindingOnWrongFieldName(KieBaseTestConfiguration kieBaseTestConfiguration) { //JBRULES-2527 String drl = @@ -136,7 +130,7 @@ public void testFieldBindingOnWrongFieldName() { "then\n" + "end\n"; - testBingWrongFieldName(drl); + testBingWrongFieldName(kieBaseTestConfiguration, drl); drl = "package org.drools.compiler.integrationtests.drl;\n" + @@ -148,10 +142,10 @@ public void testFieldBindingOnWrongFieldName() { "then\n" + "end\n"; - testBingWrongFieldName(drl); + testBingWrongFieldName(kieBaseTestConfiguration, drl); } - private void testBingWrongFieldName(final String drl) { + private void testBingWrongFieldName(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { try { final KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, @@ -163,8 +157,9 @@ private void testBingWrongFieldName(final String drl) { } } - @Test - public void testBindingsOnConnectiveExpressions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingsOnConnectiveExpressions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -195,8 +190,9 @@ public void testBindingsOnConnectiveExpressions() { } } - @Test - public void testAutomaticBindings() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAutomaticBindings(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/CommentTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/CommentTest.java index 256298cfe16..e0c125ddf5e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/CommentTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/CommentTest.java @@ -18,34 +18,26 @@ */ package org.drools.compiler.integrationtests.drl; -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.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 CommentTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public CommentTest(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 testCommentDelimiterInString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCommentDelimiterInString(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3401 final String drl = "rule x\n" + "dialect \"mvel\"\n" + @@ -59,8 +51,9 @@ public void testCommentDelimiterInString() { ksession.dispose(); } - @Test - public void testCommentWithCommaInRHS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCommentWithCommaInRHS(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3648 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ConsequenceTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ConsequenceTest.java index 7b645668712..3f1d77907fb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ConsequenceTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ConsequenceTest.java @@ -19,8 +19,8 @@ package org.drools.compiler.integrationtests.drl; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.model.Person; @@ -28,10 +28,9 @@ 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.event.rule.ObjectDeletedEvent; @@ -46,22 +45,15 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class ConsequenceTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ConsequenceTest(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 testConsequenceException() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConsequenceException(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -90,8 +82,9 @@ public void testConsequenceException() { } } - @Test - public void testConsequenceBuilderException() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConsequenceBuilderException(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "global java.util.List results;\n" + "rule \"error compiling consequence\"\n" + @@ -115,8 +108,9 @@ public void testConsequenceBuilderException() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testMetaConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMetaConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "global java.util.List results;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -154,8 +148,9 @@ public void testMetaConsequence() { } } - @Test - public void testMVELConsequenceWithMapsAndArrays() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELConsequenceWithMapsAndArrays(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import java.util.ArrayList\n" + "import java.util.HashMap\n" + @@ -186,8 +181,9 @@ public void testMVELConsequenceWithMapsAndArrays() { } } - @Test - public void testMVELConsequenceWithoutSemiColon1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELConsequenceWithoutSemiColon1(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package prg.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLCepTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLCepTest.java index 3ba7d1292d7..4d38dccf9fd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLCepTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLCepTest.java @@ -18,36 +18,28 @@ */ package org.drools.compiler.integrationtests.drl; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.StockTick; 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 DRLCepTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DRLCepTest(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(); } - @Test - public void testEventsInDifferentPackages() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventsInDifferentPackages(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + StockTick.class.getCanonicalName() + ";\n" + "declare StockTick\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLTest.java index 796da8ad124..cb748bd7670 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DRLTest.java @@ -19,10 +19,10 @@ package org.drools.compiler.integrationtests.drl; 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.testcoverage.common.model.A; import org.drools.testcoverage.common.model.B; @@ -34,10 +34,9 @@ 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; @@ -47,22 +46,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DRLTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DRLTest(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 testDuplicateRuleName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateRuleName(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "rule R when\n" + "then\n" + @@ -75,8 +67,9 @@ public void testDuplicateRuleName() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testEmptyRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "global java.util.List list\n" + @@ -106,8 +99,9 @@ public void testEmptyRule() { } } - @Test - public void testRuleMetaAttributes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleMetaAttributes(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "rule \"test meta attributes\"\n" + @@ -131,8 +125,9 @@ public void testRuleMetaAttributes() { } } - @Test - public void testWithInvalidRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithInvalidRule(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -155,8 +150,9 @@ public void testWithInvalidRule() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testWithInvalidRule2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithInvalidRule2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -174,8 +170,9 @@ public void testWithInvalidRule2() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testDuplicateVariableBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateVariableBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -246,8 +243,9 @@ public void testDuplicateVariableBinding() { } } - @Test - public void testDeclarationUsage() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationUsage(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -264,8 +262,9 @@ public void testDeclarationUsage() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testDeclarationNonExistingField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationNonExistingField(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -282,8 +281,9 @@ public void testDeclarationNonExistingField() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testDRLWithoutPackageDeclaration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDRLWithoutPackageDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "global java.util.List results\n" + "\n" + @@ -327,8 +327,9 @@ public void testDRLWithoutPackageDeclaration() throws Exception { } } - @Test - public void testPackageNameOfTheBeast() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPackageNameOfTheBeast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-2749 Various rules stop firing when they are in unlucky packagename and there is a function declared final String ruleFileContent1 = "package org.drools.integrationtests;\n" + @@ -360,8 +361,9 @@ public void testPackageNameOfTheBeast() throws Exception { } } - @Test - public void testLargeDRL() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLargeDRL(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "org/drools/compiler/integrationtests/largedrl.drl"); final KieSession kieSession = kieBase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DeclareTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DeclareTest.java index ee85a7a6c2e..6bdfecda4a9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DeclareTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DeclareTest.java @@ -19,40 +19,34 @@ package org.drools.compiler.integrationtests.drl; 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.testcoverage.common.model.ClassB; import org.drools.testcoverage.common.model.InterfaceB; 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.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.type.FactType; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DeclareTest extends AbstractDeclareTest { - public DeclareTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(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 testDeclaredTypesDefaultHashCode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypesDefaultHashCode(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3481 final String str = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -99,8 +93,9 @@ public void testDeclaredTypesDefaultHashCode() { } } - @Test - public void testDeclareAndFrom() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareAndFrom(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.integrationtests.drl\n" + "\n" + "declare Profile\n" + @@ -132,8 +127,9 @@ public void testDeclareAndFrom() throws Exception { } } - @Test - public void testDeclaredFactAndFunction() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredFactAndFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "global java.util.List list\n" + "declare Address\n" + @@ -169,8 +165,9 @@ public void testDeclaredFactAndFunction() throws Exception { } } - @Test - public void testTypeDeclarationOnSeparateResource() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeDeclarationOnSeparateResource(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package a.b.c\n" + "declare SomePerson\n" + " weight : double\n" + @@ -203,8 +200,9 @@ public void testTypeDeclarationOnSeparateResource() { } } - @Test - public void testDeclaredTypeAsFieldForAnotherDeclaredType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypeAsFieldForAnotherDeclaredType(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3468 final String drl = "package com.sample\n" + "\n" + @@ -264,8 +262,9 @@ public void testDeclaredTypeAsFieldForAnotherDeclaredType() { } } - @Test - public void testDeclaredTypeWithHundredsProps() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypeWithHundredsProps(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3621 final StringBuilder sb = new StringBuilder("declare MyType\n"); for (int i = 0; i < 300; i++) { @@ -278,8 +277,9 @@ public void testDeclaredTypeWithHundredsProps() { ksession.dispose(); } - @Test - public void testMvelFunctionWithDeclaredTypeArg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelFunctionWithDeclaredTypeArg(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3562 final String drl = "package org.drools.compiler.integrationtests.drl; \n" + "dialect \"mvel\"\n" + @@ -317,8 +317,9 @@ public void testMvelFunctionWithDeclaredTypeArg() { } } - @Test - public void testMvelFunctionWithDeclaredTypeArgForGuvnor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelFunctionWithDeclaredTypeArgForGuvnor(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3562 final String function = "function String getFieldValue(Bean bean) {" + " return bean.getField();" + @@ -343,8 +344,9 @@ public void testMvelFunctionWithDeclaredTypeArgForGuvnor() { ksession.dispose(); } - @Test - public void testConstructorWithOtherDefaults() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConstructorWithOtherDefaults(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "global java.util.List list;\n" + "declare Bean\n" + @@ -381,8 +383,9 @@ public void testConstructorWithOtherDefaults() { } } - @Test - public void testKeyedInterfaceField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKeyedInterfaceField(KieBaseTestConfiguration kieBaseTestConfiguration) { //JBRULES-3441 final String drl = "package org.drools.compiler.integrationtests.drl; \n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DrlSpecificFeaturesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DrlSpecificFeaturesTest.java index 8d927b5e6d4..9f19b93cec2 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DrlSpecificFeaturesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/DrlSpecificFeaturesTest.java @@ -19,18 +19,17 @@ package org.drools.compiler.integrationtests.drl; 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.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; @@ -40,24 +39,17 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -@RunWith(Parameterized.class) public class DrlSpecificFeaturesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DrlSpecificFeaturesTest( final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // This class is meant to test features only supported by non-exec-model. - return TestParametersUtil.getKieBaseCloudConfigurations(false); + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } // following test depends on MVEL: http://jira.codehaus.org/browse/MVEL-212 - @Test - public void testMVELConsequenceUsingFactConstructors() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELConsequenceUsingFactConstructors(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -77,8 +69,9 @@ public void testMVELConsequenceUsingFactConstructors() { assertThat(kieBuilder.getResults().getMessages()).isNotEmpty(); } - @Test - public void testTypeUnsafe() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeUnsafe(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "import " + DrlSpecificFeaturesTest.class.getName() + ".*\n" + "declare\n" + " Parent @typesafe(false)\n" + @@ -138,8 +131,9 @@ public int getX() { } } - @Test - public void testNoneTypeSafeDeclarations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoneTypeSafeDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) { // same namespace String str = "package " + Person.class.getPackage().getName() + ";\n" + "global java.util.List list\n" + @@ -152,7 +146,7 @@ public void testNoneTypeSafeDeclarations() { " list.add( $p );\n" + "end\n"; - executeTypeSafeDeclarations( str, + executeTypeSafeDeclarations( kieBaseTestConfiguration, str, true ); // different namespace with import @@ -167,7 +161,7 @@ public void testNoneTypeSafeDeclarations() { "then\n" + " list.add( $p );\n" + "end\n"; - executeTypeSafeDeclarations( str, + executeTypeSafeDeclarations( kieBaseTestConfiguration, str, true ); // different namespace without import using qualified name @@ -181,7 +175,7 @@ public void testNoneTypeSafeDeclarations() { "then\n" + " list.add( $p );\n" + "end\n"; - executeTypeSafeDeclarations( str, + executeTypeSafeDeclarations( kieBaseTestConfiguration, str, true ); // this should fail as it's not declared non typesafe @@ -195,11 +189,11 @@ public void testNoneTypeSafeDeclarations() { "then\n" + " list.add( $p );\n" + "end\n"; - executeTypeSafeDeclarations( str, + executeTypeSafeDeclarations( kieBaseTestConfiguration, str, false ); } - private void executeTypeSafeDeclarations(final String drl, final boolean mustSucceed) { + private void executeTypeSafeDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl, final boolean mustSucceed) { if (!mustSucceed) { assertThatThrownBy(()-> KieBaseUtil.getKieBaseFromKieModuleFromDrl("declare-test", kieBaseTestConfiguration, drl)).isInstanceOf(Throwable.class); } else { @@ -224,8 +218,9 @@ private void executeTypeSafeDeclarations(final String drl, final boolean mustSuc } } - @Test - public void testRHSClone() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRHSClone(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3539 final String drl = "import java.util.Map;\n" + "dialect \"mvel\"\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ExceptionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ExceptionTest.java index 0281c2218b7..d8da3d89427 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ExceptionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ExceptionTest.java @@ -18,32 +18,23 @@ */ package org.drools.compiler.integrationtests.drl; -import java.util.Collection; +import java.util.stream.Stream; 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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThatThrownBy; -@RunWith(Parameterized.class) public class ExceptionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ExceptionTest(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(); } public static class TestException extends RuntimeException { @@ -52,8 +43,9 @@ public TestException(String message) { } } - @Test - public void testReturnValueException() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReturnValueException(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + TestException.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/GlobalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/GlobalTest.java index 4e4c1648990..b8d08af4380 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/GlobalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/GlobalTest.java @@ -19,40 +19,32 @@ package org.drools.compiler.integrationtests.drl; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.core.base.MapGlobalResolver; 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.runtime.KieSession; import org.kie.api.runtime.StatelessKieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class GlobalTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public GlobalTest(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 testReturnValueAndGlobal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReturnValueAndGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -109,8 +101,9 @@ public void testReturnValueAndGlobal() { } } - @Test - public void testGlobalAccess() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalAccess(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.core.base.MapGlobalResolver;\n" + "global java.lang.String myGlobal;\n" + @@ -145,8 +138,9 @@ public void testGlobalAccess() { assertThat(session2.getGlobals().getGlobalKeys().contains("myGlobal")).isTrue(); } - @Test - public void testEvalNullGlobal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalNullGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBPMS-4649 final String drl = "import " + Cheese.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ImportsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ImportsTest.java index 48c7cd68fb6..6548f0ea217 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ImportsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/ImportsTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.testcoverage.common.model.Cheese; @@ -31,43 +32,32 @@ 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.definition.KiePackage; import org.kie.api.runtime.KieSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ImportsTest { - private static final Logger logger = LoggerFactory.getLogger(ImportsTest.class); - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ImportsTest(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 testImportFunctions() { - testImportFunctionsBase(StaticMethods.class.getCanonicalName(), StaticMethods2.class.getCanonicalName()); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportFunctions(KieBaseTestConfiguration kieBaseTestConfiguration) { + testImportFunctionsBase(kieBaseTestConfiguration, StaticMethods.class.getCanonicalName(), StaticMethods2.class.getCanonicalName()); } - @Test() - public void testImport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImport(KieBaseTestConfiguration kieBaseTestConfiguration) { // Same package as this test final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -88,8 +78,9 @@ public void testImport() { } } - @Test - public void testImportColision() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportColision(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl1 = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + "//list any import classes here.\n" + @@ -142,8 +133,9 @@ public void testImportColision() { } } - @Test - public void testImportConflict() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportConflict(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -161,8 +153,9 @@ public void testImportConflict() { ksession.dispose(); } - @Test - public void testMissingImport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMissingImport(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getName() + ";\n" + @@ -180,8 +173,9 @@ public void testMissingImport() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testMissingImports() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMissingImports(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package foo;\n" + "\n" + @@ -197,8 +191,9 @@ public void testMissingImports() { assertThat(kieBuilder.getResults().getMessages()).extracting(Message::getText).doesNotContain(""); } - @Test - public void testPackageImportWithMvelDialect() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPackageImportWithMvelDialect(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-2244 final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -226,8 +221,9 @@ public void testPackageImportWithMvelDialect() { } } - @Test - public void testImportStaticClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportStaticClass(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -297,8 +293,9 @@ public static String getString3(final String string, final Integer integer) { } } - @Test - public void testImportInnerFunctions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportInnerFunctions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import function " + org.drools.compiler.integrationtests.drl.ImportsTest.StaticMethods.class.getCanonicalName() + ".*;\n" + @@ -343,11 +340,11 @@ public void testImportInnerFunctions() { " list.add( getString4( \"rule4\" ) );\n" + "end"; - testImportFunctionsBase(org.drools.compiler.integrationtests.drl.ImportsTest.StaticMethods.class.getCanonicalName(), + testImportFunctionsBase(kieBaseTestConfiguration, org.drools.compiler.integrationtests.drl.ImportsTest.StaticMethods.class.getCanonicalName(), org.drools.compiler.integrationtests.drl.ImportsTest.StaticMethods2.class.getCanonicalName()); } - private void testImportFunctionsBase(final String staticMethodImport1, final String staticMethodImport2) { + private void testImportFunctionsBase(KieBaseTestConfiguration kieBaseTestConfiguration, final String staticMethodImport1, final String staticMethodImport2) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import function " + staticMethodImport1 + ".*;\n" + "import function " + staticMethodImport2 + ".getString3;\n" + @@ -415,8 +412,9 @@ private void testImportFunctionsBase(final String staticMethodImport1, final Str } } - @Test - public void testWrongImportWithDeclaredType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongImportWithDeclaredType(KieBaseTestConfiguration kieBaseTestConfiguration) { // KOGITO-7729 final String drl = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/LiteralTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/LiteralTest.java index 657e2bcd129..92608fcc8a2 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/LiteralTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/LiteralTest.java @@ -21,8 +21,8 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.model.Cheese; import org.drools.testcoverage.common.model.Cheesery; @@ -30,31 +30,23 @@ import org.drools.testcoverage.common.model.Primitives; 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 LiteralTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LiteralTest(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 testLiteral() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -87,8 +79,9 @@ public void testLiteral() { } } - @Test - public void testLiteralWithEscapes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLiteralWithEscapes(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -119,8 +112,9 @@ public void testLiteralWithEscapes() { } } - @Test - public void testLiteralWithBoolean() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLiteralWithBoolean(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -151,8 +145,9 @@ public void testLiteralWithBoolean() { } } - @Test - public void testBigLiterals() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigLiterals(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Primitives.class.getCanonicalName() + ";\n" + "rule X\n" + @@ -176,8 +171,9 @@ public void testBigLiterals() { } } - @Test - public void testBigDecimalIntegerLiteral() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalIntegerLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/NestingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/NestingTest.java index aa0370f918c..b7fc10db35a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/NestingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/NestingTest.java @@ -20,9 +20,9 @@ import java.io.StringReader; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.drl.parser.DrlParser; import org.drools.drl.ast.descr.AttributeDescr; @@ -34,32 +34,24 @@ import org.drools.testcoverage.common.model.State; 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.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NestingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NestingTest(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 testNesting() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNesting(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -119,8 +111,9 @@ public void testNesting() throws Exception { } } - @Test - public void testNestedConditionalElements() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedConditionalElements(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/PatternTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/PatternTest.java index af6f7bf9e0b..d3e0a1876ec 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/PatternTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/PatternTest.java @@ -20,8 +20,8 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.RuleBaseConfiguration; import org.drools.core.common.InternalFactHandle; @@ -42,10 +42,9 @@ 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.KieBaseConfiguration; import org.kie.api.KieServices; @@ -59,22 +58,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PatternTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PatternTest(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 testDeclaringAndUsingBindsInSamePattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaringAndUsingBindsInSamePattern(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Sensor.class.getCanonicalName() + ";\n" + @@ -131,8 +123,9 @@ public void testDeclaringAndUsingBindsInSamePattern() { } } - @Test - public void testEmptyPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + " \n" + @@ -163,8 +156,9 @@ public void testEmptyPattern() { } } - @Test - public void testPatternMatchingOnThis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatternMatchingOnThis(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "rule R1 when\n" + " $i1: Integer()\n" + @@ -186,8 +180,9 @@ public void testPatternMatchingOnThis() { } } - @Test - public void testPatternOffset() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatternOffset(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3427 final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "declare A\n" + @@ -232,8 +227,9 @@ public void testPatternOffset() throws Exception { } } - @Test - public void testPatternOnClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatternOnClass(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + InitialFactImpl.class.getCanonicalName() + "\n" + "import " + FactB.class.getCanonicalName() + "\n" + "rule \"Clear\" when\n" + @@ -264,8 +260,9 @@ public void testPatternOnClass() { } } - @Test - public void testPredicateAsFirstPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPredicateAsFirstPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package oreg.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -294,8 +291,9 @@ public void testPredicateAsFirstPattern() { } } - @Test - public void testConstantLeft() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConstantLeft(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3627 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -315,8 +313,9 @@ public void testConstantLeft() { } } - @Test - public void testUppercaseField() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUppercaseField(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "global java.util.List list\n" + "declare Address\n" + @@ -348,8 +347,9 @@ public void testUppercaseField() throws Exception { } } - @Test - public void testUppercaseField2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUppercaseField2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "declare SomeFact\n" + " Field : String\n" + @@ -377,8 +377,9 @@ public void testUppercaseField2() throws Exception { } } - @Test - public void testHelloWorld() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + " \n" + @@ -430,8 +431,9 @@ public void testHelloWorld() { } } - @Test - public void testBigDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + @@ -473,8 +475,9 @@ public void testBigDecimal() { } } - @Test - public void testSelfReference() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfReference(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Order.class.getCanonicalName() + ";\n" + @@ -516,8 +519,9 @@ public void testSelfReference() { } } - @Test - public void testSelfReference2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfReference2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -545,8 +549,9 @@ public void testSelfReference2() { } } - @Test - public void testImplicitDeclarations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImplicitDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -581,8 +586,9 @@ public void testImplicitDeclarations() { } } - @Test - public void testMethodCalls() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMethodCalls(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + "rule \"method calls\"\n" + @@ -606,8 +612,9 @@ public void testMethodCalls() { } } - @Test - public void testSelfJoinWithIndex() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfJoinWithIndex(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -642,8 +649,9 @@ public void testSelfJoinWithIndex() { } } - @Test - public void testSelfJoinAndNotWithIndex() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfJoinAndNotWithIndex(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -714,8 +722,9 @@ public void testSelfJoinAndNotWithIndex() { } } - @Test - public void testQualifiedFieldReference() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQualifiedFieldReference(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -752,8 +761,9 @@ public void testQualifiedFieldReference() { } } - @Test - public void testAutovivificationOfVariableRestrictions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAutovivificationOfVariableRestrictions(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + @@ -784,8 +794,9 @@ public void testAutovivificationOfVariableRestrictions() { } } - @Test - public void testParentheses() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testParentheses(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -825,8 +836,9 @@ public void testParentheses() { } } - @Test - public void testCovariance() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCovariance(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3392 final String drl = "import " + ClassA.class.getCanonicalName() + ";\n" + @@ -853,8 +865,9 @@ public void testCovariance() { } } - @Test - public void testCheckDuplicateVariables() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCheckDuplicateVariables(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3035 String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -888,8 +901,9 @@ public void testCheckDuplicateVariables() { assertThat(kieBuilder.getResults().getMessages()).extracting(org.kie.api.builder.Message::getText).doesNotContain(""); } - @Test - public void testCompilationFailureOnTernaryComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationFailureOnTernaryComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3642 final String drl = "declare Cont\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RHSTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RHSTest.java index 17623dfba11..6015399a154 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RHSTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RHSTest.java @@ -19,36 +19,28 @@ package org.drools.compiler.integrationtests.drl; 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.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 RHSTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RHSTest(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 testGenericsInRHS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGenericsInRHS(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl;\n" + @@ -65,8 +57,9 @@ public void testGenericsInRHS() { ksession.dispose(); } - @Test - public void testIncrementOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtest.drl \n" + "global java.util.List list \n" + @@ -96,8 +89,9 @@ public void testIncrementOperator() { } } - @Test - public void testKnowledgeHelperFixerInStrings() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeHelperFixerInStrings(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "package org.drools.compiler.integrationtests.drl; \n" + "global java.util.List list \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RuleFlowGroupTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RuleFlowGroupTest.java index 64095a7a624..a89ccdf2e55 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RuleFlowGroupTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/RuleFlowGroupTest.java @@ -18,38 +18,30 @@ */ package org.drools.compiler.integrationtests.drl; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.core.common.InternalAgenda; import org.drools.testcoverage.common.model.Cheese; 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.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 RuleFlowGroupTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleFlowGroupTest(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 testRuleFlowGroupWithLockOnActivate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleFlowGroupWithLockOnActivate(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3590 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/VariableTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/VariableTest.java index a1c299c028e..586693a54f6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/VariableTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/drl/VariableTest.java @@ -18,31 +18,23 @@ */ package org.drools.compiler.integrationtests.drl; -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; -@RunWith(Parameterized.class) public class VariableTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public VariableTest(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 testVariableDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testVariableDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "rule KickOff\n" + "dialect \"mvel\"\n" + "when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/AccumulateCepEqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/AccumulateCepEqualityModeTest.java index c22b113d3fa..476a2641c25 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/AccumulateCepEqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/AccumulateCepEqualityModeTest.java @@ -19,44 +19,36 @@ package org.drools.compiler.integrationtests.equalitymode; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.AccumulateCepTest; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AccumulateCepEqualityModeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AccumulateCepEqualityModeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.EQUALITY_MODE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.STREAM_MODE, EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } - @Test - public void testManySlidingWindows() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testManySlidingWindows(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, AccumulateCepTest.TEST_MANY_SLIDING_WINDOWS_DRL); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/BackwardChainingEqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/BackwardChainingEqualityModeTest.java index b15e2189943..aee2b8ee7cd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/BackwardChainingEqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/BackwardChainingEqualityModeTest.java @@ -18,29 +18,22 @@ */ package org.drools.compiler.integrationtests.equalitymode; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.AbstractBackwardChainingTest; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 BackwardChainingEqualityModeTest extends AbstractBackwardChainingTest { - public BackwardChainingEqualityModeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.CLOUD_MODE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CellEqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CellEqualityModeTest.java index 0d5a84f7d2c..2fc0da46df9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CellEqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CellEqualityModeTest.java @@ -18,29 +18,21 @@ */ package org.drools.compiler.integrationtests.equalitymode; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.AbstractCellTest; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 CellEqualityModeTest extends AbstractCellTest { - public CellEqualityModeTest(KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.CLOUD_MODE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CepEspEqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CepEspEqualityModeTest.java index 6ba92883881..0f1f170c298 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CepEspEqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/CepEspEqualityModeTest.java @@ -18,29 +18,21 @@ */ package org.drools.compiler.integrationtests.equalitymode; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.AbstractCellTest; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 CepEspEqualityModeTest extends AbstractCellTest { - public CepEspEqualityModeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.STREAM_MODE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/DeclareEqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/DeclareEqualityModeTest.java index dccd34e8c8d..ca167bdd2e0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/DeclareEqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/DeclareEqualityModeTest.java @@ -18,29 +18,21 @@ */ package org.drools.compiler.integrationtests.equalitymode; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.integrationtests.drl.AbstractDeclareTest; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 DeclareEqualityModeTest extends AbstractDeclareTest { - public DeclareEqualityModeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - super(kieBaseTestConfiguration); - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.CLOUD_MODE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/EqualityModeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/EqualityModeTest.java index bdf5ef03b0d..3a1b20ffa97 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/EqualityModeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/equalitymode/EqualityModeTest.java @@ -19,42 +19,34 @@ package org.drools.compiler.integrationtests.equalitymode; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.EngineTestConfiguration; 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 EqualityModeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EqualityModeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, + public static Stream parameters() { + return TestParametersUtil2.getKieBaseConfigurations(EngineTestConfiguration.ALPHA_NETWORK_COMPILER_FALSE, EngineTestConfiguration.EQUALITY_MODE, EngineTestConfiguration.CLOUD_MODE, EngineTestConfiguration.EXECUTABLE_MODEL_OFF, EngineTestConfiguration.EXECUTABLE_MODEL_FLOW, - EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN); + EngineTestConfiguration.EXECUTABLE_MODEL_PATTERN).stream(); } - @Test - public void testBasicFactEquality() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBasicFactEquality(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithEquals.class.getCanonicalName() + " \n" + "rule R \n" @@ -79,8 +71,9 @@ public void testBasicFactEquality() { } } - @Test - public void testAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithEquals.class.getCanonicalName() + " \n" + "global java.util.List result; \n" diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/FromOnlyExecModelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/FromOnlyExecModelTest.java index c30ab9cce99..a5ae4e3bd61 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/FromOnlyExecModelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/operators/FromOnlyExecModelTest.java @@ -37,7 +37,7 @@ public static Stream parameters() { } // KOGITO-3771 - @ParameterizedTest + @ParameterizedTest(name = "KieBase type={0}") @MethodSource("parameters") public void testFromSharingWithNativeImage(KieBaseTestConfiguration kieBaseTestConfiguration) { try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCanonicalModelCompilerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCanonicalModelCompilerTest.java index 85277cc8989..fe32ee094da 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCanonicalModelCompilerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCanonicalModelCompilerTest.java @@ -28,7 +28,7 @@ import org.drools.io.ClassPathResource; import org.drools.model.codegen.execmodel.PackageSources; import org.drools.model.codegen.tool.ExplicitCanonicalModelCompiler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.Resource; import org.kie.internal.builder.KnowledgeBuilderFactory; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCompilerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCompilerTest.java index 7e12fb43daf..8d159e8d953 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCompilerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/phases/ExplicitCompilerTest.java @@ -54,8 +54,8 @@ import org.drools.drl.parser.DroolsParserException; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.SessionsAwareKnowledgeBase; +import org.junit.jupiter.api.Test; import org.drools.io.ClassPathResource; -import org.junit.Test; import org.kie.api.io.Resource; import org.kie.api.runtime.KieSession; import org.kie.internal.builder.KnowledgeBuilderFactory; From 1a8b5762bf21e9acf47bcf4624b47e906cf7ba16 Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Tue, 5 Nov 2024 08:35:16 +0100 Subject: [PATCH 3/3] [incubator-kie-drools-6136] Migrate drools test coverage to JUnit5 (#6142) * Migrated first group of tests in mvel * More tests migrated * More tests migrated to Junit5 * Migrated more tests to Junit5 * More tests migrated to Junit5 --- .../java/org/drools/mvel/AlphaNodeTest.java | 41 +- .../mvel/CompositeObjectSinkAdapterTest.java | 201 ++++--- .../BaseClassFieldAccessorFactoryTest.java | 6 +- .../drools/mvel/compiler/InlineCastTest.java | 101 ++-- .../drools/mvel/compiler/MemoryLeakTest.java | 46 +- .../mvel/compiler/NestedAccessorsTest.java | 51 +- .../drools/mvel/compiler/NodeHashingTest.java | 61 +- .../compiler/api/KnowledgeBuilderTest.java | 2 +- .../beliefsystem/abductive/AbductionTest.java | 147 ++--- .../defeasible/DefeasibilityTest.java | 156 +++-- .../compiler/beliefsystem/jtms/JTMSTest.java | 99 +-- .../mvel/compiler/builder/KieBuilderTest.java | 10 +- .../KnowledgeBuilderConfigurationTest.java | 6 +- .../impl/KieFileSystemScannerTest.java | 2 +- ...KnowledgeBuilderConfigurationImplTest.java | 2 +- .../impl/KnowledgeBuilderImplTest.java | 10 +- .../builder/impl/KnowledgeBuilderTest.java | 14 +- .../command/DisposeCommandPublicAPITest.java | 3 +- .../command/MoreBatchExecutionTest.java | 35 +- .../compiler/command/PropagationListTest.java | 7 +- .../command/RegisterWorkItemHandlerTest.java | 26 +- .../command/SimpleBatchExecutionTest.java | 63 +- .../common/InternalMatchIteratorTest.java | 99 +-- .../common/TerminalNodeIteratorTest.java | 27 +- .../NativeJavaCompilerSettingsTest.java | 2 +- .../compiler/CompilerPerfProfileTest.java | 2 +- .../compiler/DescrResourceSetTest.java | 3 +- .../mvel/compiler/compiler/DrlParserTest.java | 108 ++-- .../PackageBuilderConfigurationTest.java | 18 +- .../compiler/PatternBuilderForQueryTest.java | 2 +- .../mvel/compiler/compiler/RuleErrorTest.java | 2 +- .../compiler/TypeDeclarationMergingTest.java | 2 +- .../compiler/TypeDeclarationTest.java | 173 +++--- .../TypeDeclarationUnsupportedModelTest.java | 51 +- .../io/memory/MemoryFileSystemTest.java | 6 +- .../conf/KnowledgeBaseConfigurationTest.java | 6 +- .../KnowledgeSessionConfigurationTest.java | 6 +- .../KnowledgePackageMetaDataTest.java | 28 +- .../kie/builder/DslExpansionTest.java | 31 +- .../compiler/kie/builder/WireChannelTest.java | 30 +- .../kie/builder/WireListenerTest.java | 30 +- ...ojectTransformUrlToFileSystemPathTest.java | 33 +- .../builder/impl/KieBuilderSetImplTest.java | 50 +- .../builder/impl/KieFileSystemImplTest.java | 6 +- .../kie/builder/impl/KieModuleRepoTest.java | 20 +- .../MemoryKieModuleResourceProviderTest.java | 2 +- .../kie/util/ChangeSetBuilderTest.java | 2 +- .../mvel/compiler/kproject/ReleaseIdTest.java | 2 +- .../kproject/memory/MemoryFileTest.java | 2 +- .../kproject/memory/MemoryFolderTest.java | 2 +- .../mvel/compiler/lang/DRLContextTest.java | 567 ++++++++++++------ .../mvel/compiler/lang/DRLExprParserTest.java | 14 +- .../mvel/compiler/lang/DescrDumperTest.java | 11 +- .../compiler/lang/DroolsSoftKeywordsTest.java | 2 +- .../mvel/compiler/lang/ErrorsParserTest.java | 2 +- .../mvel/compiler/lang/RuleParserTest.java | 10 +- .../compiler/lang/api/DescrBuilderTest.java | 2 +- .../compiler/lang/descr/AndDescrTest.java | 2 +- .../lang/descr/ConnectiveDescrTest.java | 2 +- .../compiler/lang/descr/PackageDescrTest.java | 2 +- .../mvel/compiler/lang/dsl/ANTLRDSLTest.java | 2 +- .../lang/dsl/DSLMappingEntryTest.java | 2 +- .../compiler/lang/dsl/DSLMappingFileTest.java | 7 +- .../lang/dsl/DSLTokenizedMappingFileTest.java | 2 +- .../lang/dsl/DefaultExpanderTest.java | 10 +- .../compiler/oopath/OOPathAccumulateTest.java | 73 ++- .../mvel/compiler/oopath/OOPathBindTest.java | 84 +-- .../mvel/compiler/oopath/OOPathCastTest.java | 36 +- .../compiler/oopath/OOPathMultilevelTest.java | 47 +- .../compiler/oopath/OOPathQueriesTest.java | 41 +- .../compiler/oopath/OOPathReactiveTest.java | 103 ++-- .../mvel/compiler/oopath/OOPathTest.java | 152 ++--- .../oopath/graph/OOPathOnGraphTest.java | 41 +- .../reteoo/ReteooBuilderPerformanceTest.java | 6 +- .../compiler/reteoo/ReteooBuilderTest.java | 2 +- .../rule/builder/XpathAnalysisTest.java | 2 +- .../dialect/JavaAndMVELCombinedTest.java | 48 +- .../dialect/java/AccumulateTemplateTest.java | 6 +- .../dialect/java/AsmGeneratorTest.java | 36 +- .../builder/dialect/java/RuleBuilderTest.java | 2 +- .../simulation/BatchRunFluentTest.java | 123 ++-- .../mvel/compiler/test/PositionalTest.java | 33 +- .../testframework/FactPopulatorTest.java | 4 +- .../RuleCoverageListenerTest.java | 3 +- .../util/debug/SessionInspectorTest.java | 31 +- .../BooleanClassFieldExtractorTest.java | 6 +- .../ByteClassFieldExtractorTest.java | 6 +- .../CharClassFieldExtractorTest.java | 6 +- .../extractors/ClassFieldAccessorTest.java | 6 +- .../DoubleClassFieldExtractorTest.java | 6 +- .../mvel/extractors/FieldIndexEntryTest.java | 6 +- .../FloatClassFieldExtractorTest.java | 6 +- .../IntClassFieldExtractorTest.java | 6 +- .../LongClassFieldExtractorTest.java | 6 +- .../MVELClassFieldExtractorTest.java | 6 +- .../ObjectClassFieldExtractorTest.java | 6 +- .../ShortClassFieldExtractorTest.java | 6 +- .../integrationtests/DynamicEvalTest.java | 10 +- .../session/AgendaFilterTest.java | 56 +- .../session/BasicUpdateTest.java | 69 +-- .../session/CrossProductTest.java | 26 +- .../integrationtests/session/DeleteTest.java | 90 +-- .../session/EntryPointTest.java | 26 +- .../session/FieldAccessTest.java | 38 +- .../integrationtests/session/InsertTest.java | 36 +- .../integrationtests/session/LocaleTest.java | 26 +- .../session/RuleRuntimeEventTest.java | 26 +- .../session/SessionsPoolTest.java | 85 +-- .../session/StatefulSessionTest.java | 54 +- .../session/StatelessSessionTest.java | 78 +-- .../session/TypeCoercionTest.java | 68 +-- .../integrationtests/session/UpdateTest.java | 127 ++-- .../org/drools/mvel/rule/DeclarationTest.java | 6 +- .../mvel/rule/EnumSerialiationTest.java | 2 +- .../drools/mvel/rule/GroupElementTest.java | 2 +- .../mvel/rule/PackageCompilationDataTest.java | 2 +- .../org/drools/mvel/rule/PatternTest.java | 2 +- .../java/org/drools/mvel/rule/RuleTest.java | 2 +- .../util/RightTupleIndexHashTableTest.java | 6 +- .../workitem/CustomWorkItemHandlerTest.java | 2 +- .../reteevaluator/ReteEvaluatorTest.java | 2 +- 121 files changed, 2214 insertions(+), 2043 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AlphaNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AlphaNodeTest.java index 562178b1b06..48701e11c60 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AlphaNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AlphaNodeTest.java @@ -18,9 +18,9 @@ */ package org.drools.mvel; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.stream.Stream; import org.drools.core.base.ClassFieldAccessorCache; @@ -40,38 +40,27 @@ import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; import org.drools.mvel.model.Cheese; import org.drools.mvel.model.MockObjectSource; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class AlphaNodeTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - private final boolean useLambdaConstraint; - - public AlphaNodeTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); } - @Test - public void testLiteralConstraintAssertObjectWithoutMemory() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testLiteralConstraintAssertObjectWithoutMemory(boolean useLambdaConstraint) throws Exception { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); BuildContext buildContext = new BuildContext( kBase, Collections.emptyList() ); buildContext.setRule(new RuleImpl("test")); @@ -131,8 +120,9 @@ public void testLiteralConstraintAssertObjectWithoutMemory() throws Exception { /* * This just test AlphaNode With a different Constraint type. */ - @Test - public void testReturnValueConstraintAssertObject() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testReturnValueConstraintAssertObject(boolean useLambdaConstraint) throws Exception { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); BuildContext buildContext = new BuildContext( kBase, Collections.emptyList() ); buildContext.setRule(new RuleImpl("test")); @@ -184,8 +174,9 @@ public void testReturnValueConstraintAssertObject() throws Exception { assertThat((Collection) sink.getAsserted()).hasSize(0); } - @Test - public void testUpdateSinkWithoutMemory() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testUpdateSinkWithoutMemory(boolean useLambdaConstraint) { // An AlphaNode should try and repropagate from its source InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); BuildContext buildContext = new BuildContext( kBase, Collections.emptyList() ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/CompositeObjectSinkAdapterTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/CompositeObjectSinkAdapterTest.java index afd7692759a..e2713646e2b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/CompositeObjectSinkAdapterTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/CompositeObjectSinkAdapterTest.java @@ -39,25 +39,24 @@ import org.drools.mvel.accessors.ClassFieldAccessorStore; import org.drools.mvel.model.Cheese; import org.drools.mvel.model.MockObjectSource; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.runtime.rule.FactHandle; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class CompositeObjectSinkAdapterTest { private InternalKnowledgeBase kBase; private BuildContext buildContext; @@ -66,21 +65,11 @@ public class CompositeObjectSinkAdapterTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - private final boolean useLambdaConstraint; - - public CompositeObjectSinkAdapterTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); @@ -92,7 +81,6 @@ public void setUp() throws Exception { } - @Test public void testAddBeta() { final MockBetaNode beta = createBetaNode(); @@ -105,7 +93,6 @@ public void testAddBeta() { hashedSinkMapIsEmpty(); } - @Test public void testAddBetaRemoveBeta() { final MockBetaNode beta = createBetaNode(); ad.addObjectSink( beta ); @@ -117,7 +104,6 @@ public void testAddBetaRemoveBeta() { } - @Test public void testAddOneAlphaNotHashable() { final AlphaNode al = createAlphaNode(new AlphaNodeFieldConstraintMock()); ad.addObjectSink( al ); @@ -126,7 +112,8 @@ public void testAddOneAlphaNotHashable() { otherSinksAre(al); } - @Test + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") public void testAddOneAlphaNotHashableRemoveOneAlpha() { final AlphaNode al = createAlphaNode(new AlphaNodeFieldConstraintMock()); ad.addObjectSink( al ); @@ -137,10 +124,11 @@ public void testAddOneAlphaNotHashableRemoveOneAlpha() { otherSinksAreEmpty(); } - @Test - public void testAddOneAlpha() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddOneAlpha(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); @@ -150,10 +138,11 @@ public void testAddOneAlpha() { hashableSinksAre(al); } - @Test - public void testAddOneAlphaRemoveOneAlpha() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddOneAlphaRemoveOneAlpha(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); ad.removeObjectSink( al ); @@ -162,12 +151,13 @@ public void testAddOneAlphaRemoveOneAlpha() { hashableSinksAreEmpty(); } - @Test - public void testAddTwoAlphas() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddTwoAlphas(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("cheddar")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "cheddar")); ad.addObjectSink( al2 ); @@ -176,12 +166,13 @@ public void testAddTwoAlphas() { hashableSinksAre(al, al2); } - @Test - public void testAddTwoAlphasAddOneBeta() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddTwoAlphasAddOneBeta(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("cheddar")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "cheddar")); ad.addObjectSink( al2 ); final BetaNode beta = createBetaNode(); @@ -191,12 +182,13 @@ public void testAddTwoAlphasAddOneBeta() { hashableSinksAre(al, al2); } - @Test - public void testAddTwoAlphasAddOneBetaRemoveOneBeta() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddTwoAlphasAddOneBetaRemoveOneBeta(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("cheddar")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "cheddar")); ad.addObjectSink( al2 ); final BetaNode beta = createBetaNode(); ad.addObjectSink( beta ); @@ -207,14 +199,15 @@ public void testAddTwoAlphasAddOneBetaRemoveOneBeta() { hashableSinksAre(al, al2); } - @Test - public void testAddThreeAlphas() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddThreeAlphas(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("cheddar")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "cheddar")); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo("stinky")); + final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stinky")); ad.addObjectSink( al3 ); @@ -223,14 +216,15 @@ public void testAddThreeAlphas() { hashedSinkMapIs(al, al2, al3); } - @Test - public void testAddThreeAlphasRemoveOneAlpha() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddThreeAlphasRemoveOneAlpha(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo("stilton")); + final AlphaNode al = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("cheddar")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "cheddar")); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo("stinky")); + final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stinky")); ad.addObjectSink( al3 ); ad.removeObjectSink( al2 ); @@ -240,14 +234,15 @@ public void testAddThreeAlphasRemoveOneAlpha() { } - @Test - public void testTripleAlphaCharacterConstraint() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTripleAlphaCharacterConstraint(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "charType" ); - final AlphaNode al = createAlphaNode(cheeseCharTypeEqualsTo(65)); + final AlphaNode al = createAlphaNode(cheeseCharTypeEqualsTo(useLambdaConstraint, 65)); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseCharTypeEqualsTo(66)); + final AlphaNode al2 = createAlphaNode(cheeseCharTypeEqualsTo(useLambdaConstraint, 66)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheeseCharTypeEqualsTo(67)); + final AlphaNode al3 = createAlphaNode(cheeseCharTypeEqualsTo(useLambdaConstraint, 67)); ad.addObjectSink( al3 ); assertThat(ad.getHashedSinkMap().get(keyForCheeseCharType('B'))).isSameAs(al2); @@ -255,24 +250,26 @@ public void testTripleAlphaCharacterConstraint() { } - @Test - public void testTripleAlphaObjectCharacterConstraint() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTripleAlphaObjectCharacterConstraint(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "charObjectType" ); - final AlphaNode al = createAlphaNode(cheeseCharObjectTypeEqualsTo(65)); + final AlphaNode al = createAlphaNode(cheeseCharObjectTypeEqualsTo(useLambdaConstraint, 65)); ad.addObjectSink( al ); - final AlphaNode al2 = createAlphaNode(cheeseCharObjectTypeEqualsTo(66)); + final AlphaNode al2 = createAlphaNode(cheeseCharObjectTypeEqualsTo(useLambdaConstraint, 66)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheeseCharObjectTypeEqualsTo(67)); + final AlphaNode al3 = createAlphaNode(cheeseCharObjectTypeEqualsTo(useLambdaConstraint, 67)); ad.addObjectSink( al3 ); assertThat(ad.getHashedSinkMap().get(keyForCheeseCharObjectType('B'))).isSameAs(al2); assertThat(ad.getHashedSinkMap().get(keyForCheeseCharObjectType('X'))).isNull(); } - @Test - public void testAddOneAlphaForRanges() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddOneAlphaForRanges(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); @@ -283,12 +280,13 @@ public void testAddOneAlphaForRanges() { } - @Test - public void testTwoAlphasForRanges() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTwoAlphasForRanges(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); - final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(20)); + final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 20)); ad.addObjectSink( al2 ); @@ -297,14 +295,15 @@ public void testTwoAlphasForRanges() { } - @Test - public void testThreeAlphasForRanges() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testThreeAlphasForRanges(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); - final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(20)); + final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 20)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(30)); + final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 30)); ad.addObjectSink( al3 ); @@ -314,14 +313,15 @@ public void testThreeAlphasForRanges() { } - @Test - public void testAddThreeAlphasRemoveOneAlphaForRanges() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddThreeAlphasRemoveOneAlphaForRanges(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); - final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(20)); + final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 20)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(30)); + final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 30)); ad.addObjectSink( al3 ); ad.removeObjectSink( al2 ); @@ -331,14 +331,15 @@ public void testAddThreeAlphasRemoveOneAlphaForRanges() { } - @Test - public void testAddThreeAlphasVerifyRangeQuery() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddThreeAlphasVerifyRangeQuery(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); - final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(20)); + final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 20)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(30)); + final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 30)); ad.addObjectSink( al3 ); // test propagation @@ -361,27 +362,29 @@ public void testAddThreeAlphasVerifyRangeQuery() { - @Test(expected = IllegalStateException.class) - public void testRangeIndexConflictKey() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testRangeIndexConflictKey(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "price" ); - final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(10)); + final AlphaNode al1 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 10)); ad.addObjectSink( al1 ); - final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(20)); + final AlphaNode al2 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 20)); ad.addObjectSink( al2 ); - final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(30)); + final AlphaNode al3 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 30)); ad.addObjectSink( al3 ); - final AlphaNode al4 = createAlphaNode(cheesePriceGreaterThan(30)); + final AlphaNode al4 = createAlphaNode(cheesePriceGreaterThan(useLambdaConstraint, 30)); - ad.addObjectSink( al4 ); // throws IllegalStateException + assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> ad.addObjectSink( al4 )); // throws IllegalStateException } - @Test - public void testPropagationWithNullValue() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testPropagationWithNullValue(boolean useLambdaConstraint) { extractor = store.getReader( Cheese.class, "type" ); - final AlphaNode al1 = createAlphaNode(cheeseTypeEqualsTo("stilton")); - final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo("brie")); - final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo("muzzarela")); + final AlphaNode al1 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "stilton")); + final AlphaNode al2 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "brie")); + final AlphaNode al3 = createAlphaNode(cheeseTypeEqualsTo(useLambdaConstraint, "muzzarela")); ad.addObjectSink( al1 ); ad.addObjectSink( al2 ); @@ -401,19 +404,19 @@ public void testPropagationWithNullValue() { } - private AlphaNodeFieldConstraint cheeseTypeEqualsTo(String value) { + private AlphaNodeFieldConstraint cheeseTypeEqualsTo(boolean useLambdaConstraint, String value) { return ConstraintTestUtil.createCheeseTypeEqualsConstraint(extractor, value, useLambdaConstraint); } - private AlphaNodeFieldConstraint cheeseCharTypeEqualsTo(int value) { + private AlphaNodeFieldConstraint cheeseCharTypeEqualsTo(boolean useLambdaConstraint, int value) { return ConstraintTestUtil.createCheeseCharTypeEqualsConstraint(extractor, value, useLambdaConstraint); } - private AlphaNodeFieldConstraint cheeseCharObjectTypeEqualsTo(int value) { + private AlphaNodeFieldConstraint cheeseCharObjectTypeEqualsTo(boolean useLambdaConstraint, int value) { return ConstraintTestUtil.createCheeseCharObjectTypeEqualsConstraint(extractor, value, useLambdaConstraint); } - private AlphaNodeFieldConstraint cheesePriceGreaterThan(int value) { + private AlphaNodeFieldConstraint cheesePriceGreaterThan(boolean useLambdaConstraint, int value) { return ConstraintTestUtil.createCheesePriceGreaterConstraint(extractor, value, useLambdaConstraint); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/asm/BaseClassFieldAccessorFactoryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/asm/BaseClassFieldAccessorFactoryTest.java index 7b31ac52713..e2196f31ca2 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/asm/BaseClassFieldAccessorFactoryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/asm/BaseClassFieldAccessorFactoryTest.java @@ -27,8 +27,8 @@ import org.drools.core.util.asm.TestAbstractImpl; import org.drools.core.util.asm.TestInterface; import org.drools.core.util.asm.TestInterfaceImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -36,7 +36,7 @@ public class BaseClassFieldAccessorFactoryTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/InlineCastTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/InlineCastTest.java index 6ff955ccc59..fe6200e3038 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/InlineCastTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/InlineCastTest.java @@ -19,36 +19,28 @@ package org.drools.mvel.compiler; 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.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 InlineCastTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public InlineCastTest(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 testInlineCast() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", address#LongAddress.country == \"uk\" )\n" + @@ -73,8 +65,9 @@ public void testInlineCast() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastWithBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", $country : address#LongAddress.country == \"uk\" )\n" + @@ -99,8 +92,9 @@ public void testInlineCastWithBinding() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastOnlyBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastOnlyBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", $country : address#LongAddress.country )\n" + @@ -125,8 +119,9 @@ public void testInlineCastOnlyBinding() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastWithFQN() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithFQN(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.Person;\n" + "rule R1 when\n" + " Person( name == \"mark\", address#org.drools.mvel.compiler.LongAddress.country == \"uk\" )\n" + @@ -144,8 +139,9 @@ public void testInlineCastWithFQN() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastOnRightOperand() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastOnRightOperand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " $person : Person( )\n" + @@ -165,8 +161,9 @@ public void testInlineCastOnRightOperand() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastOnRightOperandWithFQN() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastOnRightOperandWithFQN(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.Person;\n" + "rule R1 when\n" + " $person : Person( )\n" + @@ -186,8 +183,9 @@ public void testInlineCastOnRightOperandWithFQN() throws Exception { ksession.dispose(); } - @Test - public void testInferredCast() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInferredCast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", address instanceof LongAddress, address.country == \"uk\" )\n" + @@ -212,8 +210,9 @@ public void testInferredCast() throws Exception { ksession.dispose(); } - @Test - public void testInlineTypeCast() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineTypeCast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-136 String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + @@ -239,8 +238,9 @@ public void testInlineTypeCast() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastWithNestedAccces() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithNestedAccces(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-127 String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + @@ -266,8 +266,9 @@ public void testInlineCastWithNestedAccces() throws Exception { ksession.dispose(); } - @Test - public void testInlineCastWithNestedAcccesAndNullSafeDereferencing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithNestedAcccesAndNullSafeDereferencing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", address#LongAddress.country!.length == 2 )\n" + @@ -292,8 +293,9 @@ public void testInlineCastWithNestedAcccesAndNullSafeDereferencing() throws Exce ksession.dispose(); } - @Test - public void testInlineCastWithNestedAcccesAndNullSafeDereferencing2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithNestedAcccesAndNullSafeDereferencing2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( " + @@ -320,8 +322,9 @@ public void testInlineCastWithNestedAcccesAndNullSafeDereferencing2() throws Exc ksession.dispose(); } - @Test - public void testSuperclass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSuperclass(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.integrationtests\n" + "import org.drools.mvel.compiler.*;\n" + "rule R1\n" @@ -351,8 +354,9 @@ public void testSuperclass() { } } - @Test - public void testGroupedAccess() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGroupedAccess(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.integrationtests\n" + "import org.drools.mvel.compiler.*;\n" + "rule R1\n" @@ -382,8 +386,9 @@ public void testGroupedAccess() { } } - @Test - public void testMatchesOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMatchesOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-971008 String drl = "package org.drools.mvel.compiler.integrationtests\n" + "import org.drools.mvel.compiler.*;\n" @@ -414,8 +419,9 @@ public void testMatchesOperator() { } } - @Test - public void testInlineCastWithThis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithThis(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.integrationtests " + "import org.drools.compiler.*; " + "rule R1 " @@ -436,8 +442,9 @@ public void testInlineCastWithThis() { } } - @Test - public void testInlineCastWithFQNAndMethodInvocation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithFQNAndMethodInvocation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1337 String str = "import org.drools.mvel.compiler.Person;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java index ecee4e74f76..3668ec9836f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Stream; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.Memory; @@ -45,12 +46,12 @@ 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.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.tms.TruthMaintenanceSystemFactoryImpl; -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.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.ReleaseId; @@ -61,22 +62,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MemoryLeakTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MemoryLeakTest(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 testStagedTupleLeak() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStagedTupleLeak(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1056599 String str = "rule R1 when\n" + @@ -130,8 +124,9 @@ public void testStagedTupleLeak() throws Exception { assertThat(tms.getEntryPointsMapSize()).isEqualTo(0); } - @Test - public void testStagedLeftTupleLeak() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStagedLeftTupleLeak(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1058874 String str = "rule R1 when\n" + @@ -169,8 +164,9 @@ public void testStagedLeftTupleLeak() throws Exception { assertThat(stagedLeftTuples.getInsertFirst()).isNull(); } - @Test - public void testBetaMemoryLeakOnFactDelete() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaMemoryLeakOnFactDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-913 String drl = "rule R1 when\n" + @@ -216,10 +212,12 @@ public void testBetaMemoryLeakOnFactDelete() { } } - @Test(timeout = 5000) - @Ignore("The checkReachability method is not totally reliable and can fall in an endless loop." + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + @Disabled("The checkReachability method is not totally reliable and can fall in an endless loop." + "We need to find a better way to check this.") - public void testLeakAfterSessionDispose() { + public void testLeakAfterSessionDispose(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1655 String drl = "import " + Person.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NestedAccessorsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NestedAccessorsTest.java index 0d350995d3e..c21cfe39ff3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NestedAccessorsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NestedAccessorsTest.java @@ -19,16 +19,15 @@ package org.drools.mvel.compiler; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.CommonTestMethodBase; 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.AfterMatchFiredEvent; import org.kie.api.runtime.KieSession; @@ -39,22 +38,15 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class NestedAccessorsTest extends CommonTestMethodBase { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NestedAccessorsTest(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 testNestedAccessor() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccessor(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", cheese.(type == \"gorgonzola\", price == 10) )\n" + @@ -72,8 +64,9 @@ public void testNestedAccessor() throws Exception { ksession.dispose(); } - @Test - public void testNestedAccessorWithBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccessorWithBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String str = "import org.drools.mvel.compiler.*;\n" + "global StringBuilder sb\n" + "rule R1 when\n" + @@ -97,8 +90,9 @@ public void testNestedAccessorWithBinding() throws Exception { ksession.dispose(); } - @Test - public void testDoubleNestedAccessor() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleNestedAccessor(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", cheese.(price == 10, type.(length == 10) ) )\n" + @@ -116,8 +110,9 @@ public void testDoubleNestedAccessor() throws Exception { ksession.dispose(); } - @Test - public void testNestedAccessorWithInlineCast() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccessorWithInlineCast(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( name == \"mark\", address#LongAddress.(country == \"uk\", suburb == \"suburb\") )\n" + @@ -142,8 +137,9 @@ public void testNestedAccessorWithInlineCast() throws Exception { ksession.dispose(); } - @Test - public void testNestedAccessors() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccessors(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_NestedAccessors.drl"); final KieSession ksession = createKnowledgeSession(kbase); @@ -184,8 +180,9 @@ public void testNestedAccessors() throws Exception { assertThat(list.get(1)).isSameAs(item22); } - @Test - public void testNestedAccessors2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedAccessors2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String rule = "package org.drools.mvel.compiler\n" + "rule 'rule1'" + " salience 10\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NodeHashingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NodeHashingTest.java index d08a0e7d964..21dbb02f539 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NodeHashingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/NodeHashingTest.java @@ -20,35 +20,27 @@ import java.math.BigDecimal; import java.math.BigInteger; -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.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 NodeHashingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NodeHashingTest(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 testNodeHashTypeMismatch() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatch(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -103,8 +95,9 @@ public void testNodeHashTypeMismatch() throws Exception { ksession2.dispose(); } - @Test - public void testNodeHashTypeMismatchWithBigInteger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchWithBigInteger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -159,8 +152,9 @@ public void testNodeHashTypeMismatchWithBigInteger() throws Exception { ksession2.dispose(); } - @Test - public void testNodeHashTypeMismatchWithBigDecimal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchWithBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -215,8 +209,9 @@ public void testNodeHashTypeMismatchWithBigDecimal() throws Exception { ksession2.dispose(); } - @Test - public void testNodeHashTypeMismatchFromBigDecimal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchFromBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -273,8 +268,9 @@ public void testNodeHashTypeMismatchFromBigDecimal() throws Exception { ksession2.dispose(); } - @Test - public void testNodeHashTypeMismatchWithPrimitiveDouble() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchWithPrimitiveDouble(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -331,8 +327,9 @@ public void testNodeHashTypeMismatchWithPrimitiveDouble() throws Exception { ksession2.dispose(); } - @Test - public void testNodeHashTypeMismatchWithBigIntegerAndDecimal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchWithBigIntegerAndDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -401,8 +398,9 @@ public Double getValue() { } } - @Test - public void testNodeHashTypeMismatchWithDouble() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNodeHashTypeMismatchWithDouble(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1328380 // 2 rules -- Mvel coercion @@ -453,8 +451,9 @@ public void testNodeHashTypeMismatchWithDouble() throws Exception { ksession2.dispose(); } - @Test - public void testHashingOnClassConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHashingOnClassConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + A.class.getCanonicalName() + "\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/api/KnowledgeBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/api/KnowledgeBuilderTest.java index d612968e5e6..64b26635983 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/api/KnowledgeBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/api/KnowledgeBuilderTest.java @@ -20,7 +20,7 @@ import java.util.Collection; -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.builder.Results; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/abductive/AbductionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/abductive/AbductionTest.java index 16ba7c6ffb8..ad31f595d71 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/abductive/AbductionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/abductive/AbductionTest.java @@ -20,11 +20,11 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.commands.runtime.FlatQueryResults; import org.drools.core.BeliefSystemType; @@ -36,15 +36,14 @@ 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.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.tms.TruthMaintenanceSystemEqualityKey; import org.drools.tms.beliefsystem.BeliefSet; import org.drools.tms.beliefsystem.abductive.Abducible; import org.drools.tms.beliefsystem.defeasible.Defeasible; -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.builder.KieBuilder; import org.kie.api.builder.KieModule; @@ -62,22 +61,14 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AbductionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AbductionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // Abduction is experimental. And not supported for exec-model - return TestParametersUtil.getKieBaseCloudConfigurations(false, true); + return TestParametersUtil2.getKieBaseCloudConfigurations(false, true).stream(); } - protected KieSession getSessionFromString( String drlString, KieBaseOption... options ) { + protected KieSession getSessionFromString(KieBaseTestConfiguration kieBaseTestConfiguration, String drlString, KieBaseOption... options) { KieModule kieModule = KieUtil.getKieModuleFromDrls("test", kieBaseTestConfiguration, drlString); KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, options); @@ -86,8 +77,9 @@ protected KieSession getSessionFromString( String drlString, KieBaseOption... op return kbase.newKieSession( ksConf, null ); } - @Test - public void testAbductiveLogicWithConstructorArgs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicWithConstructorArgs(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -148,7 +140,7 @@ public void testAbductiveLogicWithConstructorArgs() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList(); session.setGlobal( "list", list ); @@ -164,8 +156,9 @@ public void testAbductiveLogicWithConstructorArgs() { } - @Test - public void testAbductiveLogicWithSelectiveConstructorArgs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicWithSelectiveConstructorArgs(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -194,7 +187,7 @@ public void testAbductiveLogicWithSelectiveConstructorArgs() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList(); session.setGlobal( "list", list ); @@ -211,8 +204,9 @@ public void testAbductiveLogicWithSelectiveConstructorArgs() { System.err.println( list ); } - @Test - public void testAbductiveLogicWithNonExistingArgsMapping() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicWithNonExistingArgsMapping(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -238,8 +232,9 @@ public void testAbductiveLogicWithNonExistingArgsMapping() { assertThat(res.getMessages(Message.Level.ERROR).size()).isEqualTo(1); } - @Test - public void testAbductiveLogicWithWrongTypeArgsMapping() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicWithWrongTypeArgsMapping(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -272,8 +267,9 @@ public void testAbductiveLogicWithWrongTypeArgsMapping() { assertThat(res.getMessages(Message.Level.ERROR).size()).isEqualTo(1); } - @Test - public void testBindNonAbductiveQueryError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindNonAbductiveQueryError(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + "" + @@ -297,8 +293,9 @@ public void testBindNonAbductiveQueryError() { - @Test - public void testAbducedReturnBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbducedReturnBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -325,7 +322,7 @@ public void testAbducedReturnBinding() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); Map map = new HashMap(); session.setGlobal( "map", map ); @@ -392,8 +389,9 @@ public String toString() { } - @Test - public void testAbducedKnownClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbducedKnownClass(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -416,7 +414,7 @@ public void testAbducedKnownClass() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); Map map = new HashMap(); session.setGlobal( "map", map ); @@ -432,8 +430,9 @@ public void testAbducedKnownClass() { - @Test - public void testAbducedWithStatus() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbducedWithStatus(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -456,7 +455,7 @@ public void testAbducedWithStatus() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); Map map = new HashMap(); session.setGlobal( "map", map ); @@ -481,8 +480,9 @@ public void testAbducedWithStatus() { } - @Test - public void testAbductiveLogicUnlinking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicUnlinking(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -518,7 +518,7 @@ public void testAbductiveLogicUnlinking() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList(); session.setGlobal( "list", list ); @@ -534,8 +534,9 @@ public void testAbductiveLogicUnlinking() { } - @Test - public void testAbductiveLogicNoConstructorFoundError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicNoConstructorFoundError(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -567,8 +568,9 @@ public void testAbductiveLogicNoConstructorFoundError() { assertThat(res.getMessages(Message.Level.ERROR).size()).isEqualTo(1); } - @Test - public void testQueryTwice() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryTwice(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -600,7 +602,7 @@ public void testQueryTwice() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList(); session.setGlobal( "list", list ); @@ -615,8 +617,9 @@ public void testQueryTwice() { - @Test - public void testAbductiveLogicSprinklerAndRainExample() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveLogicSprinklerAndRainExample(KieBaseTestConfiguration kieBaseTestConfiguration) { // Sprinkler & Rain, abductive version String droolsSource = "package org.drools.abductive.test; \n" + @@ -694,7 +697,7 @@ public void testAbductiveLogicSprinklerAndRainExample() { KieSession session; try { System.setProperty("drools.negatable", "on"); - session = getSessionFromString( droolsSource ); + session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); } finally { System.setProperty("drools.negatable", "off"); } @@ -721,8 +724,9 @@ public void testAbductiveLogicSprinklerAndRainExample() { assertThat(i).isEqualTo(3); } - @Test - public void testAbductiveFactory() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbductiveFactory(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "" + @@ -766,7 +770,7 @@ public void testAbductiveFactory() { ""; ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList(); session.setGlobal( "list", list ); @@ -779,8 +783,9 @@ public void testAbductiveFactory() { } - @Test - public void testQueryAPIs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryAPIs(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "import " + Abducible.class.getName() + "; \n" + @@ -814,7 +819,7 @@ public void testQueryAPIs() { ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); session.insert( "faa" ); session.fireAllRules(); @@ -856,8 +861,9 @@ public void testQueryAPIs() { - @Test - public void testCitizenshipExample() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCitizenshipExample(KieBaseTestConfiguration kieBaseTestConfiguration) { // from wikipedia, abductive reasoning example String droolsSource = "package org.drools.abductive.test; \n" + @@ -915,7 +921,7 @@ public void testCitizenshipExample() { ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); session.fireAllRules(); @@ -939,9 +945,10 @@ public void testCitizenshipExample() { } - @Test - @Ignore( "Not implemented yet" ) - public void testGenesExplanationBackTracking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled( "Not implemented yet" ) + public void testGenesExplanationBackTracking(KieBaseTestConfiguration kieBaseTestConfiguration) { // from wikipedia, abductive reasoning example /* @@ -1008,7 +1015,7 @@ public void testGenesExplanationBackTracking() { ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource, DeclarativeAgendaOption.ENABLED ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource, DeclarativeAgendaOption.ENABLED ); session.fireAllRules(); @@ -1020,9 +1027,10 @@ public void testGenesExplanationBackTracking() { - @Test - @Ignore( "Not implemented yet" ) - public void testBacktracking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled( "Not implemented yet" ) + public void testBacktracking(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; \n" + "import org.kie.api.runtime.rule.Match;\n" + @@ -1063,7 +1071,7 @@ public void testBacktracking() { ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource, DeclarativeAgendaOption.ENABLED ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource, DeclarativeAgendaOption.ENABLED ); session.fireAllRules(); @@ -1073,8 +1081,9 @@ public void testBacktracking() { } - @Test - public void testCheckForItemsExample() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCheckForItemsExample(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.abductive.test; " + "import " + Abducible.class.getName() + "; " + @@ -1146,7 +1155,7 @@ public void testCheckForItemsExample() { ///////////////////////////////////// - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString(kieBaseTestConfiguration, droolsSource ); List list = new ArrayList( ); session.setGlobal( "list", list ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/defeasible/DefeasibilityTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/defeasible/DefeasibilityTest.java index c8d5a937861..020f0cc3a3d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/defeasible/DefeasibilityTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/defeasible/DefeasibilityTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.beliefsystem.defeasible; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.BeliefSystemType; import org.kie.api.runtime.ClassObjectFilter; @@ -35,14 +35,15 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestParametersUtil; +import org.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.tms.TruthMaintenanceSystemEqualityKey; import org.drools.tms.beliefsystem.BeliefSet; import org.drools.tms.beliefsystem.defeasible.DefeasibilityStatus; import org.drools.tms.beliefsystem.defeasible.DefeasibleBeliefSet; -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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; @@ -52,22 +53,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class DefeasibilityTest { - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DefeasibilityTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + + public static Stream parameters() { // TODO: EM failed with some tests. File JIRAs (maybe unsupported) - return TestParametersUtil.getKieBaseCloudConfigurations(false); + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - protected KieSession getSessionFromString( String drlString) { + protected KieSession getSessionFromString( KieBaseTestConfiguration kieBaseTestConfiguration, String drlString) { KieBase kBase; try { @@ -86,7 +79,7 @@ protected KieSession getSessionFromString( String drlString) { } - protected KieSession getSession( String ruleFile ) { + protected KieSession getSession( KieBaseTestConfiguration kieBaseTestConfiguration, String ruleFile ) { KieBase kBase; try { @@ -117,9 +110,11 @@ private void checkStatus( EqualityKey key, int support, DefeasibilityStatus stat - @Test(timeout = 10000 ) - public void testStrictEntailment() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/strict.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testStrictEntailment(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/strict.drl" ); kSession.fireAllRules(); TruthMaintenanceSystem tms = TruthMaintenanceSystemFactory.get().getOrCreateTruthMaintenanceSystem( (ReteEvaluator) kSession ); @@ -142,9 +137,11 @@ public void testStrictEntailment() { - @Test(timeout = 10000 ) - public void testDefeasibleEntailmentWithStrictOverride() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/strictOverride.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDefeasibleEntailmentWithStrictOverride(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/strictOverride.drl" ); kSession.fireAllRules(); TruthMaintenanceSystem tms = TruthMaintenanceSystemFactory.get().getOrCreateTruthMaintenanceSystem( (ReteEvaluator) kSession ); @@ -168,9 +165,11 @@ public void testDefeasibleEntailmentWithStrictOverride() { - @Test(timeout = 10000 ) - public void defeasibleEntailmentMultiActivation() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/defeat.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void defeasibleEntailmentMultiActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/defeat.drl" ); kSession.fireAllRules(); TruthMaintenanceSystem tms = TruthMaintenanceSystemFactory.get().getOrCreateTruthMaintenanceSystem( (ReteEvaluator) kSession ); @@ -188,9 +187,11 @@ public void defeasibleEntailmentMultiActivation() { assertThat(kSession.getObjects().size()).isEqualTo(3); } - @Test(timeout = 10000 ) - public void testDefeaterNeutrality() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/defeaterOnly.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDefeaterNeutrality(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/defeaterOnly.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); kSession.fireAllRules(); @@ -215,9 +216,11 @@ public void testDefeaterNeutrality() { } - @Test(timeout = 10000 ) - public void testMultipleDefeats() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/multiDefeat.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMultipleDefeats(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/multiDefeat.drl" ); kSession.fireAllRules(); TruthMaintenanceSystem tms = TruthMaintenanceSystemFactory.get().getOrCreateTruthMaintenanceSystem( (ReteEvaluator) kSession ); @@ -242,9 +245,11 @@ public void testMultipleDefeats() { } - @Test(timeout = 10000 ) - public void testRemoveDefiniteJustifier() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/strictRetract.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRemoveDefiniteJustifier(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/strictRetract.drl" ); FactHandle h = kSession.insert( "go" ); kSession.fireAllRules(); @@ -278,9 +283,11 @@ public void testRemoveDefiniteJustifier() { } - @Test(timeout = 10000 ) - public void testRemoveDefeasibleJustifier() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/defeaterRetract.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRemoveDefeasibleJustifier(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/defeaterRetract.drl" ); FactHandle h = kSession.insert( "go" ); kSession.fireAllRules(); @@ -316,9 +323,12 @@ public void testRemoveDefeasibleJustifier() { - @Test(timeout = 10000 ) @Ignore - public void testRemoveDefeasibleEntailmentMultiActivationWithDefeat() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/defeatDefeaterRetract.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + @Disabled + public void testRemoveDefeasibleEntailmentMultiActivationWithDefeat(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/defeatDefeaterRetract.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -386,9 +396,11 @@ public void testRemoveDefeasibleEntailmentMultiActivationWithDefeat() { - @Test(timeout = 10000 ) - public void testDefeaterPositiveVsNegative() { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/defeatersPosNeg.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDefeaterPositiveVsNegative(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/defeatersPosNeg.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); kSession.fireAllRules(); @@ -429,10 +441,12 @@ public void testDefeaterPositiveVsNegative() { assertThat(getNegativeObjects(kSession).size()).isEqualTo(1); } - @Test(timeout = 10000 ) - public void testDefeatOutcomePosNeg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDefeatOutcomePosNeg(KieBaseTestConfiguration kieBaseTestConfiguration) { - KieSession kSession = getSession( "org/drools/mvel/compiler/beliefsystem/defeasible/negDefeatPos.drl" ); + KieSession kSession = getSession( kieBaseTestConfiguration, "org/drools/mvel/compiler/beliefsystem/defeasible/negDefeatPos.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); kSession.fireAllRules(); @@ -457,8 +471,10 @@ public void testDefeatOutcomePosNeg() { } - @Test(timeout = 10000 ) - public void testPrimeJustificationWithEqualityMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPrimeJustificationWithEqualityMode(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.tms.test; \n" + "declare Bar end \n" + @@ -487,7 +503,7 @@ public void testPrimeJustificationWithEqualityMode() { " System.out.println( $b ); \n" + "end \n" ; - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, droolsSource ); FactHandle handle1 = session.insert( 10 ); FactHandle handle2 = session.insert( 20 ); @@ -500,8 +516,10 @@ public void testPrimeJustificationWithEqualityMode() { - @Test(timeout = 10000 ) - public void testWMStatusOnNegativeDefeat() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testWMStatusOnNegativeDefeat(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.tms.test; " + "global java.util.List posList;" + @@ -553,7 +571,7 @@ public void testWMStatusOnNegativeDefeat() { ""; - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, droolsSource ); List posList = new ArrayList(); List negList = new ArrayList(); session.setGlobal( "posList", posList ); @@ -600,8 +618,9 @@ public void testWMStatusOnNegativeDefeat() { - @Test - public void testSelfDefeatWithRebuttal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfDefeatWithRebuttal(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.tms.test; " + "global java.util.List posList;" + @@ -648,7 +667,7 @@ public void testSelfDefeatWithRebuttal() { " System.out.println( ' ---- ' + $b ); " + "end " ; - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, droolsSource ); List posList = new ArrayList(); List negList = new ArrayList(); session.setGlobal( "posList", posList ); @@ -666,8 +685,9 @@ public void testSelfDefeatWithRebuttal() { } - @Test - public void testDefeatersAndDefeasibles() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDefeatersAndDefeasibles(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.tms.test; " + "global java.util.List posList;" + @@ -699,7 +719,7 @@ public void testDefeatersAndDefeasibles() { " System.out.println( ' ++++ ' + $b ); " + "end " ; - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, droolsSource ); List posList = new ArrayList(); session.setGlobal( "posList", posList ); @@ -710,8 +730,10 @@ public void testDefeatersAndDefeasibles() { } - @Test(timeout = 10000 ) - public void testManyDefeasibles() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testManyDefeasibles(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.defeasible; " + "declare Fact " + " fact: String @key " + @@ -754,7 +776,7 @@ public void testManyDefeasibles() { " insertLogical( new Fact( \"wibble\"), \"neg\" ); " + "end"; - KieSession session = getSessionFromString( drl ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, drl ); session.fireAllRules(); FactType factType = session.getKieBase().getFactType( "org.drools.defeasible", "Fact" ); @@ -771,8 +793,10 @@ public void testManyDefeasibles() { } - @Test(timeout = 10000 ) - public void testRetractNegativeDefeaters() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRetractNegativeDefeaters(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "declare Foo end " + @@ -783,7 +807,7 @@ public void testRetractNegativeDefeaters() { "then " + " insertLogical( new Foo(), 'neg' ); " + "end "; - KieSession session = getSessionFromString( drl ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, drl ); FactHandle h = session.insert( "foo" ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/jtms/JTMSTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/jtms/JTMSTest.java index 356d57aecd5..9aa335b5e66 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/jtms/JTMSTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/beliefsystem/jtms/JTMSTest.java @@ -19,9 +19,9 @@ package org.drools.mvel.compiler.beliefsystem.jtms; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.stream.Stream; import org.drools.core.BeliefSystemType; import org.drools.core.RuleSessionConfiguration; @@ -35,14 +35,14 @@ 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.drools.testcoverage.common.util.TestParametersUtil2; import org.drools.tms.TruthMaintenanceSystemEqualityKey; import org.drools.tms.TruthMaintenanceSystemImpl; import org.drools.tms.beliefsystem.jtms.JTMSBeliefSystem; -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.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; import org.kie.api.runtime.KieSessionConfiguration; @@ -54,22 +54,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class JTMSTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public JTMSTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // TODO: EM failed with testConflictToggleWithoutGoingEmpty, testPosNegNonConflictingInsertions. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false, true); + return TestParametersUtil2.getKieBaseCloudConfigurations(false, true).stream(); } - protected KieSession getSessionFromString( String drlString) { + protected KieSession getSessionFromString( KieBaseTestConfiguration kieBaseTestConfiguration, String drlString) { KieBase kBase; try { @@ -85,7 +77,7 @@ protected KieSession getSessionFromString( String drlString) { return kSession; } - protected KieSession getSessionFromFile( String ruleFile ) { + protected KieSession getSessionFromFile( KieBaseTestConfiguration kieBaseTestConfiguration, String ruleFile ) { KieBase kBase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, ruleFile); KieSessionConfiguration ksConf = RuleBaseFactory.newKnowledgeSessionConfiguration(); @@ -95,8 +87,10 @@ protected KieSession getSessionFromFile( String ruleFile ) { return kSession; } - @Test(timeout = 10000 ) - public void testPosNegNonConflictingInsertions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPosNegNonConflictingInsertions(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.drools.core.beliefsystem.jtms;\n" + "\n" + "import java.util.List \n" + @@ -134,7 +128,7 @@ public void testPosNegNonConflictingInsertions() { " l.add( s ); \n" + "end\n"; - KieSession kSession = getSessionFromString( s ); + KieSession kSession = getSessionFromString( kieBaseTestConfiguration, s ); List list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -180,8 +174,10 @@ public void onDeleteMatch( Match match ) { assertThat(getNegativeObjects(kSession).size()).isEqualTo(0); } - @Test(timeout = 10000 ) - public void testConflictToggleWithoutGoingEmpty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testConflictToggleWithoutGoingEmpty(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.drools.core.beliefsystem.jtms;\n" + "\n" + "import java.util.List \n" + @@ -235,7 +231,7 @@ public void testConflictToggleWithoutGoingEmpty() { "end\n" + ""; - KieSession kSession = getSessionFromString( s ); + KieSession kSession = getSessionFromString( kieBaseTestConfiguration, s ); List list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -268,9 +264,11 @@ public void onDeleteMatch( Match match ) { assertThat(list.contains("+xxx")).isTrue(); } - @Test(timeout = 10000 ) - @Ignore("Currently cannot support updates") - public void testChangeInPositivePrime() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + @Disabled("Currently cannot support updates") + public void testChangeInPositivePrime(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.drools.core.beliefsystem.jtms;\n" + "\n" + "import org.kie.internal.event.rule.ActivationUnMatchListener;\n" + @@ -305,7 +303,7 @@ public void testChangeInPositivePrime() { "end\n" + "\n"; - KieSession kSession = getSessionFromString( s ); + KieSession kSession = getSessionFromString( kieBaseTestConfiguration, s ); List list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -364,9 +362,11 @@ public void testChangeInPositivePrime() { assertThat(((Person) key.getBeliefSet().getFactHandle().getObject()).getNotInEqualTestObject()).isEqualTo(Integer.valueOf(2)); } - @Test(timeout = 10000 ) - @Ignore("Currently cannot support updates") - public void testChangeInNegativePrime() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000 ) + @Disabled("Currently cannot support updates") + public void testChangeInNegativePrime(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.drools.core.beliefsystem.jtms;\n" + "\n" + "import org.kie.internal.event.rule.ActivationUnMatchListener;\n" + @@ -403,7 +403,7 @@ public void testChangeInNegativePrime() { "end\n" + "\n"; - KieSession kSession = getSessionFromString( s ); + KieSession kSession = getSessionFromString( kieBaseTestConfiguration, s ); List list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -463,9 +463,11 @@ public void testChangeInNegativePrime() { assertThat(((Person) key.getBeliefSet().getFactHandle().getObject()).getNotInEqualTestObject()).isEqualTo(Integer.valueOf(2)); } - @Test(timeout = 10000 ) - @Ignore("Currently cannot support updates") - public void testRetractHandleWhenOnlyNeg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + @Disabled("Currently cannot support updates") + public void testRetractHandleWhenOnlyNeg(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.drools.core.beliefsystem.jtms;\n" + "\n" + "import java.util.List \n" + @@ -500,7 +502,7 @@ public void testRetractHandleWhenOnlyNeg() { " l.add( s ); \n" + "end\n"; - KieSession kSession = getSessionFromString( s ); + KieSession kSession = getSessionFromString( kieBaseTestConfiguration, s ); List list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -542,9 +544,11 @@ public void onDeleteMatch( Match match ) { assertThat(tms.getEqualityKeysSize()).isEqualTo(1); } - @Test(timeout = 10000 ) - public void testConflictStrict() { - KieSession kSession = getSessionFromFile( "posNegConflict.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testConflictStrict(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSessionFromFile( kieBaseTestConfiguration, "posNegConflict.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -563,10 +567,12 @@ public void testConflictStrict() { } } - @Test(timeout = 10000 ) - @Ignore("Currently cannot support updates") - public void testConflictTMS() { - KieSession kSession = getSessionFromFile( "posNegTms.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + @Disabled("Currently cannot support updates") + public void testConflictTMS(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieSession kSession = getSessionFromFile( kieBaseTestConfiguration, "posNegTms.drl" ); ArrayList list = new ArrayList(); kSession.setGlobal( "list", list ); @@ -646,8 +652,9 @@ public List getNegativeObjects(KieSession kSession) { return list; } - @Test - public void testPrimeJustificationWithEqualityMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPrimeJustificationWithEqualityMode(KieBaseTestConfiguration kieBaseTestConfiguration) { String droolsSource = "package org.drools.tms.test; \n" + "declare Bar end \n" + @@ -676,7 +683,7 @@ public void testPrimeJustificationWithEqualityMode() { " System.out.println( $b ); \n" + "end \n" ; - KieSession session = getSessionFromString( droolsSource ); + KieSession session = getSessionFromString( kieBaseTestConfiguration, droolsSource ); FactHandle handle1 = session.insert( 10 ); FactHandle handle2 = session.insert( 20 ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KieBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KieBuilderTest.java index 75736cbd2c0..666bca9fec3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KieBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KieBuilderTest.java @@ -30,9 +30,9 @@ import org.drools.compiler.kie.builder.impl.KieFileSystemImpl; import org.drools.compiler.kproject.models.KieBaseModelImpl; 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.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -57,13 +57,13 @@ public class KieBuilderTest { protected 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-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KnowledgeBuilderConfigurationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KnowledgeBuilderConfigurationTest.java index 23c79a5c255..740d8e46a49 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KnowledgeBuilderConfigurationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/KnowledgeBuilderConfigurationTest.java @@ -31,8 +31,8 @@ import org.drools.core.base.accumulators.MaxAccumulateFunction; import org.drools.mvel.evaluators.AfterEvaluatorDefinition; import org.drools.mvel.evaluators.BeforeEvaluatorDefinition; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.rule.AccumulateFunction; import org.kie.internal.builder.KnowledgeBuilderConfiguration; import org.kie.internal.builder.KnowledgeBuilderFactory; @@ -53,7 +53,7 @@ public class KnowledgeBuilderConfigurationTest { /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KieFileSystemScannerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KieFileSystemScannerTest.java index 0bb5010bf6a..24c4d95cbd7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KieFileSystemScannerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KieFileSystemScannerTest.java @@ -29,7 +29,7 @@ import java.util.List; import org.drools.compiler.kie.builder.impl.InternalKieModule; -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/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderConfigurationImplTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderConfigurationImplTest.java index d2b1711fccb..2f673c3f0c7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderConfigurationImplTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderConfigurationImplTest.java @@ -19,7 +19,7 @@ package org.drools.mvel.compiler.builder.impl; import org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.conf.ParallelRulesBuildThresholdOption; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderImplTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderImplTest.java index 5813d5eb5fa..2a75cfac3e9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderImplTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderImplTest.java @@ -21,20 +21,18 @@ import java.io.File; import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import static org.assertj.core.api.Assertions.assertThat; public class KnowledgeBuilderImplTest { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir + private File dumpDir; @Test public void testCreateDumpDrlGeneratedFileRemovingInvalidCharacters() throws Exception { - final File dumpDir = temporaryFolder.getRoot(); assertThat(KnowledgeBuilderImpl.createDumpDrlFile(dumpDir, "xxx", ".drl")).hasName("xxx.drl"); assertThat(KnowledgeBuilderImpl.createDumpDrlFile(dumpDir, "x?x?", ".drl")).hasName("x_x_.drl"); assertThat(KnowledgeBuilderImpl.createDumpDrlFile(dumpDir, "x/x/", ".drl")).hasName("x_x_.drl"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderTest.java index 601a66acf72..55ecea14b3b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/builder/impl/KnowledgeBuilderTest.java @@ -44,7 +44,6 @@ import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.phreak.RuleAgendaItem; import org.drools.core.reteoo.LeftTuple; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.RuleTerminalNode; import org.drools.core.reteoo.TerminalNode; import org.drools.core.reteoo.builder.BuildContext; @@ -91,9 +90,9 @@ import org.drools.mvel.compiler.StockTick; import org.drools.mvel.integrationtests.SerializationHelper; import org.drools.mvel.java.JavaForMvelDialectConfiguration; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.api.definition.type.FactField; import org.kie.api.definition.type.FactType; import org.kie.api.definition.type.Role; @@ -109,7 +108,7 @@ public class KnowledgeBuilderTest { - @After + @AfterEach public void tearDown() { System.getProperties().remove( "drools.warning.filters" ); System.getProperties().remove( "drools.kbuilder.severity." + DuplicateFunction.KEY); @@ -283,7 +282,7 @@ public void testSerializable() throws Exception { } @Test - @Ignore + @Disabled public void testNoPackageName() throws Exception { final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl(); try { @@ -900,7 +899,8 @@ private PackageDescr createBasicPackageWithOneRule(int line, int col) { return packageDescr; } - @Test @Ignore // TODO we now allow bindings on declarations, so update the test for this + @Test + @Disabled // TODO we now allow bindings on declarations, so update the test for this public void testDuplicateDeclaration() { final KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/DisposeCommandPublicAPITest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/DisposeCommandPublicAPITest.java index ed5a8af3a9c..fddf879c70b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/DisposeCommandPublicAPITest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/DisposeCommandPublicAPITest.java @@ -27,7 +27,7 @@ import org.drools.core.rule.consequence.KnowledgeHelper; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import org.kie.api.command.Command; import org.kie.api.runtime.KieSession; @@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class DisposeCommandPublicAPITest { + @Test public void testDisposeCommand() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java index 8d7221b0e62..132e32fc72b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/MoreBatchExecutionTest.java @@ -19,17 +19,16 @@ package org.drools.mvel.compiler.command; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.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.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.command.Command; import org.kie.api.runtime.ExecutionResults; @@ -39,23 +38,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MoreBatchExecutionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MoreBatchExecutionTest(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 KieSession ksession = null; - @After + @AfterEach public void disposeKSession() { if( ksession != null ) { ksession.dispose(); @@ -63,8 +54,9 @@ public void disposeKSession() { } } - @Test - public void testFireAllRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireAllRules(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "org/drools/mvel/integrationtests/drl/test_ImportFunctions.drl"); ksession = kbase.newKieSession(); @@ -93,8 +85,9 @@ public void testFireAllRules() { assertThat(list.get(3)).isEqualTo("rule4"); } - @Test - public void testQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "org/drools/mvel/integrationtests/simple_query_test.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/PropagationListTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/PropagationListTest.java index b98f83ab365..3b75897ff32 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/PropagationListTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/PropagationListTest.java @@ -28,12 +28,13 @@ import org.drools.core.phreak.PropagationEntry; import org.drools.core.phreak.PropagationList; import org.drools.core.phreak.SynchronizedPropagationList; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class PropagationListTest { - @Test @Ignore + @Test + @Disabled public void test() { final int OBJECT_NR = 1000000; final int THREAD_NR = 8; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/RegisterWorkItemHandlerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/RegisterWorkItemHandlerTest.java index 17aca668e1b..3c868e22a11 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/RegisterWorkItemHandlerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/RegisterWorkItemHandlerTest.java @@ -18,17 +18,16 @@ */ package org.drools.mvel.compiler.command; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.core.process.WorkItem; import org.drools.core.process.impl.DefaultWorkItemManager; import org.drools.core.process.impl.WorkItemImpl; 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.StatelessKieSession; import org.kie.api.runtime.process.WorkItemHandler; @@ -37,22 +36,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class RegisterWorkItemHandlerTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RegisterWorkItemHandlerTest(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 testRegisterWorkItemHandlerWithStatelessSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRegisterWorkItemHandlerWithStatelessSession(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.workitem.test \n" + "import " + DefaultWorkItemManager.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java index efd2b65b395..3521a19c17d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/command/SimpleBatchExecutionTest.java @@ -22,15 +22,14 @@ 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.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.command.Command; import org.kie.api.runtime.ExecutionResults; @@ -40,7 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SimpleBatchExecutionTest { private KieSession ksession; @@ -53,24 +51,17 @@ public class SimpleBatchExecutionTest { + " then\n" + "end\n"; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - public SimpleBatchExecutionTest(final 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); - } - - @Before - public void createKSession() throws Exception { + public void createKSession(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, ruleString); ksession = kbase.newKieSession(); } - @After + @AfterEach public void disposeKSession() throws Exception { if( ksession != null ) { ksession.dispose(); @@ -78,9 +69,11 @@ public void disposeKSession() throws Exception { } } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testInsertObjectCommand() throws Exception { + public void testInsertObjectCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); String expected_1 = "expected_1"; String expected_2 = "expected_2"; @@ -109,9 +102,11 @@ public void testInsertObjectCommand() throws Exception { assertThat(expectedList.isEmpty()).as("Retrieved object list did not contain expected objects.").isTrue(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testInsertElementsCommand() throws Exception { + public void testInsertElementsCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); String expected_1 = "expected_1"; String expected_2 = "expected_2"; @@ -138,9 +133,11 @@ public void testInsertElementsCommand() throws Exception { assertThat(expectedList.isEmpty()).as("Retrieved object list did not contain expected objects.").isTrue(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testSetGlobalCommand() throws Exception { + public void testSetGlobalCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); ksession.insert(new Integer(5)); ksession.insert(new Integer(7)); @@ -158,9 +155,11 @@ public void testSetGlobalCommand() throws Exception { assertThat(global).isEqualTo("France"); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testGetGlobalCommand() throws Exception { + public void testGetGlobalCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); ksession.insert(new Integer(5)); ksession.insert(new Integer(7)); @@ -178,9 +177,11 @@ public void testGetGlobalCommand() throws Exception { assertThat(global).as("Retrieved global is not equal to 'France'.").isEqualTo("France"); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testGetObjectCommand() throws Exception { + public void testGetObjectCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); String expected_1 = "expected_1"; String expected_2 = "expected_2"; @@ -204,9 +205,11 @@ public void testGetObjectCommand() throws Exception { assertThat(result.getValue("out_2")).isEqualTo(expected_2); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testGetObjectsCommand() throws Exception { + public void testGetObjectsCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + createKSession(kieBaseTestConfiguration); String expected_1 = "expected_1"; String expected_2 = "expected_2"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/InternalMatchIteratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/InternalMatchIteratorTest.java index 88d13384662..ca1c4bdc43c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/InternalMatchIteratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/InternalMatchIteratorTest.java @@ -20,8 +20,8 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.InternalAgenda; import org.drools.core.common.InternalWorkingMemory; @@ -31,10 +31,10 @@ import org.drools.serialization.protobuf.iterators.ActivationIterator; 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.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.rule.Rule; import org.kie.api.event.rule.AgendaEventListener; @@ -47,22 +47,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class InternalMatchIteratorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public InternalMatchIteratorTest(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 testSingleLian() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleLian(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -108,8 +101,9 @@ private void evaluateEagerList(KieSession ksession) { ((InternalAgenda) ksession.getAgenda()).evaluateEagerList(); } - @Test - public void testLianPlusEvaln() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLianPlusEvaln(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -151,8 +145,9 @@ public void testLianPlusEvaln() { list ); } - @Test - public void testLianPlusEvalnWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLianPlusEvalnWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // Rule 0 single LiaNode // Rule 1 and 2 are shared // Rule 3 shares the LIANode with 1 and 2 @@ -231,8 +226,9 @@ public void testLianPlusEvalnWithSharing() { list ); } - @Test - public void testLianPlusEvalnWithSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLianPlusEvalnWithSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { // Rule 0 single LiaNode // Rule 1 and 2 are shared // Rule 3 shares the LIANode with 1 and 2 @@ -293,8 +289,9 @@ public void testLianPlusEvalnWithSharingWithMixedDormantAndActive() { list ); } - @Test - public void testSingleJoinNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleJoinNode(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -330,8 +327,9 @@ public void testSingleJoinNode() { list ); } - @Test - public void testSingleJoinNodePlusEvaln() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleJoinNodePlusEvaln(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -369,8 +367,9 @@ public void testSingleJoinNodePlusEvaln() { list ); } - @Test - public void testSingleJoinNodePlusEvalnWithSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleJoinNodePlusEvalnWithSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -436,8 +435,9 @@ public void testSingleJoinNodePlusEvalnWithSharing() { list ); } - @Test - public void testSingleJoinNodePlusEvalnWithSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleJoinNodePlusEvalnWithSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 salience ( Integer.parseInt( '1'+$s1+'0'+$s2 ) ) when\n" + @@ -487,8 +487,9 @@ public void testSingleJoinNodePlusEvalnWithSharingWithMixedDormantAndActive() { list ); } - @Test - public void testNotSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) salience 10 when\n" + @@ -535,8 +536,9 @@ public void testNotSharingWithMixedDormantAndActive() { list ); } - @Test - public void testExistsSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExistsSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule3 @Propagation(EAGER) salience ( Integer.parseInt( $s1+'1' ) ) when\n" + @@ -584,8 +586,9 @@ public void testExistsSharingWithMixedDormantAndActive() { list ); } - @Test - public void testFromnSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromnSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "global java.util.List list \n" + "\n" + @@ -630,8 +633,9 @@ public void testFromnSharingWithMixedDormantAndActive() { list); } - @Test - public void testAccnSharingWithMixedDormantAndActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccnSharingWithMixedDormantAndActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 @Propagation(EAGER) when\n" + @@ -680,8 +684,10 @@ public void assertContains(Object[] objects, } } - @Test(timeout=10000) - public void testEagerEvaluation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEagerEvaluation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "package org.simple \n" + "rule xxx @Propagation(EAGER) \n" + @@ -715,8 +721,10 @@ public void matchCreated(org.kie.api.event.rule.MatchCreatedEvent event) { assertThat(list.size()).isEqualTo(2); } - @Test(timeout=10000) - public void testFilteredEagerEvaluation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testFilteredEagerEvaluation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "package org.simple \n" + "rule xxx @Propagation(EAGER) \n" + @@ -756,8 +764,9 @@ public void matchCreated(org.kie.api.event.rule.MatchCreatedEvent event) { assertThat(list.size()).isEqualTo(1); } - @Test - public void testCollectAndCountActivationsWithNodesSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAndCountActivationsWithNodesSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // KIE-1062 String str = "import " + CartLineDetails.class.getCanonicalName() + ";" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/TerminalNodeIteratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/TerminalNodeIteratorTest.java index e5e40f46871..cfc245a05a8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/TerminalNodeIteratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/common/TerminalNodeIteratorTest.java @@ -19,39 +19,30 @@ package org.drools.mvel.compiler.common; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.serialization.protobuf.iterators.TerminalNodeIterator; -import org.drools.core.reteoo.RuleTerminalNode; import org.drools.core.reteoo.TerminalNode; import org.drools.core.util.Iterator; 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 TerminalNodeIteratorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TerminalNodeIteratorTest(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 testTerminalNodeListener() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTerminalNodeListener(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie.test \n" + "\n" + "rule rule1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/commons/jci/compilers/NativeJavaCompilerSettingsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/commons/jci/compilers/NativeJavaCompilerSettingsTest.java index b2227bbb255..dc952a6225b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/commons/jci/compilers/NativeJavaCompilerSettingsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/commons/jci/compilers/NativeJavaCompilerSettingsTest.java @@ -21,7 +21,7 @@ import java.util.List; import org.assertj.core.data.Index; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.memorycompiler.jdknative.NativeJavaCompilerSettings; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/CompilerPerfProfileTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/CompilerPerfProfileTest.java index 53b3a77feef..036f2a92cff 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/CompilerPerfProfileTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/CompilerPerfProfileTest.java @@ -24,7 +24,7 @@ import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; import org.drools.base.definitions.InternalKnowledgePackage; import org.drools.drl.parser.DroolsParserException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DescrResourceSetTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DescrResourceSetTest.java index 046b3b293a2..74da3913296 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DescrResourceSetTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DescrResourceSetTest.java @@ -29,12 +29,11 @@ import java.util.Set; import java.util.TreeSet; -import org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl; import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; import org.drools.drl.parser.DrlParser; import org.drools.drl.ast.descr.PackageDescr; import org.drools.io.InputStreamResource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.KnowledgeBuilderConfiguration; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.conf.LanguageLevelOption; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DrlParserTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DrlParserTest.java index e9f8b0af96d..6b686037b4d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DrlParserTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/DrlParserTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.compiler; import java.io.StringReader; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.drl.ast.descr.PackageDescr; import org.drools.drl.ast.descr.TypeDeclarationDescr; @@ -32,34 +32,26 @@ import org.drools.drl.parser.lang.dsl.DefaultExpanderResolver; 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; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DrlParserTest { private static final String NL = System.getProperty("line.separator"); - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DrlParserTest(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 testExpandDRL() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpandDRL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String dsl = "[condition]Something=Something()" + NL + "[then]another=another();"; String drl = "rule 'foo' " + NL + " when " + NL + " Something " + NL + " then " + NL + " another " + NL + "end"; @@ -69,8 +61,9 @@ public void testExpandDRL() throws Exception { .isEqualToIgnoringWhitespace(result); } - @Test - public void testExpandDRLUsingInjectedExpander() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpandDRLUsingInjectedExpander(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String dsl = "[condition]Something=Something()" + NL + "[then]another=another();"; String drl = "rule 'foo' " + NL + " when " + NL + " Something " + NL + " then " + NL + " another " + NL + "end"; @@ -93,8 +86,9 @@ public void testExpandDRLUsingInjectedExpander() throws Exception { .isEqualToIgnoringWhitespace(result); } - @Test - public void testDeclaredSuperType() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredSuperType(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "age: int \n" @@ -113,8 +107,9 @@ public void testDeclaredSuperType() throws Exception { assertThat(bean2Type.getSuperTypeName()).isEqualTo("Bean1"); } - @Test - public void testBigDecimalWithZeroValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalWithZeroValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigDecimal \n" @@ -125,11 +120,12 @@ public void testBigDecimalWithZeroValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testBigDecimalWithZeroDecimalPointValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalWithZeroDecimalPointValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigDecimal \n" @@ -140,11 +136,12 @@ public void testBigDecimalWithZeroDecimalPointValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testBigDecimalWithNonZeroValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalWithNonZeroValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigDecimal \n" @@ -155,11 +152,12 @@ public void testBigDecimalWithNonZeroValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testBigDecimalWithNonZeroDecimalPointValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalWithNonZeroDecimalPointValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigDecimal \n" @@ -170,11 +168,12 @@ public void testBigDecimalWithNonZeroDecimalPointValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testBigIntegerWithZeroValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigIntegerWithZeroValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigInteger \n" @@ -185,11 +184,12 @@ public void testBigIntegerWithZeroValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testBigIntegerWithNonZeroValue() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigIntegerWithNonZeroValue(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package foo \n" + "declare Bean1 \n" + "field1: java.math.BigInteger \n" @@ -200,11 +200,12 @@ public void testBigIntegerWithNonZeroValue() throws Exception { + "then \n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testParseConsequenceWithSingleQuoteInsideDoubleQuotesFollowedByUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testParseConsequenceWithSingleQuoteInsideDoubleQuotesFollowedByUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "declare Person\n" + " name: String\n" + "end\n" + @@ -217,11 +218,12 @@ public void testParseConsequenceWithSingleQuoteInsideDoubleQuotesFollowedByUpdat " update($p);\n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testParseConsequenceWithEscapedDoubleQuoteInsideDoubleQuotesFollowedByUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testParseConsequenceWithEscapedDoubleQuoteInsideDoubleQuotesFollowedByUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "declare Person\n" + " name: String\n" + "end\n" + @@ -234,11 +236,12 @@ public void testParseConsequenceWithEscapedDoubleQuoteInsideDoubleQuotesFollowed " update($p);\n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( drl ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, drl ); } - @Test - public void testIfAfterPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfAfterPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "rule R when\n" + " $sum : Integer()\n" + @@ -247,12 +250,13 @@ public void testIfAfterPattern() { "then[greater]\n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( str ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, str ); } - @Test - public void testIfAfterAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfAfterAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "rule R when\n" + " accumulate ( $p: Object(); \n" + @@ -263,10 +267,10 @@ public void testIfAfterAccumulate() { "then[greater]\n" + "end"; - createKBuilderAddDrlAndAssertHasNoErrors( str ); + createKBuilderAddDrlAndAssertHasNoErrors( kieBaseTestConfiguration, str ); } - private void createKBuilderAddDrlAndAssertHasNoErrors(String drl) { + private void createKBuilderAddDrlAndAssertHasNoErrors(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl); List errors = kieBuilder.getResults().getMessages(Message.Level.ERROR); assertThat(errors.size()).as("Expected no build errors, but got: " + errors.toString()).isEqualTo(0); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PackageBuilderConfigurationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PackageBuilderConfigurationTest.java index 579f1a48415..9f1aa5964be 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PackageBuilderConfigurationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PackageBuilderConfigurationTest.java @@ -59,11 +59,11 @@ import org.drools.drl.ast.descr.RuleDescr; import org.drools.mvel.java.JavaForMvelDialectConfiguration; import org.drools.util.TypeResolver; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.io.Resource; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.builder.KnowledgeBuilderResult; @@ -83,13 +83,13 @@ public class PackageBuilderConfigurationTest { private static String droolsDialectJavaCompilerOrig; private static String droolsDialectDefaultOrig; - @BeforeClass + @BeforeAll public static void backupPropertyValues() { droolsDialectJavaCompilerOrig = System.getProperty( JavaForMvelDialectConfiguration.JAVA_COMPILER_PROPERTY); droolsDialectDefaultOrig = System.getProperty(DefaultDialectOption.PROPERTY_NAME); } - @AfterClass + @AfterAll public static void restorePropertyValues() { if (droolsDialectJavaCompilerOrig != null) { System.setProperty( JavaForMvelDialectConfiguration.JAVA_COMPILER_PROPERTY, droolsDialectJavaCompilerOrig); @@ -99,13 +99,13 @@ public static void restorePropertyValues() { } } - @Before + @BeforeEach public void setUp() throws Exception { System.getProperties().remove("drools.dialect.java.compiler"); System.getProperties().remove("drools.dialect.default"); } - @After + @AfterEach public void tearDown() throws Exception { System.getProperties().remove("drools.dialect.java.compiler"); System.getProperties().remove("drools.dialect.default"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PatternBuilderForQueryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PatternBuilderForQueryTest.java index 6ab6221c6c7..635db90cda3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PatternBuilderForQueryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/PatternBuilderForQueryTest.java @@ -33,7 +33,7 @@ import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.compiler.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.QueryResults; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/RuleErrorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/RuleErrorTest.java index 4dcbe458ae7..0f65316343f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/RuleErrorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/RuleErrorTest.java @@ -21,7 +21,7 @@ import org.drools.compiler.compiler.DescrBuildError; import org.drools.drl.ast.descr.AndDescr; import org.drools.drl.ast.descr.RuleDescr; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.jci.CompilationProblem; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationMergingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationMergingTest.java index 600e454e723..682741f6d57 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationMergingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationMergingTest.java @@ -19,9 +19,9 @@ package org.drools.mvel.compiler.compiler; import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; +import org.junit.jupiter.api.Test; import org.drools.base.rule.TypeDeclaration; import org.drools.base.rule.TypeDeclaration.Format; -import org.junit.Test; import org.kie.api.definition.type.Position; import org.kie.api.definition.type.Role; import org.kie.api.io.ResourceType; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationTest.java index b85952cc472..0fb765ba12f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationTest.java @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Stream; import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; import org.drools.compiler.kie.builder.impl.InternalKieModule; @@ -38,10 +39,9 @@ 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.KieServices; import org.kie.api.builder.KieBuilder; @@ -67,24 +67,18 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class TypeDeclarationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TypeDeclarationTest(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 testClassNameClashing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassNameClashing(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n" + "declare org.kie.Character \n" + @@ -96,7 +90,8 @@ public void testClassNameClashing() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testAnnotationReDefinition(){ String str1 = ""; str1 += "package org.kie \n" + @@ -154,7 +149,8 @@ public void testAnnotationReDefinition(){ } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testNoAnnotationUpdateIfError(){ String str1 = ""; str1 += "package org.drools.mvel.compiler \n" + @@ -208,8 +204,9 @@ public void testNoAnnotationUpdateIfError(){ * The same resource (containing a type declaration) is added twice in the * kbuilder. */ - @Test - public void testDuplicatedTypeDeclarationWith2FieldsInSameResource() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicatedTypeDeclarationWith2FieldsInSameResource(KieBaseTestConfiguration kieBaseTestConfiguration) { //same package, different resources String str1 = ""; str1 += "package org.drools.mvel.compiler \n" + @@ -231,8 +228,9 @@ public void testDuplicatedTypeDeclarationWith2FieldsInSameResource() { * kbuilder. * The expectation here is to silently discard the second type declaration. */ - @Test - public void testDuplicatedTypeDeclarationInDifferentResources() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicatedTypeDeclarationInDifferentResources(KieBaseTestConfiguration kieBaseTestConfiguration) { //same package, different resources String str1 = ""; str1 += "package org.drools.mvel.compiler \n" + @@ -257,8 +255,9 @@ public void testDuplicatedTypeDeclarationInDifferentResources() { * The expectation here is that compilation fails because we are changing * the type of a field */ - @Test - public void testClashingTypeDeclarationInDifferentResources() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClashingTypeDeclarationInDifferentResources(KieBaseTestConfiguration kieBaseTestConfiguration) { // Note: Didn't applied new APIs because KieUtil.getKieBuilderFromResources() didn't reproduce the issue. // TODO: File a JIRA to revisit and write a valid test for new APIs and exec-model @@ -298,8 +297,9 @@ public void testClashingTypeDeclarationInDifferentResources() { * UPDATE : any use of the full-arg constructor in the second DRL will fail, * so we generate an error anyway */ - @Test - public void testNotSoHarmlessTypeReDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotSoHarmlessTypeReDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // Note: Didn't applied new APIs because KieUtil.getKieBuilderFromResources() didn't reproduce the issue. // TODO: File a JIRA to revisit and write a valid test for new APIs and exec-model @@ -357,8 +357,9 @@ public void testNotSoHarmlessTypeReDeclaration() { * The expectation here is that the compilation fails because we are * adding a new field to the declared Type */ - @Test - public void testTypeReDeclarationWithExtraField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeReDeclarationWithExtraField(KieBaseTestConfiguration kieBaseTestConfiguration) { // Note: Didn't applied new APIs because KieUtil.getKieBuilderFromResources() didn't reproduce the issue. // TODO: File a JIRA to revisit and write a valid test for new APIs and exec-model @@ -397,8 +398,9 @@ public void testTypeReDeclarationWithExtraField() { * trying to add an incompatible re-definition of the declared type: * it introduces a new field 'lastName' */ - @Test - public void testTypeReDeclarationWithExtraField2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeReDeclarationWithExtraField2(KieBaseTestConfiguration kieBaseTestConfiguration) { // Note: Didn't applied new APIs because KieUtil.getKieBuilderFromResources() didn't reproduce the issue. // TODO: File a JIRA to revisit and write a valid test for new APIs and exec-model @@ -432,8 +434,9 @@ public void testTypeReDeclarationWithExtraField2() { - @Test - public void testDuplicateDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.compiler \n" + "declare Bean \n" + @@ -462,8 +465,9 @@ public void testDuplicateDeclaration() { String prop(); } - @Test - public void testTypeDeclarationMetadata() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeDeclarationMetadata(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.compiler.test; \n" + "import org.drools.mvel.compiler.compiler.TypeDeclarationTest.KlassAnnotation; \n" + @@ -512,8 +516,9 @@ public static class Foo { } } - @Test - public void testTypeDeclarationWithInnerClasses() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeDeclarationWithInnerClasses(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-150 String str = ""; str += "package org.drools.mvel.compiler;\n" + @@ -534,8 +539,9 @@ public void testTypeDeclarationWithInnerClasses() { } - @Test - public void testTypeDeclarationWithInnerClassesImport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeDeclarationWithInnerClassesImport(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-150 String str = ""; str += "package org.drools.mvel.compiler;\n" + @@ -578,7 +584,8 @@ public void setAge( Integer age ) { } } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testMultipleTypeReDeclaration() { // Note: Didn't applied new APIs because KieUtil.getKieBuilderFromResources() didn't reproduce the issue. // TODO: File a JIRA to revisit and write a valid test for new APIs and exec-model @@ -611,8 +618,9 @@ public void testMultipleTypeReDeclaration() { } } - @Test - public void testDeclareFieldArray() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareFieldArray(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = "" + "package org.drools " + @@ -660,8 +668,9 @@ public void testDeclareFieldArray() { } } - @Test( expected = UnsupportedOperationException.class ) - public void testPreventReflectionAPIsOnJavaClasses() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPreventReflectionAPIsOnJavaClasses(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.test; " + // existing java class @@ -671,17 +680,18 @@ public void testPreventReflectionAPIsOnJavaClasses() { ""; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isFalse(); KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase(); - FactType type = kieBase.getFactType( "org.drools.mvel.compiler", "Person" ); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> kieBase.getFactType( "org.drools.mvel.compiler", "Person" )); } - @Test - public void testCrossPackageDeclares() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCrossPackageDeclares(KieBaseTestConfiguration kieBaseTestConfiguration) { // TODO: enable exec-model String pkg1 = @@ -753,15 +763,16 @@ public void testCrossPackageDeclares() { } - @Test - public void testUnknownField() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnknownField(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { // DROOLS-546 String drl = "package org.test; " + "declare Pet" + " " + "end \n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isFalse(); KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase(); @@ -772,8 +783,9 @@ public void testUnknownField() throws InstantiationException, IllegalAccessExcep factType.set(instance, "unknownField", "myValue"); } - @Test - public void testPositionalArguments() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPositionalArguments(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { String drl = "package org.test;\n" + "global java.util.List names;\n" + "declare Person\n" + @@ -786,7 +798,7 @@ public void testPositionalArguments() throws InstantiationException, IllegalAcce " names.add( $p.getName() );\n" + "end\n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isFalse(); KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase(); @@ -807,8 +819,9 @@ public void testPositionalArguments() throws InstantiationException, IllegalAcce assertThat(names.get(0)).isEqualTo("Mark"); } - @Test - public void testExplictPositionalArguments() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExplictPositionalArguments(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { String drl = "package org.test;\n" + "global java.util.List names;\n" + "declare Person\n" + @@ -821,7 +834,7 @@ public void testExplictPositionalArguments() throws InstantiationException, Ille " names.add( $p.getName() );\n" + "end\n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isFalse(); KieBase kieBase = KieServices.Factory.get().newKieContainer( kieBuilder.getKieModule().getReleaseId() ).getKieBase(); @@ -842,8 +855,9 @@ public void testExplictPositionalArguments() throws InstantiationException, Ille assertThat(names.get(0)).isEqualTo("Mark"); } - @Test - public void testTooManyPositionalArguments() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTooManyPositionalArguments(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { // DROOLS-559 String drl = "package org.test;\n" + "global java.util.List names;\n" + @@ -857,13 +871,14 @@ public void testTooManyPositionalArguments() throws InstantiationException, Ille " names.add( $p.getName() );\n" + "end\n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isTrue(); } - @Test - public void testOutOfRangePositions() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutOfRangePositions(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { // DROOLS-559 String drl = "package org.test;\n" + "global java.util.List names;\n" + @@ -877,13 +892,14 @@ public void testOutOfRangePositions() throws InstantiationException, IllegalAcce " names.add( $p.getName() );\n" + "end\n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isTrue(); } - @Test - public void testDuplicatedPositions() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicatedPositions(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { // DROOLS-559 String drl = "package org.test;\n" + "global java.util.List names;\n" + @@ -897,17 +913,18 @@ public void testDuplicatedPositions() throws InstantiationException, IllegalAcce " names.add( $p.getName() );\n" + "end\n"; - KieBuilder kieBuilder = build(drl); + KieBuilder kieBuilder = build(kieBaseTestConfiguration, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isTrue(); } - private KieBuilder build(String drl) { + private KieBuilder build(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { return KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl); } - @Test - public void testMultipleAnnotationDeclarations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleAnnotationDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = ""; str1 += "package org.kie1 " + "" + @@ -970,8 +987,9 @@ public static interface Ext extends Base { public void setFld( String s ); } - @Test - public void testDeclareWithExtensionAndOverride() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareWithExtensionAndOverride(KieBaseTestConfiguration kieBaseTestConfiguration) { final String s1 = "package test; " + "global java.util.List list; " + @@ -1037,8 +1055,9 @@ public static class BeanishClass { public void setFooAsString( String x ) { foo = Integer.parseInt( x ); } } - @Test - public void testDeclarationOfClassWithNonStandardSetter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationOfClassWithNonStandardSetter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String s1 = "package test; " + "import " + BeanishClass.class.getCanonicalName() + "; " + @@ -1051,8 +1070,9 @@ public void testDeclarationOfClassWithNonStandardSetter() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testDeclarationOfClassWithNonStandardSetterAndCanonicalName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationOfClassWithNonStandardSetterAndCanonicalName(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-815 final String s1 = "package test; " + "import " + BeanishClass.class.getCanonicalName() + "; " + @@ -1066,8 +1086,9 @@ public void testDeclarationOfClassWithNonStandardSetterAndCanonicalName() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testDeclarationOfClassWithNonStandardSetterAndFulllName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationOfClassWithNonStandardSetterAndFulllName(KieBaseTestConfiguration kieBaseTestConfiguration) { final String s1 = "package test; " + "import " + BeanishClass.class.getCanonicalName() + "; " + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationUnsupportedModelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationUnsupportedModelTest.java index caefebe4588..d60aef5d289 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationUnsupportedModelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/TypeDeclarationUnsupportedModelTest.java @@ -18,36 +18,28 @@ */ package org.drools.mvel.compiler.compiler; -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.builder.KieBuilder; import org.kie.api.builder.Message; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TypeDeclarationUnsupportedModelTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TypeDeclarationUnsupportedModelTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test() - public void testTraitExtendPojo() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTraitExtendPojo(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-697 final String s1 = "package test;\n" + @@ -63,8 +55,9 @@ public void testTraitExtendPojo() { assertThat(errors.size()).isEqualTo(1); } - @Test - public void testRedeclareWithInterfaceExtensionAndOverride() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRedeclareWithInterfaceExtensionAndOverride(KieBaseTestConfiguration kieBaseTestConfiguration) { final String s1 = "package test;\n" + "declare trait " + TypeDeclarationTest.Ext.class.getCanonicalName() + " extends " + TypeDeclarationTest.Base.class.getCanonicalName() + " " + @@ -80,8 +73,9 @@ public void testRedeclareWithInterfaceExtensionAndOverride() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testDeclaresInForeignPackages() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaresInForeignPackages(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = "" + "package org.drools \n" + "declare foreign.ClassC fld : foreign.ClassD end " + @@ -94,8 +88,9 @@ public void testDeclaresInForeignPackages() { } - @Test - public void testTypeReDeclarationPojo() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeReDeclarationPojo(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = "" + "package org.drools \n" + "import " + TypeDeclarationTest.class.getName() + ".ClassC; \n" + @@ -110,8 +105,9 @@ public void testTypeReDeclarationPojo() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testTypeReDeclarationPojoMoreFields() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeReDeclarationPojoMoreFields(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = "" + "package org.drools \n" + "import " + TypeDeclarationTest.class.getName() + ".ClassC; \n" + @@ -127,8 +123,9 @@ public void testTypeReDeclarationPojoMoreFields() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testTypeReDeclarationPojoLessFields() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeReDeclarationPojoLessFields(KieBaseTestConfiguration kieBaseTestConfiguration) { String str1 = "" + "package org.drools \n" + "import " + TypeDeclarationTest.class.getName() + ".ClassC; \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/io/memory/MemoryFileSystemTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/io/memory/MemoryFileSystemTest.java index 47f9d913a85..66d6ff0c025 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/io/memory/MemoryFileSystemTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/compiler/io/memory/MemoryFileSystemTest.java @@ -20,8 +20,8 @@ import org.drools.compiler.compiler.io.File; import org.drools.compiler.compiler.io.memory.MemoryFileSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -29,7 +29,7 @@ public class MemoryFileSystemTest { private MemoryFileSystem memoryFileSystem; - @Before + @BeforeEach public void setup() { memoryFileSystem = new MemoryFileSystem(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeBaseConfigurationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeBaseConfigurationTest.java index 37a3d20a340..0839d3fe654 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeBaseConfigurationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeBaseConfigurationTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.conf; import org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.kie.api.KieBaseConfiguration; import org.kie.api.KieServices; import org.kie.api.conf.BetaRangeIndexOption; @@ -52,7 +52,7 @@ public class KnowledgeBaseConfigurationTest { /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { config = KieServices.Factory.get().newKieBaseConfiguration(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeSessionConfigurationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeSessionConfigurationTest.java index c91ebb04427..8734564da8f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeSessionConfigurationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/conf/KnowledgeSessionConfigurationTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.conf; import org.drools.core.BeliefSystemType; -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.runtime.conf.AccumulateNullPropagationOption; import org.kie.api.runtime.conf.BeliefSystemTypeOption; @@ -37,7 +37,7 @@ public class KnowledgeSessionConfigurationTest { /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { config = KieServices.Factory.get().newKieSessionConfiguration(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/definitions/KnowledgePackageMetaDataTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/definitions/KnowledgePackageMetaDataTest.java index c65545359f9..ca714972670 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/definitions/KnowledgePackageMetaDataTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/definitions/KnowledgePackageMetaDataTest.java @@ -19,15 +19,14 @@ package org.drools.mvel.compiler.definitions; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.base.definitions.rule.impl.GlobalImpl; 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.definition.rule.Query; @@ -37,18 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class KnowledgePackageMetaDataTest { - - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KnowledgePackageMetaDataTest(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 String drl ="" + @@ -89,8 +80,9 @@ public static Collection getParameters() { "then\n" + "end"; - @Test - public void testMetaData() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMetaData(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KiePackage pack = kBase.getKiePackage( "org.drools.mvel.compiler.test.definitions" ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/DslExpansionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/DslExpansionTest.java index 7c9778adc95..d2361118a23 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/DslExpansionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/DslExpansionTest.java @@ -18,15 +18,14 @@ */ package org.drools.mvel.compiler.kie.builder; -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; @@ -40,22 +39,15 @@ /** * Test for DSL expansion with KieBuilder */ -@RunWith(Parameterized.class) public class DslExpansionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DslExpansionTest(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 testDSLExpansion_MessageImplNPE() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLExpansion_MessageImplNPE(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId = ks.newReleaseId( "org.kie", "dsl-test", "1.0" ); final KieModuleModel kproj = ks.newKieModuleModel(); @@ -76,8 +68,9 @@ public void testDSLExpansion_MessageImplNPE() throws Exception { assertThat(messages.isEmpty()).isTrue(); } - @Test - public void testDSLExpansion_NoExpansion() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLExpansion_NoExpansion(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieServices ks = KieServices.Factory.get(); final ReleaseId releaseId = ks.newReleaseId( "org.kie", "dsl-test", "1.0" ); final KieModuleModel kproj = ks.newKieModuleModel(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireChannelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireChannelTest.java index 3f8983c5211..38a3ebf5576 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireChannelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireChannelTest.java @@ -20,15 +20,14 @@ import java.io.IOException; 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.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; @@ -42,30 +41,23 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.drools.compiler.kie.builder.impl.KieBuilderImpl.generatePomXml; -@RunWith(Parameterized.class) public class WireChannelTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public WireChannelTest(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 List channelMessages = new ArrayList(); - @Test - public void testWireChannel() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWireChannel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { channelMessages.clear(); KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "listener-test", "1.0"); - build(ks, releaseId); + build(kieBaseTestConfiguration, ks, releaseId); KieContainer kieContainer = ks.newKieContainer(releaseId); KieSession ksession = kieContainer.newKieSession(); @@ -75,7 +67,7 @@ public void testWireChannel() throws Exception { assertThat(channelMessages.get(0)).isEqualTo("Test Message"); } - private void build(KieServices ks, ReleaseId releaseId) throws IOException { + private void build(KieBaseTestConfiguration kieBaseTestConfiguration, KieServices ks, ReleaseId releaseId) throws IOException { KieModuleModel kproj = ks.newKieModuleModel(); KieSessionModel ksession1 = kproj.newKieBaseModel("KBase1").newKieSessionModel("KSession1").setDefault(true); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireListenerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireListenerTest.java index 3e19ade2f73..46fefcd49ab 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireListenerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/WireListenerTest.java @@ -20,15 +20,14 @@ import java.io.IOException; 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.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; @@ -46,26 +45,19 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.drools.compiler.kie.builder.impl.KieBuilderImpl.generatePomXml; -@RunWith(Parameterized.class) public class WireListenerTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public WireListenerTest(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 List insertEvents = new ArrayList(); private static final List updateEvents = new ArrayList(); private static final List retractEvents = new ArrayList(); - @Test - public void testWireListener() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWireListener(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { insertEvents.clear(); updateEvents.clear(); retractEvents.clear(); @@ -73,7 +65,7 @@ public void testWireListener() throws Exception { KieServices ks = KieServices.Factory.get(); ReleaseId releaseId = ks.newReleaseId("org.kie", "listener-test", "1.0"); - build(ks, releaseId); + build(kieBaseTestConfiguration, ks, releaseId); KieContainer kieContainer = ks.newKieContainer(releaseId); KieSession ksession = kieContainer.newKieSession(); @@ -84,7 +76,7 @@ public void testWireListener() throws Exception { assertThat(retractEvents.size()).isEqualTo(1); } - private void build(KieServices ks, ReleaseId releaseId) throws IOException { + private void build(KieBaseTestConfiguration kieBaseTestConfiguration, KieServices ks, ReleaseId releaseId) throws IOException { KieModuleModel kproj = ks.newKieModuleModel(); KieSessionModel ksession1 = kproj.newKieBaseModel("KBase1").newKieSessionModel("KSession1").setDefault(true); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/ClasspathKieProjectTransformUrlToFileSystemPathTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/ClasspathKieProjectTransformUrlToFileSystemPathTest.java index 9bbe587d83f..0c376ce9637 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/ClasspathKieProjectTransformUrlToFileSystemPathTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/ClasspathKieProjectTransformUrlToFileSystemPathTest.java @@ -19,36 +19,29 @@ package org.drools.mvel.compiler.kie.builder.impl; import java.net.URL; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.kie.builder.impl.ClasspathKieProject; -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.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 ClasspathKieProjectTransformUrlToFileSystemPathTest { - @Parameterized.Parameters(name = "URL={0}, expectedPath={1}") - public static Collection data() throws Exception { - return Arrays.asList(new Object[][] { - { new URL("file:/some-path-to-the-module/target/test-classes"), "/some-path-to-the-module/target/test-classes" }, - { new URL("file:/some-path-to-the-module/target/test-classes/META-INF/kmodule.xml"), "/some-path-to-the-module/target/test-classes" }, - { new URL("jar:file:/C:/proj/parser/jar/parser.jar!/test.xml"), "/C:/proj/parser/jar/parser.jar" } - }); + public static Stream parameters() throws Exception { + + return Stream.of(arguments(new URL("file:/some-path-to-the-module/target/test-classes"), "/some-path-to-the-module/target/test-classes"), + arguments(new URL("file:/some-path-to-the-module/target/test-classes/META-INF/kmodule.xml"), "/some-path-to-the-module/target/test-classes"), + arguments(new URL("jar:file:/C:/proj/parser/jar/parser.jar!/test.xml"), "/C:/proj/parser/jar/parser.jar")); } - @Parameterized.Parameter(0) - public URL url; - @Parameterized.Parameter(1) - public String expectedPath; - - @Test - public void testTransformUrl() { + @ParameterizedTest(name = "URL={0}, expectedPath={1}") + @MethodSource("parameters") + public void testTransformUrl(URL url, String expectedPath) { String actualPath = ClasspathKieProject.fixURLFromKProjectPath(url); assertThat(actualPath).isEqualTo(expectedPath); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieBuilderSetImplTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieBuilderSetImplTest.java index 6adf0fd8a3a..e63c40220ef 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieBuilderSetImplTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieBuilderSetImplTest.java @@ -18,18 +18,17 @@ */ package org.drools.mvel.compiler.kie.builder.impl; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.kie.builder.impl.KieBuilderImpl; import org.drools.compiler.kie.builder.impl.KieBuilderSetImpl; import org.drools.mvel.CommonTestMethodBase; 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; @@ -39,28 +38,21 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class KieBuilderSetImplTest extends CommonTestMethodBase { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public KieBuilderSetImplTest(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 testBuild() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBuild(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); kfs.write( "src/main/resources/rule%201.drl", ruleContent() ); - final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl( kieBuilder( ks, kfs ) ); + final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl( kieBuilder( kieBaseTestConfiguration, ks, kfs ) ); kieBuilderSet.setFiles( new String[]{ "src/main/resources/rule%201.drl" } ); @@ -70,16 +62,17 @@ public void testBuild() throws Exception { assertThat(build.getRemovedMessages().size()).isEqualTo(0); } - @Test - @Ignore("RHPAM-1184, RHDM-601") - public void testBuildPercentageAndWhiteSpaceInName() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("RHPAM-1184, RHDM-601") + public void testBuildPercentageAndWhiteSpaceInName(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieServices ks = KieServices.Factory.get(); final KieFileSystem kfs = ks.newKieFileSystem(); kfs.write("src/main/resources/my rule 100% okay.rdrl", ResourceFactory.newInputStreamResource(this.getClass().getResourceAsStream("my rule 100% okay.rdrl"))); - final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl(kieBuilder(ks, kfs)); + final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl(kieBuilder(kieBaseTestConfiguration, ks, kfs)); kieBuilderSet.setFiles(new String[]{"src/main/resources/my rule 100% okay.rdrl"}); @@ -89,7 +82,8 @@ public void testBuildPercentageAndWhiteSpaceInName() throws Exception { assertThat(build.getRemovedMessages().size()).isEqualTo(0); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testDummyResourceWithAnEncodedFileName() { final Resource dummyResource = new KieBuilderSetImpl.DummyResource( "Dummy%20Resource" ); final Resource testResource = new KieBuilderSetImpl.DummyResource( "Dummy Resource" ); @@ -97,14 +91,16 @@ public void testDummyResourceWithAnEncodedFileName() { assertThat(dummyResource).isEqualTo(testResource); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") public void testDummyResourceWithWrongEncodedFileName() { final Resource dummyResource = new KieBuilderSetImpl.DummyResource("Dummy 100%"); assertThat("Dummy 100%").isEqualTo(dummyResource.getSourcePath()); } - private KieBuilderImpl kieBuilder( final KieServices ks, - final KieFileSystem kfs ) { + private KieBuilderImpl kieBuilder(KieBaseTestConfiguration kieBaseTestConfiguration, + final KieServices ks, + final KieFileSystem kfs) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromKieFileSystem(kieBaseTestConfiguration, kfs, true); return (KieBuilderImpl) kieBuilder; } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieFileSystemImplTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieFileSystemImplTest.java index 5be259b2cb1..ea04352def9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieFileSystemImplTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieFileSystemImplTest.java @@ -22,10 +22,10 @@ import org.drools.compiler.compiler.io.memory.MemoryFileSystem; import org.drools.compiler.kie.builder.impl.KieFileSystemImpl; -import org.junit.Before; -import org.junit.Test; import org.kie.api.builder.KieFileSystem; import org.drools.util.PortablePath; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +33,7 @@ public class KieFileSystemImplTest { KieFileSystemImpl kieFileSystem; - @Before + @BeforeEach public void setup() { kieFileSystem = new KieFileSystemImpl(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieModuleRepoTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieModuleRepoTest.java index 23afb8e649d..8546c7aef6e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieModuleRepoTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/KieModuleRepoTest.java @@ -44,9 +44,10 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.io.InternalResource; import org.drools.wiring.api.ResourceProvider; -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.junit.jupiter.api.Timeout; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.KieModule; import org.kie.api.builder.KieRepository; @@ -88,7 +89,7 @@ public class KieModuleRepoTest { private Field maxSizeGaCacheField; private Field maxSizeGaVersionsCacheField; - @Before + @BeforeEach public void before() throws Exception { kieModuleRepo = new KieModuleRepo(new ReentrantLock()); @@ -99,7 +100,7 @@ public void before() throws Exception { maxSizeGaVersionsCacheField = KieModuleRepo.class.getDeclaredField("MAX_SIZE_GA_VERSIONS_CACHE"); } - @After + @AfterEach public void after() throws Exception { setCacheSize(maxSizeGaCacheField, null, maxSizeGaCacheOrig); setCacheSize(maxSizeGaVersionsCacheField, null, maxSizeGaVersionsCacheOrig); @@ -176,7 +177,8 @@ private static void setCacheSize( final Field field, final Object fieldObject, f // simultaneous requests to deploy two new deployments (different versions) // for an empty/new GA artifactMap - @Test(timeout=5000) + @Test + @Timeout(5000) public void testDeployTwoArtifactVersionsSameTime() throws Exception { final String groupId = "org"; final String artifactId = "one"; @@ -231,7 +233,8 @@ public Runnable getStoreArtifactRunnable(final KieModuleRepo kieModuleRepo, fina // remove request followed by a store request on a high load system // * remove does not completely finish before store starts - @Test(timeout=5000) + @Test + @Timeout(5000) public void removeStoreArtifactMapTest() throws Exception { // actual test final ReleaseIdImpl releaseId = new ReleaseIdImpl("org", "redeploy", "2.0"); @@ -446,7 +449,8 @@ public ReleaseId getReleaseId() { // 2. simultaneous deploy requests // - multitenant UI // - duplicate REST requests - @Test(timeout=5000) + @Test + @Timeout(5000) public void newerVersionDeployOverwritesTest() throws Exception { // setup diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/MemoryKieModuleResourceProviderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/MemoryKieModuleResourceProviderTest.java index 2815cde5b1d..5aca01c17b1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/MemoryKieModuleResourceProviderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/builder/impl/MemoryKieModuleResourceProviderTest.java @@ -24,7 +24,7 @@ import org.drools.compiler.compiler.io.memory.MemoryFolder; import org.drools.compiler.kie.builder.impl.MemoryKieModule; import org.drools.wiring.api.ResourceProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.builder.ReleaseId; import org.kie.api.builder.model.KieModuleModel; import org.drools.util.PortablePath; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/util/ChangeSetBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/util/ChangeSetBuilderTest.java index 2b2777c0201..e2c6f007f2f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/util/ChangeSetBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kie/util/ChangeSetBuilderTest.java @@ -25,7 +25,7 @@ import org.drools.compiler.kie.util.ChangeSetBuilder; import org.drools.compiler.kie.util.KieJarChangeSet; import org.drools.compiler.kproject.models.KieModuleModelImpl; -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.builder.model.KieBaseModel; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/ReleaseIdTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/ReleaseIdTest.java index 09b3d056712..582183c061a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/ReleaseIdTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/ReleaseIdTest.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.ReleaseId; import org.kie.api.builder.ReleaseIdComparator; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFileTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFileTest.java index 0d8ae2bdf13..f4674d1ddd9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFileTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFileTest.java @@ -26,7 +26,7 @@ import org.drools.compiler.compiler.io.Folder; import org.drools.compiler.compiler.io.memory.MemoryFileSystem; import org.drools.util.StringUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFolderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFolderTest.java index 8d308f7fa83..2f778a46bf7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFolderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/kproject/memory/MemoryFolderTest.java @@ -26,7 +26,7 @@ import org.drools.compiler.compiler.io.Folder; import org.drools.compiler.compiler.io.memory.MemoryFileSystem; import org.drools.compiler.compiler.io.memory.MemoryFolder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLContextTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLContextTest.java index efda0727f2f..4d0e65de9e0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLContextTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLContextTest.java @@ -28,9 +28,10 @@ import org.drools.drl.parser.lang.DroolsToken; import org.drools.drl.parser.lang.Location; import org.drools.compiler.builder.impl.EvaluatorRegistry; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; @@ -38,13 +39,14 @@ public class DRLContextTest { - @Before + @BeforeEach public void setUp() throws Exception { // initializes pluggable operators new EvaluatorRegistry(); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_OPERATORS_AND_COMPLEMENT1() throws DroolsParserException, RecognitionException { String input = "rule MyRule when Class ( property memberOf collection "; @@ -59,7 +61,8 @@ public void testCheckLHSLocationDetermination_OPERATORS_AND_COMPLEMENT1() .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_OPERATORS_AND_COMPLEMENT2() throws DroolsParserException, RecognitionException { String input = "rule MyRule when Class ( property not memberOf collection"; @@ -74,7 +77,8 @@ public void testCheckLHSLocationDetermination_OPERATORS_AND_COMPLEMENT2() .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_COMPOSITE_OPERATOR1() throws DroolsParserException, RecognitionException { String input = "rule MyRule when Class ( property in ( "; @@ -89,7 +93,8 @@ public void testCheckLHSLocationDetermination_COMPOSITE_OPERATOR1() .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION1() throws DroolsParserException, RecognitionException { String input = "rule MyRule \n" + " when \n" + " "; @@ -104,7 +109,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION1() .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION2() { String input = "rule MyRule \n" + " when \n" + " Class( condition == true ) \n" + " "; @@ -120,7 +126,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION2() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION3() { String input = "rule MyRule \n" + " when \n" + " class: Class( condition == true, condition2 == null ) \n" @@ -137,7 +144,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION3() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION4() { String input = "rule MyRule \n" + " when \n" + " Cl"; @@ -152,7 +160,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION4() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION5() { String input = "rule MyRule \n" + " when \n" + " Class( condition == true ) \n" + " Cl"; @@ -168,7 +177,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION5() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION6() { String input = "rule MyRule \n" + " when \n" + " class: Cl"; @@ -183,7 +193,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION6() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION7() { String input = "rule MyRule \n" + " when \n" + " class:Cl"; @@ -199,7 +210,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION7() { } /** Inside of condition: start */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START1() { String input = "rule MyRule \n" + " when \n" + " Class ("; @@ -214,7 +226,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START1() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START2() { String input = "rule MyRule \n" + " when \n" + " Class ( na"; @@ -229,7 +242,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START2() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START3() { String input = "rule MyRule \n" + " when \n" + " Class ( name.subProperty['test'].subsu"; @@ -245,7 +259,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START3() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START4() { String input = "rule MyRule \n" + " when \n" + " Class ( condition == true, "; @@ -261,7 +276,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START4() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START5() { String input = "rule MyRule \n" + " when \n" + " Class ( condition == true, na"; @@ -277,7 +293,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START5() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() { String input = "rule MyRule \n" + " when \n" + " Class ( \n" + " "; @@ -292,7 +309,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START7() { String input = "rule MyRule \n" + " when \n" + " Class ( condition == true, \n" + " "; @@ -308,7 +326,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START7() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() { String input = "rule MyRule \n" + " when \n" + " Class ( c: condition, \n" + " "; @@ -331,7 +350,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9a() { String input = "rule MyRule \n" + " when \n" + " Class ( name:"; @@ -346,7 +366,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9a() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9b() { String input = "rule MyRule \n" + " when \n" + " Class ( name: "; @@ -361,7 +382,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9b() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START10() { String input = "rule MyRule \n" + " when \n" + " Class ( name:"; @@ -377,7 +399,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START10() { } /** Inside of condition: Operator */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR1() { String input = "rule MyRule \n" + " when \n" + " Class ( property "; @@ -392,7 +415,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR1() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR2() { String input = "rule MyRule \n" + " when \n" + " Class(property "; @@ -407,7 +431,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR2() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR3() { String input = "rule MyRule \n" + " when \n" + " Class ( name : property "; @@ -423,7 +448,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR3() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR4() { String input = "rule MyRule \n" + " when \n" + " Class (name:property "; @@ -439,7 +465,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR4() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR5() { String input = "rule MyRule \n" + " when \n" + " Class (name:property "; @@ -455,7 +482,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR5() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR6() { String input = "rule MyRule \n" + " when \n" + " Class ( name1 : property1, name : property "; @@ -471,7 +499,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR6() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR7() { String input = "rule MyRule \n" + " when \n" + " Class ( name1 : property1 == \"value\", name : property "; @@ -487,7 +516,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR7() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR8() { String input = "rule MyRule \n" + " when \n" + " Class ( name1 : property1 == \"value\",property "; @@ -503,7 +533,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR8() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR9() { String input = "rule MyRule \n" + " when \n" + " Class ( name1 : property1, \n" + " name : property "; @@ -520,7 +551,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR9() { } /** Inside of condition: argument */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() { String input = "rule MyRule \n" + " when \n" + " Class ( property == "; @@ -535,7 +567,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT2() { String input = "rule MyRule \n" + " when \n" + " Class ( property== "; @@ -550,7 +583,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT2() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() { String input = "rule MyRule \n" + " when \n" + " Class ( name : property <= "; @@ -566,7 +600,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT4() { String input = "rule MyRule \n" + " when \n" + " Class ( name:property != "; @@ -582,7 +617,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT4() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT5() { String input = "rule MyRule \n" + " when \n" + " Class ( name1 : property1, property2 == "; @@ -598,7 +634,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT5() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT6() { String input = "rule MyRule \n" + " when \n" + " Class (name:property== "; @@ -614,7 +651,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT6() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7a() { String input = "rule MyRule \n" + " when \n" + " Class ( property == otherPropertyN"; @@ -630,7 +668,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7a() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7b() { String input = "rule MyRule \n" + " when \n" + " Class ( property == otherPropertyN "; @@ -646,7 +685,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7b() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT8() { String input = "rule MyRule \n" + " when \n" + " Class ( property == \"someth"; @@ -662,7 +702,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT8() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9a() { String input = "rule MyRule \n" + " when \n" + " Class ( property contains "; @@ -678,7 +719,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9a() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9b() { String input = "rule MyRule \n" + " when \n" + " Class ( property not contains "; @@ -694,7 +736,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9b() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT10() { String input = "rule MyRule \n" + " when \n" + " Class ( property excludes "; @@ -710,7 +753,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT10() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT11() { String input = "rule MyRule \n" + " when \n" + " Class ( property matches \"prop"; @@ -726,7 +770,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT11() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT12() { String input = "rule MyRule \n" + " when \n" + " Class ( property in "; @@ -757,7 +802,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END1() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START11() { String input = "rule MyRule \n" + " when \n" + " Class ( property in ('1', '2'), "; @@ -773,8 +819,9 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START11() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) - @Ignore + @Test + @Timeout(10*1000) + @Disabled public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT13() { String input = "rule MyRule \n" + " when \n" + " Class ( property not in "; @@ -790,7 +837,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT13() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() { String input = "rule MyRule \n" + " when \n" + " Class ( property not in ('1', '2') "; @@ -806,7 +854,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START12() { String input = "rule MyRule \n" + " when \n" + " Class ( property not in ('1', '2'), "; @@ -822,7 +871,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START12() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT14() { String input = "rule MyRule \n" + " when \n" + " Class ( property memberOf "; @@ -838,7 +888,9 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT14() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) @Ignore + @Test + @Timeout(10*1000) + @Disabled public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() { // FIXME for now it will be a limitation of the parser... memberOf is a // soft-keyword and this sentence cannot be parsed correctly if @@ -857,7 +909,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START13() { String input = "rule MyRule \n" + " when \n" + " Class ( property memberOf collection, "; @@ -873,7 +926,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START13() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT15() { String input = "rule MyRule \n" + " when \n" + " Class ( property not memberOf "; @@ -889,7 +943,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT15() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END4() { String input = "rule MyRule \n" + " when \n" + " Class ( property not memberOf collection "; @@ -905,7 +960,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END4() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START14() { String input = "rule MyRule \n" + " when \n" + " Class ( property not memberOf collection, "; @@ -926,7 +982,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START14() { } /** EXISTS */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() { String input = "rule MyRule \n" + " when \n" + " exists "; @@ -941,7 +998,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS2() { String input = "rule MyRule \n" + " when \n" + " exists ( "; @@ -956,7 +1014,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS2() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS3() { String input = "rule MyRule \n" + " when \n" + " exists("; @@ -971,7 +1030,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS3() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS4() { String input = "rule MyRule \n" + " when \n" + " exists Cl"; @@ -986,7 +1046,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS4() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS5() { String input = "rule MyRule \n" + " when \n" + " exists ( Cl"; @@ -1001,7 +1062,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS5() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS6() { String input = "rule MyRule \n" + " when \n" + " exists ( name : Cl"; @@ -1016,7 +1078,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS6() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDeterminationINSIDE_CONDITION_START16() { String input = "rule MyRule \n" + " when \n" + " exists Class ("; @@ -1031,7 +1094,8 @@ public void testCheckLHSLocationDeterminationINSIDE_CONDITION_START16() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION() { String input = "rule MyRule \n" + " when \n" + " exists Class ( ) \n" + " "; @@ -1048,7 +1112,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION() { } /** NOT */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT1() { String input = "rule MyRule \n" + " when \n" + " not "; @@ -1063,7 +1128,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT1() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT2() { String input = "rule MyRule \n" + " when \n" + " not Cl"; @@ -1078,7 +1144,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT2() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS7() { String input = "rule MyRule \n" + " when \n" + " not ( exists "; @@ -1093,7 +1160,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS7() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS8() { String input = "rule MyRule \n" + " when \n" + " not ( exists Cl"; @@ -1108,7 +1176,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS8() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() { String input = "rule MyRule \n" + " when \n" + " not Class ("; @@ -1123,7 +1192,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START22() { String input = "rule MyRule \n" + " when \n" + " not ( exists Class ("; @@ -1138,7 +1208,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START22() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START23() { String input = "rule MyRule \n" + " when \n" + " not ( exists name : Class ("; @@ -1154,7 +1225,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START23() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION9() { String input = "rule MyRule \n" + " when \n" + " not Class () \n" + " "; @@ -1171,7 +1243,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION9() { } /** AND */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR1() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and "; @@ -1186,7 +1259,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR1() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR2() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and "; @@ -1201,7 +1275,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR2() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR3() { String input = "rule MyRule \n" + " when \n" + " Class () and "; @@ -1216,7 +1291,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR3() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() { String input = "rule MyRule \n" + " when \n" + " name : Class ( name: property ) and "; @@ -1237,7 +1313,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() { .getEditorType()).isEqualTo(DroolsEditorType.IDENTIFIER_VARIABLE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR5() { String input = "rule MyRule \n" + " when \n" + " Class ( name: property ) \n" + " and "; @@ -1253,7 +1330,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR5() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR6() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and Cl"; @@ -1268,7 +1346,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR6() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR7() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and name : Cl"; @@ -1284,7 +1363,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR7() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR8() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and name : Cl"; @@ -1300,7 +1380,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR8() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION31() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and Class ( ) \n" + " "; @@ -1316,7 +1397,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION31() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION32() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and not Class ( ) \n" + " "; @@ -1332,7 +1414,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION32() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION33() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and exists Class ( ) \n" + " "; @@ -1348,7 +1431,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION33() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START20() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and Class ( "; @@ -1364,7 +1448,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START20() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR21() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and Class ( name "; @@ -1380,7 +1465,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR21() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR22() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and Class ( name == "; @@ -1396,7 +1482,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR22() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() { String input = "rule MyRule \n" + " when \n" + " exists Class ( ) and not "; @@ -1412,7 +1499,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS() { String input = "rule MyRule \n" + " when \n" + " exists Class ( ) and exists "; @@ -1428,7 +1516,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION30() { String input = "rule MyRule \n" + " when \n" + " Class ( ) and not Class ( ) \n" + " "; @@ -1445,7 +1534,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION30() { } /** OR */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR21() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or "; @@ -1460,7 +1550,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR21() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or "; @@ -1475,7 +1566,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR23() { String input = "rule MyRule \n" + " when \n" + " Class () or "; @@ -1490,7 +1582,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR23() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR24() { String input = "rule MyRule \n" + " when \n" + " name : Class ( name: property ) or "; @@ -1506,7 +1599,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR24() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR25() { String input = "rule MyRule \n" + " when \n" + " Class ( name: property ) \n" + " or "; @@ -1522,7 +1616,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR25() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR26() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or Cl"; @@ -1537,7 +1632,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR26() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR27() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or name : Cl"; @@ -1553,7 +1649,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR27() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR28() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or name : Cl"; @@ -1569,7 +1666,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR28() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION40() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or Class ( ) \n" + " "; @@ -1585,7 +1683,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION40() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START40() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or Class ( "; @@ -1601,7 +1700,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START40() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or Class ( name "; @@ -1617,7 +1717,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT30() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or Class ( name == "; @@ -1633,7 +1734,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT30() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_EGIN_OF_CONDITION_NOT() { String input = "rule MyRule \n" + " when \n" + " exists Class ( ) or not "; @@ -1649,7 +1751,8 @@ public void testCheckLHSLocationDetermination_EGIN_OF_CONDITION_NOT() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS40() { String input = "rule MyRule \n" + " when \n" + " exists Class ( ) or exists "; @@ -1666,7 +1769,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS40() { } /** EVAL */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL1() { String input = "rule MyRule \n" + " when \n" + " eval ( "; @@ -1681,7 +1785,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL1() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL2() { String input = "rule MyRule \n" + " when \n" + " eval("; @@ -1696,7 +1801,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL2() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL3() { String input = "rule MyRule \n" + " when \n" + " eval( myCla"; @@ -1711,7 +1817,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL3() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL4() { String input = "rule MyRule \n" + " when \n" + " eval( param.getMetho"; @@ -1726,7 +1833,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL4() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL5() { String input = "rule MyRule \n" + " when \n" + " eval( param.getMethod("; @@ -1742,7 +1850,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL5() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL6() { String input = "rule MyRule \n" + " when \n" + " eval( param.getMethod().get"; @@ -1758,7 +1867,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL6() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL7() { String input = "rule MyRule \n" + " when \n" + " eval( param.getMethod(\"someStringWith)))\").get"; @@ -1774,7 +1884,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL7() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL8() { String input = "rule MyRule \n" + " when \n" + " eval( param.getMethod(\"someStringWith(((\").get"; @@ -1790,7 +1901,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL8() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL9() { String input = "rule MyRule \n" + " when \n" + " eval( true )"; @@ -1805,7 +1917,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL9() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION50() { String input = "rule MyRule \n" + " when \n" + " eval( param.getProperty(name).isTrue() )"; @@ -1821,7 +1934,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION50() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION51() { String input = "rule MyRule \n" + " when \n" + " eval( param.getProperty(\"someStringWith(((\").isTrue() )"; @@ -1837,7 +1951,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION51() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_EVAL10() { String input = "rule MyRule \n" + " when \n" + " eval( param.getProperty((((String) s) )"; @@ -1853,7 +1968,8 @@ public void testCheckLHSLocationDetermination_INSIDE_EVAL10() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_EVAL); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION52() { String input = "rule MyRule \n" + " when \n" + " eval( param.getProperty((((String) s))))"; @@ -1869,7 +1985,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION52() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION53() { String input = "rule MyRule \n" + " when \n" + " eval( true ) \n" + " "; @@ -1886,7 +2003,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION53() { } /** MULTIPLE RESTRICTIONS */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR12() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && "; @@ -1902,7 +2020,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR12() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR13() { String input = "rule MyRule \n" + " when \n" + " Class ( name : property1, property2 > 0 && "; @@ -1918,7 +2037,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR13() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR14() { String input = "rule MyRule \n" + " when \n" + " Class ( property1 < 20, property2 > 0 && "; @@ -1934,7 +2054,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR14() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT20() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && < "; @@ -1950,7 +2071,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT20() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END6() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && < 10 "; @@ -1966,7 +2088,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END6() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START41() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && < 10, "; @@ -1982,7 +2105,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START41() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR60() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 || "; @@ -1998,7 +2122,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR60() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR61() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && \n" + " "; @@ -2014,7 +2139,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR61() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR62() { String input = "rule MyRule \n" + " when \n" + " Class ( name : property1, property2 > 0 || "; @@ -2030,7 +2156,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR62() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR63() { String input = "rule MyRule \n" + " when \n" + " Class ( property1 < 20, property2 > 0 || "; @@ -2046,7 +2173,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR63() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END10() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 "; @@ -2062,7 +2190,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END10() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END11() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 \n" + " "; @@ -2078,7 +2207,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END11() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END12() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 && < 10 "; @@ -2094,7 +2224,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END12() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END13() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 || < 10 "; @@ -2110,7 +2241,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END13() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_END); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END14() { String input = "rule MyRule \n" + " when \n" + " Class ( property == \"test\" || == \"test2\" "; @@ -2127,7 +2259,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END14() { } /** FROM */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION60() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) "; @@ -2143,7 +2276,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION60() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION61() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) fr"; @@ -2159,7 +2293,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION61() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM1() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from "; @@ -2175,7 +2310,8 @@ public void testCheckLHSLocationDetermination_FROM1() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_LHS_FROM); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from myGlob"; @@ -2191,7 +2327,8 @@ public void testCheckLHSLocationDetermination_FROM2() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_LHS_FROM); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM3() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from myGlobal.get"; @@ -2207,7 +2344,8 @@ public void testCheckLHSLocationDetermination_FROM3() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_LHS_FROM); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION75() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from myGlobal.getList() \n" @@ -2224,7 +2362,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION75() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION71() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from getDroolsFunction() \n" @@ -2242,7 +2381,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION71() { } /** FROM ACCUMULATE */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE1() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate ( "; @@ -2258,7 +2398,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE1() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate("; @@ -2274,7 +2415,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE2() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION73() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2295,7 +2437,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION73() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2312,7 +2455,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2330,7 +2474,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE3() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2348,7 +2493,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE3() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2368,7 +2514,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2386,7 +2533,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE2() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2404,7 +2552,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE2() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2424,7 +2573,8 @@ public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE2() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2441,7 +2591,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR40() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2458,7 +2609,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR40() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" @@ -2476,7 +2628,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT() { } /** FROM COLLECT */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_COLLECT1() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect ( "; @@ -2492,7 +2645,8 @@ public void testCheckLHSLocationDetermination_FROM_COLLECT1() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_COLLECT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM_COLLECT2() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect("; @@ -2508,7 +2662,8 @@ public void testCheckLHSLocationDetermination_FROM_COLLECT2() { .getContent())).isEqualTo(Location.LOCATION_LHS_FROM_COLLECT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION67() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect ( \n" @@ -2525,7 +2680,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION67() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START31() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect ( \n" + " Cheese( "; @@ -2541,7 +2697,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START31() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR31() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect ( \n" @@ -2558,7 +2715,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR31() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT21() { String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from collect ( \n" @@ -2576,7 +2734,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT21() { } /** NESTED FROM */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION68() { String input = "rule MyRule \n" + " when \n" @@ -2593,7 +2752,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION68() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM5() { String input = "rule MyRule \n" + " when \n" @@ -2610,7 +2770,8 @@ public void testCheckLHSLocationDetermination_FROM5() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_LHS_FROM); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION69() { String input = "rule MyRule \n" + " when \n" @@ -2627,7 +2788,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION69() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION70() { String input = "rule MyRule \n" + " when \n" @@ -2644,7 +2806,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION70() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_FROM6() { String input = "rule MyRule \n" + " when \n" @@ -2662,7 +2825,8 @@ public void testCheckLHSLocationDetermination_FROM6() { } /** FORALL */ - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION81() { String input = "rule MyRule \n" + " when \n" + " forall ( "; @@ -2677,7 +2841,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION81() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START32() { String input = "rule MyRule \n" + " when \n" + " forall ( " + " Class ( pr"; @@ -2693,7 +2858,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START32() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR32() { String input = "rule MyRule \n" + " when \n" + " forall ( " + " Class ( property "; @@ -2709,7 +2875,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR32() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT22() { String input = "rule MyRule \n" + " when \n" + " forall ( " + " Class ( property == "; @@ -2725,7 +2892,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT22() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION76() { String input = "rule MyRule \n" + " when \n" + " forall ( " + " Class ( property == \"test\")" + " C"; @@ -2741,7 +2909,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION76() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77a() { String input = "rule MyRule \n" + " when \n" @@ -2758,7 +2927,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77a() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77b() { String input = "rule MyRule \n" + " when \n" @@ -2775,7 +2945,8 @@ public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77b() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45a() { String input = "rule MyRule \n" + " when \n" + " Class ( name :"; @@ -2791,7 +2962,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45a() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45b() { String input = "rule MyRule \n" + " when \n" + " Class ( name : "; @@ -2807,7 +2979,8 @@ public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45b() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRHSLocationDetermination_firstLineOfLHS() { String input = "rule MyRule \n" + " when\n" + " Class ( )\n" + " then\n" + " "; @@ -2823,7 +2996,8 @@ public void testCheckRHSLocationDetermination_firstLineOfLHS() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RHS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRHSLocationDetermination_startOfNewlINE() { String input = "rule MyRule \n" + " when\n" + " Class ( )\n" + " then\n" + " assert(null);\n" + " "; @@ -2839,7 +3013,8 @@ public void testCheckRHSLocationDetermination_startOfNewlINE() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RHS); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRHSLocationDetermination3() { String input = "rule MyRule \n" + " when\n" + " Class ( )\n" + " then\n" + " meth"; @@ -2863,7 +3038,8 @@ public void testCheckRHSLocationDetermination3() { assertThat(lastToken.getText()).isEqualTo("meth"); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination() { String input = "rule MyRule "; @@ -2878,7 +3054,8 @@ public void testCheckRuleHeaderLocationDetermination() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination2() { String input = "rule MyRule \n" + " salience 12 activation-group \"my"; @@ -2898,7 +3075,8 @@ public void testCheckRuleHeaderLocationDetermination2() { .getContent())).isEqualTo(Location.LOCATION_RULE_HEADER_KEYWORD); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination3() { String input = "rule \"Hello World\" ruleflow-group \"hello\" s"; @@ -2913,7 +3091,8 @@ public void testCheckRuleHeaderLocationDetermination3() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination_dialect1() { String input = "rule MyRule \n" + " dialect \"java\""; @@ -2928,7 +3107,8 @@ public void testCheckRuleHeaderLocationDetermination_dialect1() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination_dialect2() { String input = "rule MyRule \n" + " dialect \"mvel\""; @@ -2943,7 +3123,8 @@ public void testCheckRuleHeaderLocationDetermination_dialect2() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination_dialect3() { String input = "rule MyRule \n" + " dialect "; @@ -2963,7 +3144,8 @@ public void testCheckRuleHeaderLocationDetermination_dialect3() { .getContent())).isEqualTo(Location.LOCATION_RULE_HEADER_KEYWORD); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckRuleHeaderLocationDetermination_dialect4() { String input = "rule MyRule \n" + " dialect \""; @@ -2985,7 +3167,8 @@ public void testCheckRuleHeaderLocationDetermination_dialect4() { // TODO: add tests for dialect defined at package header level - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER1() { String input = "query MyQuery "; @@ -3000,7 +3183,8 @@ public void testCheckQueryLocationDetermination_RULE_HEADER1() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER2() { String input = "query \"MyQuery\" "; @@ -3015,7 +3199,8 @@ public void testCheckQueryLocationDetermination_RULE_HEADER2() { .getEditorInterface().get(0).getContent())).isEqualTo(Location.LOCATION_RULE_HEADER); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckQueryLocationDetermination_LHS_BEGIN_OF_CONDITION() { String input = "query MyQuery() "; @@ -3030,7 +3215,8 @@ public void testCheckQueryLocationDetermination_LHS_BEGIN_OF_CONDITION() { .getContent())).isEqualTo(Location.LOCATION_LHS_BEGIN_OF_CONDITION); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testCheckQueryLocationDetermination_LHS_INSIDE_CONDITION_START() { String input = "query MyQuery \n" + " Class ("; @@ -3045,7 +3231,8 @@ public void testCheckQueryLocationDetermination_LHS_INSIDE_CONDITION_START() { .getContent())).isEqualTo(Location.LOCATION_LHS_INSIDE_CONDITION_START); } - @Test(timeout=10*1000) + @Test + @Timeout(10*1000) public void testRuleParameters_PATTERN_1() { String input = "rule MyRule \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLExprParserTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLExprParserTest.java index 3a59b507301..7f53d77d06f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLExprParserTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DRLExprParserTest.java @@ -26,9 +26,10 @@ import org.drools.drl.ast.descr.RelationalExprDescr; import org.drools.drl.parser.DrlExprParser; import org.drools.drl.parser.DrlExprParserFactory; -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.junit.jupiter.api.Timeout; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; @@ -40,13 +41,13 @@ public class DRLExprParserTest { DrlExprParser parser; - @Before + @BeforeEach public void setUp() throws Exception { new EvaluatorRegistry(); this.parser = DrlExprParserFactory.getDrlExprParser(LanguageLevelOption.DRL6); } - @After + @AfterEach public void tearDown() throws Exception { this.parser = null; } @@ -250,7 +251,8 @@ public void testDeepBinding() throws Exception { } - @Test(timeout = 10000L) + @Test + @Timeout(10000L) public void testNestedExpression() throws Exception { // DROOLS-982 String source = "(((((((((((((((((((((((((((((((((((((((((((((((((( a > b ))))))))))))))))))))))))))))))))))))))))))))))))))"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DescrDumperTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DescrDumperTest.java index 0af0bc01635..082d111f761 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DescrDumperTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DescrDumperTest.java @@ -27,9 +27,9 @@ import org.drools.drl.parser.DrlExprParserFactory; import org.drools.mvel.evaluators.MatchesEvaluatorsDefinition; import org.drools.mvel.evaluators.SetEvaluatorsDefinition; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; @@ -38,7 +38,7 @@ public class DescrDumperTest { private DescrDumper dumper; - @Before + @BeforeEach public void setUp() throws Exception { // configure operators new SetEvaluatorsDefinition(); @@ -135,7 +135,8 @@ public void testDumpExcludes2() throws Exception { assertThat(result).isEqualTo(expected); } - @Test @Ignore + @Test + @Disabled public void testDumpWithDateAttr() throws Exception { String input = "son.birthDate == \"01-jan-2000\""; String expected = "son.birthDate == org.drools.util.DateUtils.parseDate( \"01-jan-2000\" )"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DroolsSoftKeywordsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DroolsSoftKeywordsTest.java index a12b9f1b100..8b23b920b83 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DroolsSoftKeywordsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/DroolsSoftKeywordsTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.lang; import org.drools.drl.parser.lang.DroolsSoftKeywords; +import org.junit.jupiter.api.Test; import org.drools.compiler.builder.impl.EvaluatorRegistry; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; 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 535d8a1105e..3296e941654 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 @@ -26,7 +26,7 @@ import org.drools.drl.parser.lang.DRLParser; import org.drools.drl.parser.lang.Expander; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/RuleParserTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/RuleParserTest.java index 1566604d241..f1d80122517 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/RuleParserTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/RuleParserTest.java @@ -63,9 +63,9 @@ import org.drools.drl.parser.lang.DRL6Lexer; import org.drools.drl.parser.lang.DRL6Parser; import org.drools.drl.parser.lang.DRLParser; -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.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; @@ -77,13 +77,13 @@ public class RuleParserTest { private DRLParser parser; - @Before + @BeforeEach public void setUp() throws Exception { // initializes pluggable operators new EvaluatorRegistry(); } - @After + @AfterEach public void tearDown() throws Exception { } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/api/DescrBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/api/DescrBuilderTest.java index 087a0b095cd..20d4560a45a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/api/DescrBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/api/DescrBuilderTest.java @@ -41,7 +41,7 @@ import org.drools.mvel.DrlDumper; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.compiler.StockTick; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.definition.type.FactType; import org.kie.api.event.rule.AfterMatchFiredEvent; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/AndDescrTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/AndDescrTest.java index 8a4d6cf7df1..8ae3ccfebf4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/AndDescrTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/AndDescrTest.java @@ -21,7 +21,7 @@ import org.drools.drl.ast.descr.AndDescr; import org.drools.drl.ast.descr.NotDescr; import org.drools.drl.ast.descr.PatternDescr; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/ConnectiveDescrTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/ConnectiveDescrTest.java index 346adfca684..adf7b13a276 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/ConnectiveDescrTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/ConnectiveDescrTest.java @@ -20,7 +20,7 @@ import org.drools.drl.ast.descr.ConnectiveDescr; import org.drools.drl.ast.descr.ConnectiveDescr.RestrictionConnectiveType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/PackageDescrTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/PackageDescrTest.java index d924b3df113..28b3db51256 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/PackageDescrTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/descr/PackageDescrTest.java @@ -34,7 +34,7 @@ import org.drools.drl.ast.descr.PackageDescr; import org.drools.drl.ast.descr.RuleDescr; import org.drools.mvel.compiler.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/ANTLRDSLTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/ANTLRDSLTest.java index 154f7ba3027..d8895096e99 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/ANTLRDSLTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/ANTLRDSLTest.java @@ -25,7 +25,7 @@ import org.drools.drl.parser.lang.dsl.DSLMappingEntry; import org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ANTLRDSLTest { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingEntryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingEntryTest.java index 4615e200883..bd71ecbfe86 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingEntryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingEntryTest.java @@ -27,7 +27,7 @@ import org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile; import org.drools.drl.parser.lang.dsl.DefaultDSLMapping; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingFileTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingFileTest.java index 8aed7b802b8..c039d56f9fe 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingFileTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLMappingFileTest.java @@ -27,8 +27,8 @@ import org.drools.drl.parser.lang.dsl.DSLMappingFile; import org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -198,7 +198,8 @@ public void testParseFileWithEscapes() { } - @Test @Ignore + @Test + @Disabled public void testParseFileWithEscaptedEquals() { String file = "[when][]something:\\={value}=Attribute( something == \"{value}\" )"; try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLTokenizedMappingFileTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLTokenizedMappingFileTest.java index f69963ca222..79972f9e2b7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLTokenizedMappingFileTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DSLTokenizedMappingFileTest.java @@ -27,7 +27,7 @@ import org.drools.drl.parser.lang.dsl.DSLMappingFile; import org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DefaultExpanderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DefaultExpanderTest.java index 01012d786ad..7b3a91dd882 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DefaultExpanderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/lang/dsl/DefaultExpanderTest.java @@ -28,8 +28,9 @@ import org.drools.drl.parser.lang.dsl.DSLMappingFile; import org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile; import org.drools.drl.parser.lang.dsl.DefaultExpander; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import static org.assertj.core.api.Assertions.assertThat; @@ -41,7 +42,7 @@ public class DefaultExpanderTest { private DSLTokenizedMappingFile tokenizedFile = null; private DefaultExpander expander = null; - @Before + @BeforeEach public void setUp() throws Exception { final String filename = "test_metainfo.dsl"; final Reader reader = new InputStreamReader(this.getClass().getResourceAsStream(filename)); @@ -440,7 +441,8 @@ public void testExpandExpr() throws Exception { assertThat(drl).isEqualTo(expected); } - @Test(timeout = 1000) + @Test + @Timeout(1000) public void testExpandInfiniteLoop() throws Exception { // DROOLS-73 DSLMappingFile file = new DSLTokenizedMappingFile(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathAccumulateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathAccumulateTest.java index 5701330e263..deedfb2163b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathAccumulateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathAccumulateTest.java @@ -19,70 +19,69 @@ package org.drools.mvel.compiler.oopath; import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.oopath.model.Child; import org.drools.mvel.compiler.oopath.model.Man; 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 OOPathAccumulateTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathAccumulateTest(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 testAccumulateAverage() { - testAccumulate("average", 10); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateAverage(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulate(kieBaseTestConfiguration, "average", 10); } - @Test - public void testAccumulateMin() { - testAccumulate("min", 8); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateMin(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulate(kieBaseTestConfiguration, "min", 8); } - @Test - public void testAccumulateMax() { - testAccumulate("max", 12); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateMax(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulate(kieBaseTestConfiguration, "max", 12); } - @Test - public void testAccumulateCount() { - testAccumulate("count", 2); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateCount(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulate(kieBaseTestConfiguration, "count", 2); } - @Test - public void testAccumulateSum() { - testAccumulate("sum", 20); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateSum(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulate(kieBaseTestConfiguration, "sum", 20); } - @Test - public void testAccumulateCollectList() { - testAccumulateCollection("collectList", 12, 8); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateCollectList(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulateCollection(kieBaseTestConfiguration, "collectList", 12, 8); } - @Test - public void testAccumulateCollectSet() { - testAccumulateCollection("collectSet", 12, 8); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateCollectSet(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAccumulateCollection(kieBaseTestConfiguration, "collectSet", 12, 8); } - private void testAccumulate(final String accumulateFunction, final Number expectedResult) { + private void testAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration, final String accumulateFunction, final Number expectedResult) { // DROOLS-1265 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -112,7 +111,7 @@ private void testAccumulate(final String accumulateFunction, final Number expect } } - private void testAccumulateCollection(final String accumulateFunction, final Integer... expectedResults) { + private void testAccumulateCollection(KieBaseTestConfiguration kieBaseTestConfiguration, String accumulateFunction, final Integer... expectedResults) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.Collection globalVar\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathBindTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathBindTest.java index a8f39f99bf8..6ce2518ca7c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathBindTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathBindTest.java @@ -19,12 +19,12 @@ package org.drools.mvel.compiler.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.stream.Stream; import org.drools.mvel.compiler.oopath.model.Child; import org.drools.mvel.compiler.oopath.model.Man; @@ -32,40 +32,35 @@ import org.drools.mvel.compiler.oopath.model.Woman; 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.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; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class OOPathBindTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathBindTest(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 testBindIntegerFireAllRules() throws InterruptedException, ExecutionException { - testBindInteger(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindIntegerFireAllRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException { + testBindInteger(kieBaseTestConfiguration, false); } - @Test(timeout = 1000) - public void testBindIntegerFireUntilHalt() throws InterruptedException, ExecutionException { - testBindInteger(true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(1000) + public void testBindIntegerFireUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException { + testBindInteger(kieBaseTestConfiguration, true); } - public void testBindInteger(final boolean fireUntilHalt) throws InterruptedException, ExecutionException { + public void testBindInteger(KieBaseTestConfiguration kieBaseTestConfiguration, final boolean fireUntilHalt) throws InterruptedException, ExecutionException { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -117,8 +112,9 @@ private void waitForResultAndStopFireUntilHalt(final List resultList, f } } - @Test - public void testBindString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindString(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -129,11 +125,12 @@ public void testBindString() { " list.add( $name );\n" + "end\n"; - testScenarioBindString(drl, "Bob", "Alice"); + testScenarioBindString(kieBaseTestConfiguration, drl, "Bob", "Alice"); } - @Test - public void testBindStringWithConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindStringWithConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -144,11 +141,12 @@ public void testBindStringWithConstraint() { " list.add( $name );\n" + "end\n"; - testScenarioBindString(drl, "Bob"); + testScenarioBindString(kieBaseTestConfiguration, drl, "Bob"); } - @Test - public void testBindStringWithAlphaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindStringWithAlphaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -159,11 +157,12 @@ public void testBindStringWithAlphaConstraint() { " list.add( $name );\n" + "end\n"; - testScenarioBindString(drl, "Bob"); + testScenarioBindString(kieBaseTestConfiguration, drl, "Bob"); } - @Test - public void testBindStringWithBetaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindStringWithBetaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -175,10 +174,10 @@ public void testBindStringWithBetaConstraint() { " list.add( $name );\n" + "end\n"; - testScenarioBindString(drl, "Bob"); + testScenarioBindString(kieBaseTestConfiguration, drl, "Bob"); } - private void testScenarioBindString(final String drl, final String... expectedResults) { + private void testScenarioBindString(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl, final String... expectedResults) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSession ksession = kbase.newKieSession(); @@ -195,8 +194,9 @@ private void testScenarioBindString(final String drl, final String... expectedRe assertThat(list).containsExactlyInAnyOrder(expectedResults); } - @Test - public void testBindObjectFromList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindObjectFromList(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -223,8 +223,9 @@ public void testBindObjectFromList() { assertThat(list).containsExactlyInAnyOrder("Charles", "Debbie"); } - @Test - public void testBindList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindList(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -260,8 +261,9 @@ public void testBindList() { assertThat(list).containsExactlyInAnyOrder(1, 2); } - @Test - public void testBindListWithConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindListWithConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathCastTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathCastTest.java index 638326db10f..f1fd59bba91 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathCastTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathCastTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.oopath.model.BabyBoy; import org.drools.mvel.compiler.oopath.model.BabyGirl; @@ -30,10 +30,9 @@ 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; @@ -41,22 +40,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class OOPathCastTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathCastTest(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 testInlineCast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCast(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -92,8 +84,9 @@ public void testInlineCast() { assertThat(list).containsExactlyInAnyOrder("doll"); } - @Test - public void testInvalidCast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidCast(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -109,8 +102,9 @@ public void testInvalidCast() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testInlineCastWithConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInlineCastWithConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathMultilevelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathMultilevelTest.java index 30be8d32c45..07b10c2a136 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathMultilevelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathMultilevelTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.oopath; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.oopath.model.Child; import org.drools.mvel.compiler.oopath.model.Man; @@ -28,31 +28,23 @@ import org.drools.mvel.compiler.oopath.model.Woman; 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 OOPathMultilevelTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathMultilevelTest(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 testClassTwoLevelPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassTwoLevelPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -88,8 +80,9 @@ public void testClassTwoLevelPath() { assertThat(list).containsExactlyInAnyOrder("car", "ball", "doll"); } - @Test - public void testClassThreeLevelPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassThreeLevelPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -122,8 +115,9 @@ public void testClassThreeLevelPath() { assertThat(list).containsExactlyInAnyOrder("car", "ball"); } - @Test - public void testClassTwoLevelPathWithAlphaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassTwoLevelPathWithAlphaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -134,11 +128,12 @@ public void testClassTwoLevelPathWithAlphaConstraint() { " list.add( $toy.getName() );\n" + "end\n"; - testScenarioTwoLevelPathWithConstraint(drl); + testScenarioTwoLevelPathWithConstraint(kieBaseTestConfiguration, drl); } - @Test - public void testClassTwoLevelPathWithBetaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassTwoLevelPathWithBetaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -149,10 +144,10 @@ public void testClassTwoLevelPathWithBetaConstraint() { "then\n" + " list.add( $toy.getName() );\n" + "end\n"; - testScenarioTwoLevelPathWithConstraint(drl); + testScenarioTwoLevelPathWithConstraint(kieBaseTestConfiguration, drl); } - private void testScenarioTwoLevelPathWithConstraint(final String drl) { + private void testScenarioTwoLevelPathWithConstraint(KieBaseTestConfiguration kieBaseTestConfiguration,final String drl) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathQueriesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathQueriesTest.java index 4d874a900cc..15dc13c512c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathQueriesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathQueriesTest.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.stream.StreamSupport; import org.drools.mvel.compiler.oopath.model.Room; @@ -30,10 +30,9 @@ import org.drools.mvel.compiler.oopath.model.Thing; 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.QueryResults; @@ -41,23 +40,16 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class OOPathQueriesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathQueriesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testQueryFromCode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryFromCode(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.Thing;\n" + "query isContainedIn( Thing $x, Thing $y )\n" + @@ -82,8 +74,9 @@ public void testQueryFromCode() { ksession.dispose(); } - @Test - public void testReactiveQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.Room;\n" + "import org.drools.mvel.compiler.oopath.model.Sensor;\n" + @@ -133,8 +126,9 @@ public void testReactiveQuery() { ksession.dispose(); } - @Test - public void testNonReactiveOOPathInQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonReactiveOOPathInQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.Room;\n" + "import org.drools.mvel.compiler.oopath.model.Sensor;\n" + @@ -184,8 +178,9 @@ public void testNonReactiveOOPathInQuery() { ksession.dispose(); } - @Test - public void testRecursiveOOPathQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRecursiveOOPathQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.Thing;\n" + "global java.util.List list\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathReactiveTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathReactiveTest.java index 88a3662458e..efd048eb860 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathReactiveTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathReactiveTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.compiler.oopath; 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; @@ -29,11 +29,9 @@ import org.drools.core.reteoo.LeftInputAdapterNode; import org.drools.core.reteoo.ObjectTypeNode; import org.drools.core.reteoo.ReactiveFromNode; -import org.drools.core.reteoo.Tuple; import org.drools.core.reteoo.TupleImpl; import org.drools.core.reteoo.TupleMemory; import org.drools.core.util.FastIterator; -import org.drools.core.util.Iterator; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.mvel.compiler.oopath.model.Adult; import org.drools.mvel.compiler.oopath.model.Child; @@ -47,10 +45,9 @@ 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; @@ -61,22 +58,15 @@ import static org.drools.mvel.compiler.oopath.model.BodyMeasurement.CHEST; import static org.drools.mvel.compiler.oopath.model.BodyMeasurement.RIGHT_FOREARM; -@RunWith(Parameterized.class) public class OOPathReactiveTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathReactiveTest(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 testReactiveOnLia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveOnLia(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -118,8 +108,9 @@ public void testReactiveOnLia() { assertThat(list).containsExactlyInAnyOrder("doll"); } - @Test - public void testReactiveDeleteOnLia() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveDeleteOnLia(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -184,8 +175,9 @@ public void testReactiveDeleteOnLia() { } } - @Test - public void testRemoveFromReactiveListBasic() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveFromReactiveListBasic(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -230,8 +222,9 @@ public void testRemoveFromReactiveListBasic() { assertThat(ksession.getObjects().contains(debbie)).isFalse(); } - @Test - public void testRemoveFromReactiveListExtended() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveFromReactiveListExtended(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -278,8 +271,9 @@ public void testRemoveFromReactiveListExtended() { assertThat(factsCollection(ksession).contains("Y.Bea")).isFalse(); } - @Test - public void testRemoveFromAndAddToReactiveSet() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveFromAndAddToReactiveSet(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -348,8 +342,9 @@ public void testRemoveFromAndAddToReactiveSet() { /** * Same test as above but with serialization. */ - @Test - public void testRemoveFromReactiveListExtendedWithSerialization() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveFromReactiveListExtendedWithSerialization(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -403,8 +398,9 @@ public void testRemoveFromReactiveListExtendedWithSerialization() { assertThat(factsCollection(ksession).contains("Y.Bea")).isFalse(); } - @Test - public void testReactiveOnBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveOnBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -448,8 +444,9 @@ public void testReactiveOnBeta() { assertThat(list).containsExactlyInAnyOrder("doll"); } - @Test - public void testReactive2Rules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactive2Rules(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List toyList\n" + @@ -508,8 +505,9 @@ public void testReactive2Rules() { assertThat(teenagers).containsExactlyInAnyOrder("Charles", "Debbie"); } - @Test - public void testReactiveList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveList(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -551,8 +549,9 @@ public void testReactiveList() { assertThat(list).containsExactlyInAnyOrder("gun"); } - @Test - public void testReactiveSet() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveSet(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -592,8 +591,9 @@ public void testReactiveSet() { assertThat(list).containsExactlyInAnyOrder("epilepsy"); } - @Test - public void testReactiveMap() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveMap(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -625,8 +625,9 @@ public void testReactiveMap() { assertThat(list).containsExactlyInAnyOrder(38, 80); } - @Test - public void testNonReactivePart() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonReactivePart(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -668,8 +669,9 @@ public void testNonReactivePart() { assertThat(list).isEmpty(); } - @Test - public void testAllNonReactiveAfterNonReactivePart() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllNonReactiveAfterNonReactivePart(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -711,8 +713,9 @@ public void testAllNonReactiveAfterNonReactivePart() { assertThat(list).isEmpty(); } - @Test - public void testInvalidDoubleNonReactivePart() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidDoubleNonReactivePart(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -727,8 +730,9 @@ public void testInvalidDoubleNonReactivePart() { assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isTrue(); } - @Test - public void testSingleFireOnReactiveChange() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleFireOnReactiveChange(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1302 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -771,8 +775,9 @@ public void testSingleFireOnReactiveChange() { assertThat(list).hasSize(1); } - @Test - public void testReactivitySettingAttributeInDrl() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactivitySettingAttributeInDrl(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathTest.java index 43ec72696f3..467d25aca44 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/OOPathTest.java @@ -20,11 +20,11 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.ListIterator; import java.util.Set; +import java.util.stream.Stream; import org.drools.core.phreak.AbstractReactiveObject; import org.drools.core.phreak.ReactiveSet; @@ -42,10 +42,9 @@ 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; @@ -58,22 +57,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.drools.mvel.compiler.TestUtil.assertDrlHasCompilationError; -@RunWith(Parameterized.class) public class OOPathTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathTest(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 testInvalidOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -84,11 +76,12 @@ public void testInvalidOOPath() { " list.add( $toy.getName() );\n" + "end\n"; - testInvalid(drl); + testInvalid(kieBaseTestConfiguration, drl); } - @Test - public void testInvalidOOPathProperty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidOOPathProperty(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -99,16 +92,17 @@ public void testInvalidOOPathProperty() { " list.add( $toy.getName() );\n" + "end\n"; - testInvalid(drl); + testInvalid(kieBaseTestConfiguration, drl); } - private void testInvalid(final String drl) { + private void testInvalid(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl); assertThat(kieBuilder.getResults().hasMessages(Message.Level.ERROR)).isTrue(); } - @Test - public void testIndexedAccess() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIndexedAccess(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -144,8 +138,9 @@ public void testIndexedAccess() { assertThat(list).containsExactlyInAnyOrder("ball"); } - @Test - public void testBackReferenceConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBackReferenceConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n" + @@ -182,8 +177,9 @@ public void testBackReferenceConstraint() { assertThat(list).containsExactlyInAnyOrder("ball", "guitar"); } - @Test - public void testPrimitives() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPrimitives(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1266 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -219,8 +215,9 @@ public void testPrimitives() { assertThat(list).isEqualTo(Arrays.asList("t2:12:t2", "t1:12:t1", "t4:8:t4", "t3:8:t3")); } - @Test - public void testDoubleAdd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleAdd(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1376 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -267,8 +264,9 @@ public void testDoubleAdd() { assertThat(factsCollection(ksession).contains("Y.Bea")).isFalse(); } - @Test - public void testDoubleRemove() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleRemove(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1376 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -309,8 +307,9 @@ public void testDoubleRemove() { assertThat(factsCollection(ksession).contains("Y.Bea")).isFalse(); } - @Test - public void testAddAllRemoveIdx() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddAllRemoveIdx(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -360,8 +359,9 @@ public void testAddAllRemoveIdx() { assertThat(factsCollection(ksession).contains("Y.Bea")).isFalse(); } - @Test - public void testMiscListMethods() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMiscListMethods(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -440,8 +440,9 @@ public void testMiscListMethods() { assertThat(factsCollection(ksession).contains("Y.File2")).isTrue(); } - @Test - public void testCollectionIteratorRemove() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectionIteratorRemove(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -506,8 +507,9 @@ public void testCollectionIteratorRemove() { assertThat(iterator.hasNext()).isFalse(); } - @Test - public void testListIteratorRemove() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testListIteratorRemove(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -611,8 +613,9 @@ public void objectUpdated(ObjectUpdatedEvent event) { assertThat(yIterator.hasPrevious()).isFalse(); } - @Test - public void testListIteratorMisc() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testListIteratorMisc(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -712,8 +715,9 @@ public void objectUpdated(ObjectUpdatedEvent event) { assertThat(factsCollection(ksession).contains("Y.File0R")).isTrue(); } - @Test - public void testRemoveIfSupport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveIfSupport(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -781,8 +785,9 @@ public void objectUpdated(ObjectUpdatedEvent event) { assertThat(factsCollection(ksession).contains("Y.File2")).isTrue(); } - @Test - public void testMiscSetMethods() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMiscSetMethods(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + "\n" + @@ -850,8 +855,9 @@ public void testMiscSetMethods() { assertThat(factsCollection(ksession).contains("Y.File2")).isTrue(); } - @Test - public void testDeclarationOutsideOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationOutsideOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -883,8 +889,9 @@ public void testDeclarationOutsideOOPath() { assertThat(duplicateNames.contains("File1")).isFalse(); } - @Test - public void testDereferencedDeclarationOutsideOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDereferencedDeclarationOutsideOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -916,8 +923,9 @@ public void testDereferencedDeclarationOutsideOOPath() { assertThat(duplicateNames.contains("File1")).isFalse(); } - @Test - public void testDeclarationInsideOOPath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationInsideOOPath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -949,8 +957,9 @@ public void testDeclarationInsideOOPath() { assertThat(duplicateNames.contains("File1")).isFalse(); } - @Test - public void testCompileErrorOnDoubleOOPathInPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompileErrorOnDoubleOOPathInPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -965,8 +974,9 @@ public void testCompileErrorOnDoubleOOPathInPattern() { assertDrlHasCompilationError( drl, 1, kieBaseTestConfiguration ); } - @Test - public void testOOPathWithLocalDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathWithLocalDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -1015,8 +1025,9 @@ public Set getFiles() { } } - @Test - public void testOOPathWithLocalInnerDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathWithLocalInnerDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1411 final String drl = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -1058,8 +1069,9 @@ private List factsCollection(KieSession ksession) { return res; } - @Test - public void testWith2Peers() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWith2Peers(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1589 String header = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -1121,8 +1133,9 @@ public void testWith2Peers() { assertThat(list.size()).isEqualTo(0); } - @Test - public void testWithExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithExists(KieBaseTestConfiguration kieBaseTestConfiguration) { String header = "import org.drools.mvel.compiler.oopath.model.*;\n" + "global java.util.List list\n\n"; @@ -1151,8 +1164,9 @@ public void testWithExists() { list.clear(); } - @Test - public void testNotReactivePeer() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotReactivePeer(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1727 String drl1 = "import org.drools.mvel.compiler.oopath.model.*;\n" + @@ -1187,8 +1201,9 @@ public void testNotReactivePeer() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testConstraintExternalToOopath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConstraintExternalToOopath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2135 final String drl = "import "+ Parent.class.getCanonicalName() +";\n" + @@ -1246,8 +1261,9 @@ public void setChildren(List children) { } } - @Test - public void testOopathAfterNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOopathAfterNot(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6541 final String drl = "import "+ Pojo1.class.getCanonicalName() +";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/graph/OOPathOnGraphTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/graph/OOPathOnGraphTest.java index 93feca06d63..44844eec987 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/graph/OOPathOnGraphTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/oopath/graph/OOPathOnGraphTest.java @@ -19,37 +19,29 @@ package org.drools.mvel.compiler.oopath.graph; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.phreak.AbstractReactiveObject; 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 OOPathOnGraphTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OOPathOnGraphTest(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 testOOPathOnGraph() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathOnGraph(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.compiler.oopath.graph.*;\n" + "import " + Library.class.getCanonicalName() + ";\n" + @@ -86,8 +78,9 @@ public void testOOPathOnGraph() { assertThat(list.contains("Alan")).isTrue(); } - @Test - public void testOOPathOnGraphWithReactiveContentModification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathOnGraphWithReactiveContentModification(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.compiler.oopath.graph.*;\n" + "import " + Library.class.getCanonicalName() + ";\n" + @@ -124,8 +117,9 @@ public void testOOPathOnGraphWithReactiveContentModification() { assertThat(list.contains("Raoul")).isTrue(); } - @Test - public void testOOPathOnGraphWithReactiveContentModificationInSubgraph() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathOnGraphWithReactiveContentModificationInSubgraph(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.compiler.oopath.graph.*;\n" + "import " + Library.class.getCanonicalName() + ";\n" + @@ -162,8 +156,9 @@ public void testOOPathOnGraphWithReactiveContentModificationInSubgraph() { assertThat(list.contains("Raoul")).isTrue(); } - @Test - public void testOOPathOnGraphWithNonReactiveContentModification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOOPathOnGraphWithNonReactiveContentModification(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.compiler.oopath.graph.*;\n" + "import " + Library.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderPerformanceTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderPerformanceTest.java index 3df0bf9bd56..eeb1f415553 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderPerformanceTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderPerformanceTest.java @@ -30,8 +30,8 @@ import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.reteoo.ReteooBuilder; import org.drools.mvel.integrationtests.LargeRuleBase; -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.rule.Rule; import org.kie.internal.conf.CompositeBaseConfiguration; @@ -41,7 +41,7 @@ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 20, 2008 Time: 2:36:47 PM To change this template use File | * Settings | File Templates. */ -@Ignore +@Disabled public class ReteooBuilderPerformanceTest { private static final int RULE_COUNT = Integer.parseInt(System.getProperty("rule.count", "1000")); private static final int RETEBUILDER_COUNT = Integer.parseInt(System.getProperty("retebuilder.count", "1")); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderTest.java index e935ab5fe06..994d010d648 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/reteoo/ReteooBuilderTest.java @@ -33,7 +33,7 @@ import org.drools.core.reteoo.ObjectSink; import org.drools.core.reteoo.ObjectSource; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/XpathAnalysisTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/XpathAnalysisTest.java index 506f36e3c60..17e7320c23f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/XpathAnalysisTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/XpathAnalysisTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.drools.drl.parser.lang.XpathAnalysis; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/JavaAndMVELCombinedTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/JavaAndMVELCombinedTest.java index 700960bdc97..af7fee62e91 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/JavaAndMVELCombinedTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/JavaAndMVELCombinedTest.java @@ -18,47 +18,41 @@ */ package org.drools.mvel.compiler.rule.builder.dialect; -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.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; -@RunWith(Parameterized.class) public class JavaAndMVELCombinedTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public JavaAndMVELCombinedTest(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 final static String FN1 = "mveljavarules.drl"; private final static String FN2 = "mvelonly.drl"; private final static String FN3 = "javaonly.drl"; - @Test - public void testMixed() { - timing( FN1, "mveljava: "); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMixed(KieBaseTestConfiguration kieBaseTestConfiguration) { + timing(kieBaseTestConfiguration, FN1, "mveljava: "); } - @Test - public void testMVEL() { - timing( FN2, " mvel: "); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + timing(kieBaseTestConfiguration, FN2, " mvel: "); } - @Test - public void testJAVA() { - timing( FN3, " java: "); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJAVA(KieBaseTestConfiguration kieBaseTestConfiguration) { + timing(kieBaseTestConfiguration, FN3, " java: "); } // public void testJavaMVELCombination() throws Exception { @@ -84,14 +78,14 @@ public void testJAVA() { // // } - private void timing( String name, String msg ) { + private void timing( KieBaseTestConfiguration kieBaseTestConfiguration, String name, String msg ) { long start = System.currentTimeMillis(); - readDRL( name ); + readDRL(kieBaseTestConfiguration, name); long time = System.currentTimeMillis()-start; System.out.println(msg+time/1000.); } - private void readDRL(String fn) { + private void readDRL(KieBaseTestConfiguration kieBaseTestConfiguration, String fn) { try { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, fn); } catch ( Throwable t ) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AccumulateTemplateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AccumulateTemplateTest.java index 0a03041b52d..6e79d60d329 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AccumulateTemplateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AccumulateTemplateTest.java @@ -29,11 +29,11 @@ import org.drools.base.rule.Declaration; import org.drools.base.rule.accessor.PatternExtractor; import org.drools.util.StringUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.compiler.Person; import org.drools.mvel.java.JavaRuleBuilderHelper; -import org.junit.Before; -import org.junit.Test; import org.mvel2.integration.impl.MapVariableResolverFactory; import org.mvel2.templates.CompiledTemplate; import org.mvel2.templates.SimpleTemplateRegistry; @@ -46,7 +46,7 @@ public class AccumulateTemplateTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AsmGeneratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AsmGeneratorTest.java index 650998e295f..8a5ab000396 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AsmGeneratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/AsmGeneratorTest.java @@ -19,38 +19,30 @@ package org.drools.mvel.compiler.rule.builder.dialect.java; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; 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 static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AsmGeneratorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AsmGeneratorTest(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 testPatterDeclarations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatterDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.kie.test\n" + "global java.util.List list\n" + @@ -82,8 +74,9 @@ public void testPatterDeclarations() { assertThat(list.get(0)).isEqualTo("s1s2s3s5"); } - @Test - public void testAllGeneratedConstructs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllGeneratedConstructs(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.kie.test\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -122,8 +115,9 @@ public void testAllGeneratedConstructs() { assertThat(list.get(0)).isEqualTo("s1[Person name='s1 age='0' likes='']s1s3[Person name='s3 age='0' likes='']s3"); } - @Test - public void testOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOr(KieBaseTestConfiguration kieBaseTestConfiguration) { String s = "package org.kie.test\n" + "import " + Person.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java index 4e2fc39a81c..9c6b77c8320 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/rule/builder/dialect/java/RuleBuilderTest.java @@ -43,8 +43,8 @@ import org.drools.core.time.impl.IntervalTimer; import org.drools.drl.parser.DroolsParserException; import org.drools.util.DateUtils; +import org.junit.jupiter.api.Test; import org.drools.mvel.MVELConstraint; -import org.junit.Test; import org.kie.internal.builder.conf.LanguageLevelOption; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/simulation/BatchRunFluentTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/simulation/BatchRunFluentTest.java index 831c8dda03a..555b9c79b6d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/simulation/BatchRunFluentTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/simulation/BatchRunFluentTest.java @@ -18,20 +18,18 @@ */ package org.drools.mvel.compiler.simulation; -import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.stream.Stream; import org.drools.commands.fluent.ExecutableBuilderImpl; import org.drools.mvel.compiler.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.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.KieServices; import org.kie.api.builder.ReleaseId; import org.kie.api.io.Resource; @@ -45,11 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class BatchRunFluentTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - String header = "package org.drools.mvel.compiler\n" + "import " + Message.class.getCanonicalName() + "\n"; @@ -74,24 +69,20 @@ public class BatchRunFluentTest { String id = "org.kie"; ReleaseId releaseId; - public BatchRunFluentTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true, true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true, true).stream(); } - @Before - public void setUp() { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { releaseId = KieUtil.generateReleaseId(id); final List resources = KieUtil.getResourcesFromDrls(header + drl1); KieUtil.getKieModuleFromResources(releaseId, kieBaseTestConfiguration, KieSessionTestConfiguration.STATEFUL_PSEUDO, new HashMap<>(), resources.toArray(new Resource[]{})); } - @Test - public void testOutName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutName(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -106,8 +97,10 @@ public void testOutName() { assertThat(requestContext.getOutputs().get("outS")).isEqualTo("h1"); } - @Test - public void testOutWithPriorSetAndNoName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutWithPriorSetAndNoName(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -123,8 +116,10 @@ public void testOutWithPriorSetAndNoName() { assertThat(requestContext.get("outS")).isEqualTo("h1"); } - @Test - public void testSetAndOutBehaviour() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetAndOutBehaviour(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -145,9 +140,11 @@ public void testSetAndOutBehaviour() { assertThat(requestContext.get("outS1")).isEqualTo(requestContext.get("outS")); } - @Test - public void testOutWithoutPriorSetAndNoName() { - ExecutableBuilder f = ExecutableBuilder.create(); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutWithoutPriorSetAndNoName(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); + ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") .getKieContainer(releaseId).newSession() @@ -166,8 +163,10 @@ public void testOutWithoutPriorSetAndNoName() { } } - @Test - public void testSetAndGetWithCommandRegisterWithEnds() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetAndGetWithCommandRegisterWithEnds(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -196,8 +195,10 @@ public void testSetAndGetWithCommandRegisterWithEnds() { assertThat(requestContext.getOutputs().get("outS2")).isEqualTo("h2"); } - @Test - public void testSetAndGetWithCommandRegisterWithoutEnds() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetAndGetWithCommandRegisterWithoutEnds(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -226,8 +227,10 @@ public void testSetAndGetWithCommandRegisterWithoutEnds() { assertThat(requestContext.getOutputs().get("outS2")).isEqualTo("h2"); } - @Test - public void testDifferentConversationIds() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentConversationIds(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(); RequestContext requestContext = runner.createContext(); @@ -248,8 +251,10 @@ public void testDifferentConversationIds() { assertThat(requestContext.getConversationContext().getName()).isNotEqualTo(conversationId); } - @Test - public void testRequestScope() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRequestScope(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") @@ -269,8 +274,10 @@ public void testRequestScope() { assertThat(requestContext.get("outS1")).isEqualTo("h1"); } - @Test - public void testApplicationScope() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testApplicationScope(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(); ExecutableBuilder f = ExecutableBuilder.create(); @@ -303,8 +310,10 @@ public void testApplicationScope() { assertThat(requestContext.getApplicationContext().get("outS2")).isEqualTo("h2"); } - @Test - public void testConversationScope() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConversationScope(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(); ExecutableBuilder f = ExecutableBuilder.create(); @@ -348,8 +357,10 @@ public void testConversationScope() { assertThat(requestContext.getConversationContext()).isNull(); } - @Test - public void testContextScopeSearching() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testContextScopeSearching(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(); ExecutableBuilder f = ExecutableBuilder.create(); @@ -403,8 +414,10 @@ public void testContextScopeSearching() { assertThat(requestContext.get("outS1")).isEqualTo("h3"); } - @Test - public void testAfter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfter(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(0L); ExecutableBuilder f = ExecutableBuilder.create(); @@ -431,8 +444,10 @@ public void testAfter() { assertThat(requestContext.getOutputs().get("timeNow2")).isEqualTo(2000l); } - @Test - public void testSetKieContainerTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetKieContainerTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); KieServices kieServices = KieServices.Factory.get(); KieContainer kieContainer = kieServices.newKieContainer(releaseId); @@ -453,8 +468,10 @@ public void testSetKieContainerTest() { assertThat(requestContext.getOutputs().get("outS1")).isEqualTo("h1"); } - @Test - public void testKieSessionCustomizationTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieSessionCustomizationTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(0L); ExecutableBuilder f = ExecutableBuilder.create(); @@ -472,8 +489,10 @@ public void testKieSessionCustomizationTest() { assertThat(requestContext.getOutputs().get("outS1")).isEqualTo("h1"); } - @Test - public void testKieSessionByName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieSessionByName(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(0L); ExecutableBuilder f = ExecutableBuilder.create(); @@ -491,8 +510,10 @@ public void testKieSessionByName() { assertThat(requestContext.getOutputs().get("outS1")).isEqualTo("h1"); } - @Test - public void testAgendaGroup() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ExecutableRunner runner = ExecutableRunner.create(0L); ExecutableBuilder f = ExecutableBuilder.create(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/test/PositionalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/test/PositionalTest.java index 3770a5dfec9..40fb29023f9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/test/PositionalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/test/PositionalTest.java @@ -19,36 +19,29 @@ package org.drools.mvel.compiler.test; import java.util.ArrayList; -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.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.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PositionalTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PositionalTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // TODO: EM failed with ttestPositional. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(true); + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testPositional() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPositional(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + Man.class.getCanonicalName() + ";\n" + @@ -78,8 +71,10 @@ public void testPositional() { } - @Test(timeout = 5000) - public void testPositionalWithNull() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testPositionalWithNull(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-51 String str = "declare Bean\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/FactPopulatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/FactPopulatorTest.java index 63995a59af1..dcd0d0c4716 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/FactPopulatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/FactPopulatorTest.java @@ -21,9 +21,9 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Test; - import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; import org.mvel2.MVEL; public class FactPopulatorTest { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/RuleCoverageListenerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/RuleCoverageListenerTest.java index 0412a514e92..0449e4c2af8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/RuleCoverageListenerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/testframework/RuleCoverageListenerTest.java @@ -31,12 +31,11 @@ import org.drools.core.event.rule.impl.AfterActivationFiredEventImpl; import org.drools.core.phreak.RuleAgendaItem; import org.drools.core.reteoo.TerminalNode; -import org.drools.core.reteoo.Tuple; import org.drools.core.reteoo.TupleImpl; import org.drools.core.rule.consequence.InternalMatch; +import org.junit.jupiter.api.Test; import org.drools.base.rule.consequence.Consequence; import org.drools.core.common.PropagationContext; -import org.junit.Test; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/util/debug/SessionInspectorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/util/debug/SessionInspectorTest.java index c76b87225f9..23ec955b413 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/util/debug/SessionInspectorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/util/debug/SessionInspectorTest.java @@ -20,7 +20,7 @@ import java.awt.Dimension; import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.kiesession.debug.SessionInspector; import org.drools.kiesession.debug.StatefulKnowledgeSessionInfo; @@ -31,32 +31,24 @@ import org.drools.mvel.compiler.Worker; 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; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SessionInspectorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SessionInspectorTest(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 testGetSessionInfo() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetSessionInfo(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "org/drools/mvel/integrationtests/test_SubNetworks.drl", "org/drools/mvel/integrationtests/test_AccumulateWithFromChaining.drl", @@ -125,8 +117,9 @@ public void testGetSessionInfo() { assertThat(report).isNotNull(); } - @Test - public void testGetSessionInfoWithCustomTemplate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetSessionInfoWithCustomTemplate(KieBaseTestConfiguration kieBaseTestConfiguration) { if ( System.getProperty("java.vendor").toUpperCase().contains("IBM") ) { return; //Does not work in the IBM JDK due to a bug in MVEL } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/BooleanClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/BooleanClassFieldExtractorTest.java index 7a050f26e6c..f1fd8227155 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/BooleanClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/BooleanClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -32,7 +32,7 @@ public class BooleanClassFieldExtractorTest extends BaseClassFieldExtractorsTest ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ByteClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ByteClassFieldExtractorTest.java index b8df855d4a3..fd64b43fb3c 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ByteClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ByteClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -33,7 +33,7 @@ public class ByteClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/CharClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/CharClassFieldExtractorTest.java index 18b7702d638..21521df31de 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/CharClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/CharClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -32,7 +32,7 @@ public class CharClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ClassFieldAccessorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ClassFieldAccessorTest.java index 5bc96bb4763..c7ca2e33a53 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ClassFieldAccessorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ClassFieldAccessorTest.java @@ -22,6 +22,8 @@ import org.drools.core.base.ClassFieldAccessorCache; import org.drools.mvel.accessors.ClassFieldAccessorStore; import org.drools.mvel.accessors.ClassFieldReader; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.drools.core.base.ConcreteChild; import org.drools.core.util.asm.BeanInherit; import org.drools.core.util.asm.InterfaceChild; @@ -30,8 +32,6 @@ import org.drools.core.util.asm.TestBean; import org.drools.core.util.asm.TestInterface; import org.drools.core.util.asm.TestInterfaceImpl; -import org.junit.Before; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -41,7 +41,7 @@ public class ClassFieldAccessorTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/DoubleClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/DoubleClassFieldExtractorTest.java index 1a39f866234..9c9b4f80728 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/DoubleClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/DoubleClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +35,7 @@ public class DoubleClassFieldExtractorTest extends BaseClassFieldExtractorsTest ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FieldIndexEntryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FieldIndexEntryTest.java index 516387c41c1..fc86bab82b1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FieldIndexEntryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FieldIndexEntryTest.java @@ -22,6 +22,8 @@ import org.drools.core.base.ClassFieldAccessorCache; import org.drools.mvel.accessors.ClassFieldAccessorStore; import org.drools.mvel.accessors.ClassFieldReader; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.reteoo.TupleImpl ; @@ -33,8 +35,6 @@ import org.drools.base.util.IndexedValueReader; import org.drools.core.util.AbstractHashTable.SingleIndex; import org.drools.core.util.index.TupleList; -import org.junit.Before; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +42,7 @@ public class FieldIndexEntryTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FloatClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FloatClassFieldExtractorTest.java index 0e4a21dccc0..8d2fdf00405 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FloatClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/FloatClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +35,7 @@ public class FloatClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor reader;; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/IntClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/IntClassFieldExtractorTest.java index b759031451e..e2d16ededfd 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/IntClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/IntClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +35,7 @@ public class IntClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/LongClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/LongClassFieldExtractorTest.java index abbc20b3bfd..5f0f8e6871a 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/LongClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/LongClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +35,7 @@ public class LongClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor extractor; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/MVELClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/MVELClassFieldExtractorTest.java index 7e8641b446e..7a16fe0392a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/MVELClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/MVELClassFieldExtractorTest.java @@ -26,8 +26,8 @@ import org.drools.core.test.model.Person; import org.drools.mvel.MVELDialectRuntimeData; import org.drools.wiring.api.classloader.ProjectClassLoader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -40,7 +40,7 @@ public class MVELClassFieldExtractorTest { private final Address[] business = new Address[2]; private final Address[] home = new Address[2]; - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ObjectClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ObjectClassFieldExtractorTest.java index 36a2f6f9305..903675de15b 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ObjectClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ObjectClassFieldExtractorTest.java @@ -25,8 +25,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -36,7 +36,7 @@ public class ObjectClassFieldExtractorTest extends BaseClassFieldExtractorsTest ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ShortClassFieldExtractorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ShortClassFieldExtractorTest.java index 6f9a983606d..51a235c5d39 100755 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ShortClassFieldExtractorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/extractors/ShortClassFieldExtractorTest.java @@ -22,8 +22,8 @@ import org.drools.core.base.TestBean; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +35,7 @@ public class ShortClassFieldExtractorTest extends BaseClassFieldExtractorsTest { ReadAccessor reader; TestBean bean = new TestBean(); - @Before + @BeforeEach public void setUp() throws Exception { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicEvalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicEvalTest.java index 819ef874f53..7d68dc8cc6d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicEvalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicEvalTest.java @@ -23,9 +23,9 @@ import org.drools.core.impl.InternalRuleBase; import org.drools.core.impl.RuleBaseFactory; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -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.KieBaseConfiguration; import org.kie.api.conf.EventProcessingOption; @@ -57,7 +57,7 @@ public class DynamicEvalTest { KieBaseConfiguration baseConfig; KieSessionConfiguration sessionConfig; - @Before + @BeforeEach public void setUp() throws Exception { baseConfig = RuleBaseFactory.newKnowledgeBaseConfiguration(); @@ -91,7 +91,7 @@ public void loadPackages( Resource res, ResourceType type ) { } - @After + @AfterEach public void tearDown() { if (session != null) { session.dispose(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/AgendaFilterTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/AgendaFilterTest.java index 1fc176224d6..5f671386872 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/AgendaFilterTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/AgendaFilterTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.integrationtests.session; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.core.base.RuleNameEndsWithAgendaFilter; import org.drools.core.base.RuleNameEqualsAgendaFilter; @@ -26,10 +26,9 @@ import org.drools.core.base.RuleNameStartsWithAgendaFilter; 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.KieServices; import org.kie.api.runtime.Environment; @@ -44,41 +43,37 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class AgendaFilterTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AgendaFilterTest(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 testAgendaFilterRuleNameStartsWith() { - testAgendaFilter(new RuleNameStartsWithAgendaFilter("B"), "Bbb"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaFilterRuleNameStartsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAgendaFilter(kieBaseTestConfiguration, new RuleNameStartsWithAgendaFilter("B"), "Bbb"); } - @Test - public void testAgendaFilterRuleNameEndsWith() { - testAgendaFilter(new RuleNameEndsWithAgendaFilter("a"), "Aaa"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaFilterRuleNameEndsWith(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAgendaFilter(kieBaseTestConfiguration, new RuleNameEndsWithAgendaFilter("a"), "Aaa"); } - @Test - public void testAgendaFilterRuleNameMatches() { - testAgendaFilter(new RuleNameMatchesAgendaFilter(".*b."), "Bbb"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaFilterRuleNameMatches(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAgendaFilter(kieBaseTestConfiguration, new RuleNameMatchesAgendaFilter(".*b."), "Bbb"); } - @Test - public void testAgendaFilterRuleNameEquals() { - testAgendaFilter(new RuleNameEqualsAgendaFilter("Aaa"), "Aaa"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaFilterRuleNameEquals(KieBaseTestConfiguration kieBaseTestConfiguration) { + testAgendaFilter(kieBaseTestConfiguration, new RuleNameEqualsAgendaFilter("Aaa"), "Aaa"); } - private void testAgendaFilter(final AgendaFilter agendaFilter, final String expectedMatchingRuleName) { + private void testAgendaFilter(KieBaseTestConfiguration kieBaseTestConfiguration, final AgendaFilter agendaFilter, final String expectedMatchingRuleName) { final String str = "package org.drools.compiler\n" + "rule Aaa when then end\n" + "rule Bbb when then end\n"; @@ -97,8 +92,9 @@ private void testAgendaFilter(final AgendaFilter agendaFilter, final String expe assertThat(arg.getValue().getMatch().getRule().getName()).isEqualTo(expectedMatchingRuleName); } - @Test - public void testDirectFiringIgnoresAgendaFilter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDirectFiringIgnoresAgendaFilter(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6510 String str = "rule R when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/BasicUpdateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/BasicUpdateTest.java index 91cdaf5a054..669ef4c0ede 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/BasicUpdateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/BasicUpdateTest.java @@ -20,19 +20,17 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.test.model.Cheese; import org.drools.core.test.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.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -40,39 +38,32 @@ import org.kie.api.runtime.rule.QueryResultsRow; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -@RunWith(Parameterized.class) public class BasicUpdateTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public BasicUpdateTest(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 UPDATE_TEST_DRL = "org/drools/mvel/integrationtests/session/update_test.drl"; private KieSession ksession; - @Before - public void setUp() { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, UPDATE_TEST_DRL); ksession = kbase.newKieSession(); } - @After + @AfterEach public void tearDown() { ksession.dispose(); } - @Test - public void updateTheOnlyFactTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateTheOnlyFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Person person = new Person("George", 18); final FactHandle factPerson = ksession.insert(person); assertThat(ksession.getObjects()).hasSize(1); @@ -88,17 +79,21 @@ public void updateTheOnlyFactTest() { verifyPerson(person, personToBeVerified, 21, "Henry", false); } - @Test(expected = NullPointerException.class) - public void updateWithNullTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateWithNullTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Person person = new Person("George", 18); final FactHandle factPerson = ksession.insert(person); verifyFactsPresentInSession(1, Person.class); - ksession.update(factPerson, null); + assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> ksession.update(factPerson, null)); } - @Test - public void updateWithDifferentClassGetQueryResultsTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateWithDifferentClassGetQueryResultsTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Person person = new Person("George", 18); final FactHandle fact = ksession.insert(person); @@ -118,8 +113,10 @@ public void updateWithDifferentClassGetQueryResultsTest() { } - @Test - public void updateWithDifferentClassGetObjectsTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateWithDifferentClassGetObjectsTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Person person = new Person("George", 18); final FactHandle factPerson = ksession.insert(person); final Person personToBeVerified = verifyFactsPresentInSession(1, Person.class).get(0); @@ -133,8 +130,10 @@ public void updateWithDifferentClassGetObjectsTest() { verifyCheese(cheeseToBeVerified, 50, "Camembert"); } - @Test - public void updateFireRulesTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateFireRulesTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Person george = new Person("George", 17); final Person henry = new Person("Henry", 25); final FactHandle georgeFact = ksession.insert(george); @@ -158,8 +157,10 @@ public void updateFireRulesTest() { verifyList(drivers, null, george, henry); } - @Test - public void updateFactOnRuleFireTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void updateFactOnRuleFireTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); final Cheese camembert = new Cheese("Camembert", 19); final Cheese cheddar = new Cheese("Cheddar", 45); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/CrossProductTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/CrossProductTest.java index 15e88abe037..36c07a1e8a7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/CrossProductTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/CrossProductTest.java @@ -20,38 +20,30 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.SpecialString; 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 CrossProductTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public CrossProductTest(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 testCrossProductRemovingIdentityEquals() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCrossProductRemovingIdentityEquals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CrossProductRemovingIdentityEquals.drl"); KieSession session = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java index 234bdce1109..999661fbd9e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.test.model.Cheese; import org.drools.core.test.model.Person; @@ -31,10 +32,10 @@ import org.drools.mvel.integrationtests.facts.InterfaceB; 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.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.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.kie.api.KieBase; @@ -45,20 +46,13 @@ import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -@RunWith(Parameterized.class) public class DeleteTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DeleteTest(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 Logger logger = LoggerFactory.getLogger(DeleteTest.class); @@ -67,19 +61,22 @@ public static Collection getParameters() { private KieSession ksession; - @Before - public void setUp() { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, DELETE_TEST_DRL); ksession = kbase.newKieSession(); } - @After + @AfterEach public void tearDown() { - ksession.dispose(); + if (ksession != null) { + ksession.dispose(); + } } - @Test - public void deleteFactTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void deleteFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); ksession.insert(new Person("Petr", 25)); FactHandle george = ksession.insert(new Person("George", 19)); @@ -93,8 +90,10 @@ public void deleteFactTest() { assertThat(results.iterator().next().get("$countOfPerson")).isEqualTo(1L); } - @Test - public void deleteFactTwiceTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void deleteFactTwiceTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); FactHandle george = ksession.insert(new Person("George", 19)); QueryResults results = ksession.getQueryResults("countPerson"); assertThat(results).isNotEmpty(); @@ -110,13 +109,17 @@ public void deleteFactTwiceTest() { assertThat(results.iterator().next().get("$personCount")).isEqualTo(0L); } - @Test(expected = IllegalArgumentException.class) - public void deleteNullFactTest() { - ksession.delete(null); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void deleteNullFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() ->ksession.delete(null)); } - @Test - public void deleteUpdatedFactTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void deleteUpdatedFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); FactHandle person = ksession.insert(new Person("George", 18)); ksession.update(person, new Person("John", 21)); @@ -131,8 +134,10 @@ public void deleteUpdatedFactTest() { assertThat(results.iterator().next().get("$personCount")).isEqualTo(0L); } - @Test - public void deleteUpdatedFactDifferentClassTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void deleteUpdatedFactDifferentClassTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); FactHandle fact = ksession.insert(new Person("George", 18)); assertThat(ksession.getObjects()).hasSize(1); @@ -148,8 +153,9 @@ public void deleteUpdatedFactDifferentClassTest() { assertThat(ksession.getObjects()).isEmpty(); } - @Test - public void testRetractLeftTuple() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRetractLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3420 final String str = "import " + ClassA.class.getCanonicalName() + ";\n" + @@ -187,8 +193,9 @@ public void testRetractLeftTuple() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(3); } - @Test - public void testAssertRetract() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAssertRetract(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // postponed while I sort out KnowledgeHelperFixer KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "assert_retract.drl"); final KieSession ksession = kbase.newKieSession(); @@ -214,8 +221,9 @@ public void testAssertRetract() throws Exception { assertThat(results.contains("fifth")).isTrue(); } - @Test - public void testEmptyAfterRetractInIndexedMemory() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyAfterRetractInIndexedMemory(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.simple \n"; str += "import org.drools.mvel.compiler.Person\n"; @@ -243,8 +251,9 @@ public void testEmptyAfterRetractInIndexedMemory() { assertThat(list.get(0)).isEqualTo("ackbar"); } - @Test - public void testModifyRetractAndModifyInsert() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyRetractAndModifyInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ModifyRetractInsert.drl"); KieSession ksession = kbase.newKieSession(); @@ -262,8 +271,9 @@ public void testModifyRetractAndModifyInsert() throws Exception { assertThat(list.size()).as("should have fired only once").isEqualTo(1); } - @Test - public void testModifyRetractWithFunction() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyRetractWithFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_RetractModifyWithFunction.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/EntryPointTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/EntryPointTest.java index af86ab9b30b..2a41298bc30 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/EntryPointTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/EntryPointTest.java @@ -19,36 +19,28 @@ package org.drools.mvel.integrationtests.session; 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.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 EntryPointTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EntryPointTest(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 testEntryPointWithVarIN() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEntryPointWithVarIN(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler.test;\n" + "\n" + "global java.util.List list;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/FieldAccessTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/FieldAccessTest.java index 94c80c51fbf..695172f6e59 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/FieldAccessTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/FieldAccessTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.integrationtests.session; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.Address; import org.drools.mvel.compiler.Cat; @@ -27,34 +27,26 @@ import org.drools.mvel.compiler.Primitives; 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 FieldAccessTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FieldAccessTest(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 + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") // this isn't possible, we can only narrow with type safety, not widen. // unless typesafe=false is used - public void testAccessFieldsFromSubClass() throws Exception { + public void testAccessFieldsFromSubClass(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = ""; rule += "package org.drools.compiler;\n"; rule += "import org.drools.mvel.compiler.Person;\n"; @@ -79,8 +71,9 @@ public void testAccessFieldsFromSubClass() throws Exception { session.fireAllRules(); } - @Test - public void testAccessClassTypeField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccessClassTypeField(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler\n" + "rule r1\n" + "when\n" + @@ -96,8 +89,9 @@ public void testAccessClassTypeField() { assertThat(rules).isEqualTo(1); } - @Test - public void testGenericsOption() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGenericsOption(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3579 final String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/InsertTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/InsertTest.java index e0a1c28829f..9da82df6512 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/InsertTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/InsertTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests.session; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Move; import org.drools.mvel.compiler.Person; @@ -29,31 +29,23 @@ import org.drools.mvel.compiler.Win; 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 InsertTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public InsertTest(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 testInsert() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = ""; drl += "package test\n"; drl += "import org.drools.mvel.compiler.Person\n"; @@ -88,8 +80,9 @@ public void testInsert() throws Exception { assertThat(list.get(0)).isSameAs(p); } - @Test - public void testInsertionOrder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertionOrder(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_InsertionOrder.drl"); KieSession ksession = kbase.newKieSession(); List results = new ArrayList<>(); @@ -119,8 +112,9 @@ public void testInsertionOrder() { assertThat(results.contains(win3)).isTrue(); } - @Test - public void testInsertFinalClassInstance() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertFinalClassInstance(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_FinalClass.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/LocaleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/LocaleTest.java index f61405c2ccd..4a23b3bae5e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/LocaleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/LocaleTest.java @@ -19,39 +19,31 @@ package org.drools.mvel.integrationtests.session; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.stream.Stream; import org.drools.mvel.compiler.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.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class LocaleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LocaleTest(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 testLatinLocale() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLatinLocale(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Locale defaultLoc = Locale.getDefault(); try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/RuleRuntimeEventTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/RuleRuntimeEventTest.java index d5afec8fdc4..2d573a3528d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/RuleRuntimeEventTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/RuleRuntimeEventTest.java @@ -18,15 +18,14 @@ */ package org.drools.mvel.integrationtests.session; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.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.ObjectDeletedEvent; import org.kie.api.event.rule.ObjectInsertedEvent; @@ -39,22 +38,15 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class RuleRuntimeEventTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public RuleRuntimeEventTest(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 testEventModel() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventModel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_EventModel.drl"); KieSession wm = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/SessionsPoolTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/SessionsPoolTest.java index 737492325ba..f47c181832f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/SessionsPoolTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/SessionsPoolTest.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests.session; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; @@ -27,6 +26,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.core.common.EventSupport; import org.drools.core.event.DefaultAgendaEventListener; @@ -37,10 +37,9 @@ 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.KieBaseConfiguration; import org.kie.api.KieServices; @@ -60,23 +59,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class SessionsPoolTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SessionsPoolTest(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 testKieSessionsPool() { - KieContainerSessionsPool pool = getKieContainer().newKieSessionsPool( 1 ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieSessionsPool(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieContainerSessionsPool pool = getKieContainer(kieBaseTestConfiguration).newKieSessionsPool( 1 ); KieSession ksession = pool.newKieSession(); try { @@ -110,11 +102,12 @@ public void testKieSessionsPool() { } catch (IllegalStateException e) { } } - @Test - public void testPooledKieBase() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPooledKieBase(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBaseConfiguration kbConf = KieServices.get().newKieBaseConfiguration(); kbConf.setOption(SessionsPoolOption.get(1)); - KieBase kBase = getKieContainer().newKieBase(kbConf); + KieBase kBase = getKieContainer(kieBaseTestConfiguration).newKieBase(kbConf); KieSession ksession = kBase.newKieSession(); try { @@ -136,9 +129,10 @@ public void testPooledKieBase() { checkKieSession( ksession2 ); } - @Test - public void testKieSessionsPoolInMultithreadEnv() throws InterruptedException, ExecutionException { - KieContainerSessionsPool pool = getKieContainer().newKieSessionsPool( 4 ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieSessionsPoolInMultithreadEnv(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException { + KieContainerSessionsPool pool = getKieContainer(kieBaseTestConfiguration).newKieSessionsPool( 4 ); final int THREAD_NR = 10; ExecutorService executor = Executors.newFixedThreadPool(THREAD_NR, r -> { @@ -180,9 +174,10 @@ public void testKieSessionsPoolInMultithreadEnv() throws InterruptedException, E } catch (IllegalStateException e) { } } - @Test - public void testStatelessKieSessionsPool() { - KieContainerSessionsPool pool = getKieContainer().newKieSessionsPool( 1 ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStatelessKieSessionsPool(KieBaseTestConfiguration kieBaseTestConfiguration) { + KieContainerSessionsPool pool = getKieContainer(kieBaseTestConfiguration).newKieSessionsPool( 1 ); StatelessKieSession session = pool.newStatelessKieSession(); List list = new ArrayList<>(); @@ -195,11 +190,12 @@ public void testStatelessKieSessionsPool() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testStatelessKieSessionsPoolWithConf() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStatelessKieSessionsPoolWithConf(KieBaseTestConfiguration kieBaseTestConfiguration) { KieServices kieServices = KieServices.get(); - KieSessionsPool pool = getKieContainer().getKieBase().newKieSessionsPool( 1 ); + KieSessionsPool pool = getKieContainer(kieBaseTestConfiguration).getKieBase().newKieSessionsPool( 1 ); StatelessKieSession session = pool.newStatelessKieSession(kieServices.newKieSessionConfiguration()); List list = new ArrayList<>(); @@ -212,7 +208,7 @@ public void testStatelessKieSessionsPoolWithConf() { assertThat(list.size()).isEqualTo(1); } - private KieContainer getKieContainer() { + private KieContainer getKieContainer(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List list\n" + "rule R1 when\n" + @@ -232,8 +228,9 @@ private void checkKieSession( KieSession ksession ) { assertThat(list.size()).isEqualTo(1); } - @Test - public void testSegmentMemoriesReset() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMemoriesReset(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3228 String drl = "import " + AtomicInteger.class.getCanonicalName() + ";\n" + @@ -291,8 +288,9 @@ public void testSegmentMemoriesReset() { pool.shutdown(); } - @Test - public void testSegmentMemoriesResetWithNotNodeInTheMiddle() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMemoriesResetWithNotNodeInTheMiddle(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + FactA.class.getCanonicalName() + ";\n" + "import " + FactB.class.getCanonicalName() + ";\n" + @@ -343,8 +341,9 @@ public void testSegmentMemoriesResetWithNotNodeInTheMiddle() { pool.shutdown(); } - @Test - public void testSegmentMemoriesResetWithNotNodeInTheMiddle2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMemoriesResetWithNotNodeInTheMiddle2(KieBaseTestConfiguration kieBaseTestConfiguration) { // FactB constrains in R1 and R2 are different from testSegmentMemoriesResetWithNotNodeInTheMiddle() String drl = "import " + FactA.class.getCanonicalName() + ";\n" + @@ -411,8 +410,9 @@ private void createFactAndInsert(KieSession ksession) { ksession.insert(factC); } - @Test - public void testStatelessSequential() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStatelessSequential(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3228 String drl = "import " + AtomicInteger.class.getCanonicalName() + ";\n" + @@ -450,9 +450,10 @@ public void testStatelessSequential() { pool.shutdown(); } - @Test - public void testListenersReset() { - final KieContainerSessionsPool pool = getKieContainer().newKieSessionsPool( 1 ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testListenersReset(KieBaseTestConfiguration kieBaseTestConfiguration) { + final KieContainerSessionsPool pool = getKieContainer(kieBaseTestConfiguration).newKieSessionsPool( 1 ); KieSession ksession = pool.newKieSession(); try { ksession.addEventListener(new DefaultAgendaEventListener()); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatefulSessionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatefulSessionTest.java index 5c5afd96934..f2cd0fff560 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatefulSessionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatefulSessionTest.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.stream.Stream; import org.kie.api.runtime.ClassObjectFilter; import org.drools.core.common.DefaultFactHandle; @@ -32,9 +33,9 @@ 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; @@ -42,22 +43,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class StatefulSessionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public StatefulSessionTest(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 testDispose() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final StringBuilder rule = new StringBuilder(); rule.append("package org.drools.mvel.compiler\n"); rule.append("rule X\n"); @@ -86,8 +80,9 @@ public void testDispose() throws Exception { } } - @Test - public void testGetStatefulKnowledgeSessions() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetStatefulKnowledgeSessions(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "../empty.drl"); KieSession ksession_1 = kbase.newKieSession(); @@ -115,8 +110,9 @@ public void testGetStatefulKnowledgeSessions() throws Exception { assertThat(coll_3.size() == 0).isTrue(); } - @Test - public void testGetFactHandle() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactHandle(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "../empty.drl"); KieSession ksession = kbase.newKieSession(); @@ -130,8 +126,9 @@ public void testGetFactHandle() throws Exception { ksession.dispose(); } - @Test - public void testGetFactHandleEqualityBehavior() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactHandleEqualityBehavior(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig); KieSession ksession = kbase.newKieSession(); @@ -142,8 +139,9 @@ public void testGetFactHandleEqualityBehavior() throws Exception { assertThat(fh).isNotNull(); } - @Test - public void testGetFactHandleIdentityBehavior() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetFactHandleIdentityBehavior(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBaseTestConfiguration identityConfig = TestParametersUtil.getIdentityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", identityConfig); KieSession ksession = kbase.newKieSession(); @@ -156,8 +154,9 @@ public void testGetFactHandleIdentityBehavior() throws Exception { assertThat(fh2).isNotNull(); } - @Test - public void testDisconnectedFactHandle() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDisconnectedFactHandle(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration); KieSession ksession = kbase.newKieSession(); final DefaultFactHandle helloHandle = (DefaultFactHandle) ksession.insert( "hello" ); @@ -170,8 +169,9 @@ public void testDisconnectedFactHandle() { assertThat(ksession.getObject(key)).isEqualTo("goodbye"); } - @Test - public void testIterateObjects() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIterateObjects(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_IterateObjects.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatelessSessionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatelessSessionTest.java index c8c942fd178..99f068e2da1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatelessSessionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/StatelessSessionTest.java @@ -20,10 +20,10 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import org.drools.commands.runtime.BatchExecutionCommandImpl; import org.drools.mvel.compiler.Cheese; @@ -31,10 +31,9 @@ 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.KieModule; import org.kie.api.command.Command; @@ -50,25 +49,19 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class StatelessSessionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public StatelessSessionTest(final 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); - } final List list = new ArrayList(); final Cheesery cheesery = new Cheesery(); - @Test - public void testSingleObjectAssert() throws Exception { - final StatelessKieSession session = getSession2( "statelessSessionTest.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSingleObjectAssert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + final StatelessKieSession session = getSession2(kieBaseTestConfiguration, "statelessSessionTest.drl" ); final Cheese stilton = new Cheese( "stilton", 5 ); @@ -78,9 +71,10 @@ public void testSingleObjectAssert() throws Exception { assertThat(list.get(0)).isEqualTo("stilton"); } - @Test - public void testArrayObjectAssert() throws Exception { - final StatelessKieSession session = getSession2( "statelessSessionTest.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArrayObjectAssert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + final StatelessKieSession session = getSession2(kieBaseTestConfiguration, "statelessSessionTest.drl" ); final Cheese stilton = new Cheese( "stilton", 5 ); @@ -90,9 +84,10 @@ public void testArrayObjectAssert() throws Exception { assertThat(list.get(0)).isEqualTo("stilton"); } - @Test - public void testCollectionObjectAssert() throws Exception { - final StatelessKieSession session = getSession2( "statelessSessionTest.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectionObjectAssert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + final StatelessKieSession session = getSession2(kieBaseTestConfiguration, "statelessSessionTest.drl" ); final Cheese stilton = new Cheese( "stilton", 5 ); @@ -104,8 +99,9 @@ public void testCollectionObjectAssert() throws Exception { assertThat(list.get(0)).isEqualTo("stilton"); } - @Test - public void testInsertObject() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertObject(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -119,7 +115,7 @@ public void testInsertObject() throws Exception { Cheese stilton = new Cheese( "stilton", 5 ); - final StatelessKieSession ksession = getSession2( ResourceFactory.newByteArrayResource( str.getBytes() ) ); + final StatelessKieSession ksession = getSession2( kieBaseTestConfiguration, ResourceFactory.newByteArrayResource( str.getBytes() ) ); final ExecutableCommand cmd = (ExecutableCommand) CommandFactory.newInsert( stilton, "outStilton" ); final BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl( Arrays.asList(cmd) ); @@ -128,8 +124,9 @@ public void testInsertObject() throws Exception { assertThat(stilton.getPrice()).isEqualTo(30); } - @Test - public void testSetGlobal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -152,7 +149,7 @@ public void testSetGlobal() throws Exception { List list2 = new ArrayList(); List list3 = new ArrayList(); - final StatelessKieSession ksession = getSession2( ResourceFactory.newByteArrayResource( str.getBytes() ) ); + final StatelessKieSession ksession = getSession2(kieBaseTestConfiguration, ResourceFactory.newByteArrayResource( str.getBytes() ) ); final Command setGlobal1 = CommandFactory.newSetGlobal( "list1", list1 ); final Command setGlobal2 = CommandFactory.newSetGlobal( "list2", list2, true ); final Command setGlobal3 = CommandFactory.newSetGlobal( "list3", list3, "outList3" ); @@ -181,8 +178,9 @@ public void testSetGlobal() throws Exception { assertThat(list3.get(0)).isSameAs(stilton); } - @Test - public void testQuery() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQuery(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie.test \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -242,8 +240,9 @@ public void testQuery() throws Exception { assertThat(newSet).isEqualTo(set); } - @Test - public void testNotInStatelessSession() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotInStatelessSession(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieModule kieModule = KieUtil.getKieModuleFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "test_NotInStatelessSession.drl"); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, SequentialOption.YES); final StatelessKieSession session = kbase.newStatelessKieSession(); @@ -254,8 +253,9 @@ public void testNotInStatelessSession() throws Exception { assertThat(list.get(0)).isEqualTo("not integer"); } - @Test - public void testChannels() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChannels(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -270,7 +270,7 @@ public void testChannels() throws Exception { final Cheese stilton = new Cheese("stilton", 5); final Channel channel = Mockito.mock(Channel.class); - final StatelessKieSession ksession = getSession2(ResourceFactory.newByteArrayResource(str.getBytes())); + final StatelessKieSession ksession = getSession2(kieBaseTestConfiguration, ResourceFactory.newByteArrayResource(str.getBytes())); ksession.registerChannel("x", channel); assertThat(ksession.getChannels().size()).isEqualTo(1); @@ -286,11 +286,11 @@ public void testChannels() throws Exception { assertThat(ksession.getChannels().get("x")).isNull(); } - private StatelessKieSession getSession2(final String fileName) throws Exception { - return getSession2( ResourceFactory.newClassPathResource( fileName, getClass() ) ); + private StatelessKieSession getSession2(KieBaseTestConfiguration kieBaseTestConfiguration, final String fileName) throws Exception { + return getSession2(kieBaseTestConfiguration, ResourceFactory.newClassPathResource( fileName, getClass() ) ); } - private StatelessKieSession getSession2(final Resource resource) throws Exception { + private StatelessKieSession getSession2(KieBaseTestConfiguration kieBaseTestConfiguration, final Resource resource) throws Exception { resource.setTargetPath("r1.drl"); KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, resource); final StatelessKieSession session = kbase.newStatelessKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/TypeCoercionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/TypeCoercionTest.java index 8d6ea9b9ca6..e12b2f8663e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/TypeCoercionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/TypeCoercionTest.java @@ -19,18 +19,17 @@ package org.drools.mvel.integrationtests.session; 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.compiler.PolymorphicFact; import org.drools.mvel.compiler.Primitives; 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.type.FactType; import org.kie.api.runtime.KieSession; @@ -38,23 +37,16 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TypeCoercionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TypeCoercionTest(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 testRuntimeTypeCoercion() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuntimeTypeCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_RuntimeTypeCoercion.drl"); KieSession ksession = kbase.newKieSession(); @@ -82,8 +74,9 @@ public void testRuntimeTypeCoercion() throws Exception { assertThat(list.size()).isEqualTo(2); } - @Test - public void testRuntimeTypeCoercion2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuntimeTypeCoercion2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_RuntimeTypeCoercion2.drl"); KieSession ksession = kbase.newKieSession(); @@ -122,8 +115,9 @@ public void testRuntimeTypeCoercion2() throws Exception { assertThat(list.get(index)).isEqualTo("null object"); } - @Test - public void testUnwantedCoersion() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnwantedCoersion(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String rule = "package org.drools.compiler\n" + "import " + InnerBean.class.getCanonicalName() + ";\n" + "import " + OuterBean.class.getCanonicalName() + ";\n" + @@ -206,8 +200,9 @@ public void setId(final String id) { } } - @Test - public void testCoercionOfStringValueWithoutQuotes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCoercionOfStringValueWithoutQuotes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3080 final String str = "package org.drools.mvel.compiler.test; \n" + "declare A\n" + @@ -229,8 +224,9 @@ public void testCoercionOfStringValueWithoutQuotes() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testPrimitiveToBoxedCoercionInMethodArgument() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPrimitiveToBoxedCoercionInMethodArgument(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String str = "package org.drools.mvel.compiler.test;\n" + "import " + TypeCoercionTest.class.getName() + "\n" + "import org.drools.mvel.compiler.*\n" + @@ -252,8 +248,9 @@ public static String integer2String(final Integer value) { return "" + value; } - @Test - public void testStringCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStringCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1688 final String drl = "package org.drools.mvel.compiler.test;\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -274,8 +271,9 @@ public void testStringCoercion() { assertThat(kieSession.fireAllRules()).isEqualTo(2); } - @Test - public void testIntCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1688 final String drl = "package org.drools.mvel.compiler.test;\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -296,8 +294,9 @@ public void testIntCoercion() { assertThat(kieSession.fireAllRules()).isEqualTo(2); } - @Test - public void testCoercionInJoin() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCoercionInJoin(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2695 final String drl = " rule R1 when\n" + @@ -313,8 +312,9 @@ public void testCoercionInJoin() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testCoercionInJoinOnField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCoercionInJoinOnField(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2695 final String drl = "import " + Person.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/UpdateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/UpdateTest.java index dbe65bd7041..24a89fcf07d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/UpdateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/UpdateTest.java @@ -20,8 +20,8 @@ import java.io.IOException; 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.Asset; @@ -36,10 +36,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.builder.KieBuilder; import org.kie.api.builder.Message; @@ -55,32 +55,26 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class UpdateTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public UpdateTest(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 testModifyBlock() throws Exception { - doModifyTest("test_ModifyBlock.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyBlock(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + doModifyTest(kieBaseTestConfiguration, "test_ModifyBlock.drl"); } - @Test - public void testModifyBlockWithPolymorphism() throws Exception { - doModifyTest("test_ModifyBlockWithPolymorphism.drl"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyBlockWithPolymorphism(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + doModifyTest(kieBaseTestConfiguration, "test_ModifyBlockWithPolymorphism.drl"); } - private void doModifyTest(final String drlResource) throws Exception { + private void doModifyTest(KieBaseTestConfiguration kieBaseTestConfiguration, final String drlResource) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, drlResource); KieSession ksession = kbase.newKieSession(); @@ -101,8 +95,9 @@ private void doModifyTest(final String drlResource) throws Exception { assertThat(bob.getStatus()).isEqualTo("fine"); } - @Test - public void testModifyBlockWithFrom() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyBlockWithFrom(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ModifyBlockWithFrom.drl"); KieSession ksession = kbase.newKieSession(); @@ -126,8 +121,9 @@ public void testModifyBlockWithFrom() throws Exception { } // this test requires mvel 1.2.19. Leaving it commented until mvel is released. - @Test - public void testJavaModifyBlock() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJavaModifyBlock(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_JavaModifyBlock.drl"); KieSession ksession = kbase.newKieSession(); @@ -149,17 +145,19 @@ public void testJavaModifyBlock() throws Exception { assertThat(((OuterClass.InnerClass) list.get(1)).getIntAttr()).isEqualTo(2); } - @Test - public void testModifyJava() { - testModifyWithDialect("java"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyJava(KieBaseTestConfiguration kieBaseTestConfiguration) { + testModifyWithDialect(kieBaseTestConfiguration, "java"); } - @Test - public void testModifyMVEL() { - testModifyWithDialect("mvel"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) { + testModifyWithDialect(kieBaseTestConfiguration, "mvel"); } - private void testModifyWithDialect(final String dialect) { + private void testModifyWithDialect(KieBaseTestConfiguration kieBaseTestConfiguration, final String dialect) { final String str = "package org.drools.mvel.compiler\n" + "import java.util.List\n" + "rule \"test\"\n" + @@ -178,8 +176,9 @@ private void testModifyWithDialect(final String dialect) { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testModifySimple() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifySimple(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler;\n" + "\n" + "rule \"test modify block\"\n" + @@ -205,8 +204,9 @@ public void testModifySimple() { ksession.dispose(); } - @Test - public void testModifyWithLockOnActive() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithLockOnActive(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ModifyWithLockOnActive.drl"); KieSession session = kbase.newKieSession(); @@ -225,8 +225,9 @@ public void testModifyWithLockOnActive() throws Exception { assertThat(((List) session.getGlobal("results")).size()).isEqualTo(2); } - @Test - public void testMissingClosingBraceOnModify() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMissingClosingBraceOnModify(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3436 final String str = "package org.drools.mvel.compiler.test;\n" + "import org.drools.compiler.*\n" + @@ -242,8 +243,9 @@ public void testMissingClosingBraceOnModify() throws Exception { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testInvalidModify1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidModify1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.compiler \n"; str += "import " + Cheese.class.getName() + "\n"; @@ -262,8 +264,9 @@ public void testInvalidModify1() throws Exception { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testInvalidModify2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvalidModify2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.compiler \n"; str += "import " + Cheese.class.getName() + "\n"; @@ -282,8 +285,9 @@ public void testInvalidModify2() throws Exception { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testJoinNodeModifyObject() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJoinNodeModifyObject(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_JoinNodeModifyObject.drl"); KieSession ksession = kbase.newKieSession(); @@ -304,8 +308,9 @@ public void testJoinNodeModifyObject() throws IOException, ClassNotFoundExceptio } } - @Test - public void testModifyCommand() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyCommand(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "rule \"sample rule\"\n" + " when\n" + @@ -329,8 +334,9 @@ public void testModifyCommand() { ksession.execute(CommandFactory.newModify(fh, setterList)); } - @Test - public void testNotIterativeModifyBug() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotIterativeModifyBug(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-2809 // This bug occurs when a tuple is modified, the remove/add puts it onto the memory end // However before this was done it would attempt to find the next tuple, starting from itself @@ -384,8 +390,9 @@ public void testNotIterativeModifyBug() { ksession.dispose(); } - @Test - public void testLLR() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLLR(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_JoinNodeModifyTuple.drl"); KieSession ksession = kbase.newKieSession(); ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession( ksession,true ); @@ -475,8 +482,9 @@ public void testLLR() throws Exception { ksession.fireAllRules(); } - @Test - public void noDormantCheckOnModifies() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void noDormantCheckOnModifies(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // Test case for BZ 862325 final String str = "package org.drools.mvel.compiler;\n" + " rule R1\n" @@ -511,8 +519,10 @@ public void noDormantCheckOnModifies() throws Exception { verify(ael, never()).matchCancelled(any(org.kie.api.event.rule.MatchCancelledEvent.class)); } - @Test(timeout = 10000) - public void testSwapChild() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSwapChild(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6684 final String str = "package org.drools.mvel.compiler;\n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -582,8 +592,9 @@ public List getList() { } } - @Test - public void testPeerUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPeerUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6783 final String str = "import " + Firings.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/DeclarationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/DeclarationTest.java index 219ff1354ca..254187fbe72 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/DeclarationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/DeclarationTest.java @@ -24,13 +24,13 @@ import org.drools.core.base.ClassFieldAccessorCache; import org.drools.mvel.accessors.ClassFieldAccessorStore; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.drools.base.base.ClassObjectType; import org.drools.base.rule.Declaration; import org.drools.base.rule.Pattern; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.core.test.model.Cheese; -import org.junit.Before; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -38,7 +38,7 @@ public class DeclarationTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/EnumSerialiationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/EnumSerialiationTest.java index d602cacaba6..27a4faea451 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/EnumSerialiationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/EnumSerialiationTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.rule; import org.drools.base.rule.TypeDeclaration; -import org.junit.Test; import org.drools.core.integrationtests.SerializationHelper; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/GroupElementTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/GroupElementTest.java index e610f4a3310..9240967cb1e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/GroupElementTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/GroupElementTest.java @@ -24,7 +24,7 @@ import org.drools.base.rule.GroupElementFactory; import org.drools.base.rule.Pattern; import org.drools.core.test.model.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PackageCompilationDataTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PackageCompilationDataTest.java index 694cc4dd997..566f3bf597a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PackageCompilationDataTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PackageCompilationDataTest.java @@ -34,8 +34,8 @@ import org.drools.base.rule.Declaration; import org.drools.base.rule.EvalCondition; import org.drools.core.rule.JavaDialectRuntimeData; +import org.junit.jupiter.api.Test; import org.drools.base.rule.accessor.EvalExpression; -import org.junit.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/rule/PatternTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PatternTest.java index 1b5a5da372d..8cb56507bdb 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PatternTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/PatternTest.java @@ -25,7 +25,7 @@ import org.drools.base.rule.Pattern; import org.drools.base.rule.accessor.ReadAccessor; import org.drools.core.test.model.Cheese; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.prototype.PrototypeFact; import org.kie.api.prototype.PrototypeFactInstance; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/RuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/RuleTest.java index 85ae6bb564d..7a1086e8243 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/RuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/rule/RuleTest.java @@ -33,7 +33,7 @@ import org.drools.core.time.impl.PseudoClockScheduler; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.mvel.expr.MVELSalienceExpression; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieServices; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/util/RightTupleIndexHashTableTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/util/RightTupleIndexHashTableTest.java index c059a168989..3950832ffd1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/util/RightTupleIndexHashTableTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/util/RightTupleIndexHashTableTest.java @@ -27,6 +27,8 @@ import org.drools.core.reteoo.MockLeftTupleSink; import org.drools.core.util.index.IndexSpec; import org.drools.mvel.accessors.ClassFieldAccessorStore; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.drools.base.base.ClassObjectType; import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.InternalFactHandle; @@ -43,8 +45,6 @@ import org.drools.core.util.SingleLinkedEntry; import org.drools.core.util.index.TupleIndexHashTable; import org.drools.core.util.index.TupleList; -import org.junit.Before; -import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -52,7 +52,7 @@ public class RightTupleIndexHashTableTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/workitem/CustomWorkItemHandlerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/workitem/CustomWorkItemHandlerTest.java index f67b9176a17..027d2b8d652 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/workitem/CustomWorkItemHandlerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/workitem/CustomWorkItemHandlerTest.java @@ -26,7 +26,7 @@ import org.drools.core.impl.RuleBaseFactory; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java index b9a87e2a067..d2a00ed53ff 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/reteevaluator/ReteEvaluatorTest.java @@ -26,7 +26,7 @@ import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; import org.drools.model.codegen.ExecutableModelProject; import org.drools.mvel.compiler.Person; -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;