@Test public void testCookies() { ClientConfig cc = new ClientConfig(); cc.connectorProvider(new ApacheConnectorProvider()); JerseyClient client = JerseyClientBuilder.createClient(cc); WebTarget r = client.target(getBaseUri()); assertEquals("NO-COOKIE", r.request().get(String.class)); assertEquals("value", r.request().get(String.class)); final ApacheConnector connector = (ApacheConnector) client.getConfiguration().getConnector(); assertNotNull(connector.getCookieStore().getCookies()); assertEquals(1, connector.getCookieStore().getCookies().size()); assertEquals("value", connector.getCookieStore().getCookies().get(0).getValue()); }
@Test public void testDisabledCookies() { ClientConfig cc = new ClientConfig(); cc.property(ApacheClientProperties.DISABLE_COOKIES, true); cc.connectorProvider(new ApacheConnectorProvider()); JerseyClient client = JerseyClientBuilder.createClient(cc); WebTarget r = client.target(getBaseUri()); assertEquals("NO-COOKIE", r.request().get(String.class)); assertEquals("NO-COOKIE", r.request().get(String.class)); final ApacheConnector connector = (ApacheConnector) client.getConfiguration().getConnector(); if (connector.getCookieStore() != null) { assertTrue(connector.getCookieStore().getCookies().isEmpty()); } else { assertNull(connector.getCookieStore()); } }