Package org.glassfish.jersey.client

Examples of org.glassfish.jersey.client.JerseyClient$ShutdownHook


    @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();
    }
View Full Code Here


    @Test
    public void testCookies() {
        ClientConfig cc = new ClientConfig();
        cc.connectorProvider(new JettyConnectorProvider());
        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 JettyConnector connector = (JettyConnector) client.getConfiguration().getConnector();
        assertNotNull(connector.getCookieStore().getCookies());
        assertEquals(1, connector.getCookieStore().getCookies().size());
        assertEquals("value", connector.getCookieStore().getCookies().get(0).getValue());
        client.close();
    }
View Full Code Here

    @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());
        }
View Full Code Here

    @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());
    }
View Full Code Here

    }

    @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
        client.register(filter2);                                                   // instance registered into client
        client.target(getBaseUri()).register(filter).request().get(String.class);   // instance registration into target

        assertTrue("Filter was expected to be already initialized.", filter.isInitialized());
        assertTrue("Filter2 was expected to be already initialized.", filter2.isInitialized());

        client.target(getBaseUri()).register(FooListener.class).request().get(String.class); // class registration into target

        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());
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.client.JerseyClient$ShutdownHook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.