Quarkus MockServer extension for tests and local development.
To use this extension for local development, add the dependency to the target project:
<dependency>
<groupId>io.quarkiverse.mockserver</groupId>
<artifactId>quarkus-mockserver</artifactId>
<scope>provided</scope>
</dependency>
# enable or disable mockserver devservices
quarkus.mockserver.devservices.enabled=true|false
# mockserver configuration properties file, container file '/config/mockserver.properties'
quarkus.mockserver.devservices.config-file=src/test/resources/mockserver.properties
# mockserver configuration directory for the expectation initializers, container directory '/<last_name_from_path>'.
quarkus.mockserver.devservices.config-dir=src/test/resources/mockserver
# enable or disable logs of the mockserver container
quarkus.mockserver.devservices.log=true|false
# mockserver docker image name
quarkus.mockserver.devservices.imageName=jamesdbloom/mockserver:mockserver-5.13.0
# mockserver container fix port
quarkus.mockserver.devservices.port=
# container shared mode
quarkus.mockserver.devservices.shared=true|false
# mockserver devservices service name
quarkus.mockserver.devservices.serviceName=mockserver
Runtime configuration values will be set up during start of the mockserver container. These values could be used to configure rest-client in your application.
# mockserver endpoint is random port http://localhost:44556 or http://mockserver:1080 for shared containers.
quarkus.mockserver.endpoint=
# mockserver port is random testcontainers port or 1080 for shared containers
quarkus.mockserver.port=
# mockserver port is localhost or mockserver for shared containers
quarkus.mockserver.host=
# mockserver host for the test client, docker host
quarkus.mockserver.client.host=
# mockserver port for the test client, testcontainers random port
quarkus.mockserver.client.port=
Rest client configuration example:
%dev.activity-client/mp-rest/url=${quarkus.mockserver.endpoint}
%test.activity-client/mp-rest/url=${quarkus.mockserver.endpoint}
MockServer documentation:
To use the extension for test, add the dependency to the target project:
<dependency>
<groupId>io.quarkiverse.mockserver</groupId>
<artifactId>quarkus-mockserver-test</artifactId>
<scope>test</scope>
</dependency>
Test example
import io.quarkiverse.mockserver.test.MockServerResource;
import io.quarkus.test.common.QuarkusTestResource;
@QuarkusTest
@QuarkusTestResource(MockServerResource.class)
public class BaseTest extends AbstractTest {
}
We can reuse the test for the integration test.
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
public class BaseIT extends BaseTest {
}
For more information check examples in the integration-tests
directory in this repo.
Thanks goes to these wonderful people (emoji key):
Andrej Petras 💻 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!