Fix the web_jsp devtests
diff --git a/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/WebTest.java b/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/WebTest.java
index 86b1bf6..39c5628 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/WebTest.java
+++ b/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/WebTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -29,11 +29,10 @@
*/
public class WebTest {
- private static SimpleReporterAdapter stat
- = new SimpleReporterAdapter("appserv-tests");
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter("appserv-tests");
private static final String TEST_NAME = "jsp-precompiled-bundled-in-jar";
- private static final String EXPECTED_RESPONSE = "this is a test";
+ private static final String EXPECTED_RESPONSE = "This is my UPDATED output";
private String host;
private String port;
@@ -44,7 +43,7 @@
port = args[1];
contextRoot = args[2];
}
-
+
public static void main(String[] args) {
stat.addDescription("Unit test for 6273340");
WebTest webTest = new WebTest(args);
@@ -52,8 +51,8 @@
stat.printSummary(TEST_NAME);
}
- public void doTest() {
- try {
+ public void doTest() {
+ try {
invokeJsp();
} catch (Exception ex) {
stat.addStatus(TEST_NAME, stat.FAIL);
@@ -62,39 +61,23 @@
}
public void invokeJsp() throws Exception {
+ String url = "http://" + host + ":" + port + contextRoot + "/jsp/test.jsp";
+ HttpURLConnection conn = (HttpURLConnection) (new URL(url)).openConnection();
- InputStream is = null;
- BufferedReader input = null;
- try {
- String url = "http://" + host + ":" + port + contextRoot
- + "/jsps/test.jsp";
- HttpURLConnection conn = (HttpURLConnection)
- (new URL(url)).openConnection();
-
- int code = conn.getResponseCode();
- if (code != 200) {
- System.err.println("Unexpected return code: " + code);
- stat.addStatus(TEST_NAME, stat.FAIL);
- } else {
- is = conn.getInputStream();
- input = new BufferedReader(new InputStreamReader(is));
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.err.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ try (InputStream is = conn.getInputStream(); BufferedReader input = new BufferedReader(new InputStreamReader(is))) {
String line = input.readLine();
if (!EXPECTED_RESPONSE.equals(line)) {
- System.err.println("Wrong response. "
- + "Expected: " + EXPECTED_RESPONSE
- + ", received: " + line);
+ System.err.println("Wrong response. " + "Expected: " + EXPECTED_RESPONSE + ", received: " + line);
stat.addStatus(TEST_NAME, stat.FAIL);
} else {
stat.addStatus(TEST_NAME, stat.PASS);
}
}
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException ex) {}
- try {
- if (input != null) input.close();
- } catch (IOException ex) {}
}
}
}
diff --git a/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/lib/jsps.jar b/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/lib/jsps.jar
index d4bb7b2..66a962d 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/lib/jsps.jar
+++ b/appserver/tests/appserv-tests/devtests/web/jspConfigUsePrecompiled2/lib/jsps.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/WebTest.java b/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/WebTest.java
index 769eb21..c8fc588 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/WebTest.java
+++ b/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/WebTest.java
@@ -27,8 +27,7 @@
private static final String EXPECTED = "Hello, world!";
- private static SimpleReporterAdapter stat
- = new SimpleReporterAdapter("appserv-tests");
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter("appserv-tests");
private String host;
private String port;
@@ -39,7 +38,7 @@
port = args[1];
contextRoot = args[2];
}
-
+
public static void main(String[] args) {
stat.addDescription("Unit test for taglib JAR in WEB-INF/lib");
WebTest webTest = new WebTest(args);
@@ -56,21 +55,17 @@
public void doTest() throws Exception {
- BufferedReader bis = null;
- try {
- URL url = new URL("http://" + host + ":" + port + contextRoot
- + "/test.jsp");
- System.out.println("Connecting to: " + url.toString());
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.connect();
- int responseCode = conn.getResponseCode();
- if (responseCode != 200) {
- System.err.println("Wrong response code. Expected: 200"
- + ", received: " + responseCode);
- stat.addStatus(TEST_NAME, stat.FAIL);
- } else {
- bis = new BufferedReader(
- new InputStreamReader(conn.getInputStream()));
+ URL url = new URL("http://" + host + ":" + port + contextRoot + "/test.jsp");
+ System.out.println("Connecting to: " + url.toString());
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.connect();
+
+ int responseCode = conn.getResponseCode();
+ if (responseCode != 200) {
+ System.err.println("Wrong response code. Expected: 200" + ", received: " + responseCode);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ try (BufferedReader bis = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
String line = null;
while ((line = bis.readLine()) != null) {
if (EXPECTED.equals(line)) {
@@ -78,17 +73,12 @@
}
}
if (line == null) {
- System.err.println("Wrong response body. Could not find "
- + "expected string: " + EXPECTED);
+ System.err.println("Wrong response body. Could not find " + "expected string: " + EXPECTED);
stat.addStatus(TEST_NAME, stat.FAIL);
} else {
stat.addStatus(TEST_NAME, stat.PASS);
}
}
- } finally {
- try {
- if (bis != null) bis.close();
- } catch (IOException ex) {}
}
}
}
diff --git a/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/lib/mytaglib.jar b/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/lib/mytaglib.jar
index 39df42f..9ace475 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/lib/mytaglib.jar
+++ b/appserver/tests/appserv-tests/devtests/web/jspCustomTaglibBundledAsJar/lib/mytaglib.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/WebTest.java b/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/WebTest.java
index 93540ac..30fe369 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/WebTest.java
+++ b/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/WebTest.java
@@ -25,13 +25,11 @@
*/
public class WebTest {
- private static final String TEST_NAME =
- "jsp-in-webapp-with-bundled-xercesImpl";
+ private static final String TEST_NAME = "jsp-in-webapp-with-bundled-xercesImpl";
private static final String EXPECTED_RESPONSE = "Hello, world!";
- private static SimpleReporterAdapter stat
- = new SimpleReporterAdapter("appserv-tests");
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter("appserv-tests");
private String host;
private String port;
@@ -42,9 +40,8 @@
port = args[1];
contextRoot = args[2];
}
-
- public static void main(String[] args) {
+ public static void main(String[] args) {
stat.addDescription("Unit test for 6412405");
WebTest webTest = new WebTest(args);
@@ -56,27 +53,23 @@
stat.addStatus(TEST_NAME, stat.FAIL);
}
- stat.printSummary();
+ stat.printSummary();
}
public void doTest() throws Exception {
- BufferedReader bis = null;
- try {
- URL url = new URL("http://" + host + ":" + port
- + contextRoot + "/test.jsp");
- System.out.println("Connecting to: " + url.toString());
+ URL url = new URL("http://" + host + ":" + port + contextRoot + "/test.jsp");
+ System.out.println("Connecting to: " + url.toString());
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.connect();
- int responseCode = conn.getResponseCode();
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.connect();
+ int responseCode = conn.getResponseCode();
- if (responseCode != 200) {
- throw new Exception("Unexpected return code: " + responseCode);
- }
+ if (responseCode != 200) {
+ throw new Exception("Unexpected return code: " + responseCode);
+ }
- bis = new BufferedReader(
- new InputStreamReader(conn.getInputStream()));
+ try (BufferedReader bis = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
String line = null;
while ((line = bis.readLine()) != null) {
if (EXPECTED_RESPONSE.equals(line)) {
@@ -85,13 +78,7 @@
}
if (line == null) {
- throw new Exception("Wrong response body. Could not find " +
- "expected string: " + EXPECTED_RESPONSE);
- }
- } finally {
- try {
- if (bis != null) bis.close();
- } catch (IOException ex) {
+ throw new Exception("Wrong response body. Could not find " + "expected string: " + EXPECTED_RESPONSE);
}
}
}
diff --git a/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/lib/mytaglib.jar b/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/lib/mytaglib.jar
index 39df42f..9ace475 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/lib/mytaglib.jar
+++ b/appserver/tests/appserv-tests/devtests/web/jspInWebappWithBundledXercesImpl/lib/mytaglib.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.class b/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.class
index 95c8b4e..f49864a 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.class
+++ b/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.class
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.java b/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.java
index 88fdd2d..4cce1aa 100644
--- a/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.java
+++ b/appserver/tests/appserv-tests/devtests/web/jspReloadGeneratedServletIfUpdated/test_jsp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -25,11 +25,11 @@
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
- private static java.util.Vector _jspx_dependants;
+ private static java.util.List<String> _jspx_dependants;
private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector;
- public Object getDependants() {
+ public java.util.List<String> getDependants() {
return _jspx_dependants;
}
@@ -47,7 +47,7 @@
try {
response.setContentType("text/html");
- response.setHeader("X-Powered-By", "JSP/2.1");
+ response.setHeader("X-Powered-By", "JSP/2.3");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
@@ -58,13 +58,14 @@
_jspx_out = out;
_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
- out.write("This is my UPDATED output\n");
+ out.write("This is my UPDATED output\n\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
+ else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);