I am developing web application and I need to find some solution how to test some components which are from third-party so when the application is on server, I want to use mockserver to be able to mock this components from third-party. Is there any possible way how to use mockserver with the expectations which are defined in json file through the java and be able to deploy this standalone application with mockserver on my server with my application?

Locally it is not problem, I am able to use something like this

version: "2.4" services: mockServer: image: mockserver/mockserver ports: - "1080:1080" environment: MOCKSERVER_PROPERTY_FILE: /config/mockserver.properties MOCKSERVER_INITIALIZATION_JSON_PATH: /config/initializer.json volumes: - type: bind source: . target: /config and through this I was able to access my defined requests / responses and also home page from mockserver something like : localhost:1080/mockserver/dashboard. I would like to make something similar but through the java. I was searching in documentation and I did not find there something like this and I am not sure if it even possible to do it in Java.

Please if you have any advices / options how to do it, it would help me a lot. Thank you.

`public class MockServer { private static final int PORT = 1080;

public static void main(String[] args) {
    ClientAndServer mockServer = ClientAndServer.startClientAndServer(PORT);

    ConfigurationProperties.initializationJsonPath("initializer.json");
    
    new MockServerClient("localhost", PORT);


}

}`

I was trying to do something like this but without success I was not able to access the expectations from json file and as I mentioned I am not sure if it is possible to do it.

0

There are 0 answers