diff --git a/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkJUnitPlatformTestFramework.java b/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkJUnitPlatformTestFramework.java index 8b671a7..a1933a3 100644 --- a/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkJUnitPlatformTestFramework.java +++ b/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkJUnitPlatformTestFramework.java @@ -59,18 +59,23 @@ public EmbulkJUnitPlatformTestFramework(final DefaultTestFilter filter) { @Override public WorkerTestClassProcessorFactory getProcessorFactory() { + final WorkerTestClassProcessorFactory factory; + + factory = super.getProcessorFactory(); + /* - return super.getProcessorFactory(); - */ - if (!JavaVersion.current().isJava8Compatible()) { - throw new UnsupportedJavaRuntimeException("Running JUnit Platform requires Java 8+, please configure your test java executable with Java 8 or higher."); - } - return new EmbulkJUnitPlatformTestClassProcessorFactory(new JUnitPlatformSpec(this.getOptions(), + factory = new EmbulkJUnitPlatformTestClassProcessorFactory(new JUnitPlatformSpec(this.getOptions(), filter2.getIncludePatterns(), filter2.getExcludePatterns(), filter2.getCommandLineIncludePatterns())); + */ + + System.out.println(factory.getClass()); + System.out.println(factory.toString()); + + return factory; } - static class EmbulkJUnitPlatformTestClassProcessorFactory implements WorkerTestClassProcessorFactory, Serializable { + public static class EmbulkJUnitPlatformTestClassProcessorFactory implements WorkerTestClassProcessorFactory, Serializable { private final JUnitPlatformSpec spec; EmbulkJUnitPlatformTestClassProcessorFactory(JUnitPlatformSpec spec) { @@ -83,8 +88,8 @@ public TestClassProcessor create(ServiceRegistry serviceRegistry) { IdGenerator idGenerator = serviceRegistry.get(IdGenerator.class); Clock clock = serviceRegistry.get(Clock.class); ActorFactory actorFactory = serviceRegistry.get(ActorFactory.class); - // Class clazz = getClass().getClassLoader().loadClass("org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor"); - Class clazz = getClass().getClassLoader().loadClass("org.embulk.gradle.embulk_plugins.EmbulkJUnitPlatformTestClassProcessor"); + Class clazz = getClass().getClassLoader().loadClass("org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor"); + // Class clazz = getClass().getClassLoader().loadClass("org.embulk.gradle.embulk_plugins.EmbulkJUnitPlatformTestClassProcessor"); Constructor constructor = clazz.getConstructor(JUnitPlatformSpec.class, IdGenerator.class, ActorFactory.class, Clock.class); return (TestClassProcessor) constructor.newInstance(spec, idGenerator, actorFactory, clock); diff --git a/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkPluginTest.java b/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkPluginTest.java index 7ccdb14..277bb71 100644 --- a/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkPluginTest.java +++ b/src/main/java/org/embulk/gradle/embulk_plugins/EmbulkPluginTest.java @@ -39,6 +39,7 @@ public void useEmbulkJUnitPlatform() { method.setAccessible(true); System.out.println("!"); method.invoke(this, new EmbulkJUnitPlatformTestFramework((DefaultTestFilter) this.getFilter())); + // method.invoke(this, new JUnitPlatformTestFramework((DefaultTestFilter) this.getFilter())); System.out.println("?"); } catch (final IllegalAccessException ex) { throw new GradleException("Unexpected failure", ex); diff --git a/src/test/java/org/embulk/gradle/embulk_plugins/TestSimple.java b/src/test/java/org/embulk/gradle/embulk_plugins/TestSimple.java index 38196e8..76ea6a0 100644 --- a/src/test/java/org/embulk/gradle/embulk_plugins/TestSimple.java +++ b/src/test/java/org/embulk/gradle/embulk_plugins/TestSimple.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.api.io.CleanupMode; /** * Tests a simple case in the Embulk plugins Gradle plugin. @@ -40,7 +41,7 @@ class TestSimple { @Test @DisabledOnOs(OS.WINDOWS) - public void test(@TempDir Path tempDir) throws IOException { + public void test(@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path tempDir) throws IOException { final Path projectDir = prepareProjectDir(tempDir, "testSimple"); runGradle(projectDir, "compileJava", "generatePomFileForEmbulkPluginMavenPublication"); diff --git a/src/test/resources/testSimple/build.gradle b/src/test/resources/testSimple/build.gradle index 4bad6bf..07feefe 100644 --- a/src/test/resources/testSimple/build.gradle +++ b/src/test/resources/testSimple/build.gradle @@ -21,10 +21,6 @@ tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } -embulkPluginTest { - useEmbulkJUnitPlatform() -} - dependencies { compileOnly "org.embulk:embulk-api:0.10.35" compileOnly "org.embulk:embulk-spi:0.10.35" @@ -38,6 +34,8 @@ dependencies { exclude group: "*", module: "*" } implementation "com.github.jnr:jffi:1.2.23:native" + testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.1" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.1" } embulkPlugin { @@ -46,6 +44,10 @@ embulkPlugin { type = "simple" } +embulkPluginTest { + useEmbulkJUnitPlatform() +} + publishing { publications { embulkPluginMaven(MavenPublication) {