本文整理了Java中com.squareup.okhttp.mockwebserver.MockWebServer.getRequestCount()
方法的一些代码示例,展示了MockWebServer.getRequestCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.getRequestCount()
方法的具体详情如下:
包路径:com.squareup.okhttp.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:getRequestCount
[英]Returns the number of HTTP requests received thus far by this server. This may exceed the number of HTTP connections when connection reuse is in practice.
[中]返回此服务器迄今收到的HTTP请求数。在实际使用连接重用时,这可能超过HTTP连接数。
代码示例来源:origin: apache/jclouds
/**
* Ensures server received a <i>versioned</i> extensions request. This is necessary for testing APIs whose version
* is not included in the Endpoint's {@link Endpoint#getPublicURL() publicURL}.
*/
public void assertExtensions(MockWebServer server, String path) {
assertTrue(server.getRequestCount() >= 1);
try {
assertEquals(server.takeRequest().getRequestLine(), "GET " + path + "/extensions HTTP/1.1");
} catch (InterruptedException e) {
Throwables.propagate(e);
}
}
代码示例来源:origin: apache/jclouds
public void testDeleteResourceGroup() throws InterruptedException {
server.enqueue(response202WithHeader());
URI uri = api.getResourceGroupApi().delete("jcloudstest");
assertEquals(server.getRequestCount(), 1);
assertSent(server, "DELETE", requestUrl + "/jcloudstest" + version);
assertNotNull(uri);
assertTrue(uri.toString().contains("api-version"));
assertTrue(uri.toString().contains("operationresults"));
}
代码示例来源:origin: apache/jclouds
public void testListResourceGroupsReturns404() throws InterruptedException {
server.enqueue(response404());
List<ResourceGroup> resourceGroups = api.getResourceGroupApi().list();
assertTrue(isEmpty(resourceGroups));
assertEquals(server.getRequestCount(), 1);
assertSent(server, "GET", requestUrl + version);
}
代码示例来源:origin: apache/jclouds
public void testListSnapshotsReturns404() throws InterruptedException {
server.enqueue(response404());
Iterable<Snapshot> snapshots = api.dropletApi().listSnapshots(5425561).concat();
assertTrue(isEmpty(snapshots));
assertEquals(server.getRequestCount(), 1);
assertSent(server, "GET", "/droplets/5425561/snapshots");
}
代码示例来源:origin: apache/jclouds
public void testListProjectsReturns404() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(response404());
List<Project> projects = api.getProjectApi().list();
assertTrue(projects.isEmpty());
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/projects");
}
代码示例来源:origin: apache/jclouds
public void testListRegions() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(jsonResponse("/v3/regions.json"));
List<Region> regions = api.getRegionApi().list();
assertFalse(regions.isEmpty());
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/regions");
}
代码示例来源:origin: apache/jclouds
public void testListGroups() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(jsonResponse("/v3/groups.json"));
List<Group> groups = api.getUserApi().listGroups("0bedc61110fd4e94a251260a47f18f29");
assertFalse(groups.isEmpty());
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/users/0bedc61110fd4e94a251260a47f18f29/groups");
}
代码示例来源:origin: apache/jclouds
public void testListEndpoints() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(jsonResponse("/v3/endpoints.json"));
List<Endpoint> endpoints = api.getCatalogApi().endpoints();
assertFalse(endpoints.isEmpty());
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/endpoints");
}
代码示例来源:origin: apache/jclouds
public void testGetImage() throws InterruptedException {
server.enqueue(jsonResponse("/image.json"));
Image image = api.imageApi().get(1);
assertEquals(image, imageFromResource("/image.json"));
assertEquals(server.getRequestCount(), 1);
assertSent(server, "GET", "/images/1");
}
代码示例来源:origin: appnexus/mobile-sdk-android
private void confirmNoImpressionULRinQueue() {
// Wait for Any tasks and flush them.
waitForTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
// waitForTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
assertTrue(server.getRequestCount() == 1);
}
代码示例来源:origin: apache/jclouds
public void testDeleteDropletReturns404() throws InterruptedException {
server.enqueue(response404());
api.dropletApi().delete(1);
assertEquals(server.getRequestCount(), 1);
assertSent(server, "DELETE", "/droplets/1");
}
代码示例来源:origin: jclouds/jclouds-labs
public void testListOsImage() throws Exception {
server.enqueue(jsonResponse("/osImages.json"));
Iterable<OsImage> osImages = api.getServerImageApi().listOsImages().concat();
assertEquals(size(osImages), 1);
assertEquals(server.getRequestCount(), 2);
assertSent(HttpMethod.GET, getOsImageUrl().toString());
}
代码示例来源:origin: apache/jclouds
public void testGetProjectReturns404() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(response404());
Project project = api.getProjectApi().get("2f9b30f706bc45d7923e055567be2e98");
assertNull(project);
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/projects/2f9b30f706bc45d7923e055567be2e98");
}
代码示例来源:origin: apache/jclouds
public void testGetRegionReturns404() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(response404());
Region region = api.getRegionApi().get("RegionOne");
assertNull(region);
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "GET", "/regions/RegionOne");
}
代码示例来源:origin: jclouds/jclouds-labs
public void testListCustomerImageWithDatacenterFiltering() throws Exception {
server.enqueue(jsonResponse("/customerImages.json"));
Iterable<CustomerImage> customerImages = api.getServerImageApi().listCustomerImages(datacenterId(datacenters));
assertEquals(size(customerImages), 1);
assertEquals(server.getRequestCount(), 2);
assertSent(HttpMethod.GET, addZonesToUriBuilder("datacenterId", getCustomerImageUrl()).toString());
}
代码示例来源:origin: apache/jclouds
public void testListBackups() throws InterruptedException {
server.enqueue(jsonResponse("/backups-first.json"));
server.enqueue(jsonResponse("/backups-last.json"));
Iterable<Backup> backups = api.dropletApi().listBackups(5425561).concat();
assertEquals(size(backups), 2); // Force the PagedIterable to advance
assertEquals(server.getRequestCount(), 2);
assertSent(server, "GET", "/droplets/5425561/backups");
assertSent(server, "GET", "/droplets/5425561/backups?page=2");
}
代码示例来源:origin: apache/jclouds
public void testGetToken() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(jsonResponse("/v3/token.json"));
Token token = api.getAuthApi().get(authToken);
assertEquals(token, tokenFromResource("/v3/token.json"));
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
RecordedRequest request = assertSent(server, "GET", "/auth/tokens");
assertEquals(request.getHeader("X-Subject-Token"), authToken);
}
代码示例来源:origin: jclouds/jclouds-labs
public void testListOsImageWithDatacenterIdFiltering() throws Exception {
server.enqueue(jsonResponse("/osImages.json"));
Iterable<OsImage> osImages = api.getServerImageApi().listOsImages(datacenterId(datacenters)).toList();
assertEquals(size(osImages), 1);
assertEquals(server.getRequestCount(), 2);
assertSent(HttpMethod.GET, addZonesToUriBuilder("datacenterId", getOsImageUrl()).toString());
}
代码示例来源:origin: apache/jclouds
public void testGetUserOfToken() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(jsonResponse("/v3/token.json"));
User user = api.getAuthApi().getUserOfToken(authToken);
assertEquals(user, tokenFromResource("/v3/token.json").user());
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
RecordedRequest request = assertSent(server, "GET", "/auth/tokens");
assertEquals(request.getHeader("X-Subject-Token"), authToken);
}
代码示例来源:origin: apache/jclouds
public void testChangePassword() throws InterruptedException {
enqueueAuthentication(server);
server.enqueue(response204());
api.getUserApi().changePassword("0bedc61110fd4e94a251260a47f18f29", "foo", "bar");
assertEquals(server.getRequestCount(), 2);
assertAuthentication(server);
assertSent(server, "POST", "/users/0bedc61110fd4e94a251260a47f18f29/password",
"{\"user\":{\"original_password\":\"foo\",\"password\":\"bar\"}}");
}
}
内容来源于网络,如有侵权,请联系作者删除!