本文整理了Java中com.squareup.okhttp.mockwebserver.MockWebServer.getUrl()
方法的一些代码示例,展示了MockWebServer.getUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.getUrl()
方法的具体详情如下:
包路径:com.squareup.okhttp.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:getUrl
[英]Returns a URL for connecting to this server.
[中]返回用于连接到此服务器的URL。
代码示例来源:origin: facebook/stetho
compress(decompressed));
Request request = new Request.Builder()
.url(server.getUrl("/"))
.addHeader("Content-Encoding", "gzip")
.post(compressedBody)
代码示例来源:origin: segmentio/analytics-android
@Override
protected HttpURLConnection openConnection(String url) throws IOException {
String path = Uri.parse(url).getPath();
URL mockServerURL = server.getUrl(path);
return super.openConnection(mockServerURL.toString());
}
});
代码示例来源:origin: apache/jclouds
@BeforeMethod
public void start() throws IOException, URISyntaxException {
super.start();
vaultUri = server.getUrl("").toURI();
}
代码示例来源:origin: apache/jclouds
static MockWebServer createMockWebServer() throws IOException {
MockWebServer server = new MockWebServer();
server.play();
URL url = server.getUrl("");
return server;
}
代码示例来源:origin: Coinomi/coinomi-android
@Before
public void setup() throws IOException {
server = new MockWebServer();
server.start();
shapeShift = new ShapeShift();
shapeShift.baseUrl = server.getUrl("/").toString();
shapeShift.client.setConnectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT));
}
代码示例来源:origin: apache/jclouds
public void testInstanceReturns404() throws Exception {
server.enqueue(response404());
Instance instance = resourceApi().instance(server.getUrl("/foo/bar").toURI());
assertNull(instance);
assertSent(server, "GET", "/foo/bar");
}
代码示例来源:origin: apache/jclouds
public void testImageReturns404() throws Exception {
server.enqueue(response404());
Image image = resourceApi().image(server.getUrl("/foo/bar").toURI());
assertNull(image);
assertSent(server, "GET", "/foo/bar");
}
代码示例来源:origin: apache/jclouds
public void testNetworkReturns404() throws Exception {
server.enqueue(response404());
Network network = resourceApi().network(server.getUrl("/foo/bar").toURI());
assertNull(network);
assertSent(server, "GET", "/foo/bar");
}
代码示例来源:origin: apache/jclouds
@Test
public void testNoRetriesSuccessful() throws Exception {
MockWebServer server = mockWebServer(new MockResponse());
IntegrationTestClient client = client(server.getUrl("/").toString());
try {
client.download("");
assertEquals(server.getRequestCount(), 1);
} finally {
closeQuietly(client);
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testDisk() throws Exception {
server.enqueue(jsonResponse("/disk_get.json"));
Disk disk = resourceApi().disk(server.getUrl("/foo/bar").toURI());
assertEquals(disk, new ParseDiskTest().expected(url("/projects")));
assertSent(server, "GET", "/foo/bar");
}
代码示例来源:origin: apache/jclouds
public void testStopInstance() throws Exception {
server.enqueue(jsonResponse("/operation.json"));
Operation operation = resourceApi().stopInstance(server.getUrl("/foo/bar").toURI());
assertEquals(operation, new ParseOperationTest().expected(url("/projects")));
assertSent(server, "POST", "/foo/bar/stop");
}
代码示例来源:origin: apache/jclouds
public void testSetTagsOnNonExistingVirtualGuest() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(404));
VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
VirtualGuest virtualGuest = createVirtualGuest();
try {
assertFalse(api.setTags(virtualGuest.getId(), ImmutableSet.of("test1", "test2", "test3")));
assertSent(server, "POST", "/SoftLayer_Virtual_Guest/1301396/setTags");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testConnectContainerToNetwork() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(200));
NetworkApi api = api(DockerApi.class, server.getUrl("/").toString()).getNetworkApi();
try {
api.connectContainerToNetwork("123456789", "containerName");
assertSent(server, "POST", "/networks/123456789/connect", "{ \"Container\": \"containerName\" }");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testDisconnectContainerFromNetwork() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(200));
NetworkApi api = api(DockerApi.class, server.getUrl("/").toString()).getNetworkApi();
try {
api.disconnectContainerFromNetwork("123456789", "containerName");
assertSent(server, "POST", "/networks/123456789/disconnect", "{ \"Container\": \"containerName\" }");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testWaitContainer() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(200));
ContainerApi api = api(DockerApi.class, server.getUrl("/").toString()).getContainerApi();
try {
api.wait("1");
assertSent(server, "POST", "/containers/1/wait");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testRestartContainer() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(204));
ContainerApi api = api(DockerApi.class, server.getUrl("/").toString()).getContainerApi();
try {
api.restart("1");
assertSent(server, "POST", "/containers/1/restart");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testCopyFileFromContainer() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(204));
ContainerApi api = api(DockerApi.class, server.getUrl("/").toString()).getContainerApi();
try {
api.copy("1", Resource.create("test"));
assertSent(server, "POST", "/containers/1/copy");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testCreateImage() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setResponseCode(200));
ImageApi api = api(DockerApi.class, server.getUrl("/").toString()).getImageApi();
try {
api.createImage(CreateImageOptions.Builder.fromImage("base"));
assertSent(server, "POST", "/images/create?fromImage=base");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testRebootHardVirtualGuest() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/datacenter_get.json")));
VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
try {
api.rebootHardVirtualGuest(1301396);
assertSent(server, "GET", "/SoftLayer_Virtual_Guest/1301396/rebootHard.json");
} finally {
server.shutdown();
}
}
代码示例来源:origin: apache/jclouds
public void testPauseVirtualGuest() throws Exception {
MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/datacenter_get.json")));
VirtualGuestApi api = api(SoftLayerApi.class, server.getUrl("/").toString()).getVirtualGuestApi();
try {
api.pauseVirtualGuest(1301396);
assertSent(server, "GET", "/SoftLayer_Virtual_Guest/1301396/pause.json");
} finally {
server.shutdown();
}
}
内容来源于网络,如有侵权,请联系作者删除!