Examples of NewCookie


Examples of javax.ws.rs.core.NewCookie

        assertNotNull(r.getMetadata());
        assertEquals(r.getStatus(), 200);

        URI loc = new URI("/defects/5");
        r =
            Response.created(loc).cookie(new NewCookie("cName", "cValue")).expires(new Date())
                .build();
        assertEquals(loc, r.getMetadata().getFirst(HttpHeaders.LOCATION));
        assertTrue(r.getMetadata().getFirst(HttpHeaders.SET_COOKIE).toString().indexOf("cName") > -1);

        r = Response.serverError().build();
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

        return buildNewCookie(modifiableCookie);

    }

    private NewCookie buildNewCookie(ModifiableCookie modifiableCookie) {
        NewCookie newCookie =
            new NewCookie(modifiableCookie.name, modifiableCookie.value, modifiableCookie.path,
                          modifiableCookie.domain, modifiableCookie.comment,
                          modifiableCookie.maxAge, modifiableCookie.secure);
        return newCookie;
    }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

      String output = "Created customer <a href=\"customers/" + customer.getId() + "\">" + customer.getId() + "</a>";
      String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
      URI location = URI.create("/customers/" + customer.getId());
      return Response.created(location)
              .entity(output)
              .cookie(new NewCookie("last-visit", lastVisit))
              .build();

   }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

      String output = "User-Agent: " + userAgent + "\r\n";
      output += "Last visit: " + date + "\r\n\r\n";
      output += "Customer: " + customer.getFirstName() + " " + customer.getLastName();
      String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
      return Response.ok(output)
              .cookie(new NewCookie("last-visit", lastVisit))
              .build();
   }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

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

Examples of javax.ws.rs.core.NewCookie

    }
   
       
    @Test
    public void testFromComplexString() {
        NewCookie c = NewCookie.valueOf(
                      "foo=bar;Comment=comment;Path=path;Max-Age=10;Domain=domain;Secure;Version=1");
        assertTrue("bar".equals(c.getValue())
                   && "foo".equals(c.getName())
                   && 1 == c.getVersion()
                   && "path".equals(c.getPath())
                   && "domain".equals(c.getDomain())
                   && "comment".equals(c.getComment())
                   && 10 == c.getMaxAge());
    }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

                   && 10 == c.getMaxAge());
    }
   
    @Test
    public void testToString() {
        NewCookie c = new NewCookie("foo", "bar", "path", "domain", "comment", 2, true);
        assertEquals("foo=bar;Comment=comment;Domain=domain;Max-Age=2;Path=path;Secure",
                     c.toString());
              
    }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

    @Test
    public void testAddCookie() {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Set-Cookie", "a=b");
        m.add("Set-Cookie", "c=d");
        checkBuild(Response.ok().cookie(new NewCookie("a", "b"))
                                .cookie(new NewCookie("c", "d")).build(),
                  200, null, m);
    }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

       
        if (name == null || value == null) {
            throw new IllegalArgumentException("Set-Cookie is malformed : " + c);
        }
       
        return new NewCookie(name, value, path, domain, comment, maxAge, isSecure);
    }
View Full Code Here

Examples of javax.ws.rs.core.NewCookie

    }
   
    @Test
    public void testAddCookie() {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Set-Cookie", new NewCookie("a", "b"));
        m.add("Set-Cookie", new NewCookie("c", "d"));
        checkBuild(Response.ok().cookie(new NewCookie("a", "b"))
                                .cookie(new NewCookie("c", "d")).build(),
                  200, null, m);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.