Package javax.ws.rs.core

Examples of javax.ws.rs.core.NewCookie


      String value = user.get().getSessionToken().toString();

      log.debug("Replacing session token with {}", value);

      return new NewCookie(
        OpenIDDemoConfiguration.SESSION_TOKEN_NAME,
        value,   // Value
        "/",     // Path
        null,    // Domain
        null,    // Comment
        86400 * 30, // 30 days
        false);
    } else {
      // Remove the session token cookie
      log.debug("Removing session token");

      return new NewCookie(
        OpenIDDemoConfiguration.SESSION_TOKEN_NAME,
        null,   // Value
        null,    // Path
        null,   // Domain
        null,   // Comment
View Full Code Here


                comment + "=Testing;" +
                version + "=1;" +
                secure + ";" +
                httpOnly;

        final NewCookie cookie = CookiesParser.parseNewCookie(header);

        assertThat(cookie.getName(), equalTo("foo"));
        assertThat(cookie.getValue(), equalTo("bar"));

        assertThat(cookie.getExpiry(), equalTo(dateFormat.parse("Tue, 15 Jan 2013 21:47:38 GMT")));
        assertThat(cookie.getMaxAge(), equalTo(42));
        assertThat(cookie.getPath(), equalTo("/"));
        assertThat(cookie.getDomain(), equalTo(".example.com"));
        assertThat(cookie.getComment(), equalTo("Testing"));
        assertThat(cookie.getVersion(), equalTo(1));
        assertThat(cookie.isSecure(), is(true));
        assertThat(cookie.isHttpOnly(), is(true));
    }
View Full Code Here

        @GET
        public Response get(@Context HttpHeaders h) {
            Cookie c = h.getCookies().get("name");
            String e = (c == null) ? "NO-COOKIE" : c.getValue();
            return Response.ok(e).
                    cookie(new NewCookie("name", "value")).build();
        }
View Full Code Here

        @GET
        public Response get(@Context HttpHeaders h) {
            Cookie c = h.getCookies().get("name");
            String e = (c == null) ? "NO-COOKIE" : c.getValue();
            return Response.ok(e).
                    cookie(new NewCookie("name", "value")).build();
        }
View Full Code Here

        assertTrue(".sun.com".equals(c.getDomain()));
    }

    @Test
    public void testNewCookieToString() {
        NewCookie cookie = new NewCookie("fred", "flintstone");
        String expResult = "fred=flintstone;Version=1";
        assertEquals(expResult, cookie.toString());

        cookie = new NewCookie("fred", "flintstone", null, null, null, 60, false);
        expResult = "fred=flintstone;Version=1;Max-Age=60";
        assertEquals(expResult, cookie.toString());

        cookie = new NewCookie("fred", "flintstone", null, null,"a modern stonage family", 60, false);
        expResult = "fred=flintstone;Version=1;Comment=\"a modern stonage family\";Max-Age=60";
        assertEquals(expResult, cookie.toString());
    }
View Full Code Here

        assertEquals(expResult, cookie.toString());
    }

    @Test
    public void testNewCookieValueOf() {
        NewCookie cookie = NewCookie.valueOf("fred=flintstone;Version=2");
        assertEquals("fred", cookie.getName());
        assertEquals("flintstone", cookie.getValue());
        assertEquals(2, cookie.getVersion());

        cookie = NewCookie.valueOf("fred=flintstone;Version=1;Max-Age=60");
        assertEquals("fred", cookie.getName());
        assertEquals("flintstone", cookie.getValue());
        assertEquals(1, cookie.getVersion());
        assertEquals(60, cookie.getMaxAge());

        cookie = NewCookie.valueOf("fred=flintstone;Version=1;Comment=\"a modern stonage family\";Max-Age=60;Secure");
        assertEquals("fred", cookie.getName());
        assertEquals("flintstone", cookie.getValue());
        assertEquals("a modern stonage family", cookie.getComment());
        assertEquals(1, cookie.getVersion());
        assertEquals(60, cookie.getMaxAge());
        assertTrue(cookie.isSecure());
    }
View Full Code Here

        List<String> lang = Arrays.asList("en-US", "en-GB", "zh-CN");

        String name = "name_1";
        String value = "value_1";
        Cookie ck1 = new Cookie(name, value);
        NewCookie nck1 = new NewCookie(ck1);

        List<String> cookies = Arrays.asList(nck1.toString().toLowerCase());

        Response.ResponseBuilder respb1 = Response.status(status).
                header("Content-type", "text/plain").header("Content-type",
                "text/html").header("Content-Language", "en-US").
                header("Content-Language", "en-GB").header("Content-Language",
View Full Code Here

        List<String> lang = Arrays.asList("en-US", "en-GB", "zh-CN");

        String name = "name_1";
        String value = "value_1";
        Cookie ck1 = new Cookie(name, value);
        NewCookie nck1 = new NewCookie(ck1);

        List<String> cookies = Arrays.asList(nck1.toString().toLowerCase());

        Response resp = Response.status(status).header("Content-type",
                "text/plain").header("Content-type", "text/html").header("Content-Language", "en-US").
                header("Content-Language", "en-GB").header("Content-Language",
                "zh-CN").header("Cache-Control", "no-transform").
View Full Code Here

        ClientRequestFilter outFilter = new ClientRequestFilter() {

            @Override
            public void filter(ClientRequestContext context) throws IOException {
                NewCookie cookie1 = new NewCookie("cookie1", "cookie1");
                NewCookie cookie2 = new NewCookie("cookie2", "cookie2");
                final Response response = Response.ok().cookie(cookie1).cookie(cookie2)
                        .header("head1", "head1").header(HttpHeaders.DATE, date).header(HttpHeaders.ETAG,
                                "\"123465\"").header(HttpHeaders.CONTENT_LANGUAGE, "language").header(HttpHeaders.LAST_MODIFIED,
                                date).header(HttpHeaders.CONTENT_LENGTH, 99).type(MediaType.TEXT_HTML_TYPE).location(URI.create
                                ("www.oracle.com")).build();
View Full Code Here

public class NewCookieHeaderProviderTest extends Assert {
   
       
    @Test
    public void testFromSimpleString() {
        NewCookie c = NewCookie.parse("foo=bar");
        assertTrue("bar".equals(c.getValue())
                   && "foo".equals(c.getName()));
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.NewCookie

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.