Hi Everyone, i am using below config for Wiremock ...
# help
a
Hi Everyone, i am using below config for Wiremock in Spring boot application
Copy code
@Configuration
public class WireMockConfig {

    private WireMockServer wireMockServer;

    @Value("${wiremock.root.directory}")
    private String rootDirectory;

    @Value("${wiremock.port}")
    private String wiremockPort;

    @EventListener(ApplicationReadyEvent.class)
    public void startWireMockServer(){

        wireMockServer = new WireMockServer(
                WireMockConfiguration.options()
                        .port(Integer.parseInt(wiremockPort))
                        .withRootDirectory(rootDirectory)
                        .notifier(new ConsoleNotifier(true))
        );

        wireMockServer.start();

        System.out.println("WireMock server started on port " + wiremockPort);
    }

    @Bean
    public WireMock wireMock() {
        WireMock.configureFor("localhost", Integer.parseInt(wiremockPort));
        return new WireMock();
    }

    @EventListener(ContextClosedEvent.class)
    public void stopWireMockServer() {
        if(null != wireMockServer){
            wireMockServer.stop();
            System.out.println("WireMock server stopped");
        }
    }

}
rootDirectory - is the path of mapping parent folder, So, i want to categorize the mappings inside mappings folder like Dev/ Stage/ Test. Is it possible and how
l
I don't think this is possible via WireMock natively. WireMock reads all the mappings from the
mappings
folder and I don't think it will allow categorisation of those files. Could you do this by configuring the WireMock root directory via spring so it is configured per environment? I think you should be able to configure different properties for different environments in Spring boot. By doing that, you can have a different root directory per environment: • /test/resources/dev/wiremock • /test/resources/test/wiremock • /test/resources/stage/wiremock Each of the above folders will have a mappings directory wit the mapping files specific to that environment?
a
So, we need to have different root directory for each environment, that we can configure using properties file like i did in above logic
is it possible to store these mappings in S3 bucket from Spring boot application ?
l
I think that might work. Never really tried it to be honest S3 buckets are not supported out of the box. There is a
MappingsLoaderExtension
that you could implement to achieve this - https://wiremock.org/docs/extensibility/adding-mappings-loader/
a
Ok, is there any way to Stop recording based on targetUrl instead stopping all recordings, like if i start recording on xyz, abc and whenever i will stop recording, it is stopping all recordings of xyz and abc.