use of com.google.mockwebserver.MockWebServer in project platform_frameworks_base by android.
the class CookiesTest method testCookiesWithNonMatchingCase.
/**
* Test that cookies aren't case-sensitive with respect to hostname.
* http://b/3167208
*/
public void testCookiesWithNonMatchingCase() throws Exception {
// use a proxy so we can manipulate the origin server's host name
server = new MockWebServer();
server.enqueue(new MockResponse().addHeader("Set-Cookie: a=first; Domain=my.t-mobile.com").addHeader("Set-Cookie: b=second; Domain=.T-mobile.com").addHeader("Set-Cookie: c=third; Domain=.t-mobile.com").setBody("This response sets some cookies."));
server.enqueue(new MockResponse().setBody("This response gets those cookies back."));
server.play();
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost("localhost", server.getPort()));
HttpResponse getCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
getCookies.getEntity().consumeContent();
server.takeRequest();
HttpResponse sendCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
sendCookies.getEntity().consumeContent();
RecordedRequest sendCookiesRequest = server.takeRequest();
assertContains(sendCookiesRequest.getHeaders(), "Cookie: a=first; b=second; c=third");
}
use of com.google.mockwebserver.MockWebServer in project platform_frameworks_base by android.
the class CookiesTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
server = new MockWebServer();
}
use of com.google.mockwebserver.MockWebServer in project android_frameworks_base by crdroidandroid.
the class CookiesTest method testCookiesWithNonMatchingCase.
/**
* Test that cookies aren't case-sensitive with respect to hostname.
* http://b/3167208
*/
public void testCookiesWithNonMatchingCase() throws Exception {
// use a proxy so we can manipulate the origin server's host name
server = new MockWebServer();
server.enqueue(new MockResponse().addHeader("Set-Cookie: a=first; Domain=my.t-mobile.com").addHeader("Set-Cookie: b=second; Domain=.T-mobile.com").addHeader("Set-Cookie: c=third; Domain=.t-mobile.com").setBody("This response sets some cookies."));
server.enqueue(new MockResponse().setBody("This response gets those cookies back."));
server.play();
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost("localhost", server.getPort()));
HttpResponse getCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
getCookies.getEntity().consumeContent();
server.takeRequest();
HttpResponse sendCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
sendCookies.getEntity().consumeContent();
RecordedRequest sendCookiesRequest = server.takeRequest();
assertContains(sendCookiesRequest.getHeaders(), "Cookie: a=first; b=second; c=third");
}
use of com.google.mockwebserver.MockWebServer in project robospice by stephanenicolas.
the class BitmapRequestTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mockWebServer = new MockWebServer();
cacheFile = new File(getContext().getCacheDir(), "test");
cacheFile.delete();
}
use of com.google.mockwebserver.MockWebServer in project ribbon by Netflix.
the class ManyShortLivedRequestsSurvivorTest method survive.
@Test
public void survive() throws IOException, ClientException, URISyntaxException, InterruptedException {
String clientName = "RibbonClientTest-loadBalancingDefaultPolicyRoundRobin";
String serverListKey = clientName + ".ribbon.listOfServers";
int nbHitsPerServer = 60;
MockWebServer server1 = new MockWebServer();
MockWebServer server2 = new MockWebServer();
for (int i = 0; i < nbHitsPerServer; i++) {
server1.enqueue(new MockResponse().setResponseCode(200).setBody("server1 success <" + i + ">!"));
server2.enqueue(new MockResponse().setResponseCode(200).setBody("server2 success <" + i + ">!"));
}
server1.play();
server2.play();
getConfigInstance().setProperty(serverListKey, hostAndPort(server1.getUrl("")) + "," + hostAndPort(server2.getUrl("")));
RestClient client = (RestClient) ClientFactory.getNamedClient(clientName);
HttpRequest request;
for (int i = 0; i < nbHitsPerServer * 2; i++) {
request = HttpRequest.newBuilder().uri(new URI("/")).build();
HttpResponse response = client.executeWithLoadBalancer(request);
response.close();
}
}
Aggregations