use of com.google.mockwebserver.MockWebServer in project robovm by robovm.
the class CookiesTest method testQuotedAttributeValues.
public void testQuotedAttributeValues() throws Exception {
CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER);
CookieHandler.setDefault(cookieManager);
MockWebServer server = new MockWebServer();
try {
// RoboVM note: Modified to call server.shutdown() after test finishes.
server.play();
server.enqueue(new MockResponse().addHeader("Set-Cookie2: a=\"android\"; " + "Comment=\"this cookie is delicious\"; " + "CommentURL=\"http://google.com/\"; " + "Discard; " + "Domain=\"" + server.getCookieDomain() + "\"; " + "Max-Age=\"60\"; " + "Path=\"/path\"; " + "Port=\"80,443," + server.getPort() + "\"; " + "Secure; " + "Version=\"1\""));
get(server, "/path/foo");
List<HttpCookie> cookies = cookieManager.getCookieStore().getCookies();
assertEquals(1, cookies.size());
HttpCookie cookie = cookies.get(0);
assertEquals("a", cookie.getName());
assertEquals("android", cookie.getValue());
assertEquals("this cookie is delicious", cookie.getComment());
assertEquals("http://google.com/", cookie.getCommentURL());
assertEquals(true, cookie.getDiscard());
assertEquals(server.getCookieDomain(), cookie.getDomain());
assertEquals(60, cookie.getMaxAge());
assertEquals("/path", cookie.getPath());
assertEquals("80,443," + server.getPort(), cookie.getPortlist());
assertEquals(true, cookie.getSecure());
assertEquals(1, cookie.getVersion());
} finally {
server.shutdown();
}
}
use of com.google.mockwebserver.MockWebServer in project robovm by robovm.
the class URLConnectionTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
server = new MockWebServer();
hostName = server.getHostName();
}
use of com.google.mockwebserver.MockWebServer in project platform_frameworks_base by android.
the class DownloadManagerBaseTest method setUp.
/**
* {@inheritDoc}
*/
@Override
public void setUp() throws Exception {
mContext = getInstrumentation().getContext();
mDownloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
mServer = new MockWebServer();
mServer.play();
mReceiver = registerNewMultipleDownloadsReceiver();
// Note: callers overriding this should call mServer.play() with the desired port #
}
use of com.google.mockwebserver.MockWebServer in project platform_frameworks_base by android.
the class DefaultHttpClientTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
server = new MockWebServer();
}
use of com.google.mockwebserver.MockWebServer in project j2objc by google.
the class CookiesTest method testNetscapeResponse.
public void testNetscapeResponse() throws Exception {
CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER);
CookieHandler.setDefault(cookieManager);
MockWebServer server = new MockWebServer();
server.play();
server.enqueue(new MockResponse().addHeader("Set-Cookie: a=android; " + "expires=Fri, 31-Dec-9999 23:59:59 GMT; " + "path=/path; " + "domain=" + server.getCookieDomain() + "; " + "secure"));
get(server, "/path/foo");
List<HttpCookie> cookies = cookieManager.getCookieStore().getCookies();
assertEquals(1, cookies.size());
HttpCookie cookie = cookies.get(0);
assertEquals("a", cookie.getName());
assertEquals("android", cookie.getValue());
assertEquals(null, cookie.getComment());
assertEquals(null, cookie.getCommentURL());
assertEquals(false, cookie.getDiscard());
assertEquals(server.getCookieDomain(), cookie.getDomain());
assertTrue(cookie.getMaxAge() > 100000000000L);
assertEquals("/path", cookie.getPath());
assertEquals(true, cookie.getSecure());
assertEquals(0, cookie.getVersion());
}
Aggregations