-
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.
Allow applications using quakus-info to contribute data to the /info …
…at runtime
- Loading branch information
Showing
5 changed files
with
110 additions
and
10 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
61 changes: 61 additions & 0 deletions
61
...info/deployment/src/test/java/io/quarkus/info/deployment/ExternalInfoContributorTest.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,61 @@ | ||
package io.quarkus.info.deployment; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
import java.util.Map; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.info.runtime.spi.InfoContributor; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ExternalInfoContributorTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.addBuildChainCustomizer( | ||
buildChainBuilder -> buildChainBuilder.addBuildStep( | ||
context -> new AdditionalBeanBuildItem(TestInfoContributor.class)) | ||
.produces(AdditionalBeanBuildItem.class) | ||
.build()) | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(TestInfoContributor.class)); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/q/info") | ||
.then() | ||
.statusCode(200) | ||
.body("os", is(notNullValue())) | ||
.body("os.name", is(notNullValue())) | ||
.body("java", is(notNullValue())) | ||
.body("java.version", is(notNullValue())) | ||
.body("build", is(notNullValue())) | ||
.body("build.time", is(notNullValue())) | ||
.body("git", is(notNullValue())) | ||
.body("git.branch", is(notNullValue())) | ||
.body("test", is(notNullValue())) | ||
.body("test.foo", is("bar")); | ||
|
||
} | ||
|
||
@ApplicationScoped | ||
public static class TestInfoContributor implements InfoContributor { | ||
|
||
@Override | ||
public String name() { | ||
return "test"; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> data() { | ||
return Map.of("foo", "bar"); | ||
} | ||
} | ||
} |
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