use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method replaceCookieWhenSetOnSamePathBySameUri.
// NOTE: Similar to replaceCookieWhenSetOnSameDomainAndPath()
private void replaceCookieWhenSetOnSamePathBySameUri() {
CookieStore store = new ThreadSafeCookieStore();
Uri uri = Uri.create("https://foo.org/");
store.add(uri, ClientCookieDecoder.LAX.decode("cookie1=VALUE1; Path=/"));
store.add(uri, ClientCookieDecoder.LAX.decode("cookie1=VALUE2; Path=/"));
store.add(uri, ClientCookieDecoder.LAX.decode("cookie1=VALUE3; Path=/"));
assertTrue(store.getAll().size() == 1);
assertTrue(store.get(uri).get(0).value().equals("VALUE3"));
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method cookieWithSameNameMustCoexistIfSetOnDifferentDomains.
private void cookieWithSameNameMustCoexistIfSetOnDifferentDomains() {
CookieStore store = new ThreadSafeCookieStore();
Uri uri1 = Uri.create("http://www.foo.com");
store.add(uri1, ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com"));
Uri uri2 = Uri.create("http://www.bar.com");
store.add(uri2, ClientCookieDecoder.LAX.decode("ALPHA=VALUE2; Domain=www.bar.com"));
assertTrue(store.get(uri1).size() == 1);
assertTrue(store.get(uri1).get(0).value().equals("VALUE1"));
assertTrue(store.get(uri2).size() == 1);
assertTrue(store.get(uri2).get(0).value().equals("VALUE2"));
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method ignoreQueryParametersInUri.
private void ignoreQueryParametersInUri() {
CookieStore store = new ThreadSafeCookieStore();
store.add(Uri.create("http://www.foo.com/bar?query1"), ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com; path=/"));
assertTrue(store.get(Uri.create("http://www.foo.com/bar?query2")).size() == 1);
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class CookieStoreTest method replaceCookieWhenSetOnSameDomainAndPath.
private void replaceCookieWhenSetOnSameDomainAndPath() {
CookieStore store = new ThreadSafeCookieStore();
Uri uri = Uri.create("http://www.foo.com/bar/baz");
store.add(uri, ClientCookieDecoder.LAX.decode("ALPHA=VALUE1; Domain=www.foo.com; path=/bar"));
store.add(uri, ClientCookieDecoder.LAX.decode("ALPHA=VALUE2; Domain=www.foo.com; path=/bar"));
assertTrue(store.getAll().size() == 1);
assertTrue(store.get(uri).get(0).value().equals("VALUE2"));
}
use of org.asynchttpclient.cookie.CookieStore in project async-http-client by AsyncHttpClient.
the class DefaultAsyncHttpClientTest method testWithSharedNettyTimerShouldScheduleCookieEvictionOnlyOnce.
@Test
public void testWithSharedNettyTimerShouldScheduleCookieEvictionOnlyOnce() throws IOException {
Timer nettyTimerMock = mock(Timer.class);
CookieStore cookieStore = new ThreadSafeCookieStore();
AsyncHttpClientConfig config = config().setNettyTimer(nettyTimerMock).setCookieStore(cookieStore).build();
try (AsyncHttpClient client1 = asyncHttpClient(config)) {
try (AsyncHttpClient client2 = asyncHttpClient(config)) {
assertEquals(cookieStore.count(), 2);
verify(nettyTimerMock, times(1)).newTimeout(any(CookieEvictionTask.class), anyLong(), any(TimeUnit.class));
}
}
}
Aggregations