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.
Monitor config additional locations for hot deployment.
(cherry picked from commit d3d70ac)
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 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
66 changes: 66 additions & 0 deletions
66
core/test-extension/deployment/src/test/java/io/quarkus/extest/AdditionalLocationsTest.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,66 @@ | ||
package io.quarkus.extest; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
import io.restassured.filter.log.RequestLoggingFilter; | ||
import io.restassured.filter.log.ResponseLoggingFilter; | ||
import io.vertx.ext.web.Router; | ||
|
||
public class AdditionalLocationsTest { | ||
@RegisterExtension | ||
static final QuarkusDevModeTest TEST = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(DevBean.class) | ||
.addAsResource(new StringAsset("quarkus.config.locations=additional.properties\n"), | ||
"application.properties") | ||
.addAsResource(new StringAsset("additional.property=1234\n"), "additional.properties")); | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); | ||
} | ||
|
||
@Test | ||
void additionalLocations() { | ||
// A combination of QuarkusUnitTest and QuarkusProdModeTest tests ordering may mess with the port leaving it in | ||
// 8081 and QuarkusDevModeTest does not changes to the right port. | ||
RestAssured.port = -1; | ||
|
||
RestAssured.when().get("/config").then() | ||
.statusCode(200) | ||
.body(is("1234")); | ||
|
||
TEST.modifyResourceFile("additional.properties", s -> "additional.property=5678\n"); | ||
|
||
RestAssured.when().get("/config").then() | ||
.statusCode(200) | ||
.body(is("5678")); | ||
} | ||
|
||
@ApplicationScoped | ||
public static class DevBean { | ||
@Inject | ||
Router router; | ||
@Inject | ||
Config config; | ||
|
||
public void register(@Observes StartupEvent ev) { | ||
router.get("/config").handler(rc -> rc.response().end(config.getValue("additional.property", String.class))); | ||
} | ||
} | ||
} |