Java Code Examples for com.github.tomakehurst.wiremock.client.WireMock#reset()

The following examples show how to use com.github.tomakehurst.wiremock.client.WireMock#reset() . 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: ChecksumResetsOnRetryTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
private void stubSuccessAfterOneRetry(Consumer<ResponseDefinitionBuilder> successfulResponseModifier) {
    WireMock.reset();

    String scenario = "stubSuccessAfterOneRetry";
    stubFor(any(anyUrl())
                .willReturn(aResponse().withStatus(500).withBody("<xml></xml>"))
                .inScenario(scenario)
                .whenScenarioStateIs(Scenario.STARTED)
                .willSetStateTo("200"));

    ResponseDefinitionBuilder successfulResponse = aResponse().withStatus(200).withBody("<xml></xml>");
    successfulResponseModifier.accept(successfulResponse);
    stubFor(any(anyUrl())
                .willReturn(successfulResponse)
                .inScenario(scenario)
                .whenScenarioStateIs("200"));
}
 
Example 2
Source File: ClockSkewAdjustmentTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
private void stubForClockSkewFailureThenSuccess(Instant serviceTime, int statusCode, String errorCode) {
    WireMock.reset();

    stubFor(post(urlEqualTo(PATH))
                    .inScenario(SCENARIO)
                    .whenScenarioStateIs(Scenario.STARTED)
                    .willSetStateTo("1")
                    .willReturn(aResponse()
                                        .withStatus(statusCode)
                                        .withHeader("x-amzn-ErrorType", errorCode)
                                        .withHeader("Date", DateUtils.formatRfc1123Date(serviceTime))
                                        .withBody("{}")));

    stubFor(post(urlEqualTo(PATH))
                    .inScenario(SCENARIO)
                    .whenScenarioStateIs("1")
                    .willSetStateTo("2")
                    .willReturn(aResponse()
                                        .withStatus(200)
                                        .withBody(JSON_BODY)));
}
 
Example 3
Source File: ClockSkewAdjustmentTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private void stubForResponse(Instant serviceTime, int statusCode, String errorCode) {
    WireMock.reset();

    stubFor(post(urlEqualTo(PATH))
                    .willReturn(aResponse()
                                        .withStatus(statusCode)
                                        .withHeader("x-amzn-ErrorType", errorCode)
                                        .withHeader("Date", DateUtils.formatRfc1123Date(serviceTime))
                                        .withBody("{}")));
}
 
Example 4
Source File: MarshallingTestRunner.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Reset wire mock and re-configure stubbing.
 */
private void resetWireMock() {
    WireMock.reset();
    // Stub to return 200 for all requests
    ResponseDefinitionBuilder responseDefBuilder = aResponse().withStatus(200);
    // XML Unmarshallers expect at least one level in the XML document.
    if (model.getMetadata().isXmlProtocol()) {
        responseDefBuilder.withBody("<foo></foo>");
    }
    stubFor(any(urlMatching(".*")).willReturn(responseDefBuilder));
}
 
Example 5
Source File: WireMockConfiguration.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
void resetMappings() {
	if (this.server.isRunning()) {
		this.server.resetAll();
		this.server.resetRequests();
		this.server.resetScenarios();
		WireMock.reset();
		WireMock.resetAllRequests();
		WireMock.resetAllScenarios();
		registerStubs();
		logRegisteredMappings();
	}
}
 
Example 6
Source File: UserServiceClientWireMockTest.java    From spring-microservice-sample with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void setup() {
    WireMock.reset();
}
 
Example 7
Source File: FakeHttpServer.java    From styx with Apache License 2.0 4 votes vote down vote up
public FakeHttpServer reset() {
    configureFor("localhost", adminPort());
    WireMock.reset();
    return this;
}
 
Example 8
Source File: FakeHttpServer.java    From styx with Apache License 2.0 4 votes vote down vote up
public FakeHttpServer reset() {
    configureFor("localhost", adminPort());
    WireMock.reset();
    return this;
}
 
Example 9
Source File: UnmarshallingTestRunner.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * Reset wire mock and re-configure stubbing.
 */
private void resetWireMock(GivenResponse givenResponse) {
    WireMock.reset();
    // Stub to return given response in test definition.
    stubFor(any(urlMatching(".*")).willReturn(toResponseBuilder(givenResponse)));
}
 
Example 10
Source File: CDIFollowRedirectsTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@BeforeMethod
public void reset() {
    WireMock.reset();
}
 
Example 11
Source File: FollowRedirectsTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@BeforeMethod
public void reset() {
    WireMock.reset();
}
 
Example 12
Source File: WiremockArquillianTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupServer() {
    setupWireMockConnection();
    WireMock.configureFor(scheme, host, port, context);
    WireMock.reset();
}