use of com.github.tomakehurst.wiremock.client.WireMock in project azure-sdk-for-java by Azure.
the class MockIntegrationTestBase method setupTest.
protected void setupTest(final String testName) throws Exception {
if (currentTestName == null) {
currentTestName = testName;
} else {
throw new Exception("Setting up another test in middle of a test");
}
SdkContext.setResourceNamerFactory(new TestResourceNamerFactory(this));
SdkContext.setDelayProvider(new TestDelayProvider());
SdkContext.setRxScheduler(Schedulers.trampoline());
int retries = 10;
while (retries > 0) {
retries--;
try {
wireMock = new WireMock(HOST, wireMockRule.port());
wireMock.resetMappings();
break;
} catch (Exception ex) {
Thread.sleep(3000);
}
}
if (IS_MOCKED) {
File recordFile = getRecordFile();
ObjectMapper mapper = new ObjectMapper();
testRecord = mapper.readValue(recordFile, TestRecord.class);
System.out.println("Total records " + testRecord.networkCallRecords.size());
} else {
testRecord = new TestRecord();
}
this.interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
if (IS_MOCKED) {
return registerRecordedResponse(chain);
}
return recordRequestAndResponse(chain);
}
};
}
Aggregations