This commit is contained in:
Marcin Grzejszczak
2019-02-18 10:27:59 +01:00
parent b733a718a4
commit d72aada46c
3 changed files with 12 additions and 6 deletions

View File

@@ -109,17 +109,22 @@ public class WireMockConfiguration implements SmartLifecycle {
this.server = new WireMockServer(this.options);
}
registerStubs();
if (log.isDebugEnabled()) {
log.debug("WireMock server has [" + this.server.getStubMappings().size()
+ "] stubs registered");
}
logRegisteredMappings();
if (!this.beanFactory.containsBean(WIREMOCK_SERVER_BEAN_NAME)) {
this.beanFactory.registerSingleton(WIREMOCK_SERVER_BEAN_NAME, this.server);
}
}
private void logRegisteredMappings() {
if (log.isDebugEnabled()) {
log.debug("WireMock server has [" + this.server.getStubMappings().size()
+ "] stubs registered");
}
}
void resetMappings() {
this.server.resetToDefaultMappings();
this.server.resetAll();
logRegisteredMappings();
}
private void registerStubs() throws IOException {

View File

@@ -71,7 +71,7 @@ public final class WireMockTestExecutionListener extends AbstractTestExecutionLi
if (log.isDebugEnabled()) {
log.debug(
"Resetting mappings for the next test to restart them. That's necessary when"
+ "reusing the same context with new servers running on random ports");
+ " reusing the same context with new servers running on random ports");
}
wireMockConfig(testContext).resetMappings();
}

View File

@@ -1,3 +1,4 @@
logging:
level:
org.springframework.cloud.contract: debug
com.github.tomakehurst.wiremock: debug