use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class CookieTest method testDisabledCookies.
@Test
public void testDisabledCookies() {
ClientConfig cc = new ClientConfig();
cc.property(JettyClientProperties.DISABLE_COOKIES, true);
cc.connectorProvider(new JettyConnectorProvider());
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 JettyConnector connector = (JettyConnector) client.getConfiguration().getConnector();
if (connector.getCookieStore() != null) {
assertTrue(connector.getCookieStore().getCookies().isEmpty());
} else {
assertNull(connector.getCookieStore());
}
client.close();
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class CookieTest method testDisabledCookies.
@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());
}
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class ShutdownHookMemoryLeakTest method getShutdownHooks.
private Collection getShutdownHooks(javax.ws.rs.client.Client client) throws NoSuchFieldException, IllegalAccessException {
JerseyClient jerseyClient = (JerseyClient) client;
Field shutdownHooksField = JerseyClient.class.getDeclaredField("shutdownHooks");
shutdownHooksField.setAccessible(true);
return (Collection) shutdownHooksField.get(jerseyClient);
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class ClientDestroyTest method testLifecycleListenerProvider.
@Test
public void testLifecycleListenerProvider() {
final JerseyClientBuilder builder = new JerseyClientBuilder();
final JerseyClient client = builder.build();
final BarListener filter = new BarListener();
final BarListener filter2 = new BarListener2();
// ClientRuntime initializes lazily, so it is forced by invoking a (dummy) request
// instance registered into client
client.register(filter2);
// instance registration into target
client.target(getBaseUri()).register(filter).request().get(String.class);
assertTrue("Filter was expected to be already initialized.", filter.isInitialized());
assertTrue("Filter2 was expected to be already initialized.", filter2.isInitialized());
// class registration into target
client.target(getBaseUri()).register(FooListener.class).request().get(String.class);
assertTrue("Class-registered filter was expected to be already initialized", FooListener.isInitialized());
assertFalse("Class-registered filter was expected to be still open.", FooListener.isClosed());
assertFalse("Filter was expected to be still open.", filter.isClosed());
assertFalse("Filter2 was expected to be still open.", filter2.isClosed());
client.close();
assertTrue("Class-registered filter was expected to be closed.", FooListener.isClosed());
assertTrue("Filter was expected to be closed.", filter.isClosed());
assertTrue("Filter2 was expected to be closed.", filter2.isClosed());
}
Aggregations