Stub Mappings are not found
See original GitHub issueI need to build a standalone wiremock service which will act a replacement for a future service. It wont have any tests in it. Just mock templates.
Trying to use the spring-cloud-contract-wiremock, with spring boot… Reason being, it provides some functionalities that i want to use. All my json mappings are located under resources/wiremock/mappings/v1 (5 template files) and the files under resources/wiremock/__files (5 corresponding response body files).
My Dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
Configuration:
@Configuration
@AutoConfigureWireMock(stubs = "classpath:/wiremock")
public class WireMockConfig {
@Bean
public WireMockConfigurationCustomizer wireMockConfigurationCustomizer() {
return config -> config.preserveHostHeader(true)
.containerThreads(150)
.notifier(new Slf4jNotifier(true))
.extensions(new ResponseTemplateTransformer(false));
}
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
return objectMapper;
}
}
Since, content of resources (src/main/resources) folder is available at classpath, i have given stub location as classpath:/wiremock.
However its unable to find any mappings. I get response that No response could be served as there are no stub mappings in this WireMock instance.
NOTE: My application works fine if i use plain wiremock dependency with spring boot
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top Related StackOverflow Question
@marcingrzejszczak I have pushed the sample project here: https://github.com/fsantiag/stub-server In this example, I expected the .json file to be loaded since the annotation
@AutoConfigureWireMock(stubs="classpath:/stubs")is pointing to the stubs folder. I can see the stub using the wiremock api works fine, however the json file doesn’t get loaded.I am experiencing the same problem. Have you guys found a solution for this issue?