More tolerance in CookieEncoderTest
This commit is contained in:
parent
f2f09e66aa
commit
f61412c828
@ -55,11 +55,21 @@ public class CookieEncoderTest {
|
|||||||
String encodedCookie = encoder.encode();
|
String encodedCookie = encoder.encode();
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
assertTrue(
|
boolean fail = true;
|
||||||
encodedCookie.equals(result.replace("XXX", df.format(new Date(currentTime + 50000)))) ||
|
// +/- 10-second tolerance
|
||||||
encodedCookie.equals(result.replace("XXX", df.format(new Date(currentTime + 50750)))) ||
|
for (int delta = 0; delta <= 20000; delta += 250) {
|
||||||
encodedCookie.equals(result.replace("XXX", df.format(new Date(currentTime + 49250)))));
|
if (encodedCookie.equals(result.replace(
|
||||||
|
"XXX", df.format(new Date(currentTime + 40000 + delta))))) {
|
||||||
|
fail = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fail) {
|
||||||
|
fail("Expected: " + result + ", Actual: " + encodedCookie);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodingSingleCookieV1() {
|
public void testEncodingSingleCookieV1() {
|
||||||
String result = "myCookie=myValue;Max-Age=50;Path=\"/apathsomewhere\";Domain=.adomainsomewhere;Secure;Comment=\"this is a Comment\";Version=1";
|
String result = "myCookie=myValue;Max-Age=50;Path=\"/apathsomewhere\";Domain=.adomainsomewhere;Secure;Comment=\"this is a Comment\";Version=1";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user