Skip to content

Instantly share code, notes, and snippets.

@kzimnicki-zalando
Created July 8, 2016 07:13
Show Gist options
  • Save kzimnicki-zalando/98ebcf140d578b1bb74222b179d0f69e to your computer and use it in GitHub Desktop.
Save kzimnicki-zalando/98ebcf140d578b1bb74222b179d0f69e to your computer and use it in GitHub Desktop.
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
curl http://localhost:8089/ &
package org.sample;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
public class Test {
private static final String SCENARIO_NAME = "scenario1";
private static final String FIRST_STATE = Scenario.STARTED;
private static final String SECOND_STATE = "2nd";
public static void main(String[] args) throws InterruptedException {
WireMockServer server = new WireMockServer(8089);
server.stubFor(WireMock.get(WireMock.urlMatching("/"))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs(FIRST_STATE)
.willSetStateTo(SECOND_STATE)
.willReturn(
WireMock.aResponse()
.withBody("1\n")
.withStatus(200)
));
server.stubFor(WireMock.get(WireMock.urlMatching("/"))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs(SECOND_STATE)
.willReturn(
WireMock.aResponse()
.withBody("2\n")
.withStatus(200))
);
server.start();
Thread.sleep(20 * 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment