本文整理了Java中com.squareup.okhttp.mockwebserver.MockWebServer.play()
方法的一些代码示例,展示了MockWebServer.play()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.play()
方法的具体详情如下:
包路径:com.squareup.okhttp.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:play
暂无
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
tempAuthServer = new MockWebServer();
tempAuthServer.play();
swiftServer = new MockWebServer();
swiftServer.play();
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
regionToServers.put(DEFAULT_REGION, server);
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
suffix.set(0);
server = new MockWebServer();
server.play();
}
代码示例来源:origin: apache/jclouds
@BeforeMethod(alwaysRun = true)
public void start() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
regionToServers.put(DEFAULT_REGION, server);
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
suffix.set(0);
server = new MockWebServer();
server.play();
}
代码示例来源:origin: apache/jclouds
public static MockWebServer mockWebServer() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
return server;
}
代码示例来源:origin: apache/jclouds
static MockWebServer createMockWebServer() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
URL url = server.getUrl("");
return server;
}
代码示例来源:origin: apache/jclouds
/**
* Creates a {@link MockWebServer} that uses the
* {@link GlobalChecksRequestDispatcher}.
*/
protected static MockWebServer mockWebServer(MockResponse... responses) throws IOException {
MockWebServer server = new MockWebServer();
server.play();
for (MockResponse response : responses) {
server.enqueue(response);
}
return server;
}
代码示例来源:origin: apache/jclouds
/**
* Creates a {@link MockWebServer} that uses the given {@link Dispatcher}.
*/
protected static MockWebServer mockWebServer(Dispatcher dispatcher) throws IOException {
MockWebServer server = new MockWebServer();
server.play();
server.setDispatcher(dispatcher);
return server;
}
代码示例来源:origin: apache/jclouds
public static MockWebServer mockOpenStackServer() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
URL url = server.getUrl("");
server.setDispatcher(getURLReplacingQueueDispatcher(url));
return server;
}
代码示例来源:origin: apache/jclouds
@Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "This session already has a job running")
public void test200OnFailureThrowsExceptionWithoutRetryWhenJobRunning() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(running));
server.play();
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
try {
api.getZoneApi().list();
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
@Test(expectedExceptions = TargetExistsException.class, expectedExceptionsMessageRegExp = "Name already exists")
public void test200OnFailureThrowsExceptionWithoutRetryOnNameExists() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(targetExists));
server.play();
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
try {
api.getZoneApi().list();
} finally {
server.shutdown();
}
}
}
代码示例来源:origin: apache/jclouds
public void testSourceEncodedOnCopy() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setBody("<CopyObjectResult>\n" +
" <LastModified>2009-10-28T22:32:00</LastModified>\n" +
" <ETag>\"9b2cf535f27731c974343645a3985328\"</ETag>\n" +
" </CopyObjectResult>"));
server.play();
S3Client client = getS3Client(server.getUrl("/"));
client.copyObject("sourceBucket", "apples#?:$&'\"<>čॐ", "destinationBucket", "destinationObject", CopyObjectOptions.NONE);
RecordedRequest request = server.takeRequest();
assertEquals(request.getHeaders("x-amz-copy-source"), ImmutableList.of("/sourceBucket/apples%23%3F%3A%24%26%27%22%3C%3E%C4%8D%E0%A5%90"));
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
server.play();
S3Client client = getS3Client(server.getUrl("/"));
S3Object nada = client.newS3Object();
nada.getMetadata().setKey("object");
nada.setPayload(new byte[] {});
assertEquals(client.putObject("bucket", nada), "ABCDEF");
RecordedRequest request = server.takeRequest();
assertEquals(request.getRequestLine(), "PUT /bucket/object HTTP/1.1");
assertEquals(request.getHeaders(CONTENT_LENGTH), ImmutableList.of("0"));
assertThat(request.getHeaders(EXPECT)).isEmpty();
server.shutdown();
}
代码示例来源:origin: apache/jclouds
@Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "Operation blocked by current task")
public void test200OnFailureThrowsExceptionWithoutRetryWhenOperationBlocked() throws IOException,
InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(taskBlocking));
server.play();
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
try {
api.getZoneApi().list();
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testDirectorySeparator() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
server.play();
S3Client client = getS3Client(server.getUrl("/"));
S3Object fileInDir = client.newS3Object();
fileInDir.getMetadata().setKey("someDir/fileName");
fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });
assertEquals(client.putObject("bucket", fileInDir), "ABCDEF");
RecordedRequest request = server.takeRequest();
assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
server.shutdown();
}
代码示例来源:origin: jclouds/jclouds-labs
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
ctx = ContextBuilder.newBuilder(DimensionDataCloudControlProviderMetadata.builder().build()).credentials("", "")
.endpoint(url("")).modules(modules).overrides(new Properties()).build();
json = ctx.utils().injector().getInstance(Json.class);
api = ctx.getApi();
applyAdditionalServerConfig();
assertedRequestCount = 0;
datacenters = getZones();
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException, URISyntaxException {
server = new MockWebServer();
server.play();
context = ContextBuilder.newBuilder(testProviderMetadata())
.credentials("mock", MOCK_BEARER_TOKEN)
.endpoint(server.getUrl("/").toString() + "subscriptions/SUBSCRIPTIONID")
.modules(setupModules())
.overrides(setupProperties())
.build();
api = context.getApi();
dateService = context.utils().injector().getInstance(DateService.class);
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
ctx = ContextBuilder.newBuilder("packet")
.credentials("", X_AUTHORIZATION_TOKEN)
.endpoint(url(""))
.modules(modules)
.overrides(overrides())
.build();
json = ctx.utils().injector().getInstance(Json.class);
api = ctx.getApi();
}
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
ApiContext<DigitalOcean2Api> ctx = ContextBuilder.newBuilder("digitalocean2")
.credentials("", MOCK_BEARER_TOKEN)
.endpoint(url(""))
.modules(modules)
.overrides(overrides())
.build();
json = ctx.utils().injector().getInstance(Json.class);
api = ctx.getApi();
}
内容来源于网络,如有侵权,请联系作者删除!