org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner Java Examples

The following examples show how to use org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StubRunnerWireMockTestExecutionListener.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
@Override
public void afterTestClass(TestContext testContext) {
	if (testContext.getTestClass()
			.getAnnotationsByType(AutoConfigureStubRunner.class).length == 0) {
		if (log.isDebugEnabled()) {
			log.debug("No @AutoConfigureStubRunner annotation found on ["
					+ testContext.getTestClass() + "]. Skipping");
		}
		return;
	}
	if (!WireMockHttpServerStub.SERVERS.isEmpty() && WireMockHttpServerStub.SERVERS
			.values().stream().noneMatch(p -> p.random)) {
		if (log.isWarnEnabled()) {
			log.warn("You've used fixed ports for WireMock setup - "
					+ "will mark context as dirty. Please use random ports, as much "
					+ "as possible. Your tests will be faster and more reliable and this "
					+ "warning will go away");
		}
		testContext
				.markApplicationContextDirty(DirtiesContext.HierarchyMode.EXHAUSTIVE);
	}
	// potential race condition
	WireMockHttpServerStub.SERVERS.clear();
}