-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reproducer for JDK 8 bridge method issue
- Loading branch information
1 parent
d1a4d03
commit bd07d9c
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
platform-tooling-support-tests/projects/reflection-tests/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
plugins { | ||
java | ||
} | ||
|
||
// grab jupiter version from system environment | ||
val jupiterVersion: String = System.getenv("JUNIT_JUPITER_VERSION") | ||
val vintageVersion: String = System.getenv("JUNIT_VINTAGE_VERSION") | ||
val platformVersion: String = System.getenv("JUNIT_PLATFORM_VERSION") | ||
|
||
repositories { | ||
maven { url = uri(file(System.getProperty("maven.repo"))) } | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter:$jupiterVersion") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion") | ||
testRuntimeOnly("org.junit.platform:junit-platform-reporting:$platformVersion") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
|
||
testLogging { | ||
events("failed") | ||
} | ||
|
||
reports { | ||
html.required = true | ||
} | ||
|
||
val outputDir = reports.junitXml.outputLocation | ||
jvmArgumentProviders += CommandLineArgumentProvider { | ||
listOf( | ||
"-Djunit.platform.reporting.open.xml.enabled=true", | ||
"-Djunit.platform.reporting.output.dir=${outputDir.get().asFile.absolutePath}" | ||
) | ||
} | ||
|
||
doFirst { | ||
println("Using Java version: ${JavaVersion.current()}") | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
platform-tooling-support-tests/projects/reflection-tests/settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "reflection-tests" |
45 changes: 45 additions & 0 deletions
45
...orm-tooling-support-tests/projects/reflection-tests/src/test/java/ReflectionTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package standalone; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.DynamicContainer.dynamicContainer; | ||
import static org.junit.jupiter.api.DynamicTest.dynamicTest; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.DynamicNode; | ||
import org.junit.jupiter.api.TestFactory; | ||
import org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.ClassTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.JupiterTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.NestedClassTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor; | ||
import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor; | ||
|
||
class ReflectionTestCase { | ||
|
||
@TestFactory | ||
Stream<DynamicNode> canReadParameters() { | ||
return Stream.of(JupiterTestDescriptor.class, ClassBasedTestDescriptor.class, ClassTestDescriptor.class, | ||
MethodBasedTestDescriptor.class, TestMethodTestDescriptor.class, TestTemplateTestDescriptor.class, | ||
TestTemplateInvocationTestDescriptor.class, TestFactoryTestDescriptor.class, | ||
NestedClassTestDescriptor.class) // | ||
.map(descriptorClass -> dynamicContainer(descriptorClass.getSimpleName(), | ||
Arrays.stream(descriptorClass.getDeclaredMethods()) // | ||
.map(method -> dynamicTest(method.getName(), | ||
() -> assertDoesNotThrow(method::getParameters))))); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...port-tests/src/test/java/platform/tooling/support/tests/ReflectionCompatibilityTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package platform.tooling.support.tests; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static platform.tooling.support.Helper.TOOL_TIMEOUT; | ||
|
||
import java.nio.file.Paths; | ||
|
||
import de.sormuras.bartholdy.tool.GradleWrapper; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.opentest4j.TestAbortedException; | ||
|
||
import platform.tooling.support.Helper; | ||
import platform.tooling.support.MavenRepo; | ||
import platform.tooling.support.Request; | ||
|
||
/** | ||
* @since 1.11 | ||
*/ | ||
class ReflectionCompatibilityTests { | ||
|
||
@Test | ||
void gradle_wrapper() { | ||
var request = Request.builder() // | ||
.setTool(new GradleWrapper(Paths.get(".."))) // | ||
.setProject("reflection-tests") // | ||
.addArguments("-Dmaven.repo=" + MavenRepo.dir()) // | ||
.addArguments("build", "--no-daemon", "--stacktrace") // | ||
.setTimeout(TOOL_TIMEOUT) // | ||
.setJavaHome(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) // | ||
.build(); | ||
|
||
var result = request.run(); | ||
|
||
assertFalse(result.isTimedOut(), () -> "tool timed out: " + result); | ||
|
||
assertEquals(0, result.getExitCode()); | ||
assertTrue(result.getOutputLines("out").stream().anyMatch(line -> line.contains("BUILD SUCCESSFUL"))); | ||
assertThat(result.getOutput("out")).contains("Using Java version: 1.8"); | ||
} | ||
} |