@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;
    // 2 secs should be fine
    assertTrue(Math.abs(diff - maxAge) <= 2);
}