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 {