Git Product home page Git Product logo

quarkus-mockserver's Introduction

Quarkus MockServer

Build License Central All Contributors

Quarkus MockServer extension for tests and local development.

Usage

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>

Example project

Configuration

# 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:

  • Configuration properties file link
  • Expectation Initializer JSON link

Testing

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.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Andrej Petras

๐Ÿ’ป ๐Ÿšง

This project follows the all-contributors specification. Contributions of any kind welcome!

quarkus-mockserver's People

Contributors

andrejpetras avatar actions-user avatar dlucasd avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.