@Test public void testEncodingSingleCookieV0() throws ParseException { int maxAge = 50; String result = "myCookie=myValue; Max-Age=50; Expires=(.+?); Path=/apathsomewhere; Domain=.adomainsomewhere; Secure"; Cookie cookie = new DefaultCookie("myCookie", "myValue"); cookie.setDomain(".adomainsomewhere"); cookie.setMaxAge(maxAge); cookie.setPath("/apathsomewhere"); cookie.setSecure(true); String encodedCookie = ServerCookieEncoder.STRICT.encode(cookie); Matcher matcher = Pattern.compile(result).matcher(encodedCookie); assertTrue(matcher.find()); Date expiresDate = DateFormatter.parseHttpDate(matcher.group(1)); long diff = (expiresDate.getTime() - System.currentTimeMillis()) / 1000; assertTrue(Math.abs(diff - maxAge) <= 2); }
public String encode(String name, String value) { return encode(new DefaultCookie(name, value)); }
ServerCookieEncoder extends CookieEncoder { public String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } }
ServerCookieEncoder extends CookieEncoder { public String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } private  ServerCookieEncoder(boolean strict); }
ServerCookieEncoder extends CookieEncoder { public String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } private  ServerCookieEncoder(boolean strict); String encode(String name, String value); String encode(Cookie cookie); List<String> encode(Cookie... cookies); List<String> encode(Collection<? extends Cookie> cookies); List<String> encode(Iterable<? extends Cookie> cookies); }
ServerCookieEncoder extends CookieEncoder { public String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } private  ServerCookieEncoder(boolean strict); String encode(String name, String value); String encode(Cookie cookie); List<String> encode(Cookie... cookies); List<String> encode(Collection<? extends Cookie> cookies); List<String> encode(Iterable<? extends Cookie> cookies); static final ServerCookieEncoder STRICT; static final ServerCookieEncoder LAX; }