Skip to content

Commit

Permalink
Update getRealPath() test
Browse files Browse the repository at this point in the history
Changes due to jakartaee/servlet#105
  • Loading branch information
markt-asf committed Dec 3, 2021
1 parent 6c3ecd0 commit f2bda48
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void getMimeType_1(ServletRequest request, ServletResponse response)
*/
public void getRealPath(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
boolean passed = false;
boolean passed = true;
PrintWriter pw = response.getWriter();

String path = "/servlet_js_ServletContext/Test";
Expand All @@ -166,13 +166,26 @@ public void getRealPath(ServletRequest request, ServletResponse response)
if ((realPath == null) || (realPath.indexOf(path) > -1) || // UNIX path
(realPath.indexOf(win32Path) > -1)) // Win32 path
{
passed = true;
pw.println("realPath = " + realPath);
} else {
passed = false;
pw.println("getRealPath(" + path + ") did not contain the named files");
pw.println("Actual result = " + realPath + " ");
}

// Leading '/' is optional. Ensure the result is the same with or without it
String pathNoSolidus = path.substring(1);
String realPathNoSolidus = context.getRealPath(pathNoSolidus);

if (realPath == null && realPathNoSolidus == null ||
realPath != null && realPath.equals(realPathNoSolidus)) {
pw.println("realPathNoSolidus = " + realPathNoSolidus);
} else {
passed = false;
pw.println("getRealPath(" + path + ") returned [" + realPath + "]");
pw.println("getRealPath(" + pathNoSolidus + ") returned [" + realPathNoSolidus + "]");
pw.println("The return values should be the same");
}
ServletTestUtil.printResult(pw, passed);
}

Expand Down

0 comments on commit f2bda48

Please sign in to comment.