-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register a Config instance to bootstrap tests
- Loading branch information
Showing
33 changed files
with
337 additions
and
302 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
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
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
4 changes: 1 addition & 3 deletions
4
...ects/project-using-test-callback-from-extension/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
quarkus.test.continuous-testing=enabled | ||
# this should not be needed, but something in the tests is setting this to 1234 and confusing the test framework, so set it here to match | ||
quarkus.http.non-application-root-path=1234 | ||
quarkus.test.continuous-testing=enabled |
4 changes: 1 addition & 3 deletions
4
...projects/project-using-test-parameter-injection/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
quarkus.test.continuous-testing=enabled | ||
# this should not be needed, but something in the tests is setting this to 1234 and confusing the test framework, so set it here to match | ||
quarkus.http.non-application-root-path=1234 | ||
quarkus.test.continuous-testing=enabled |
4 changes: 1 addition & 3 deletions
4
...t-template-from-extension-with-bytecode-changes/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
quarkus.test.continuous-testing=enabled | ||
# this should not be needed, but something in the tests is setting this to 1234 and confusing the test framework, so set it here to match | ||
quarkus.http.non-application-root-path=1234 | ||
quarkus.test.continuous-testing=enabled |
4 changes: 1 addition & 3 deletions
4
...ects/project-using-test-template-from-extension/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
quarkus.test.continuous-testing=enabled | ||
# this should not be needed, but something in the tests is setting this to 1234 and confusing the test framework, so set it here to match | ||
quarkus.http.non-application-root-path=1234 | ||
quarkus.test.continuous-testing=enabled |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-test-framework</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-junit5-config</artifactId> | ||
<name>Quarkus - Test Framework - JUnit 5 Config</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye.config</groupId> | ||
<artifactId>smallrye-config</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
28 changes: 28 additions & 0 deletions
28
test-framework/junit5-config/src/main/java/io/quarkus/test/config/ConfigLauncherSession.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,28 @@ | ||
package io.quarkus.test.config; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigProviderResolver; | ||
import org.junit.platform.launcher.LauncherSession; | ||
import org.junit.platform.launcher.LauncherSessionListener; | ||
|
||
import io.quarkus.runtime.LaunchMode; | ||
|
||
/** | ||
* A JUnit {@link LauncherSessionListener}, used to register the initial test config. Test set up code can safely call | ||
* <code>ConfigProvider.getConfig()</code> to retrieve an instance of the Quarkus configuration. | ||
* <p> | ||
* The test config only contains sources known at bootstrap test time. For instance, config sources generated by | ||
* Quarkus are not available in the test config. | ||
*/ | ||
public class ConfigLauncherSession implements LauncherSessionListener { | ||
@Override | ||
public void launcherSessionOpened(final LauncherSession session) { | ||
TestConfigProviderResolver resolver = new TestConfigProviderResolver(); | ||
ConfigProviderResolver.setInstance(resolver); | ||
resolver.getConfig(LaunchMode.TEST); | ||
} | ||
|
||
@Override | ||
public void launcherSessionClosed(final LauncherSession session) { | ||
((TestConfigProviderResolver) ConfigProviderResolver.instance()).restore(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test-framework/junit5-config/src/main/java/io/quarkus/test/config/LoggingSetupExtension.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,17 @@ | ||
package io.quarkus.test.config; | ||
|
||
import org.junit.jupiter.api.extension.Extension; | ||
|
||
import io.quarkus.runtime.logging.LoggingSetupRecorder; | ||
|
||
/** | ||
* A global JUnit extension that enables/sets up basic logging if logging has not already been set up. | ||
* <p/> | ||
* This is useful for getting log output from non-Quarkus tests (if executed separately or before the first Quarkus | ||
* test), but also for getting instant log output from {@code QuarkusTestResourceLifecycleManagers} etc. | ||
*/ | ||
public class LoggingSetupExtension implements Extension { | ||
public LoggingSetupExtension() { | ||
LoggingSetupRecorder.handleFailedStart(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
test-framework/junit5-config/src/main/java/io/quarkus/test/config/QuarkusClassOrderer.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,41 @@ | ||
package io.quarkus.test.config; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.junit.jupiter.api.ClassOrderer; | ||
import org.junit.jupiter.api.ClassOrdererContext; | ||
import org.junit.platform.commons.util.ReflectionUtils; | ||
|
||
import io.quarkus.deployment.dev.testing.TestConfig; | ||
import io.smallrye.config.SmallRyeConfig; | ||
|
||
/** | ||
* A JUnit {@link ClassOrderer}, used to delegate to a custom implementations of {@link ClassOrderer} set by Quarkus | ||
* config. | ||
*/ | ||
public class QuarkusClassOrderer implements ClassOrderer { | ||
private final ClassOrderer delegate; | ||
|
||
public QuarkusClassOrderer() { | ||
SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); | ||
TestConfig testConfig = config.getConfigMapping(TestConfig.class); | ||
|
||
delegate = testConfig.classOrderer() | ||
.map(klass -> ReflectionUtils.tryToLoadClass(klass) | ||
.andThenTry(ReflectionUtils::newInstance) | ||
.andThenTry(instance -> (ClassOrderer) instance) | ||
.toOptional().orElse(EMPTY)) | ||
.orElse(EMPTY); | ||
} | ||
|
||
@Override | ||
public void orderClasses(final ClassOrdererContext context) { | ||
delegate.orderClasses(context); | ||
} | ||
|
||
private static final ClassOrderer EMPTY = new ClassOrderer() { | ||
@Override | ||
public void orderClasses(final ClassOrdererContext context) { | ||
|
||
} | ||
}; | ||
} |
Oops, something went wrong.