Skip to content

Commit

Permalink
Migrated kie memory compiler to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
pibizza committed Dec 3, 2024
1 parent 79705ec commit 9dbd332
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions kie-memory-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
<artifactId>drools-util</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -52,10 +53,11 @@ public void compileAndLoadClass() throws Exception {
assertThat(result).isEqualTo(5);
}

@Test(expected = KieMemoryCompilerException.class)
@Test
public void invalidClass() {
Map<String, String> 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9dbd332

Please sign in to comment.