Skip to content

Commit

Permalink
Align pluggability cookie tests with non-pluggability cookie tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Mar 26, 2024
1 parent fdb6d18 commit 101d9c2
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ public void setMaxAgePositiveTest() throws Exception {
String body = null;

HttpExchange request = new HttpExchange("GET " + getContextRoot() + "/"
+ getServletName() + "?testname=" + testName + " HTTP/1.1", _hostname,
_port);
+ getServletName() + "?testname=" + testName + " HTTP/1.1", _hostname,
_port);

try {
response = request.execute();
Expand All @@ -275,7 +275,9 @@ public void setMaxAgePositiveTest() throws Exception {
List<String> cookiesHeaders = response.getResponseHeaders("Set-Cookie");
int i = 0;
while (i < cookiesHeaders.size()) {
logger.trace("Checking set-cookiei {}:{}", String.valueOf(i), cookiesHeaders.get(i));
if(logger.isTraceEnabled()) {
logger.trace("Checking set-cookiei {}:{}", String.valueOf(i), cookiesHeaders.get(i));
}
List<HttpCookie> cookies = HttpCookie.parse(cookiesHeaders.get(i));
Optional<HttpCookie> optionalHttpCookie = cookies.stream().filter(httpCookie -> httpCookie.getName().equals("name1"))
.findFirst();
Expand All @@ -289,8 +291,9 @@ public void setMaxAgePositiveTest() throws Exception {
i++;
}

if (!foundcookie)
if (!foundcookie) {
throw new Exception("The test cookie was not located in the response");
}
} catch (Throwable t) {
throw new Exception("Exception occurred:" + t, t);
}
Expand All @@ -302,10 +305,10 @@ public void setMaxAgePositiveTest() throws Exception {
try {
Date resultDate = sdf.parse(resultStringDate);
Date expectedDate = sdf
.parse(dateHeader.substring(dateHeader.indexOf(": ") + 2).trim());
.parse(dateHeader.substring(dateHeader.indexOf(": ") + 2).trim());
if (resultDate.before(expectedDate)) {
throw new Exception("The expiry date was incorrect, expected ="
+ expectedDate + ", result = " + resultDate);
+ expectedDate + ", result = " + resultDate);
}
} catch (Throwable t) {
throw new Exception("Exception occurred: " + t);
Expand Down

0 comments on commit 101d9c2

Please sign in to comment.