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.
Support Test Resources from @testprofile in native mode
## Description In quarkusio#13154, the annotation `@TestProfile` was supported also in Native tests. However, the native extension was not processing the test resources in the test profile like: ``` public class ConfluentTestProfile implements QuarkusTestProfile { @OverRide public String getConfigProfile() { return "confluent"; } @OverRide public List<TestResourceEntry> testResources() { return Collections.singletonList(new TestResourceEntry(ConfluentKafkaResource.class)); } } ``` This PR makes the above to be supported. The solution behaves the same as done in the Quarkus Test extension.
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...e/src/test/java/io/quarkus/it/nat/test/profile/RuntimeValueChangeFromTestResourcesIT.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,12 @@ | ||
package io.quarkus.it.nat.test.profile; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.NativeImageTest; | ||
|
||
/** | ||
* This test ensures that the NativeTestExtension starts the test resources from the Test Profile annotation. | ||
*/ | ||
@NativeImageTest | ||
public class RuntimeValueChangeFromTestResourcesIT extends RuntimeValueChangeFromTestResourcesTest { | ||
} |
53 changes: 53 additions & 0 deletions
53
...src/test/java/io/quarkus/it/nat/test/profile/RuntimeValueChangeFromTestResourcesTest.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,53 @@ | ||
package io.quarkus.it.nat.test.profile; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
@TestProfile(RuntimeValueChangeFromTestResourcesTest.CustomTestProfile.class) | ||
public class RuntimeValueChangeFromTestResourcesTest { | ||
|
||
private static final String EXPECTED_VALUE = "RuntimeTimeValueChangeFromTestResources"; | ||
|
||
@Test | ||
public void failInNativeTestExtension_beforeEach() { | ||
RestAssured.when() | ||
.get("/native-config-profile/myConfigValue") | ||
.then() | ||
.body(is(EXPECTED_VALUE)); | ||
} | ||
|
||
public static class CustomTestProfile implements QuarkusTestProfile { | ||
@Override | ||
public List<TestResourceEntry> testResources() { | ||
return Collections.singletonList(new TestResourceEntry(DummyTestResource.class)); | ||
} | ||
} | ||
|
||
/** | ||
* This only used to ensure that the TestResource has been handled correctly by the QuarkusTestExtension | ||
*/ | ||
public static class DummyTestResource implements QuarkusTestResourceLifecycleManager { | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
return Collections.singletonMap("my.config.value", EXPECTED_VALUE); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
// do nothing | ||
} | ||
} | ||
} |
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