Hi there, I'm hoping you guys can help me out. I'...
# wiremock-java
w
Hi there, I'm hoping you guys can help me out. I've got a (kinda weird) requirement from business. The requirement is that our PROD-application should return specific responses if the request matches a certain pattern. This is used to help new customers onboard on product easier. It should be something like: GET /someResource/TEST0001/whatever > should return a 200 GET / someResource/TEST0002/whatever > should return a 400 (traceable problem) The weird thing, obviously(?), is that these responses need to be returned in production. Can I use wiremock to set this up? I'm trying to make it work but I cannot trigger the hardcoded responses. Current setup:
Copy code
@Bean(initMethod = "start", destroyMethod = "stop")
public WireMockServer wiremockStubServer(WireMockConfigProperties properties) {
    Options options = createOptions(properties);

    return new WireMockServer(options);
}

public static Options createOptions(WireMockConfigProperties properties) {
    final String fileBaseDir = properties.files();
    return options()
            .port(properties.defaultPort()) // 8000
            .usingFilesUnderClasspath(fileBaseDir) // "BOOT-INF/classes/wiremock/responses"
            .mappingSource(new JsonFileMappingsSource(new ClasspathFileSource(properties.mappings()))); // "BOOT-INF/classes/wiremock/mappings"
}
And the files are indeed available in these locations.
Copy code
"request": {
    "method": "GET",
    "urlPath": "/someResource/TEST0001/whatever
  },
l
Are you trying to run WireMock in the same process as your main application or are you forwarding the requests to a WireMock instance running in a separate process?
w
In the same application/process.
l
If you are not using WireMock's http stack then you might want to look at this page - https://wiremock.org/docs/running-without-http-server/
w
Looking good. I'm going to try it out. Thanks
👍 1