forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use a constant for sharing data between the two processes * Raise an exception if the mapping data is invalid. * Include a functional-test for verifying the plugin behavior
- Loading branch information
Showing
10 changed files
with
189 additions
and
6 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
.../gradle/src/funcTest/java/io/quarkus/gradle/functional/test/AdditionalSourceSetsTest.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,47 @@ | ||
package io.quarkus.gradle.functional.test; | ||
|
||
import org.gradle.testkit.runner.BuildResult; | ||
import org.gradle.testkit.runner.GradleRunner; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
/** | ||
* Functional test for verifying that the plugin can work with test sources which are included as part of a custom | ||
* source set. | ||
*/ | ||
public class AdditionalSourceSetsTest { | ||
|
||
private static final String BUILD_FILE = "additional-source-sets/build.gradle"; | ||
|
||
@Test | ||
public void executeFunctionalTest() throws URISyntaxException { | ||
File buildFile = getBuildFile(BUILD_FILE); | ||
GradleRunner runner = GradleRunner.create() | ||
.withPluginClasspath() | ||
.withProjectDir(buildFile.getParentFile()); | ||
BuildResult result = runner.withArguments( | ||
"-s", | ||
"-DQUARKUS_VERSION=" + System.getenv("QUARKUS_VERSION"), | ||
"functionalTest") | ||
.build(); | ||
String buildOutput = result.getOutput(); | ||
System.out.println(buildOutput); | ||
} | ||
|
||
/** | ||
* Get the build file by searching for it on the classpath. | ||
* | ||
* @param path the path to the build file. | ||
* @return the build file reference. | ||
*/ | ||
private File getBuildFile(String path) throws URISyntaxException { | ||
URL resource = Thread.currentThread().getContextClassLoader().getResource(BUILD_FILE); | ||
assertNotNull(resource, "Build file not found."); | ||
return new File(resource.toURI()); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
devtools/gradle/src/funcTest/resources/additional-source-sets/build.gradle
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,55 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
String quarkusVersion = System.getProperty('QUARKUS_VERSION') | ||
dependencies { | ||
implementation "io.quarkus:quarkus-arc:${quarkusVersion}" | ||
testImplementation "io.quarkus:quarkus-junit5:${quarkusVersion}" | ||
} | ||
|
||
sourceSets { | ||
// Functional Tests | ||
funcTest { | ||
java.srcDir 'src/funcTest/java' | ||
if (file('src/funcTest/resources').exists()) { | ||
resources.srcDir 'src/funcTest/resources' | ||
} | ||
|
||
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath + configurations.compileOnly | ||
runtimeClasspath += output + compileClasspath | ||
} | ||
} | ||
|
||
compileJava { | ||
options.compilerArgs << '-parameters' | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
/* | ||
* Functional tests for this module. | ||
*/ | ||
task functionalTest(type: Test, description: 'Functional tests', dependsOn: [processResources, classes]) { | ||
description = 'Run the functional tests.' | ||
group = 'verification' | ||
|
||
useJUnitPlatform() | ||
testClassesDirs = sourceSets.funcTest.output.classesDirs | ||
classpath = sourceSets.funcTest.runtimeClasspath | ||
|
||
// Show standard streams on the console. | ||
testLogging { | ||
showStandardStreams = true | ||
} | ||
systemProperty 'quarkus.http.host', 'localhost' | ||
} |
1 change: 1 addition & 0 deletions
1
devtools/gradle/src/funcTest/resources/additional-source-sets/settings.gradle
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 = 'functional-test' |
19 changes: 19 additions & 0 deletions
19
...le/src/funcTest/resources/additional-source-sets/src/funcTest/java/ft/SimpleBeanTest.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,19 @@ | ||
package ft; | ||
|
||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@QuarkusTest | ||
public class SimpleBeanTest { | ||
|
||
@Inject | ||
SimpleBean bean; | ||
|
||
@Test | ||
public void verify() { | ||
assertEquals("hello", bean.hello(), "Did the implementation of the SimpleBean change?"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ols/gradle/src/funcTest/resources/additional-source-sets/src/main/java/ft/SimpleBean.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,11 @@ | ||
package ft; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class SimpleBean { | ||
|
||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...radle/src/funcTest/resources/additional-source-sets/src/main/resources/META-INF/beans.xml
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" | ||
bean-discovery-mode="all"> | ||
</beans> |
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
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
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