});
final HttpHost target = start();
final CookieStore cookieStore = new BasicCookieStore();
final HttpClientContext context = HttpClientContext.create();
context.setCookieStore(cookieStore);
// First request : retrieve a domain cookie from remote server.
URI uri = new URI("http://app.mydomain.fr");
HttpRequest httpRequest = new HttpGet(uri);
httpRequest.addHeader("X-Request", "1");
@SuppressWarnings("resource")
final HttpResponse response1 = this.httpclient.execute(target, httpRequest, context);
final HttpEntity e1 = response1.getEntity();
EntityUtils.consume(e1);
// We should have one cookie set on domain.
final List<Cookie> cookies = cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(1, cookies.size());
Assert.assertEquals("name1", cookies.get(0).getName());
// Second request : send the cookie back.