diff --git a/drools-ecj/pom.xml b/drools-ecj/pom.xml
index 1393a5669d0..0f64225390b 100644
--- a/drools-ecj/pom.xml
+++ b/drools-ecj/pom.xml
@@ -49,11 +49,11 @@
ecj
-
- junit
- junit
- test
-
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
org.assertj
assertj-core
diff --git a/drools-ecj/src/test/java/org/drools/ecj/JavaCompilerI18NTest.java b/drools-ecj/src/test/java/org/drools/ecj/JavaCompilerI18NTest.java
index c2db63729d0..2ed1f3fbd49 100644
--- a/drools-ecj/src/test/java/org/drools/ecj/JavaCompilerI18NTest.java
+++ b/drools-ecj/src/test/java/org/drools/ecj/JavaCompilerI18NTest.java
@@ -21,10 +21,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
import org.kie.memorycompiler.CompilationResult;
import org.kie.memorycompiler.resources.MemoryResourceReader;
import org.kie.memorycompiler.resources.MemoryResourceStore;
-import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/drools-persistence/drools-persistence-jpa/pom.xml b/drools-persistence/drools-persistence-jpa/pom.xml
index 17680599b83..914db801384 100644
--- a/drools-persistence/drools-persistence-jpa/pom.xml
+++ b/drools-persistence/drools-persistence-jpa/pom.xml
@@ -254,7 +254,11 @@
-
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
org.assertj
assertj-core
diff --git a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/TransactionManagerFactoryTest.java b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/TransactionManagerFactoryTest.java
index 51851a96b2e..2528568d053 100644
--- a/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/TransactionManagerFactoryTest.java
+++ b/drools-persistence/drools-persistence-jpa/src/test/java/org/drools/persistence/TransactionManagerFactoryTest.java
@@ -23,8 +23,8 @@
import org.drools.persistence.api.TransactionManagerFactory;
import org.drools.persistence.jta.JtaTransactionManager;
import org.drools.persistence.jta.JtaTransactionManagerFactory;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.kie.api.runtime.Environment;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class TransactionManagerFactoryTest {
TransactionManagerFactory transactionManagerFactory =
getTransactionManagerFactory();
- @After
+ @AfterEach
public void cleanup() {
System.clearProperty("org.kie.txm.factory.class");
transactionManagerFactory.resetInstance();
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 a0864484736..6c96d9eecce 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
@@ -23,18 +23,16 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.stream.Stream;
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.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.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.io.ResourceType;
@@ -59,29 +57,18 @@
import static org.drools.persistence.util.DroolsPersistenceUtil.cleanUp;
import static org.drools.persistence.util.DroolsPersistenceUtil.createEnvironment;
-@RunWith(Parameterized.class)
-public class MoreBatchExecutionPersistenceTest extends CommonTestMethodBase {
+public class MoreBatchExecutionPersistenceTest {
private KieSession ksession = null;
private Map context;
- private boolean locking;
- @Parameters(name="{0}")
- public static Collection
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
-
+
org.assertj
assertj-core
diff --git a/drools-retediagram/src/test/java/org/drools/retediagram/RuleTest.java b/drools-retediagram/src/test/java/org/drools/retediagram/RuleTest.java
index 1a34e81bd58..729eb6da06d 100644
--- a/drools-retediagram/src/test/java/org/drools/retediagram/RuleTest.java
+++ b/drools-retediagram/src/test/java/org/drools/retediagram/RuleTest.java
@@ -29,8 +29,8 @@
import org.drools.mvel.CommonTestMethodBase;
import org.drools.retediagram.ReteDiagram.Layout;
import org.drools.retediagram.model.Measurement;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.KieBase;
import org.kie.api.event.rule.DebugAgendaEventListener;
import org.kie.api.io.ResourceType;
@@ -47,7 +47,7 @@
public class RuleTest extends CommonTestMethodBase {
static final Logger LOG = LoggerFactory.getLogger(RuleTest.class);
- @BeforeClass
+ @BeforeAll
public static void init() { // route dependencies using java util Logging to slf4j
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
diff --git a/drools-serialization-protobuf/pom.xml b/drools-serialization-protobuf/pom.xml
index 728273f4cf4..5c2c4611fc0 100644
--- a/drools-serialization-protobuf/pom.xml
+++ b/drools-serialization-protobuf/pom.xml
@@ -93,16 +93,16 @@
commons-lang3
test
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
org.assertj
assertj-core
test
-
- junit
- junit
- test
-
org.mockito
mockito-core
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/EventAccessorRestoreTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/EventAccessorRestoreTest.java
index dacb7ca5c6d..b4b3e97e1c6 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/EventAccessorRestoreTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/EventAccessorRestoreTest.java
@@ -19,19 +19,19 @@
package org.drools.serialization.protobuf;
import java.io.EOFException;
-import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import org.drools.base.common.DroolsObjectInputStream;
import org.drools.base.common.DroolsObjectOutputStream;
import org.drools.mvel.CommonTestMethodBase;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.kie.api.KieBase;
import org.kie.api.marshalling.Marshaller;
import org.kie.api.marshalling.ObjectMarshallingStrategy;
@@ -44,14 +44,14 @@
public class EventAccessorRestoreTest extends CommonTestMethodBase {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
+ @TempDir
+ public Path temp;
- private File kbaseFile = null;
+ private Path kbaseFile = null;
private KieBase kbase;
- @Before
+ @BeforeEach
public void setUp() {
String str =
"package org.drools.test;\n" +
@@ -80,8 +80,8 @@ public void setUp() {
KieSession ksession = kbase.newKieSession();
try {
- kbaseFile = temp.newFile( "test.bin" );
- FileOutputStream fos = new FileOutputStream( kbaseFile ) ;
+ kbaseFile = Files.createFile(temp.resolve("test.bin" ));
+ FileOutputStream fos = new FileOutputStream( kbaseFile.toFile() ) ;
saveSession( fos, ksession );
fos.close();
} catch ( Exception e ) {
@@ -123,7 +123,7 @@ public KieSession loadSession( FileInputStream input ) throws IOException, Class
@Test
public void testDeserialization() {
try {
- FileInputStream fis = new FileInputStream( kbaseFile );
+ FileInputStream fis = new FileInputStream( kbaseFile.toFile() );
KieSession knowledgeSession = loadSession( fis );
ArrayList list = new ArrayList();
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java
index 254f6beec3f..44e849c40aa 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java
@@ -41,7 +41,7 @@
import org.drools.mvel.compiler.Person;
import org.drools.serialization.protobuf.marshalling.ObjectMarshallingStrategyStoreImpl;
import org.drools.util.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.kie.api.KieBaseConfiguration;
import org.kie.api.conf.EventProcessingOption;
import org.kie.api.marshalling.ObjectMarshallingStrategy;
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshalledInternalMatchSortTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshalledInternalMatchSortTest.java
index 7b7e2cb3631..83538a96c4f 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshalledInternalMatchSortTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshalledInternalMatchSortTest.java
@@ -29,8 +29,7 @@
import org.drools.base.definitions.rule.impl.RuleImpl;
import org.drools.core.reteoo.TupleImpl;
import org.drools.core.rule.consequence.InternalMatch;
-import org.drools.core.reteoo.Tuple;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallerTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallerTest.java
index 6b2a95f6e49..df518c80cda 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallerTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallerTest.java
@@ -23,16 +23,16 @@
import java.util.List;
import java.util.Objects;
import java.util.UUID;
+import java.util.stream.Stream;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.impl.EnvironmentFactory;
import org.drools.core.marshalling.ClassObjectMarshallingStrategyAcceptor;
import org.drools.serialization.protobuf.marshalling.JavaSerializableResolverStrategy;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.drools.core.marshalling.SerializablePlaceholderResolverStrategy;
import org.drools.mvel.compiler.Person;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.kie.api.KieBase;
import org.kie.api.conf.EqualityBehaviorOption;
import org.kie.api.io.ResourceType;
@@ -44,24 +44,23 @@
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(Parameterized.class)
public class MarshallerTest {
- private Environment env;
+ private Environment env = EnvironmentFactory.newEnvironment();
- @Parameterized.Parameters(name = "{0}")
- public static Object[] params() {
- return new Object[] { new JavaSerializableResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT ),
- new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT ) };
+ public static Stream parameters() {
+ return Stream.of(new JavaSerializableResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT),
+ new SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT));
}
- public MarshallerTest(ObjectMarshallingStrategy strategy) {
- this.env = EnvironmentFactory.newEnvironment();
+ private void setupEnvironment(ObjectMarshallingStrategy strategy) {
this.env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{ strategy } );
}
- @Test
- public void testAgendaDoNotSerializeObject() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testAgendaDoNotSerializeObject(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
KieSession ksession = null;
try {
String str =
@@ -96,8 +95,10 @@ public void testAgendaDoNotSerializeObject() throws Exception {
}
}
- @Test
- public void testFromWithFireBeforeSerialization() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromWithFireBeforeSerialization(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -121,8 +122,10 @@ public void testFromWithFireBeforeSerialization() throws Exception {
}
}
- @Test
- public void testFromWithFireAfterSerialization() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromWithFireAfterSerialization(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -145,8 +148,10 @@ public void testFromWithFireAfterSerialization() throws Exception {
}
}
- @Test
- public void testFromWithPartialFiring() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromWithPartialFiring(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -170,8 +175,10 @@ public void testFromWithPartialFiring() throws Exception {
}
}
- @Test
- public void test2FromsWithPartialFiring() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void test2FromsWithPartialFiring(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -196,8 +203,10 @@ public void test2FromsWithPartialFiring() throws Exception {
}
}
- @Test
- public void testFromAndJoinWithPartialFiring() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromAndJoinWithPartialFiring(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -223,9 +232,10 @@ public void testFromAndJoinWithPartialFiring() throws Exception {
}
}
- @Test
- public void testAgendaReconciliationAccumulate() throws Exception {
-
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testAgendaReconciliationAccumulate(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import " + Person.class.getCanonicalName() + ";" +
"rule X when\n" +
@@ -257,10 +267,11 @@ public void testAgendaReconciliationAccumulate() throws Exception {
}
}
- @Test
- public void testAgendaReconciliationAccumulate2() throws Exception {
-
- String str =
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testAgendaReconciliationAccumulate2(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
+ String str =
"import " + Person.class.getCanonicalName() + ";" +
"rule X when\n" +
" accumulate ( $p: Person ( getName().startsWith(\"M\")); \n" +
@@ -289,10 +300,12 @@ public void testAgendaReconciliationAccumulate2() throws Exception {
}
}
- @Test
- public void testMultiAccumulate() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testMultiAccumulate(ObjectMarshallingStrategy strategy) throws Exception {
// DROOLS-5579
- String str =
+ setupEnvironment(strategy);
+ String str =
"import " + Person.class.getCanonicalName() + ";" +
"rule X when\n" +
" accumulate ( Person ( getName().startsWith(\"M\"), $age : age ); \n" +
@@ -323,9 +336,11 @@ public void testMultiAccumulate() throws Exception {
}
}
- @Test
- public void testSubnetwork() throws Exception {
- final String str =
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testSubnetwork(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
+ final String str =
"rule R1 when\n" +
" String()\n" +
" Long()\n" +
@@ -361,9 +376,11 @@ public void testSubnetwork() throws Exception {
}
}
- @Test
- public void testSubnetwork2() throws Exception {
- final String str =
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testSubnetwork2(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
+ final String str =
"rule R1 when\n" +
" String()\n" +
" Long()\n" +
@@ -394,8 +411,10 @@ public void testSubnetwork2() throws Exception {
}
}
- @Test
- public void testFromJoinWithPartialFiring() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromJoinWithPartialFiring(ObjectMarshallingStrategy strategy) throws Exception {
+ setupEnvironment(strategy);
String str =
"import java.util.Collection\n" +
"rule R1 when\n" +
@@ -489,9 +508,11 @@ public int hashCode() {
}
}
- @Test
- public void testFromWithInsertLogical() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("parameters")
+ public void testFromWithInsertLogical(ObjectMarshallingStrategy strategy) throws Exception {
// DROOLS-5713
+ setupEnvironment(strategy);
String str =
"import " + LongFact.class.getCanonicalName() + "\n" +
"import " + LongFacts.class.getCanonicalName() + "\n" +
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallingTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallingTest.java
index 97e72f878d0..f80c8a7ee42 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallingTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/MarshallingTest.java
@@ -32,8 +32,6 @@
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
import org.drools.base.base.ClassObjectType;
import org.drools.base.base.ValueResolver;
@@ -41,7 +39,6 @@
import org.drools.base.common.DroolsObjectOutputStream;
import org.drools.base.definitions.InternalKnowledgePackage;
import org.drools.base.definitions.rule.impl.RuleImpl;
-import org.drools.base.rule.MapBackedClassLoader;
import org.drools.base.rule.consequence.Consequence;
import org.drools.base.rule.consequence.ConsequenceContext;
import org.drools.core.ClockType;
@@ -77,8 +74,9 @@
import org.drools.mvel.integrationtests.IteratorToList;
import org.drools.serialization.protobuf.marshalling.IdentityPlaceholderResolverStrategy;
import org.drools.serialization.protobuf.marshalling.RuleBaseNodes;
-import org.junit.Ignore;
-import org.junit.Test;
+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.KieServices;
@@ -101,8 +99,6 @@
import org.kie.api.runtime.conf.TimerJobFactoryOption;
import org.kie.api.runtime.rule.EntryPoint;
import org.kie.api.time.SessionPseudoClock;
-import org.kie.internal.builder.KnowledgeBuilderConfiguration;
-import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.marshalling.MarshallerFactory;
import org.kie.internal.utils.KieHelper;
@@ -1843,7 +1839,8 @@ public void testAccumulateSessionSerialization() throws Exception {
*
* @throws Exception
*/
- @Test @Ignore
+ @Test
+ @Disabled
public void testDroolsObjectOutputInputStream() throws Exception {
KieBase kbase = loadKnowledgeBase("org/drools/compiler/integrationtests/test_Serializable.drl" );
KieSession session = kbase.newKieSession();
@@ -1992,7 +1989,8 @@ public void testMarshallEvents() throws Exception {
assertThat(ksession.getObjects().size()).isEqualTo(2);
}
- @Test @Ignore("This test is suspicious to say the least...")
+ @Test
+ @Disabled("This test is suspicious to say the least...")
public void testScheduledActivation() {
InternalKnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
InternalKnowledgePackage impl = CoreComponentFactory.get().createKnowledgePackage( "test" );
@@ -2223,7 +2221,8 @@ public void testMarshallEntryPointsWithNot() throws Exception {
assertThat(list.size()).isEqualTo(0);
}
- @Test @Ignore("beta4 phreak")
+ @Test
+ @Disabled("beta4 phreak")
public void testMarshallEntryPointsWithSlidingTimeWindow() throws Exception {
String str =
"package org.domain.test \n" +
@@ -2515,7 +2514,7 @@ public void testMarshallWithTimedRule() {
}
@Test
- @Ignore("Reproduces with pseudoclock. It takes too long with system clock")
+ @Disabled("Reproduces with pseudoclock. It takes too long with system clock")
public void testMarshallWithTimedRuleRealClock() {
// DROOLS-795
String drl = "rule \"Rule A Timeout\"\n" +
@@ -2765,7 +2764,8 @@ public void setJob( String job ) {
}
}
- @Test(timeout = 10_000L)
+ @Test
+ @Timeout(10000)
public void testDisposeAfterMarshall() throws InterruptedException, IOException {
// DROOLS-4413
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ObjectMarshallingStrategyStoreTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ObjectMarshallingStrategyStoreTest.java
index 754043397af..e32f198d3c9 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ObjectMarshallingStrategyStoreTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ObjectMarshallingStrategyStoreTest.java
@@ -32,7 +32,7 @@
import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.drools.serialization.protobuf.marshalling.IdentityPlaceholderResolverStrategy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.kie.api.KieBaseConfiguration;
import org.kie.api.KieServices;
import org.kie.api.conf.EventProcessingOption;
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ProtobufOutputMarshallerTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ProtobufOutputMarshallerTest.java
index 987e6148471..519e57cc4c5 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ProtobufOutputMarshallerTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/ProtobufOutputMarshallerTest.java
@@ -24,7 +24,7 @@
import org.drools.core.common.DefaultFactHandle;
import org.drools.core.common.InternalFactHandle;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/QueryTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/QueryTest.java
index fbf4b1ba491..7b1c4e7bab4 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/QueryTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/QueryTest.java
@@ -30,9 +30,7 @@
import org.drools.core.runtime.rule.impl.FlatQueryResultRow;
import org.drools.mvel.CommonTestMethodBase;
import org.drools.mvel.compiler.Cheese;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.Test;
import org.kie.api.KieBase;
import org.kie.api.definition.rule.Rule;
import org.kie.api.runtime.KieSession;
@@ -44,13 +42,6 @@
public class QueryTest extends CommonTestMethodBase {
- @org.junit.Rule
- public TestName testName = new TestName();
-
- @Before
- public void before() {
- System.out.println( "] " + testName.getMethodName());
- }
private static QueryResults getQueryResults(KieSession session, String queryName, Object... arguments ) throws Exception {
QueryResultsImpl results = (QueryResultsImpl) session.getQueryResults( queryName, arguments );
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/TruthMaintenanceTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/TruthMaintenanceTest.java
index 24ede56803d..b3a81cf5d16 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/TruthMaintenanceTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/TruthMaintenanceTest.java
@@ -38,8 +38,9 @@
import org.drools.mvel.compiler.CheeseEqual;
import org.drools.mvel.compiler.Person;
import org.drools.mvel.compiler.Sensor;
-import org.junit.Ignore;
-import org.junit.Test;
+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.definition.KiePackage;
import org.kie.api.io.ResourceType;
@@ -211,7 +212,8 @@ public void testLogicalInsertionsDynamicRule() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertions() throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "test_LogicalInsertions.drl",
@@ -263,7 +265,8 @@ public void testLogicalInsertions() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertionsBacking() throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "test_LogicalInsertionsBacking.drl",
@@ -328,7 +331,8 @@ public void testLogicalInsertionsBacking() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
//@Ignore("in Java 8, the byte[] generated by serialization are not the same and requires investigation")
public void testLogicalInsertionsWithModify() throws Exception {
KieBase kbase = loadKnowledgeBase("test_LogicalInsertionsWithUpdate.drl");
@@ -364,7 +368,8 @@ public void testLogicalInsertionsWithModify() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertions2() throws Exception {
KieBase kbase = loadKnowledgeBase("test_LogicalInsertions2.drl");
KieSession ksession = kbase.newKieSession();
@@ -408,7 +413,8 @@ public void testLogicalInsertions2() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
//@Ignore("in Java 8, the byte[] generated by serialization are not the same and requires investigation")
public void testLogicalInsertionsNot() throws Exception {
KieBase kbase = loadKnowledgeBase("test_LogicalInsertionsNot.drl");
@@ -456,8 +462,9 @@ public void testLogicalInsertionsNot() throws Exception {
}
}
- @Test(timeout=10000)
- @Ignore("Currently cannot support updates")
+ @Test
+ @Timeout(10000)
+ @Disabled("Currently cannot support updates")
//@Ignore("in Java 8, the byte[] generated by serialization are not the same and requires investigation")
public void testLogicalInsertionsUpdateEqual() throws Exception {
// calling update on a justified FH, states it
@@ -503,7 +510,8 @@ public void testLogicalInsertionsUpdateEqual() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
//@Ignore("in Java 8, the byte[] generated by serialization are not the same and requires investigation")
public void testLogicalInsertionsWithExists() throws Exception {
KieBase kbase = loadKnowledgeBase("test_LogicalInsertionWithExists.drl");
@@ -602,7 +610,8 @@ public void testLogicalInsertionsWithExists() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertions3() throws Exception {
KieBase kbase = loadKnowledgeBase("test_logicalInsertions3.drl");
KieSession ksession = kbase.newKieSession();
@@ -650,7 +659,8 @@ public void testLogicalInsertions3() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertionsAccumulatorPattern() throws Exception {
// JBRULES-449
KieBase kbase = loadKnowledgeBase( "test_LogicalInsertionsAccumulatorPattern.drl" );
@@ -692,7 +702,8 @@ public void testLogicalInsertionsAccumulatorPattern() throws Exception {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(10000)
public void testLogicalInsertionsModifySameRuleGivesDifferentLogicalInsertion() throws Exception {
// TODO JBRULES-1804
diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/UnmarshallingTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/UnmarshallingTest.java
index cfb2ca99a71..d4338f631fb 100644
--- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/UnmarshallingTest.java
+++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/UnmarshallingTest.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.KieBaseConfiguration;
import org.kie.api.KieServices;
diff --git a/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/LogicalTraitTest.java b/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/LogicalTraitTest.java
index bedb76d286e..a500b0bb8fe 100644
--- a/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/LogicalTraitTest.java
+++ b/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/LogicalTraitTest.java
@@ -19,10 +19,9 @@
package org.drools.traits.compiler.factmodel.traits;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Set;
+import java.util.stream.Stream;
import org.drools.core.common.InternalFactHandle;
import org.drools.base.factmodel.traits.CoreWrapper;
@@ -35,13 +34,11 @@
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.drools.serialization.protobuf.SerializationHelper;
import org.drools.traits.compiler.CommonTraitTest;
-import org.drools.traits.compiler.ReviseTraitTestWithPRAlwaysCategory;
import org.drools.traits.core.factmodel.TraitFactoryImpl;
import org.drools.traits.core.factmodel.VirtualPropertyMode;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-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.definition.type.FactType;
import org.kie.api.io.ResourceType;
@@ -59,25 +56,17 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
-@RunWith(Parameterized.class)
public class LogicalTraitTest extends CommonTraitTest {
private static final Logger LOGGER = LoggerFactory.getLogger(LogicalTraitTest.class);
- public VirtualPropertyMode mode;
-
- @Parameterized.Parameters
- public static Collection modes() {
- return List.of(VirtualPropertyMode.MAP, VirtualPropertyMode.TRIPLES);
- }
-
- public LogicalTraitTest( VirtualPropertyMode m ) {
- this.mode = m;
+ public static Stream parameters() {
+ return Stream.of(VirtualPropertyMode.MAP, VirtualPropertyMode.TRIPLES);
}
-
- @Test
- public void testShadowAlias() throws Exception {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAlias(VirtualPropertyMode mode) throws Exception {
KnowledgeBuilder kbuilderImpl = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilderImpl.add( ResourceFactory.newClassPathResource( "org/drools/compiler/factmodel/traits/testTraitedAliasing.drl" ), ResourceType.DRL );
@@ -107,13 +96,9 @@ public void testShadowAlias() throws Exception {
assertThat(list).hasSize(8);
}
-
-
-
-
-
- @Test
- public void testShadowAliasTraitOnClass() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAliasTraitOnClass(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -175,9 +160,9 @@ public void testShadowAliasTraitOnClass() {
}
-
- @Test
- public void testShadowAliasClassOnTrait() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAliasClassOnTrait(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -251,11 +236,9 @@ public void testShadowAliasClassOnTrait() {
}
-
-
-
- @Test
- public void testShadowAliasTraitOnTrait() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAliasTraitOnTrait(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -324,11 +307,9 @@ public void testShadowAliasTraitOnTrait() {
}
-
-
-
- @Test
- public void initializationConflictManagement() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void initializationConflictManagement(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"" +
"global java.util.List list; \n" +
@@ -407,11 +388,9 @@ public void initializationConflictManagement() {
}
}
-
-
-
- @Test
- public void testInitializationConflictManagementPrimitiveTypes() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testInitializationConflictManagementPrimitiveTypes(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"" +
"global java.util.List list; \n" +
@@ -509,9 +488,10 @@ public void setNum( Integer num ) {
}
}
- @Category(ReviseTraitTestWithPRAlwaysCategory.class)
- @Test
- public void testHardGetSetOnLogicallyTraitedField() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ @Disabled("check file ReviseTraitTestWithPRAlwaysCategory.java") //
+ public void testHardGetSetOnLogicallyTraitedField(VirtualPropertyMode mode) {
String drl = "package org.drools.test; " +
"import " + Qty.class.getCanonicalName() + "; " +
"" +
@@ -566,11 +546,9 @@ public void testHardGetSetOnLogicallyTraitedField() {
knowledgeSession.dispose();
}
-
-
-
- @Test
- public void testFieldTypeDonMap() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testFieldTypeDonMap(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"" +
"global java.util.List list; \n" +
@@ -640,11 +618,9 @@ public void testFieldTypeDonMap() {
}
-
-
-
- @Test
- public void testDataStructs() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testDataStructs(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"" +
"global java.util.List list; \n" +
@@ -722,10 +698,9 @@ public void testDataStructs() {
}
-
-
- @Test
- public void shadowAliasSelf() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void shadowAliasSelf(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -786,9 +761,9 @@ public void shadowAliasSelf() {
}
-
- @Test
- public void traitOnSet() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void traitOnSet(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -882,12 +857,9 @@ public void traitOnSet() {
assertThat(list).isEqualTo(List.of("ok1"));
}
-
-
-
-
- @Test
- public void testShadowAliasTraitOnClassLogicalRetract() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAliasTraitOnClassLogicalRetract(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -1019,12 +991,9 @@ public void testShadowAliasTraitOnClassLogicalRetract() {
}
-
-
-
-
- @Test
- public void testShadowAliasClassOnTraitLogicalRetract() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testShadowAliasClassOnTraitLogicalRetract(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -1124,12 +1093,9 @@ public void testShadowAliasClassOnTraitLogicalRetract() {
}
-
-
-
-
- @Test
- public void testSerial() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testSerial(VirtualPropertyMode mode) {
String drl = "package org.drools.test; \n" +
"import org.drools.base.factmodel.traits.*; \n" +
@@ -1185,8 +1151,9 @@ public void testSerial() {
}
}
- @Test
- public void testTraitMismatchTypes()
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitMismatchTypes(VirtualPropertyMode mode)
{
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
@@ -1237,8 +1204,9 @@ public void testTraitMismatchTypes()
assertThat(list).hasSize(1).containsNull();
}
- @Test
- public void testTraitMismatchTypes2()
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitMismatchTypes2(VirtualPropertyMode mode)
{
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
@@ -1291,9 +1259,9 @@ public void testTraitMismatchTypes2()
assertThat(list).hasSize(1).containsNull();
}
- @Test
- public void testTraitMismatchTypes3()
- {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitMismatchTypes3(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
diff --git a/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/TraitTest.java b/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/TraitTest.java
index 8c9142f1664..ddfa9a038e2 100644
--- a/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/TraitTest.java
+++ b/drools-traits/src/test/java/org/drools/traits/compiler/factmodel/traits/TraitTest.java
@@ -40,7 +40,6 @@
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.drools.traits.compiler.CommonTraitTest;
import org.drools.traits.compiler.Person;
-import org.drools.traits.compiler.ReviseTraitTestWithPRAlwaysCategory;
import org.drools.traits.core.factmodel.Entity;
import org.drools.traits.core.factmodel.HierarchyEncoder;
import org.drools.traits.core.factmodel.MapWrapper;
@@ -53,11 +52,10 @@
import org.drools.traits.core.factmodel.VirtualPropertyMode;
import org.drools.traits.core.reteoo.TraitRuntimeComponentFactory;
import org.drools.traits.core.util.CodedHierarchyImpl;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-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.command.Command;
import org.kie.api.conf.EqualityBehaviorOption;
@@ -101,29 +99,21 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-@RunWith(Parameterized.class)
public class TraitTest extends CommonTraitTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TraitTest.class);
- public VirtualPropertyMode mode;
-
- @Parameterized.Parameters
- public static Collection modes() {
- return List.of(VirtualPropertyMode.MAP, VirtualPropertyMode.TRIPLES);
- }
-
- public TraitTest(VirtualPropertyMode m) {
- this.mode = m;
+ public static Stream parameters() {
+ return Stream.of(VirtualPropertyMode.MAP, VirtualPropertyMode.TRIPLES);
}
private KieSession getSession(String... ruleFiles) {
@@ -142,8 +132,9 @@ private KieBase getKieBaseFromString(String drl, KieBaseOption... options) {
return new KieHelper().addContent(drl, ResourceType.DRL).build(options);
}
- @Test
- public void testRetract() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testRetract(VirtualPropertyMode mode) {
String drl = "package org.drools.compiler.trait.test; \n" +
"import org.drools.base.factmodel.traits.Traitable; \n" +
"" +
@@ -173,8 +164,9 @@ public void testRetract() {
assertThat(ks.getObjects()).isEmpty();
}
- @Test
- public void testTraitWrapGetAndSet() throws Exception {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitWrapGetAndSet(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -191,31 +183,32 @@ public void testTraitWrapGetAndSet() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- Class> trait = kb.getFactType("org.drools.compiler.trait.test", "Student").getFactClass();
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ Class> trait = kb.getFactType("org.drools.compiler.trait.test", "Student").getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- Map virtualFields = imp._getDynamicProperties();
- Map wrapper = proxy.getFields();
+ Map virtualFields = imp._getDynamicProperties();
+ Map wrapper = proxy.getFields();
- wrapper.put("name", "john");
+ wrapper.put("name", "john");
- wrapper.put("virtualField", "xyz");
+ wrapper.put("virtualField", "xyz");
- wrapper.entrySet();
- assertThat(wrapper).hasSize(4);
- assertThat(virtualFields).hasSize(2);
+ wrapper.entrySet();
+ assertThat(wrapper).hasSize(4);
+ assertThat(virtualFields).hasSize(2);
- assertThat(wrapper.get("name")).isEqualTo("john");
- assertThat(wrapper.get("virtualField")).isEqualTo("xyz");
+ assertThat(wrapper.get("name")).isEqualTo("john");
+ assertThat(wrapper.get("virtualField")).isEqualTo("xyz");
- assertThat(impClass.get(imp, "name")).isEqualTo("john");
+ assertThat(impClass.get(imp, "name")).isEqualTo("john");
}
- @Test
- public void testTraitShed() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitShed(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitShed.drl";
KieSession ks = getSession(source);
@@ -247,8 +240,9 @@ public void testTraitShed() {
}
- @Test
- public void testTraitDon() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitDon(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KieSession ks = getSession(source);
@@ -277,8 +271,10 @@ public void testTraitDon() {
LOGGER.debug(x.getClass().getSuperclass().toString());
LOGGER.debug(List.of(x.getClass().getInterfaces()).toString());
}
- @Test
- public void testMixin() {
+
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testMixin(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitMixin.drl";
KieSession ks = getSession(source);
@@ -292,9 +288,9 @@ public void testMixin() {
assertThat(info).contains("27");
}
-
- @Test
- public void traitMethodsWithObjects() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void traitMethodsWithObjects(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitWrapping.drl";
KieSession ks = getSession(source);
@@ -312,9 +308,9 @@ public void traitMethodsWithObjects() {
}
-
- @Test
- public void traitMethodsWithPrimitives() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void traitMethodsWithPrimitives(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitWrappingPrimitives.drl";
KieSession ks = getSession(source);
@@ -332,9 +328,9 @@ public void traitMethodsWithPrimitives() {
}
-
- @Test
- public void testTraitProxy() throws Exception {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitProxy(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
@@ -351,39 +347,40 @@ public void testTraitProxy() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- impClass.set(imp, "name", "aaa");
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ impClass.set(imp, "name", "aaa");
- Class> trait = kb.getFactType("org.drools.compiler.trait.test", "Student").getFactClass();
- Class> trait2 = kb.getFactType("org.drools.compiler.trait.test", "Role").getFactClass();
+ Class> trait = kb.getFactType("org.drools.compiler.trait.test", "Student").getFactClass();
+ Class> trait2 = kb.getFactType("org.drools.compiler.trait.test", "Role").getFactClass();
- assertThat(trait).isNotNull();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- proxy.getFields().put("field", "xyz");
- // proxy.getFields().put("name", "aaa");
+ assertThat(trait).isNotNull();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ proxy.getFields().put("field", "xyz");
+ // proxy.getFields().put("name", "aaa");
- assertThat(proxy).isNotNull();
+ assertThat(proxy).isNotNull();
- TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- assertThat(proxy).isSameAs(proxy2);
+ TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ assertThat(proxy).isSameAs(proxy2);
- TraitProxyImpl proxy3 = (TraitProxyImpl) tFactory.getProxy(imp, trait2, false);
- assertThat(proxy3).isNotNull();
- assertThat(proxy3.getFields().get("field")).isEqualTo("xyz");
- assertThat(proxy3.getFields().get("name")).isEqualTo("aaa");
+ TraitProxyImpl proxy3 = (TraitProxyImpl) tFactory.getProxy(imp, trait2, false);
+ assertThat(proxy3).isNotNull();
+ assertThat(proxy3.getFields().get("field")).isEqualTo("xyz");
+ assertThat(proxy3.getFields().get("name")).isEqualTo("aaa");
- TraitableBean imp2 = (TraitableBean) impClass.newInstance();
- impClass.set(imp2, "name", "aaa");
- TraitProxyImpl proxy4 = (TraitProxyImpl) tFactory.getProxy(imp2, trait, false);
- // proxy4.getFields().put("name", "aaa");
- proxy4.getFields().put("field", "xyz");
+ TraitableBean imp2 = (TraitableBean) impClass.newInstance();
+ impClass.set(imp2, "name", "aaa");
+ TraitProxyImpl proxy4 = (TraitProxyImpl) tFactory.getProxy(imp2, trait, false);
+ // proxy4.getFields().put("name", "aaa");
+ proxy4.getFields().put("field", "xyz");
- assertThat(proxy4).isEqualTo(proxy2);
+ assertThat(proxy4).isEqualTo(proxy2);
}
- @Test
- public void testWrapperSize() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testWrapperSize(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -401,72 +398,73 @@ public void testWrapperSize() throws Exception {
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = traitClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = traitClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- Map virtualFields = imp._getDynamicProperties();
- Map wrapper = proxy.getFields();
- assertThat(wrapper).hasSize(3);
- assertThat(virtualFields).hasSize(1);
+ Map virtualFields = imp._getDynamicProperties();
+ Map wrapper = proxy.getFields();
+ assertThat(wrapper).hasSize(3);
+ assertThat(virtualFields).hasSize(1);
- impClass.set(imp, "name", "john");
- assertThat(wrapper).hasSize(3);
- assertThat(virtualFields).hasSize(1);
+ impClass.set(imp, "name", "john");
+ assertThat(wrapper).hasSize(3);
+ assertThat(virtualFields).hasSize(1);
- proxy.getFields().put("school", "skol");
- assertThat(wrapper).hasSize(3);
- assertThat(virtualFields).hasSize(1);
+ proxy.getFields().put("school", "skol");
+ assertThat(wrapper).hasSize(3);
+ assertThat(virtualFields).hasSize(1);
- proxy.getFields().put("surname", "xxx");
- assertThat(wrapper).hasSize(4);
- assertThat(virtualFields).hasSize(2);
+ proxy.getFields().put("surname", "xxx");
+ assertThat(wrapper).hasSize(4);
+ assertThat(virtualFields).hasSize(2);
- // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
- // TraitableBean ind = (TraitableBean) indClass.newInstance();
- TraitableBean ind = new Entity();
+ // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
+ // TraitableBean ind = (TraitableBean) indClass.newInstance();
+ TraitableBean ind = new Entity();
- TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait, false);
+ TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait, false);
- Map virtualFields2 = ind._getDynamicProperties();
- Map wrapper2 = proxy2.getFields();
- assertThat(wrapper2).hasSize(3);
- assertThat(virtualFields2).hasSize(3);
+ Map virtualFields2 = ind._getDynamicProperties();
+ Map wrapper2 = proxy2.getFields();
+ assertThat(wrapper2).hasSize(3);
+ assertThat(virtualFields2).hasSize(3);
- traitClass.set(proxy2, "name", "john");
- assertThat(wrapper2).hasSize(3);
- assertThat(virtualFields2).hasSize(3);
+ traitClass.set(proxy2, "name", "john");
+ assertThat(wrapper2).hasSize(3);
+ assertThat(virtualFields2).hasSize(3);
- proxy2.getFields().put("school", "skol");
- assertThat(wrapper2).hasSize(3);
- assertThat(virtualFields2).hasSize(3);
+ proxy2.getFields().put("school", "skol");
+ assertThat(wrapper2).hasSize(3);
+ assertThat(virtualFields2).hasSize(3);
- proxy2.getFields().put("surname", "xxx");
- assertThat(wrapper2).hasSize(4);
- assertThat(virtualFields2).hasSize(4);
+ proxy2.getFields().put("surname", "xxx");
+ assertThat(wrapper2).hasSize(4);
+ assertThat(virtualFields2).hasSize(4);
- FactType traitClass2 = kb.getFactType("org.drools.compiler.trait.test", "Role");
- Class> trait2 = traitClass2.getFactClass();
- // TraitableBean ind2 = (TraitableBean) indClass.newInstance();
- TraitableBean ind2 = new Entity();
+ FactType traitClass2 = kb.getFactType("org.drools.compiler.trait.test", "Role");
+ Class> trait2 = traitClass2.getFactClass();
+ // TraitableBean ind2 = (TraitableBean) indClass.newInstance();
+ TraitableBean ind2 = new Entity();
- TraitProxyImpl proxy99 = (TraitProxyImpl) tFactory.getProxy(ind2, trait2, false);
+ TraitProxyImpl proxy99 = (TraitProxyImpl) tFactory.getProxy(ind2, trait2, false);
- proxy99.getFields().put("surname", "xxx");
- proxy99.getFields().put("name", "xyz");
- proxy99.getFields().put("school", "skol");
+ proxy99.getFields().put("surname", "xxx");
+ proxy99.getFields().put("name", "xyz");
+ proxy99.getFields().put("school", "skol");
- assertThat(proxy99.getFields()).hasSize(3);
+ assertThat(proxy99.getFields()).hasSize(3);
- TraitProxyImpl proxy100 = (TraitProxyImpl) tFactory.getProxy(ind2, trait, false);
+ TraitProxyImpl proxy100 = (TraitProxyImpl) tFactory.getProxy(ind2, trait, false);
- assertThat(proxy100.getFields()).hasSize(4);
+ assertThat(proxy100.getFields()).hasSize(4);
}
- @Test
- public void testWrapperEmpty() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testWrapperEmpty(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -484,47 +482,48 @@ public void testWrapperEmpty() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
- FactType studentClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = studentClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ FactType studentClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = studentClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- Map wrapper = proxy.getFields();
- assertThat(wrapper).isNotEmpty();
+ Map wrapper = proxy.getFields();
+ assertThat(wrapper).isNotEmpty();
- studentClass.set(proxy, "name", "john");
- assertThat(wrapper).isNotEmpty();
-
- studentClass.set(proxy, "name", null);
- assertThat(wrapper).isNotEmpty();
+ studentClass.set(proxy, "name", "john");
+ assertThat(wrapper).isNotEmpty();
+
+ studentClass.set(proxy, "name", null);
+ assertThat(wrapper).isNotEmpty();
- studentClass.set(proxy, "age", 32);
- assertThat(wrapper).isNotEmpty();
+ studentClass.set(proxy, "age", 32);
+ assertThat(wrapper).isNotEmpty();
- studentClass.set(proxy, "age", null);
- assertThat(wrapper).isNotEmpty();
+ studentClass.set(proxy, "age", null);
+ assertThat(wrapper).isNotEmpty();
- // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
- TraitableBean ind = new Entity();
+ // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
+ TraitableBean ind = new Entity();
- FactType RoleClass = kb.getFactType("org.drools.compiler.trait.test", "Role");
- Class> trait2 = RoleClass.getFactClass();
- TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait2, false);
+ FactType RoleClass = kb.getFactType("org.drools.compiler.trait.test", "Role");
+ Class> trait2 = RoleClass.getFactClass();
+ TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait2, false);
- Map wrapper2 = proxy2.getFields();
- assertThat(wrapper2).isEmpty();
+ Map wrapper2 = proxy2.getFields();
+ assertThat(wrapper2).isEmpty();
- proxy2.getFields().put("name", "john");
- assertThat(wrapper2).isNotEmpty();
+ proxy2.getFields().put("name", "john");
+ assertThat(wrapper2).isNotEmpty();
- proxy2.getFields().put("name", null);
- assertThat(wrapper2).isNotEmpty();
+ proxy2.getFields().put("name", null);
+ assertThat(wrapper2).isNotEmpty();
}
- @Test
- public void testWrapperContainsKey() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testWrapperContainsKey(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -542,83 +541,84 @@ public void testWrapperContainsKey() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- impClass.set(imp, "name", "john");
-
- FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = traitClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
-
- Map wrapper = proxy.getFields();
-
- assertThat(wrapper).containsKey("name");
- assertThat(wrapper).containsKey("school");
- assertThat(wrapper).containsKey("age");
- assertThat(wrapper).doesNotContainKey("surname");
-
- proxy.getFields().put("school", "skol");
- proxy.getFields().put("surname", "xxx");
- assertThat(wrapper).containsKey("surname");
-
- // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
- TraitableBean ind = new Entity();
-
- TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait, false);
-
- Map wrapper2 = proxy2.getFields();
- assertThat(wrapper2).containsKey("name");
- assertThat(wrapper2).containsKey("school");
- assertThat(wrapper2).containsKey("age");
- assertThat(wrapper2).doesNotContainKey("surname");
-
- traitClass.set(proxy2, "name", "john");
- proxy2.getFields().put("school", "skol");
- proxy2.getFields().put("surname", "xxx");
- assertThat(wrapper2).containsKey("surname");
-
- FactType traitClass2 = kb.getFactType("org.drools.compiler.trait.test", "Role");
- Class> trait2 = traitClass2.getFactClass();
- TraitableBean ind2 = new Entity();
-
- TraitProxyImpl proxy99 = (TraitProxyImpl) tFactory.getProxy(ind2, trait2, false);
- Map wrapper99 = proxy99.getFields();
-
- assertThat(wrapper99).doesNotContainKey("name");
- assertThat(wrapper99).doesNotContainKey("school");
- assertThat(wrapper99).doesNotContainKey("age");
- assertThat(wrapper99).doesNotContainKey("surname");
-
- proxy99.getFields().put("surname", "xxx");
- proxy99.getFields().put("name", "xyz");
- proxy99.getFields().put("school", "skol");
-
- assertThat(wrapper99).containsKey("name");
- assertThat(wrapper99).containsKey("school");
- assertThat(wrapper99).doesNotContainKey("age");
- assertThat(wrapper99).containsKey("surname");
- assertThat(proxy99.getFields()).hasSize(3);
-
- TraitableBean ind0 = new Entity();
-
- TraitProxyImpl proxy100 = (TraitProxyImpl) tFactory.getProxy(ind0, trait2, false);
- Map wrapper100 = proxy100.getFields();
- assertThat(wrapper100).doesNotContainKey("name");
- assertThat(wrapper100).doesNotContainKey("school");
- assertThat(wrapper100).doesNotContainKey("age");
- assertThat(wrapper100).doesNotContainKey("surname");
-
- TraitProxyImpl proxy101 = (TraitProxyImpl) tFactory.getProxy(ind0, trait, false);
- // object gains properties by virtue of another trait
- // so new props are accessible even using the old proxy
- assertThat(wrapper100).containsKey("name");
- assertThat(wrapper100).containsKey("school");
- assertThat(wrapper100).containsKey("age");
- assertThat(wrapper100).doesNotContainKey("surname");
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ impClass.set(imp, "name", "john");
+
+ FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = traitClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+
+ Map wrapper = proxy.getFields();
+
+ assertThat(wrapper).containsKey("name");
+ assertThat(wrapper).containsKey("school");
+ assertThat(wrapper).containsKey("age");
+ assertThat(wrapper).doesNotContainKey("surname");
+
+ proxy.getFields().put("school", "skol");
+ proxy.getFields().put("surname", "xxx");
+ assertThat(wrapper).containsKey("surname");
+
+ // FactType indClass = kb.getFactType("org.drools.compiler.trait.test","Entity");
+ TraitableBean ind = new Entity();
+
+ TraitProxyImpl proxy2 = (TraitProxyImpl) tFactory.getProxy(ind, trait, false);
+
+ Map wrapper2 = proxy2.getFields();
+ assertThat(wrapper2).containsKey("name");
+ assertThat(wrapper2).containsKey("school");
+ assertThat(wrapper2).containsKey("age");
+ assertThat(wrapper2).doesNotContainKey("surname");
+
+ traitClass.set(proxy2, "name", "john");
+ proxy2.getFields().put("school", "skol");
+ proxy2.getFields().put("surname", "xxx");
+ assertThat(wrapper2).containsKey("surname");
+
+ FactType traitClass2 = kb.getFactType("org.drools.compiler.trait.test", "Role");
+ Class> trait2 = traitClass2.getFactClass();
+ TraitableBean ind2 = new Entity();
+
+ TraitProxyImpl proxy99 = (TraitProxyImpl) tFactory.getProxy(ind2, trait2, false);
+ Map wrapper99 = proxy99.getFields();
+
+ assertThat(wrapper99).doesNotContainKey("name");
+ assertThat(wrapper99).doesNotContainKey("school");
+ assertThat(wrapper99).doesNotContainKey("age");
+ assertThat(wrapper99).doesNotContainKey("surname");
+
+ proxy99.getFields().put("surname", "xxx");
+ proxy99.getFields().put("name", "xyz");
+ proxy99.getFields().put("school", "skol");
+
+ assertThat(wrapper99).containsKey("name");
+ assertThat(wrapper99).containsKey("school");
+ assertThat(wrapper99).doesNotContainKey("age");
+ assertThat(wrapper99).containsKey("surname");
+ assertThat(proxy99.getFields()).hasSize(3);
+
+ TraitableBean ind0 = new Entity();
+
+ TraitProxyImpl proxy100 = (TraitProxyImpl) tFactory.getProxy(ind0, trait2, false);
+ Map wrapper100 = proxy100.getFields();
+ assertThat(wrapper100).doesNotContainKey("name");
+ assertThat(wrapper100).doesNotContainKey("school");
+ assertThat(wrapper100).doesNotContainKey("age");
+ assertThat(wrapper100).doesNotContainKey("surname");
+
+ TraitProxyImpl proxy101 = (TraitProxyImpl) tFactory.getProxy(ind0, trait, false);
+ // object gains properties by virtue of another trait
+ // so new props are accessible even using the old proxy
+ assertThat(wrapper100).containsKey("name");
+ assertThat(wrapper100).containsKey("school");
+ assertThat(wrapper100).containsKey("age");
+ assertThat(wrapper100).doesNotContainKey("surname");
}
- @Test
- public void testInternalComponents1() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testInternalComponents1(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -636,40 +636,41 @@ public void testInternalComponents1() throws Exception {
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = traitClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
- Object proxyFields = proxy.getFields();
- Object coreTraits = imp._getTraitMap();
- Object coreProperties = imp._getDynamicProperties();
-
- assertThat(proxyFields).isNotNull();
- assertThat(coreTraits).isNotNull();
- assertThat(coreProperties).isNotNull();
-
- if (mode == VirtualPropertyMode.MAP) {
- assertThat(proxyFields).isInstanceOf(MapWrapper.class);
- assertThat(coreTraits).isInstanceOf(TraitTypeMapImpl.class);
- assertThat(coreProperties).isInstanceOf(HashMap.class);
- } else {
- assertThat(proxyFields.getClass().getName()).isEqualTo("org.drools.compiler.trait.test.Student.org.drools.compiler.trait.test.Imp_ProxyWrapper");
-
- assertThat(proxyFields).isInstanceOf(TripleBasedStruct.class);
- assertThat(coreTraits).isInstanceOf(TraitTypeMapImpl.class);
- assertThat(coreProperties).isInstanceOf(TripleBasedBean.class);
- }
-
-
- StudentProxyImpl2 sp2 = new StudentProxyImpl2(new Imp2(), null);
- LOGGER.debug(sp2.toString());
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = traitClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+ Object proxyFields = proxy.getFields();
+ Object coreTraits = imp._getTraitMap();
+ Object coreProperties = imp._getDynamicProperties();
+
+ assertThat(proxyFields).isNotNull();
+ assertThat(coreTraits).isNotNull();
+ assertThat(coreProperties).isNotNull();
+
+ if (mode == VirtualPropertyMode.MAP) {
+ assertThat(proxyFields).isInstanceOf(MapWrapper.class);
+ assertThat(coreTraits).isInstanceOf(TraitTypeMapImpl.class);
+ assertThat(coreProperties).isInstanceOf(HashMap.class);
+ } else {
+ assertThat(proxyFields.getClass().getName()).isEqualTo("org.drools.compiler.trait.test.Student.org.drools.compiler.trait.test.Imp_ProxyWrapper");
+
+ assertThat(proxyFields).isInstanceOf(TripleBasedStruct.class);
+ assertThat(coreTraits).isInstanceOf(TraitTypeMapImpl.class);
+ assertThat(coreProperties).isInstanceOf(TripleBasedBean.class);
+ }
+
+
+ StudentProxyImpl2 sp2 = new StudentProxyImpl2(new Imp2(), null);
+ LOGGER.debug(sp2.toString());
}
- @Test
- public void testWrapperKeySetAndValues() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testWrapperKeySetAndValues(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -686,53 +687,54 @@ public void testWrapperKeySetAndValues() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = traitClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
-
- impClass.set(imp, "name", "john");
- proxy.getFields().put("surname", "xxx");
- proxy.getFields().put("name2", "john");
- proxy.getFields().put("nfield", null);
-
- assertThat(proxy.getFields()).hasSize(6);
- assertThat(proxy.getFields().keySet()).contains("name", "surname", "age", "school", "name2", "nfield");
-
- List col1 = new ArrayList<>(proxy.getFields().values());
- List col2 = Arrays.asList("john", null, 0, "xxx", "john", null);
-
- Comparator comp = new Comparator() {
-
- public int compare(Object o1, Object o2) {
- if (o1 == null && o2 != null) {
- return 1;
- }
- if (o1 != null && o2 == null) {
- return -1;
- }
- if (o1 == null && o2 == null) {
- return 0;
- }
- return o1.toString().compareTo(o2.toString());
- }
- };
-
- Collections.sort(col1, comp);
- Collections.sort(col2, comp);
- assertThat(col2).isEqualTo(col1);
-
- assertThat(proxy.getFields()).containsValue(null);
- assertThat(proxy.getFields()).containsValue("john");
- assertThat(proxy.getFields()).containsValue(0);
- assertThat(proxy.getFields()).containsValue("xxx");
- assertThat(proxy.getFields()).doesNotContainValue("randomString");
- assertThat(proxy.getFields()).doesNotContainValue(-96);
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = traitClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+
+ impClass.set(imp, "name", "john");
+ proxy.getFields().put("surname", "xxx");
+ proxy.getFields().put("name2", "john");
+ proxy.getFields().put("nfield", null);
+
+ assertThat(proxy.getFields()).hasSize(6);
+ assertThat(proxy.getFields().keySet()).contains("name", "surname", "age", "school", "name2", "nfield");
+
+ List col1 = new ArrayList<>(proxy.getFields().values());
+ List col2 = Arrays.asList("john", null, 0, "xxx", "john", null);
+
+ Comparator comp = new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ if (o1 == null && o2 != null) {
+ return 1;
+ }
+ if (o1 != null && o2 == null) {
+ return -1;
+ }
+ if (o1 == null && o2 == null) {
+ return 0;
+ }
+ return o1.toString().compareTo(o2.toString());
+ }
+ };
+
+ Collections.sort(col1, comp);
+ Collections.sort(col2, comp);
+ assertThat(col2).isEqualTo(col1);
+
+ assertThat(proxy.getFields()).containsValue(null);
+ assertThat(proxy.getFields()).containsValue("john");
+ assertThat(proxy.getFields()).containsValue(0);
+ assertThat(proxy.getFields()).containsValue("xxx");
+ assertThat(proxy.getFields()).doesNotContainValue("randomString");
+ assertThat(proxy.getFields()).doesNotContainValue(-96);
}
- @Test
- public void testWrapperClearAndRemove() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testWrapperClearAndRemove(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -748,75 +750,76 @@ public void testWrapperClearAndRemove() throws Exception {
TraitFactoryImpl tFactory = (TraitFactoryImpl) RuntimeComponentFactory.get().getTraitFactory(kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test", "Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- impClass.set(imp, "name", "john");
- FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
- Class> trait = traitClass.getFactClass();
- TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
-
- proxy.getFields().put("surname", "xxx");
- proxy.getFields().put("name2", "john");
- proxy.getFields().put("nfield", null);
-
- Set set = new HashSet<>();
- set.add("name");
- set.add("surname");
- set.add("age");
- set.add("school");
- set.add("name2");
- set.add("nfield");
-
- assertThat(proxy.getFields()).hasSize(6);
- assertThat(proxy.getFields().keySet()).isEqualTo(set);
-
- proxy.getFields().clear();
-
- Map fields = proxy.getFields();
- assertThat(fields).hasSize(3);
- assertThat(fields).containsKey("age");
- assertThat(fields).containsKey("school");
- assertThat(fields).containsKey("name");
-
- assertThat(fields.get("age")).isEqualTo(0);
- assertThat(fields.get("school")).isNull();
- assertThat(fields.get("name")).isNotNull();
-
- proxy.getFields().put("surname", "xxx");
- proxy.getFields().put("name2", "john");
- proxy.getFields().put("nfield", null);
- proxy.getFields().put("age", 24);
-
- assertThat(proxy.getFields().get("name")).isEqualTo("john");
- assertThat(proxy.getFields().get("surname")).isEqualTo("xxx");
- assertThat(proxy.getFields().get("name2")).isEqualTo("john");
- assertThat(proxy.getFields().get("nfield")).isEqualTo(null);
- assertThat(proxy.getFields().get("age")).isEqualTo(24);
- assertThat(proxy.getFields().get("school")).isEqualTo(null);
-
- proxy.getFields().remove("surname");
- proxy.getFields().remove("name2");
- proxy.getFields().remove("age");
- proxy.getFields().remove("school");
- proxy.getFields().remove("nfield");
- assertThat(proxy.getFields()).hasSize(3);
-
- assertThat(proxy.getFields().get("age")).isEqualTo(0);
- assertThat(proxy.getFields().get("school")).isEqualTo(null);
- assertThat(proxy.getFields().get("name")).isEqualTo("john");
-
- assertThat(proxy.getFields().get("nfield")).isEqualTo(null);
- assertThat(proxy.getFields()).doesNotContainKey("nfield");
-
- assertThat(proxy.getFields().get("name2")).isEqualTo(null);
- assertThat(proxy.getFields()).doesNotContainKey("name2");
-
- assertThat(proxy.getFields().get("surname")).isEqualTo(null);
- assertThat(proxy.getFields()).doesNotContainKey("surname");
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ impClass.set(imp, "name", "john");
+ FactType traitClass = kb.getFactType("org.drools.compiler.trait.test", "Student");
+ Class> trait = traitClass.getFactClass();
+ TraitProxyImpl proxy = (TraitProxyImpl) tFactory.getProxy(imp, trait, false);
+
+ proxy.getFields().put("surname", "xxx");
+ proxy.getFields().put("name2", "john");
+ proxy.getFields().put("nfield", null);
+
+ Set set = new HashSet<>();
+ set.add("name");
+ set.add("surname");
+ set.add("age");
+ set.add("school");
+ set.add("name2");
+ set.add("nfield");
+
+ assertThat(proxy.getFields()).hasSize(6);
+ assertThat(proxy.getFields().keySet()).isEqualTo(set);
+
+ proxy.getFields().clear();
+
+ Map fields = proxy.getFields();
+ assertThat(fields).hasSize(3);
+ assertThat(fields).containsKey("age");
+ assertThat(fields).containsKey("school");
+ assertThat(fields).containsKey("name");
+
+ assertThat(fields.get("age")).isEqualTo(0);
+ assertThat(fields.get("school")).isNull();
+ assertThat(fields.get("name")).isNotNull();
+
+ proxy.getFields().put("surname", "xxx");
+ proxy.getFields().put("name2", "john");
+ proxy.getFields().put("nfield", null);
+ proxy.getFields().put("age", 24);
+
+ assertThat(proxy.getFields().get("name")).isEqualTo("john");
+ assertThat(proxy.getFields().get("surname")).isEqualTo("xxx");
+ assertThat(proxy.getFields().get("name2")).isEqualTo("john");
+ assertThat(proxy.getFields().get("nfield")).isEqualTo(null);
+ assertThat(proxy.getFields().get("age")).isEqualTo(24);
+ assertThat(proxy.getFields().get("school")).isEqualTo(null);
+
+ proxy.getFields().remove("surname");
+ proxy.getFields().remove("name2");
+ proxy.getFields().remove("age");
+ proxy.getFields().remove("school");
+ proxy.getFields().remove("nfield");
+ assertThat(proxy.getFields()).hasSize(3);
+
+ assertThat(proxy.getFields().get("age")).isEqualTo(0);
+ assertThat(proxy.getFields().get("school")).isEqualTo(null);
+ assertThat(proxy.getFields().get("name")).isEqualTo("john");
+
+ assertThat(proxy.getFields().get("nfield")).isEqualTo(null);
+ assertThat(proxy.getFields()).doesNotContainKey("nfield");
+
+ assertThat(proxy.getFields().get("name2")).isEqualTo(null);
+ assertThat(proxy.getFields()).doesNotContainKey("name2");
+
+ assertThat(proxy.getFields().get("surname")).isEqualTo(null);
+ assertThat(proxy.getFields()).doesNotContainKey("surname");
}
- @Test
- public void testIsAEvaluator() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAEvaluator(VirtualPropertyMode mode) {
String source = "package org.drools.compiler.trait.test;\n" +
"\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -886,8 +889,9 @@ public void testIsAEvaluator() {
- @Test
- public void testIsA() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsA(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitIsA.drl";
KieSession ks = getSession(source);
@@ -911,8 +915,9 @@ public void testIsA() {
- @Test
- public void testOverrideType() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testOverrideType(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitOverride.drl";
KieSession ks = getSession(source);
@@ -922,17 +927,18 @@ public void testOverrideType() {
ks.setGlobal("list", info);
assertThatException()
- .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
- .isThrownBy(() -> ks.fireAllRules())
- .extracting(e -> e.getCause())
- .isInstanceOf(UnsupportedOperationException.class);
+ .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
+ .isThrownBy(() -> ks.fireAllRules())
+ .extracting(e -> e.getCause())
+ .isInstanceOf(UnsupportedOperationException.class);
}
- @Test
- public void testOverrideType2() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testOverrideType2(VirtualPropertyMode mode) {
String drl = "package org.drools.compiler.trait.test; \n" +
"import org.drools.base.factmodel.traits.Traitable; \n" +
"" +
@@ -951,16 +957,17 @@ public void testOverrideType2() {
TraitFactoryImpl.setMode(mode, ks.getKieBase());
assertThatException()
- .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
- .isThrownBy(() -> ks.fireAllRules())
- .extracting(e -> e.getCause())
- .isInstanceOf(UnsupportedOperationException.class);
+ .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
+ .isThrownBy(() -> ks.fireAllRules())
+ .extracting(e -> e.getCause())
+ .isInstanceOf(UnsupportedOperationException.class);
}
- @Test
- public void testOverrideType3() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testOverrideType3(VirtualPropertyMode mode) {
String drl = "package org.drools.compiler.trait.test; \n" +
"import org.drools.base.factmodel.traits.Traitable; \n" +
"" +
@@ -980,15 +987,16 @@ public void testOverrideType3() {
assertThatException()
- .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
- .isThrownBy(() -> ks.fireAllRules())
- .extracting(e -> e.getCause())
- .isInstanceOf(UnsupportedOperationException.class);
+ .as("An exception was expected since a trait can't override the type of a core class field with these settings ")
+ .isThrownBy(() -> ks.fireAllRules())
+ .extracting(e -> e.getCause())
+ .isInstanceOf(UnsupportedOperationException.class);
}
- @Test
- public void testTraitLegacy() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitLegacy(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitLegacyTrait.drl";
KieSession ks = getSession(source);
@@ -1021,8 +1029,9 @@ private void printDebugInfoSessionObjects(final Collection extends Object> fac
LOGGER.debug(" -------------- ---------------- ");
}
- @Test
- public void testTraitCollections() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitCollections(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitCollections.drl";
KieSession ks = getSession(source);
@@ -1041,8 +1050,9 @@ public void testTraitCollections() {
}
- @Test
- public void testTraitCore() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitCore(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitLegacyCore.drl";
KieSession ks = getSession(source);
@@ -1061,8 +1071,9 @@ public void testTraitCore() {
}
- @Test
- public void traitWithEquality() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitWithEquality(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitWithEquality.drl";
KieSession ks = getSession(source);
@@ -1078,8 +1089,9 @@ public void traitWithEquality() {
}
- @Test
- public void traitDeclared() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitDeclared(VirtualPropertyMode mode) {
List trueTraits = new ArrayList();
List untrueTraits = new ArrayList();
@@ -1099,8 +1111,9 @@ public void traitDeclared() {
assertThat(untrueTraits).doesNotContain(1);
}
- @Test
- public void traitPojo() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitPojo(VirtualPropertyMode mode) {
List trueTraits = new ArrayList();
List untrueTraits = new ArrayList();
@@ -1120,8 +1133,9 @@ public void traitPojo() {
assertThat(untrueTraits).doesNotContain(1);
}
- @Test
- public void testIsAOperator() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAOperator(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitIsA2.drl";
KieSession ksession = getSession(source);
TraitFactoryImpl.setMode(mode, ksession.getKieBase());
@@ -1146,8 +1160,9 @@ public void testIsAOperator() {
}
- @Test
- public void testManyTraits() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testManyTraits(VirtualPropertyMode mode) {
String source = "" +
"import " + Message.class.getCanonicalName() + ";\n" +
"" +
@@ -1205,8 +1220,9 @@ public void testManyTraits() {
}
- @Test
- public void traitManyTimes() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitManyTimes(VirtualPropertyMode mode) {
KieSession ksession = getSession("org/drools/compiler/factmodel/traits/testTraitDonMultiple.drl");
TraitFactoryImpl.setMode(mode, ksession.getKieBase());
@@ -1229,8 +1245,9 @@ public void traitManyTimes() {
}
// BZ #748752
- @Test
- public void traitsInBatchExecution() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitsInBatchExecution(VirtualPropertyMode mode) {
String str = "package org.jboss.qa.brms.traits\n" +
"import org.drools.traits.compiler.Person;\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -1298,8 +1315,10 @@ public void traitsInBatchExecution() {
assertThat(list).contains(2);
}
- @Test(timeout=10000)
- public void testManyTraitsStateless() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ @Timeout(10000)
+ public void testManyTraitsStateless(VirtualPropertyMode mode) {
String source = "" +
"import " + Message.class.getCanonicalName() + ";\n" +
"" +
@@ -1357,8 +1376,9 @@ public void testManyTraitsStateless() {
- @Test
- public void testAliasing() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testAliasing(VirtualPropertyMode mode) {
String drl = "package org.drools.traits\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
"import org.drools.base.factmodel.traits.Alias;\n" +
@@ -1430,8 +1450,9 @@ public void testAliasing() {
- @Test
- public void testTraitLogicalRemoval() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitLogicalRemoval(VirtualPropertyMode mode) {
String drl = "package org.drools.trait.test;\n" +
"\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -1505,8 +1526,9 @@ public void testTraitLogicalRemoval() {
}
- @Test
- public void testTMSConsistencyWithNonTraitableBeans() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTMSConsistencyWithNonTraitableBeans(VirtualPropertyMode mode) {
String s1 = "package org.drools.test;\n" +
"import org.drools.traits.compiler.Person; \n" +
@@ -1569,8 +1591,9 @@ public static class TBean {
- @Test
- public void testTraitsLegacyWrapperCoherence() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitsLegacyWrapperCoherence(VirtualPropertyMode mode) {
String str = "package org.drools.trait.test; \n" +
"global java.util.List list; \n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -1641,8 +1664,9 @@ public void testTraitsLegacyWrapperCoherence() {
- @Test
- public void testHasTypes() throws Exception {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testHasTypes(VirtualPropertyMode mode) throws Exception {
String source = "org/drools/compiler/factmodel/traits/testTraitDon.drl";
@@ -1659,31 +1683,32 @@ public void testHasTypes() throws Exception {
TraitFactoryImpl.setMode(mode, kb);
FactType impClass = kb.getFactType("org.drools.compiler.trait.test","Imp");
- TraitableBean imp = (TraitableBean) impClass.newInstance();
- impClass.set(imp, "name", "aaabcd");
+ TraitableBean imp = (TraitableBean) impClass.newInstance();
+ impClass.set(imp, "name", "aaabcd");
- Class> trait = kb.getFactType("org.drools.compiler.trait.test","Student").getFactClass();
- Class> trait2 = kb.getFactType("org.drools.compiler.trait.test","Role").getFactClass();
+ Class> trait = kb.getFactType("org.drools.compiler.trait.test","Student").getFactClass();
+ Class> trait2 = kb.getFactType("org.drools.compiler.trait.test","Role").getFactClass();
- assertThat(trait).isNotNull();
+ assertThat(trait).isNotNull();
- TraitProxyImpl proxy = (TraitProxyImpl) traitBuilder.getProxy(imp, trait, false);
- Thing thing = traitBuilder.getProxy(imp, Thing.class, false);
+ TraitProxyImpl proxy = (TraitProxyImpl) traitBuilder.getProxy(imp, trait, false);
+ Thing thing = traitBuilder.getProxy(imp, Thing.class, false);
- TraitableBean core = proxy.getObject();
+ TraitableBean core = proxy.getObject();
- TraitProxyImpl proxy2 = (TraitProxyImpl) traitBuilder.getProxy(imp, trait, false);
- Thing thing2 = traitBuilder.getProxy(imp, Thing.class, false);
+ TraitProxyImpl proxy2 = (TraitProxyImpl) traitBuilder.getProxy(imp, trait, false);
+ Thing thing2 = traitBuilder.getProxy(imp, Thing.class, false);
- assertThat(proxy2).isSameAs(proxy);
- assertThat(thing2).isSameAs(thing);
+ assertThat(proxy2).isSameAs(proxy);
+ assertThat(thing2).isSameAs(thing);
- assertThat(core.getTraits()).hasSize(2);
+ assertThat(core.getTraits()).hasSize(2);
}
- @Test
- public void testTraitRedundancy() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitRedundancy(VirtualPropertyMode mode) {
String str = "package org.drools.traits.compiler.factmodel.traits; \n" +
"global java.util.List list; \n" +
"" +
@@ -1742,8 +1767,9 @@ public void testTraitRedundancy() {
}
- @Test
- public void traitSimpleTypes() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitSimpleTypes(VirtualPropertyMode mode) {
String s1 = "package org.drools.factmodel.traits;\n" +
"\n" +
@@ -1798,8 +1824,9 @@ public void traitSimpleTypes() {
- @Test
- public void testTraitEncoding() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitEncoding(VirtualPropertyMode mode) {
String s1 = "package org.drools.base.factmodel.traits;\n" +
"import " + Entity.class.getCanonicalName() + ";\n" +
"declare trait A end\n" +
@@ -1873,15 +1900,15 @@ public void testTraitEncoding() {
}
-
-
- @Test
- public void testTraitActualTypeCodeWithEntities() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitActualTypeCodeWithEntities(VirtualPropertyMode mode) {
testTraitActualTypeCodeWithEntities("ent", mode);
}
- @Test
- public void testTraitActualTypeCodeWithCoreMap() {
+ @ParameterizedTest()
+ @MethodSource("parameters")
+ public void testTraitActualTypeCodeWithCoreMap(VirtualPropertyMode mode) {
testTraitActualTypeCodeWithEntities("kor", mode);
}
@@ -1933,8 +1960,9 @@ void testTraitActualTypeCodeWithEntities(String trig, VirtualPropertyMode mode)
}
- @Test
- public void testTraitModifyCore() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitModifyCore(VirtualPropertyMode mode) {
String s1 = "package test; " +
"import org.drools.base.factmodel.traits.*; " +
"" +
@@ -2021,8 +2049,9 @@ public void testTraitModifyCore() {
- @Test
- public void testTraitModifyCore2() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitModifyCore2(VirtualPropertyMode mode) {
String s1 = "package test; " +
"import org.drools.base.factmodel.traits.*; " +
"" +
@@ -2107,8 +2136,9 @@ public void testTraitModifyCore2() {
}
- @Test
- public void testTraitModifyCore2a() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitModifyCore2a(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*;\n" +
"import org.drools.traits.core.factmodel.*;\n" +
@@ -2170,8 +2200,9 @@ public void testTraitModifyCore2a() {
- @Test
- public void testTraitModifyCore3() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitModifyCore3(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*;\n" +
"import org.drools.traits.core.factmodel.*;\n" +
@@ -2281,8 +2312,9 @@ public void testTraitModifyCore3() {
- @Test
- public void testTraitModifyCoreWithPropertyReactivity() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitModifyCoreWithPropertyReactivity(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*;\n" +
"import org.drools.traits.core.factmodel.*;\n" +
@@ -2390,8 +2422,9 @@ public void testTraitModifyCoreWithPropertyReactivity() {
public static interface IntfParent {}
- @Test
- public void testTraitEncodeExtendingNonTrait() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitEncodeExtendingNonTrait(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import " + IntfParent.class.getCanonicalName() + ";\n" +
@@ -2426,8 +2459,9 @@ public void testTraitEncodeExtendingNonTrait() {
- @Test
- public void isAWithBackChaining() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void isAWithBackChaining(VirtualPropertyMode mode) {
String source = "org/drools/compiler/factmodel/traits/testTraitIsAWithBC.drl";
KieSession ksession = getSession(source);
@@ -2448,8 +2482,9 @@ public void isAWithBackChaining() {
- @Test
- public void testIsAEvaluatorOnClassification() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAEvaluatorOnClassification(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"\n" +
"global java.util.List list; \n" +
@@ -2506,8 +2541,9 @@ public void testIsAEvaluatorOnClassification() {
- @Test
- public void testShedWithTMS() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testShedWithTMS(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"\n" +
"global java.util.List list; \n" +
@@ -2584,8 +2620,9 @@ public void testShedWithTMS() {
- @Test
- public void testTraitInitialization() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitInitialization(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -2659,8 +2696,9 @@ public void testTraitInitialization() {
- @Test
- public void testUnTraitedBean() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testUnTraitedBean(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -2707,8 +2745,9 @@ public void testUnTraitedBean() {
- @Test
- public void testIsAOptimization() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAOptimization(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -2767,8 +2806,9 @@ public void testIsAOptimization() {
- @Test
- public void testTypeRefractionOnInsert() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTypeRefractionOnInsert(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -2820,8 +2860,9 @@ public void testTypeRefractionOnInsert() {
- @Test
- public void testTypeRefractionOnQuery() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTypeRefractionOnQuery(VirtualPropertyMode mode) {
String source = "declare BaseObject\n" +
"@Traitable\n" +
"id : String @key\n" +
@@ -2862,8 +2903,9 @@ public void testTypeRefractionOnQuery() {
}
- @Test
- public void testTypeRefractionOnQuery2() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTypeRefractionOnQuery2(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -2922,8 +2964,9 @@ public void testTypeRefractionOnQuery2() {
}
- @Test
- public void testNodePartitioningByProxies() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testNodePartitioningByProxies(VirtualPropertyMode mode) {
String source = "package t.x " +
"import java.util.*; " +
"import org.drools.base.factmodel.traits.Thing " +
@@ -2990,8 +3033,9 @@ public void testNodePartitioningByProxies() {
}
- @Test
- public void testNodePartitioningByProxiesAfterShed() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testNodePartitioningByProxiesAfterShed(VirtualPropertyMode mode) {
String source = "package t.x " +
"import java.util.*; " +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -3063,8 +3107,9 @@ public void testNodePartitioningByProxiesAfterShed() {
}
- @Test
- public void testTypeRefractionOnQueryWithIsA() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTypeRefractionOnQueryWithIsA(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -3121,8 +3166,9 @@ public void testTypeRefractionOnQueryWithIsA() {
- @Test
- public void testCoreUpdate4() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testCoreUpdate4(VirtualPropertyMode mode) {
String source = "package t.x \n" +
"import java.util.*; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -3179,8 +3225,9 @@ public void testCoreUpdate4() {
- @Test
- public void traitLogicalSupportAnddelete() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitLogicalSupportAnddelete(VirtualPropertyMode mode) {
String drl = "package org.drools.trait.test;\n" +
"\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -3311,8 +3358,9 @@ public void traitLogicalSupportAnddelete() {
assertThat(ksession.getObjects()).hasSize(1);
}
- @Test
- public void testShedThing() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testShedThing(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*;\n" +
"import org.drools.traits.core.factmodel.*;\n" +
@@ -3382,8 +3430,9 @@ public void testShedThing() {
}
- @Test
- public void testdeleteThings() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testdeleteThings(VirtualPropertyMode mode) {
String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*;\n" +
"import org.drools.traits.core.factmodel.*;\n" +
@@ -3452,8 +3501,9 @@ public void testdeleteThings() {
assertThat(ksession.getObjects()).isEmpty();
}
- @Test
- public void traitLogicalRemovalSimple() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void traitLogicalRemovalSimple(VirtualPropertyMode mode) {
String drl = "package org.drools.compiler.trait.test;\n" +
"\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -3540,8 +3590,9 @@ public XYZ() {
}
- @Test
- public void testTraitDonLegacyClassWithoutEmptyConstructor() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitDonLegacyClassWithoutEmptyConstructor(VirtualPropertyMode mode) {
String drl = "package org.drools.compiler.trait.test;\n" +
"\n" +
"import " + TraitableFoo.class.getCanonicalName() + ";" +
@@ -3576,8 +3627,9 @@ public void testTraitDonLegacyClassWithoutEmptyConstructor() {
- @Test
- public void testdeleteCoreObjectChained() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testdeleteCoreObjectChained(VirtualPropertyMode mode) {
String source = "package org.drools.test;\n" +
"import java.util.List; \n" +
"import org.drools.base.factmodel.traits.Thing \n" +
@@ -3642,8 +3694,9 @@ public void testdeleteCoreObjectChained() {
}
- @Test
- public void testUpdateLegacyClass() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testUpdateLegacyClass(VirtualPropertyMode mode) {
String source = "package org.drools.text;\n" +
"\n" +
"global java.util.List list;\n" +
@@ -3700,8 +3753,9 @@ public void testUpdateLegacyClass() {
- @Test
- public void testSoftPropertyClash() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testSoftPropertyClash(VirtualPropertyMode mode) {
String source = "package org.drools.text;\n" +
"\n" +
"global java.util.List list;\n" +
@@ -3782,8 +3836,9 @@ public void testSoftPropertyClash() {
}
- @Test
- public void testMultipleModifications() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testMultipleModifications(VirtualPropertyMode mode) {
String drl = "package org.drools.traits.test;\n" +
"\n" +
"import org.drools.base.factmodel.traits.Traitable;\n" +
@@ -3895,8 +3950,9 @@ public void testMultipleModifications() {
}
- @Test
- public void testPropagation() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testPropagation(VirtualPropertyMode mode) {
String drl = "package org.drools.test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"\n" +
@@ -3965,8 +4021,9 @@ public void testPropagation() {
}
- @Test
- public void testParentBlockers() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testParentBlockers(VirtualPropertyMode mode) {
String drl = "package org.drools.test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"\n" +
@@ -4002,8 +4059,9 @@ public void testParentBlockers() {
}
- @Test
- public void testTraitLogicalTMS() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitLogicalTMS(VirtualPropertyMode mode) {
String drl = "package org.drools.test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"\n" +
@@ -4052,8 +4110,9 @@ public void testTraitLogicalTMS() {
}
- @Test
- public void testTraitNoType() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitNoType(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
@@ -4109,8 +4168,9 @@ public void testTraitNoType() {
- @Test
- public void testTraitdeleteOrder() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitdeleteOrder(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
@@ -4160,8 +4220,9 @@ public void objectDeleted(org.kie.api.event.rule.ObjectDeletedEvent objectRetrac
}
- @Test
- public void testTraitWithManySoftFields() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitWithManySoftFields(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
@@ -4245,8 +4306,9 @@ public void reset() {
}
- @Test
- public void testDonManyTraitsAtOnce() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testDonManyTraitsAtOnce(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
@@ -4366,8 +4428,9 @@ public void testDonManyTraitsAtOnce() {
assertThat(list).contains(0, 1, 2, 3);
}
- @Test
- public void testDonManyTraitsAtOnce2() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testDonManyTraitsAtOnce2(VirtualPropertyMode mode) {
String drl = "" +
"package org.drools.base.factmodel.traits.test;\n" +
"\n" +
@@ -4451,35 +4514,36 @@ public void run() {
}
}
- @Test
- @Ignore("Triple Store is not thread safe and needs to be rewritten")
- public void testMultithreadingTraits() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ @Disabled("Triple Store is not thread safe and needs to be rewritten")
+ public void testMultithreadingTraits(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.TraitTest.Item;\n" +
"declare Item end\n" +
"declare trait ItemStyle\n" +
- " id: String\n" +
- " adjustable: boolean\n" +
+ " id: String\n" +
+ " adjustable: boolean\n" +
"end\n" +
"rule \"Don ItemStyle\"\n" +
- " no-loop true\n" +
- " when\n" +
- " $p : Item ()\n" +
- " not ItemStyle (id == $p.id)\n" +
- " then\n" +
- " don($p, ItemStyle.class);\n" +
+ " no-loop true\n" +
+ " when\n" +
+ " $p : Item ()\n" +
+ " not ItemStyle (id == $p.id)\n" +
+ " then\n" +
+ " don($p, ItemStyle.class);\n" +
"end\n" +
"rule \"Item Style - Adjustable\"" +
- " no-loop true" +
- " when" +
- " $style : ItemStyle (!adjustable)" +
- " Item (" +
- " id == $style.id " +
- " )" +
- " then" +
- " modify($style) {" +
- " setAdjustable(true)" +
- " };" +
+ " no-loop true" +
+ " when" +
+ " $style : ItemStyle (!adjustable)" +
+ " Item (" +
+ " id == $style.id " +
+ " )" +
+ " then" +
+ " modify($style) {" +
+ " setAdjustable(true)" +
+ " };" +
"end";
KieBase kbase = getKieBaseFromString(s1);
TraitFactoryImpl.setMode(mode, kbase);
@@ -4505,8 +4569,9 @@ public void testMultithreadingTraits() throws InterruptedException {
}
- @Test
- public void testShedOneLastTrait() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testShedOneLastTrait(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"global java.util.List list;\n" +
@@ -4517,15 +4582,15 @@ public void testShedOneLastTrait() throws InterruptedException {
"end\n" +
"" +
"rule \"Don ItemStyle\"\n" +
- " when\n" +
- " then\n" +
- " don(new Core(), Mask.class);\n" +
+ " when\n" +
+ " then\n" +
+ " don(new Core(), Mask.class);\n" +
"end\n" +
"" +
"rule \"React\" \n" +
- " when \n" +
+ " when \n" +
" $s : String() \n" +
- " $m : Mask() \n" +
+ " $m : Mask() \n" +
"then \n" +
" delete($s); \n" +
" shed($m, Mask.class); \n" +
@@ -4559,8 +4624,9 @@ public void testShedOneLastTrait() throws InterruptedException {
- @Test
- public void testShedThingCompletelyThenDonAgain() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testShedThingCompletelyThenDonAgain(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"global java.util.List list;\n" +
@@ -4571,35 +4637,35 @@ public void testShedThingCompletelyThenDonAgain() throws InterruptedException {
"declare trait Mask2 end\n" +
"" +
"rule \"Don ItemStyle\"\n" +
- " when\n" +
+ " when\n" +
" $s : String(this == \"don1\") \n" +
- " then\n" +
+ " then\n" +
" delete($s); \n" +
- " don(new Core(), Mask.class);\n" +
+ " don(new Core(), Mask.class);\n" +
"end\n" +
"" +
"rule \"Clear\" \n" +
- " when \n" +
+ " when \n" +
" $s : String(this == \"shed1\") \n" +
- " $m : Mask() \n" +
+ " $m : Mask() \n" +
"then \n" +
" delete($s); \n" +
" shed($m, Thing.class); \n" +
"end\n" +
"" +
"rule \"Add\" \n" +
- " when \n" +
+ " when \n" +
" $s : String(this == \"don2\") \n" +
- " $c : Core() \n" +
+ " $c : Core() \n" +
"then \n" +
" delete($s); \n" +
" don($c, Mask2.class); \n" +
"end\n" +
"" +
"rule \"Clear Again\" \n" +
- " when \n" +
+ " when \n" +
" $s : String(this == \"shed2\") \n" +
- " $m : Mask2() \n" +
+ " $m : Mask2() \n" +
"then \n" +
" delete($s); \n" +
" shed($m, Mask2.class); \n" +
@@ -4648,8 +4714,9 @@ public void testShedThingCompletelyThenDonAgain() throws InterruptedException {
}
- @Test
- public void testTraitImplicitInsertionExceptionOnNonTraitable() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitImplicitInsertionExceptionOnNonTraitable(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"global java.util.List list;\n" +
@@ -4659,9 +4726,9 @@ public void testTraitImplicitInsertionExceptionOnNonTraitable() throws Interrupt
"declare trait Mask id : String end\n" +
"" +
"rule \"Don ItemStyle\"\n" +
- " when\n" +
- " then\n" +
- " don(new Core(), Mask.class);\n" +
+ " when\n" +
+ " then\n" +
+ " don(new Core(), Mask.class);\n" +
"end\n" +
"" +
"";
@@ -4689,8 +4756,9 @@ public static interface SomeTrait extends Thing {
public void setFoo(String foo);
}
- @Test
- public void testTraitLegacyTraitableWithLegacyTrait() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTraitLegacyTraitableWithLegacyTrait(VirtualPropertyMode mode) {
final String s1 = "package org.drools.compiler.factmodel.traits;\n" +
"import " + TraitTest.class.getName() + ".SomeTrait; \n" +
"import " + StudentImpl.class.getCanonicalName() + ";\n" +
@@ -4699,9 +4767,9 @@ public void testTraitLegacyTraitableWithLegacyTrait() {
"global java.util.List list;\n" +
"" +
"rule \"Don ItemStyle\"\n" +
- " when\n" +
- " then\n" +
- " don(new StudentImpl(), SomeTrait.class);\n" +
+ " when\n" +
+ " then\n" +
+ " don(new StudentImpl(), SomeTrait.class);\n" +
"end\n";
KieBase kbase = getKieBaseFromString(s1);
@@ -4716,8 +4784,9 @@ public void testTraitLegacyTraitableWithLegacyTrait() {
assertThat(knowledgeSession.getObjects()).hasSize(2);
}
- @Test
- public void testIsALegacyTrait() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsALegacyTrait(VirtualPropertyMode mode) {
final String s1 = "package org.drools.traits.compiler.factmodel.traits;\n" +
"import " + TraitTest.class.getName() + ".SomeTrait; \n" +
"import " + StudentImpl.class.getCanonicalName() + ";\n" +
@@ -4728,10 +4797,10 @@ public void testIsALegacyTrait() {
"declare trait IStudent end \n" +
"" +
"rule \"Don ItemStyle\"\n" +
- " when\n" +
- " then\n" +
- " insert(new StudentImpl());\n" +
- " don(new Entity(), IStudent.class);\n" +
+ " when\n" +
+ " then\n" +
+ " insert(new StudentImpl());\n" +
+ " don(new Entity(), IStudent.class);\n" +
"end\n" +
"" +
"rule Check " +
@@ -4754,9 +4823,10 @@ public void testIsALegacyTrait() {
assertThat(list).containsExactly(1);
}
- @Category(ReviseTraitTestWithPRAlwaysCategory.class)
- @Test
- public void testClassLiteralsWithOr() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ @Disabled("Check ReviseTraitTestWithPRAlwaysCategory.java file")
+ public void testClassLiteralsWithOr(VirtualPropertyMode mode) {
String drl = "package org.drools.test; " +
"import org.drools.base.factmodel.traits.*; " +
@@ -4815,8 +4885,9 @@ public void testClassLiteralsWithOr() {
- @Test
- public void testIsASwappedArg() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsASwappedArg(VirtualPropertyMode mode) {
String drl = "package org.drools.traits.compiler.factmodel.traits;\n" +
"import " + TraitTest.class.getName() + ".SomeTrait; \n" +
@@ -4877,8 +4948,9 @@ public void testIsASwappedArg() {
}
- @Test
- public void testHierarchyEncodeOnPackageMerge() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testHierarchyEncodeOnPackageMerge(VirtualPropertyMode mode) {
String drl0 = "package org.drools.test; " +
"declare trait X end ";
@@ -4921,8 +4993,10 @@ public void testHierarchyEncodeOnPackageMerge() {
- @Test @Ignore
- public void testDonThenReinsert() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ @Disabled
+ public void testDonThenReinsert(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test;\n" +
"import org.drools.base.factmodel.traits.*; \n" +
"import org.drools.traits.compiler.factmodel.traits.TraitTest.TBean;\n" +
@@ -4938,15 +5012,15 @@ public void testDonThenReinsert() throws InterruptedException {
"end " +
"" +
"rule 'Don ItemStyle' " +
- " when\n" +
+ " when\n" +
" $e : TBean() " +
- " then " +
- " don($e, Mask.class);\n" +
+ " then " +
+ " don($e, Mask.class);\n" +
"end\n" +
"" +
"rule \"React\" \n" +
- " when \n" +
- " $m : Mask() \n" +
+ " when \n" +
+ " $m : Mask() \n" +
"then \n" +
"end\n" +
"" +
@@ -4980,8 +5054,9 @@ public void testDonThenReinsert() throws InterruptedException {
}
- @Test
- public void testCastOnTheFly() throws InterruptedException {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testCastOnTheFly(VirtualPropertyMode mode) throws InterruptedException {
final String s1 = "package test; " +
"import org.drools.base.factmodel.traits.*; " +
@@ -5005,8 +5080,8 @@ public void testCastOnTheFly() throws InterruptedException {
"rule Init " +
" dialect 'mvel' " +
- " when " +
- " then " +
+ " when " +
+ " then " +
" Foo o = insert(new Foo(42)).as(Foo.class); " +
" list.add(o.getId()); " +
"end " +
@@ -5035,8 +5110,9 @@ public void testCastOnTheFly() throws InterruptedException {
- @Test
- public void testDonModify() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testDonModify(VirtualPropertyMode mode) {
String drl =
"import org.drools.traits.core.factmodel.Entity;\n" +
"import org.drools.traits.compiler.factmodel.traits.IPerson;\n" +
@@ -5077,8 +5153,9 @@ public void testDonModify() {
assertThat(kSession.fireAllRules()).isEqualTo(3);
}
- @Test
- public void testAlphaNodeSharing() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testAlphaNodeSharing(VirtualPropertyMode mode) {
String drl =
"package test; " +
"import " + Entity.class.getName() + " " +
@@ -5116,8 +5193,9 @@ public void testAlphaNodeSharing() {
assertThat(otn.getObjectSinkPropagator().getSinks().length).isEqualTo(1);
}
- @Test
- public void testPartitionWithSiblingsOnDelete() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testPartitionWithSiblingsOnDelete(VirtualPropertyMode mode) {
String drl =
"import " + Entity.class.getName() + ";" +
"global java.util.List list; " +
@@ -5169,8 +5247,9 @@ public void testPartitionWithSiblingsOnDelete() {
}
- @Test
- public void testTupleIntegrityOnModification() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testTupleIntegrityOnModification(VirtualPropertyMode mode) {
String drl = "package test " +
"import " + Entity.class.getName() + ";" +
"global java.util.List list; " +
@@ -5220,8 +5299,9 @@ public void testTupleIntegrityOnModification() {
assertThat(list).containsExactly(0, 42);
}
- @Test
- public void testShedVacancy() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testShedVacancy(VirtualPropertyMode mode) {
String drl = "package org.drools.test " +
"import " + Entity.class.getName() + ";" +
"global java.util.List list; " +
@@ -5313,8 +5393,9 @@ public void testShedVacancy() {
}
- @Test
- public void testExternalUpdateWithProxyRefreshInEqualityMode() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testExternalUpdateWithProxyRefreshInEqualityMode(VirtualPropertyMode mode) {
String drl = "package org.drools.trait.test; " +
"import " + ExtEntity.class.getCanonicalName() + "; " +
"global " + List.class.getName() + " list; " +
@@ -5354,8 +5435,9 @@ public void testExternalUpdateWithProxyRefreshInEqualityMode() {
}
- @Test
- public void testIsAInstanceOf() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAInstanceOf(VirtualPropertyMode mode) {
String drl = "package org.drools.test; " +
"import " + StudentImpl.class.getName() + "; " +
@@ -5387,8 +5469,9 @@ public void testIsAInstanceOf() {
}
- @Test
- public void testIsAInstanceOfNonTraitable() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIsAInstanceOfNonTraitable(VirtualPropertyMode mode) {
String drl = "package org.drools.test; " +
"global java.util.List list; " +
@@ -5449,8 +5532,9 @@ protected Set checkOTNPartitioning(TraitableBean core, KieSession wm) {
return otns;
}
- @Test
- public void testSerializeKieBaseWithTraits() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testSerializeKieBaseWithTraits(VirtualPropertyMode mode) {
// DRL-1123
String drl = "package org.drools.test; " +
"import " + StudentImpl.class.getName() + "; " +
@@ -5482,8 +5566,9 @@ public void testSerializeKieBaseWithTraits() {
assertThat(list).containsExactly(1, 2);
}
- @Test
- public void testMixin2() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testMixin2(VirtualPropertyMode mode) {
String drl =
"package org.drools.test.traits\n" +
"import " + Scholar.class.getCanonicalName() + ";\n" +
@@ -5590,13 +5675,14 @@ public String getZValue() {
}
}
- @Test
- public void testMixinWithConflictsUsingDeclarationOrder() {
- checkMixinResolutionUsesOrder("Y,Z", "Y");
- checkMixinResolutionUsesOrder("Z,Y", "Z");
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testMixinWithConflictsUsingDeclarationOrder(VirtualPropertyMode mode) {
+ checkMixinResolutionUsesOrder("Y,Z", "Y", mode);
+ checkMixinResolutionUsesOrder("Z,Y", "Z", mode);
}
- private void checkMixinResolutionUsesOrder(String interfaces, String first) {
+ private void checkMixinResolutionUsesOrder(String interfaces, String first, VirtualPropertyMode mode) {
String drl =
"package org.drools.test.traits\n" +
"import " + Y.class.getCanonicalName() + ";\n" +
@@ -5640,8 +5726,9 @@ private void checkMixinResolutionUsesOrder(String interfaces, String first) {
assertThat(list.get(2)).isEqualTo(first);
}
- @Test
- public void testMixinWithConflictsThrowingError() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testMixinWithConflictsThrowingError(VirtualPropertyMode mode) {
String drl =
"package org.drools.test.traits\n" +
"import " + Y.class.getCanonicalName() + ";\n" +
@@ -5680,8 +5767,9 @@ public void testMixinWithConflictsThrowingError() {
assertThatException().as("don should fail due to the conflict in getShared() method").isThrownBy(() -> ks.fireAllRules());
}
- @Test
- public void testPreserveAllSetBitMask() {
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testPreserveAllSetBitMask(VirtualPropertyMode mode) {
// DROOLS-1699
String drl =
"package t.x;\n" +
diff --git a/drools-traits/src/test/java/org/drools/traits/persistence/PersistenceTest.java b/drools-traits/src/test/java/org/drools/traits/persistence/PersistenceTest.java
index ddc456bf19c..b1a4224cca3 100644
--- a/drools-traits/src/test/java/org/drools/traits/persistence/PersistenceTest.java
+++ b/drools-traits/src/test/java/org/drools/traits/persistence/PersistenceTest.java
@@ -19,15 +19,13 @@
package org.drools.traits.persistence;
import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Map;
+import java.util.stream.Stream;
import org.drools.base.factmodel.traits.Traitable;
-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.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieFileSystem;
@@ -42,31 +40,23 @@
import static org.drools.traits.persistence.DroolsPersistenceUtil.PESSIMISTIC_LOCKING;
import static org.drools.traits.persistence.DroolsPersistenceUtil.createEnvironment;
-@RunWith(Parameterized.class)
public class PersistenceTest {
private Map context;
private Environment env;
- private boolean locking;
- public PersistenceTest(String locking) {
- this.locking = PESSIMISTIC_LOCKING.equals(locking);
- }
-
- @Parameterized.Parameters(name="{0}")
- public static Collection persistence() {
- Object[][] locking = new Object[][] {
- { OPTIMISTIC_LOCKING },
- { PESSIMISTIC_LOCKING }
- };
- return Arrays.asList(locking);
- }
+ public static Stream parameters() {
+ return Stream.of(OPTIMISTIC_LOCKING, PESSIMISTIC_LOCKING);
+ };
- @Before
+ @BeforeEach
public void setUp() throws Exception {
context = DroolsPersistenceUtil.setupWithPoolingDataSource(DROOLS_PERSISTENCE_UNIT_NAME);
env = createEnvironment(context);
- if( locking ) {
+ }
+
+ private void setUpLocking(String locking) {
+ if(PESSIMISTIC_LOCKING.equals(locking)) {
env.set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true);
}
}
@@ -106,8 +96,10 @@ public void setToLocation(String toLocation) {
}
}
- @Test
- public void testTraitsSerialization() throws Exception {
+ @ParameterizedTest(name="{0}")
+ @MethodSource("parameters")
+ public void testTraitsSerialization(String locking) throws Exception {
+ setUpLocking(locking);
String drl = "package org.drools.persistence.kie.persistence.session\n" +
"\n" +
"import java.util.List\n" +
diff --git a/drools-util/pom.xml b/drools-util/pom.xml
index 3fd81109ddf..6946ecc1471 100644
--- a/drools-util/pom.xml
+++ b/drools-util/pom.xml
@@ -50,11 +50,11 @@
microprofile-config-api
true
-
- junit
- junit
- test
-
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
org.assertj
assertj-core
diff --git a/drools-util/src/test/java/org/drools/util/FileUtilsTest.java b/drools-util/src/test/java/org/drools/util/FileUtilsTest.java
index 1a7e1064ac5..79012a9e42b 100644
--- a/drools-util/src/test/java/org/drools/util/FileUtilsTest.java
+++ b/drools-util/src/test/java/org/drools/util/FileUtilsTest.java
@@ -27,7 +27,7 @@
import java.nio.file.Path;
import java.util.Optional;
-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.assertThatExceptionOfType;
diff --git a/drools-util/src/test/java/org/drools/util/JarUtilsTest.java b/drools-util/src/test/java/org/drools/util/JarUtilsTest.java
index 6453cc595c0..1992a7faa92 100644
--- a/drools-util/src/test/java/org/drools/util/JarUtilsTest.java
+++ b/drools-util/src/test/java/org/drools/util/JarUtilsTest.java
@@ -18,10 +18,11 @@
*/
package org.drools.util;
-import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.jupiter.api.Test;
+
public class JarUtilsTest {
@Test
diff --git a/drools-util/src/test/java/org/drools/util/KiePathTest.java b/drools-util/src/test/java/org/drools/util/KiePathTest.java
index 417db70b400..00cfd74bfe1 100644
--- a/drools-util/src/test/java/org/drools/util/KiePathTest.java
+++ b/drools-util/src/test/java/org/drools/util/KiePathTest.java
@@ -18,51 +18,49 @@
*/
package org.drools.util;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import java.util.stream.Stream;
+
+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 KiePathTest {
- protected final boolean isWindowsSeparator;
- protected final String fileSeparator;
-
- public KiePathTest( boolean isWindowsSeparator ) {
- this.isWindowsSeparator = isWindowsSeparator;
- this.fileSeparator = isWindowsSeparator ? "\\" : "/";
- }
-
- @Parameterized.Parameters(name = "{0}")
- public static Object[] params() {
- return new Object[] { true, false };
+ public static Stream parameters() {
+ return Stream.of(arguments(true, "\\"),
+ arguments(false, "/"));
}
- @Test
- public void testAsString() throws Exception {
+ @ParameterizedTest(name="separator = {1}")
+ @MethodSource("parameters")
+ public void testAsString(boolean isWindowsSeparator, String fileSeparator) throws Exception {
assertThat(PortablePath.of("src", isWindowsSeparator).asString()).isEqualTo("src");
assertThat(PortablePath.of("src" + fileSeparator + "test", isWindowsSeparator).asString()).isEqualTo("src/test");
assertThat(PortablePath.of("src" + fileSeparator + "test", isWindowsSeparator).asString()).isEqualTo("src/test");
assertThat(PortablePath.of("src" + fileSeparator + "test" + fileSeparator + "folder", isWindowsSeparator).asString()).isEqualTo("src/test/folder");
}
- @Test
- public void testParent() throws Exception {
+ @ParameterizedTest(name="{0}")
+ @MethodSource("parameters")
+ public void testParent(boolean isWindowsSeparator, String fileSeparator) throws Exception {
assertThat(PortablePath.of("src" + fileSeparator + "test" + fileSeparator + "folder", isWindowsSeparator).getParent().asString()).isEqualTo("src/test");
assertThat(PortablePath.of("src" + fileSeparator + "test" + fileSeparator + "folder", isWindowsSeparator).getParent().getParent().asString()).isEqualTo("src");
assertThat(PortablePath.of("src" + fileSeparator + "test" + fileSeparator + "folder", isWindowsSeparator).getParent().getParent().getParent().asString()).isEqualTo("");
}
- @Test
- public void testResolve() throws Exception {
+ @ParameterizedTest(name="{0}")
+ @MethodSource("parameters")
+ public void testResolve(boolean isWindowsSeparator, String fileSeparator) throws Exception {
assertThat(PortablePath.of("src" + fileSeparator + "test", isWindowsSeparator).resolve("folder").asString()).isEqualTo("src/test/folder");
assertThat(PortablePath.of("src" + fileSeparator + "test", isWindowsSeparator).resolve(PortablePath.of("folder" + fileSeparator + "subfolder", isWindowsSeparator)).asString()).isEqualTo("src/test/folder/subfolder");
}
- @Test
- public void testFileName() throws Exception {
+ @ParameterizedTest(name="{0}")
+ @MethodSource("parameters")
+ public void testFileName(boolean isWindowsSeparator, String fileSeparator) throws Exception {
assertThat(PortablePath.of("src" + fileSeparator + "test" + fileSeparator + "folder", isWindowsSeparator).getFileName()).isEqualTo("folder");
}
}
\ No newline at end of file
diff --git a/drools-util/src/test/java/org/drools/util/ResourceHelperTest.java b/drools-util/src/test/java/org/drools/util/ResourceHelperTest.java
index f314dfc7017..2e369618312 100644
--- a/drools-util/src/test/java/org/drools/util/ResourceHelperTest.java
+++ b/drools-util/src/test/java/org/drools/util/ResourceHelperTest.java
@@ -26,7 +26,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.drools.util.FileUtilsTest.TEST_FILE;
diff --git a/drools-util/src/test/java/org/drools/util/StringUtilsTest.java b/drools-util/src/test/java/org/drools/util/StringUtilsTest.java
index 7fca6c14fe5..7d4cd21fdf8 100644
--- a/drools-util/src/test/java/org/drools/util/StringUtilsTest.java
+++ b/drools-util/src/test/java/org/drools/util/StringUtilsTest.java
@@ -20,7 +20,7 @@
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.drools.util.StringUtils.getPkgUUID;
diff --git a/drools-util/src/test/java/org/drools/util/TypeResolverTest.java b/drools-util/src/test/java/org/drools/util/TypeResolverTest.java
index fcb359e4556..eccc5048c64 100644
--- a/drools-util/src/test/java/org/drools/util/TypeResolverTest.java
+++ b/drools-util/src/test/java/org/drools/util/TypeResolverTest.java
@@ -24,7 +24,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;
diff --git a/drools-util/src/test/java/org/drools/util/bitmask/LongBitMaskTest.java b/drools-util/src/test/java/org/drools/util/bitmask/LongBitMaskTest.java
index 3357d9bbbab..f6840b84b4f 100644
--- a/drools-util/src/test/java/org/drools/util/bitmask/LongBitMaskTest.java
+++ b/drools-util/src/test/java/org/drools/util/bitmask/LongBitMaskTest.java
@@ -19,16 +19,13 @@
package org.drools.util.bitmask;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatRuntimeException;
public class LongBitMaskTest {
- @Rule public final ExpectedException thrown = ExpectedException.none();
-
@Test
public void testSet() {
assertThat(new LongBitMask().set(0).toString()).isEqualTo("1");
@@ -62,8 +59,7 @@ public void testResetAll() {
assertThat(new LongBitMask().resetAll(EmptyButLastBitMask.get()).toString()).isEqualTo("0");
assertThat(new LongBitMask().resetAll(EmptyBitMask.get()).toString()).isEqualTo("0");
- thrown.expect(RuntimeException.class);
- new LongBitMask().resetAll(new OpenBitSet()).toString();
+ assertThatRuntimeException().isThrownBy(() -> new LongBitMask().resetAll(new OpenBitSet()).toString());
}
@Test
diff --git a/drools-xml-support/pom.xml b/drools-xml-support/pom.xml
index 0f0c11aa764..faa3c4e35ad 100644
--- a/drools-xml-support/pom.xml
+++ b/drools-xml-support/pom.xml
@@ -132,10 +132,10 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
-
+
org.mockito
mockito-core
diff --git a/drools-xml-support/src/test/java/org/drools/xml/support/CommandSerializationTest.java b/drools-xml-support/src/test/java/org/drools/xml/support/CommandSerializationTest.java
index 82622e17387..90455846f1e 100644
--- a/drools-xml-support/src/test/java/org/drools/xml/support/CommandSerializationTest.java
+++ b/drools-xml-support/src/test/java/org/drools/xml/support/CommandSerializationTest.java
@@ -68,8 +68,8 @@
import org.drools.commands.runtime.rule.UpdateCommand;
import org.drools.core.common.DefaultFactHandle;
import org.drools.core.common.DisconnectedFactHandle;
+import org.junit.jupiter.api.Test;
import org.drools.commands.jaxb.JaxbListWrapper;
-import org.junit.Test;
import org.kie.api.command.Command;
import org.kie.api.command.Setter;
import org.kie.api.runtime.rule.AgendaFilter;
diff --git a/drools-xml-support/src/test/java/org/drools/xml/support/XStreamXMLTest.java b/drools-xml-support/src/test/java/org/drools/xml/support/XStreamXMLTest.java
index f1be85ba3c5..ad8a6bebc40 100644
--- a/drools-xml-support/src/test/java/org/drools/xml/support/XStreamXMLTest.java
+++ b/drools-xml-support/src/test/java/org/drools/xml/support/XStreamXMLTest.java
@@ -42,10 +42,10 @@
import org.drools.commands.runtime.rule.ModifyCommand;
import org.drools.commands.runtime.rule.UpdateCommand;
import org.drools.core.common.DefaultFactHandle;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.drools.commands.runtime.ExecutionResultImpl;
import org.drools.commands.runtime.FlatQueryResults;
-import org.junit.Before;
-import org.junit.Test;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.api.runtime.rule.QueryResults;
@@ -56,7 +56,7 @@ public class XStreamXMLTest {
private XStream xstream;
- @Before
+ @BeforeEach
public void setup() {
xstream = createTrustingXStream();
xstream = XStreamXML.newXStreamMarshaller(xstream);
diff --git a/kie-api/pom.xml b/kie-api/pom.xml
index c069d04cf26..b80233fc0d3 100644
--- a/kie-api/pom.xml
+++ b/kie-api/pom.xml
@@ -156,10 +156,10 @@
slf4j-api
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
-
+
org.assertj
assertj-core
diff --git a/kie-api/src/test/java/org/kie/api/KModuleXSDTest.java b/kie-api/src/test/java/org/kie/api/KModuleXSDTest.java
index 172165a00cc..c432110fa0c 100644
--- a/kie-api/src/test/java/org/kie/api/KModuleXSDTest.java
+++ b/kie-api/src/test/java/org/kie/api/KModuleXSDTest.java
@@ -26,7 +26,7 @@
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
diff --git a/kie-api/src/test/java/org/kie/api/io/ResourceTypeTest.java b/kie-api/src/test/java/org/kie/api/io/ResourceTypeTest.java
index 95ad217e06e..ccdd483aac4 100644
--- a/kie-api/src/test/java/org/kie/api/io/ResourceTypeTest.java
+++ b/kie-api/src/test/java/org/kie/api/io/ResourceTypeTest.java
@@ -20,7 +20,7 @@
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/kie-internal/pom.xml b/kie-internal/pom.xml
index 619f4ee0f49..3f7b59ddfb4 100644
--- a/kie-internal/pom.xml
+++ b/kie-internal/pom.xml
@@ -122,10 +122,10 @@
test
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
-
+
org.assertj
assertj-core
diff --git a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorMergerTest.java b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorMergerTest.java
index 3ae6532c952..f8f7e3bb279 100644
--- a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorMergerTest.java
+++ b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorMergerTest.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.internal.runtime.conf.AuditMode;
import org.kie.internal.runtime.conf.DeploymentDescriptor;
import org.kie.internal.runtime.conf.MergeMode;
diff --git a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorTest.java b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorTest.java
index 6559973fa81..4c3dd2725a6 100644
--- a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorTest.java
+++ b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorTest.java
@@ -23,7 +23,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.kie.internal.runtime.conf.AuditMode;
import org.kie.internal.runtime.conf.DeploymentDescriptor;
import org.kie.internal.runtime.conf.NamedObjectModel;
diff --git a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/JaxbMarshalingTest.java b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/JaxbMarshalingTest.java
index 5038a1806fa..19647fcac00 100644
--- a/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/JaxbMarshalingTest.java
+++ b/kie-internal/src/test/java/org/kie/internal/runtime/manager/deploy/JaxbMarshalingTest.java
@@ -24,7 +24,7 @@
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.kie.internal.runtime.conf.DeploymentDescriptor;
import org.kie.internal.runtime.conf.ObjectModel;
import org.slf4j.Logger;
diff --git a/kie-memory-compiler/pom.xml b/kie-memory-compiler/pom.xml
index 2cb34dc36f2..bfafcb26f76 100644
--- a/kie-memory-compiler/pom.xml
+++ b/kie-memory-compiler/pom.xml
@@ -45,10 +45,10 @@
drools-util
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
-
+
org.assertj
assertj-core
diff --git a/kie-memory-compiler/src/test/java/org/kie/memorycompiler/KieMemoryCompilerTest.java b/kie-memory-compiler/src/test/java/org/kie/memorycompiler/KieMemoryCompilerTest.java
index 7c5e3093ebf..f22d02a106a 100644
--- a/kie-memory-compiler/src/test/java/org/kie/memorycompiler/KieMemoryCompilerTest.java
+++ b/kie-memory-compiler/src/test/java/org/kie/memorycompiler/KieMemoryCompilerTest.java
@@ -21,10 +21,11 @@
import java.lang.reflect.Method;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class KieMemoryCompilerTest {
@@ -52,10 +53,11 @@ public void compileAndLoadClass() throws Exception {
assertThat(result).isEqualTo(5);
}
- @Test(expected = KieMemoryCompilerException.class)
+ @Test
public void invalidClass() {
Map source = singletonMap("org.kie.memorycompiler.InvalidJavaClass", "Invalid Java Code");
- KieMemoryCompiler.compile(source, this.getClass().getClassLoader());
+ assertThatExceptionOfType(KieMemoryCompilerException.class).isThrownBy(
+ () -> KieMemoryCompiler.compile(source, this.getClass().getClassLoader()));
}
private final static String WARNING_CLASS =
diff --git a/kie-memory-compiler/src/test/java/org/kie/memorycompiler/jdknative/NativeJavaCompilerTest.java b/kie-memory-compiler/src/test/java/org/kie/memorycompiler/jdknative/NativeJavaCompilerTest.java
index 268f962685a..8b9e7daba6a 100644
--- a/kie-memory-compiler/src/test/java/org/kie/memorycompiler/jdknative/NativeJavaCompilerTest.java
+++ b/kie-memory-compiler/src/test/java/org/kie/memorycompiler/jdknative/NativeJavaCompilerTest.java
@@ -18,29 +18,27 @@
*/
package org.kie.memorycompiler.jdknative;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
import javax.tools.JavaCompiler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.kie.memorycompiler.KieMemoryCompilerException;
public class NativeJavaCompilerTest {
- @Test(expected = KieMemoryCompilerException.class)
+ @Test
public void simulateJre() {
-
NativeJavaCompiler compiler = new NativeJavaCompiler(new NullJavaCompilerFinder());
-
- compiler.compile(null, null, null, null, null);
+ assertThatExceptionOfType(KieMemoryCompilerException.class).isThrownBy(() -> compiler.compile(null, null, null, null, null));
}
- @Test(expected = KieMemoryCompilerException.class)
+ @Test
public void simulateJreWithException() {
-
NativeJavaCompiler compiler = new NativeJavaCompiler(new ExceptionThrowingJavaCompilerFinder());
-
- compiler.compile(null, null, null, null, null);
+ assertThatExceptionOfType(KieMemoryCompilerException.class).isThrownBy(() -> compiler.compile(null, null, null, null, null));
}
private static class NullJavaCompilerFinder implements JavaCompilerFinder {