Stub Mappings are not found

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fsantiagcommented, Jan 15, 2020

@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.

1reaction
fsantiagcommented, Jan 15, 2020

I am experiencing the same problem. Have you guys found a solution for this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

there are no stub mappings in this WireMock instance
I found solution for this. So, basically we need create a folder called "mappings" (exact name) under the directory identified by ...
Read more >
Returning stubbed HTTP responses to specific requests
Stub mappings which have been created can be persisted to the mappings directory via a call to WireMock.saveAllMappings in Java or posting a...
Read more >
there are no stub mappings in this WireMock instance - iTecNote
I found solution for this. So, basically we need create a folder called "mappings" (exact name) under the directory identified by "testResource" variable....
Read more >
Wiremock Stubbing, Stub Verification And Proxying With ...
We will define stub mappings for requests having specific responses and assign the highest priority to them. For generic responses, we can ...
Read more >
WireMock - Stub Priority with JUnit Test - GeeksforGeeks
That means it's a simple way to resolve which stub mapping should be ... response like “No matching stubs found” etc., but stub...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found