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.
Register a Config instance to bootstrap tests
- Loading branch information
Showing
31 changed files
with
309 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> |
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(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
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,54 @@ | ||
package io.quarkus.test.config; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.eclipse.microprofile.config.spi.ConfigProviderResolver; | ||
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.quarkus.runtime.LaunchMode; | ||
import io.smallrye.config.SmallRyeConfig; | ||
|
||
/** | ||
* A JUnit {@link ClassOrderer}, used to register the initial test config and delegate to custom implementations of | ||
* {@link ClassOrderer} set by Quarkus config. | ||
* <p> | ||
* Ideally a {@link org.junit.jupiter.api.extension.Extension} should register a Config instance, but we | ||
* can't be sure about the extension registration order, plus the configuration may be accessed way before the | ||
* extension initializes. The JUnit Launcher doesn't have a way to bootstrap some code, so this is one of the earliest | ||
* moments in JUnit where we can (indirectly) set up something. | ||
*/ | ||
public class QuarkusClassOrderer implements ClassOrderer { | ||
private final ClassOrderer delegate; | ||
|
||
static { | ||
TestConfigProviderResolver resolver = new TestConfigProviderResolver(); | ||
ConfigProviderResolver.setInstance(resolver); | ||
resolver.getConfig(LaunchMode.TEST); | ||
} | ||
|
||
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.