-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable global response templating (#52)
- Loading branch information
Showing
8 changed files
with
81 additions
and
4 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
31 changes: 31 additions & 0 deletions
31
deployment/src/test/java/io/quarkiverse/wiremock/devservice/WireMockTemplatingTest.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,31 @@ | ||
package io.quarkiverse.wiremock.devservice; | ||
|
||
import static io.quarkiverse.wiremock.devservice.WireMockDevServiceConfig.PORT; | ||
import static io.quarkiverse.wiremock.devservice.WireMockDevServiceConfig.PREFIX; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import org.eclipse.jetty.server.Response; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
class WireMockTemplatingTest { | ||
|
||
private static final String APP_PROPERTIES = "application-templating.properties"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest UNIT_TEST = new QuarkusUnitTest().withConfigurationResource(APP_PROPERTIES) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Test | ||
void testTemplatingEnabled() { | ||
final int port = ConfigProvider.getConfig().getValue(PREFIX + "." + PORT, Integer.class); | ||
RestAssured.when().get(String.format("http://localhost:%d/template", port)).then().statusCode(Response.SC_OK) | ||
.body(is(String.format("Everything was just fine from %d!", port))); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
deployment/src/test/resources/application-templating.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
%test.quarkus.wiremock.devservices.global-response-templating=true |
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,10 @@ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"url": "/template" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"body": "Everything was just fine from {{ request.port }}!" | ||
} | ||
} |
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