diff --git a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml index 5989419df453..4df031705e85 100644 --- a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml +++ b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml @@ -2444,7 +2444,7 @@ org.eclipse.jdt ecj - 3.35.0 + 3.36.0 org.eclipse.jetty.websocket diff --git a/dev/cnf/oss_dependencies.maven b/dev/cnf/oss_dependencies.maven index e8b2de8d54aa..32dc0500305a 100644 --- a/dev/cnf/oss_dependencies.maven +++ b/dev/cnf/oss_dependencies.maven @@ -484,7 +484,7 @@ org.eclipse.birt.runtime.3_7_1:org.apache.xml.serializer:2.7.1 org.eclipse.birt.runtime:org.w3c.css.sac:1.3.1.v200903091627 org.eclipse.jdt:ecj:3.26.0 org.eclipse.jdt:ecj:3.33.0 -org.eclipse.jdt:ecj:3.35.0 +org.eclipse.jdt:ecj:3.36.0 org.eclipse.jetty.websocket:javax-websocket-client-impl:9.2.2.v20140723 org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.39.v20210325 org.eclipse.jetty.websocket:websocket-api:9.2.2.v20140723 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/bnd.bnd b/dev/com.ibm.ws.jsp.2.3_fat/bnd.bnd index 32319cf15e35..1601cf83cc9b 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/bnd.bnd +++ b/dev/com.ibm.ws.jsp.2.3_fat/bnd.bnd @@ -6,9 +6,6 @@ # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation #******************************************************************************* -include= ~../cnf/resources/bnd/bundle.props bVersion=1.0 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/build.gradle b/dev/com.ibm.ws.jsp.2.3_fat/build.gradle index 02217c9ba72d..46569dce71d4 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/build.gradle +++ b/dev/com.ibm.ws.jsp.2.3_fat/build.gradle @@ -6,9 +6,6 @@ * http://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation *******************************************************************************/ dependencies { requiredLibs project(':io.openliberty.org.apache.commons.codec'), diff --git a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/FATSuite.java b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/FATSuite.java index 61c7f4ad9faf..af85d2f26680 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/FATSuite.java +++ b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/FATSuite.java @@ -19,6 +19,9 @@ import com.ibm.ws.jsp23.fat.tests.JSP23JSP22ServerTest; import com.ibm.ws.jsp23.fat.tests.JSPCdiTest; import com.ibm.ws.jsp23.fat.tests.JSPExceptionTests; +import com.ibm.ws.jsp23.fat.tests.JSPJava11Test; +import com.ibm.ws.jsp23.fat.tests.JSPJava17Test; +import com.ibm.ws.jsp23.fat.tests.JSPJava21Test; import com.ibm.ws.jsp23.fat.tests.JSPJava8Test; import com.ibm.ws.jsp23.fat.tests.JSPPrepareJSPThreadCountDefaultValueTests; import com.ibm.ws.jsp23.fat.tests.JSPPrepareJSPThreadCountNonDefaultValueTests; @@ -42,6 +45,9 @@ JSPExceptionTests.class, JSPSkipMetaInfTests.class, JSPJava8Test.class, + JSPJava11Test.class, + JSPJava17Test.class, + JSPJava21Test.class, JSPCdiTest.class, JSP23JSP22ServerTest.class, JSPPrepareJSPThreadCountNonDefaultValueTests.class, diff --git a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava11Test.java b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava11Test.java new file mode 100644 index 000000000000..eded92876326 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava11Test.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package com.ibm.ws.jsp23.fat.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.logging.Logger; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.websphere.simplicity.ShrinkHelper; +import com.ibm.websphere.simplicity.config.ServerConfiguration; +import com.ibm.ws.jsp23.fat.JSPUtils; +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + +import componenttest.annotation.MinimumJavaLevel; +import componenttest.annotation.Server; +import componenttest.annotation.SkipForRepeat; +import componenttest.custom.junit.runner.FATRunner; +import componenttest.custom.junit.runner.Mode; +import componenttest.custom.junit.runner.Mode.TestMode; +import componenttest.topology.impl.LibertyServer; + +/** + * JSP 2.3 tests which use Java 11 specific features. + * + * Tests must only run when Java 11 is in use. + * + */ +@Mode(TestMode.FULL) +@MinimumJavaLevel(javaLevel = 11) +@SkipForRepeat("CDI-2.0") // No need to run against cdi-2.0 since these tests don't use CDI at all. +@RunWith(FATRunner.class) +public class JSPJava11Test { + private static final String APP_NAME = "TestJSPWithJava11"; + private static final Logger LOG = Logger.getLogger(JSPJava11Test.class.getName()); + + @Server("jspJava11Server") + public static LibertyServer server; + + @BeforeClass + public static void setup() throws Exception { + ShrinkHelper.defaultDropinApp(server, APP_NAME + ".war"); + + server.startServer(JSPJava11Test.class.getSimpleName() + ".log"); + } + + @AfterClass + public static void testCleanup() throws Exception { + // Stop the server + if (server != null && server.isStarted()) { + server.stopServer(); + } + } + + /** + * Simple test for index.jsp. Page uses Java 11's String#strip method + * + * @throws Exception + * if something goes horribly wrong + */ + @Test + public void testJava11JSP() throws Exception { + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("Java 11's String strip() method failed", response.getText().contains("success-strip")); + assertTrue("Java 11's String lines() did not return a stream.", response.getText().contains("java.util.stream.ReferencePipeline")); + assertTrue("Java 11's Map copyOf method failed", response.getText().contains("{key=success-copyof}")); + } + + /** + * Same test as testJava11JSP, but using the runtime JDK (via JSP's useJDKCompiler option rather than the default Eclipse Compiler for Java (ECJ)) + * + * https://openliberty.io/docs/latest/reference/config/jspEngine.html + * + * @throws Exception if something goes horribly wrong + * + */ + @Test + public void testJava11viaUseJDKCompiler() throws Exception { + + ServerConfiguration configuration = server.getServerConfiguration(); + configuration.getJspEngine().setUseJDKCompiler(true); + LOG.info("New server configuration used: " + configuration); + server.setMarkToEndOfLog(); + server.updateServerConfiguration(configuration); + server.restartApplication(APP_NAME); + server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava11.*"); + + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("Java 11's String strip() method failed", response.getText().contains("success-strip")); + assertTrue("Java 11's String lines() did not return a stream.", response.getText().contains("java.util.stream.ReferencePipeline")); + assertTrue("Java 11's Map copyOf method failed", response.getText().contains("{key=success-copyof}")); + } +} diff --git a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava17Test.java b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava17Test.java new file mode 100644 index 000000000000..d576b54aed54 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava17Test.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2023, 2024 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package com.ibm.ws.jsp23.fat.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.logging.Logger; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.websphere.simplicity.ShrinkHelper; +import com.ibm.ws.jsp23.fat.JSPUtils; +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + +import componenttest.annotation.MinimumJavaLevel; +import componenttest.annotation.MaximumJavaLevel; +import componenttest.annotation.Server; +import componenttest.annotation.SkipForRepeat; +import componenttest.custom.junit.runner.FATRunner; +import componenttest.topology.impl.LibertyServer; + +import com.ibm.websphere.simplicity.config.ServerConfiguration; +/** + * JSP 2.3 tests which use Java 17 specific features. + * + * Tests must only run when Java 17 or later is in use. + * + */ +@MinimumJavaLevel(javaLevel = 17) +@SkipForRepeat("CDI-2.0") // No need to run against cdi-2.0 since these tests don't use CDI at all. +@RunWith(FATRunner.class) +public class JSPJava17Test { + private static final String APP_NAME = "TestJSPWithJava17"; + private static final Logger LOG = Logger.getLogger(JSPJava17Test.class.getName()); + + @Server("jspJava17Server") + public static LibertyServer server; + + @BeforeClass + public static void setup() throws Exception { + ShrinkHelper.defaultDropinApp(server, APP_NAME + ".war"); + + server.startServer(JSPJava17Test.class.getSimpleName() + ".log"); + } + + @AfterClass + public static void testCleanup() throws Exception { + // Stop the server + if (server != null && server.isStarted()) { + // testBothjdkSourceLevelAndjavaSourceLevel causes CWWJS0005W: Both javaSourceLevel=17 and jdkSourceLevel=18 are specified. Defaulting to javaSourceLevel=17 + server.stopServer("CWWJS0005W"); + } + } + + /** + * Simple test for index.jsp. Page uses Java 17's instanceof pattern matching + * + * @throws Exception + * if something goes horribly wrong + */ + @Test + public void testJava17JSP() throws Exception { + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: success", response.getText().contains("success-text-block")); + assertTrue("The response did not contain: success", response.getText().contains("success-pattern-matching")); + } + + /** + * Same test as testJava17JSP, but using the runtime JDK (via JSP's useJDKCompiler option rather than the default Eclipse Compiler for Java (ECJ)) + * + * https://openliberty.io/docs/latest/reference/config/jspEngine.html + * + * @throws Exception if something goes horribly wrong + * + */ + @Test + public void testJava17viaUseJDKCompiler() throws Exception { + + ServerConfiguration configuration = server.getServerConfiguration(); + configuration.getJspEngine().setUseJDKCompiler(true); + LOG.info("New server configuration used: " + configuration); + + server.setMarkToEndOfLog(); + server.updateServerConfiguration(configuration); + server.restartApplication(APP_NAME); + server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava17.*"); + + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: success", response.getText().contains("success-text-block")); + assertTrue("The response did not contain: success", response.getText().contains("success-pattern-matching")); + } + + /* + * Verifies that javaSourceLevel overrides jdkSourceLevel if both are set. Warning is also logged + */ + @Test + public void testBothjdkSourceLevelAndjavaSourceLevel() throws Exception { + + ServerConfiguration configuration = server.getServerConfiguration(); + configuration.getJspEngine().setJdkSourceLevel("18"); + LOG.info("New server configuration used: " + configuration); + + server.setMarkToEndOfLog(); + server.updateServerConfiguration(configuration); + server.restartApplication(APP_NAME); + server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava17.*"); + + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: success", response.getText().contains("success-text-block")); + assertTrue("The response did not contain: success", response.getText().contains("success-pattern-matching")); + } +} diff --git a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava21Test.java b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava21Test.java new file mode 100644 index 000000000000..277702840dfb --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava21Test.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package com.ibm.ws.jsp23.fat.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.logging.Logger; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.websphere.simplicity.ShrinkHelper; +import com.ibm.ws.jsp23.fat.JSPUtils; +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + +import componenttest.annotation.MinimumJavaLevel; +import componenttest.annotation.MaximumJavaLevel; +import componenttest.annotation.Server; +import componenttest.annotation.SkipForRepeat; +import componenttest.custom.junit.runner.FATRunner; +import componenttest.custom.junit.runner.Mode; +import componenttest.custom.junit.runner.Mode.TestMode; +import componenttest.topology.impl.LibertyServer; + +import com.ibm.websphere.simplicity.config.ServerConfiguration; +/** + * JSP 2.3 tests which use Java 21 specific features. + * + * Tests must only run when Java 21 or later is in use. + * + */ +@Mode(TestMode.FULL) +@MinimumJavaLevel(javaLevel = 21) +@SkipForRepeat("CDI-2.0") // No need to run against cdi-2.0 since these tests don't use CDI at all. +@RunWith(FATRunner.class) +public class JSPJava21Test { + private static final String APP_NAME = "TestJSPWithJava21"; + private static final Logger LOG = Logger.getLogger(JSPJava21Test.class.getName()); + + @Server("jspJava21Server") + public static LibertyServer server; + + @BeforeClass + public static void setup() throws Exception { + ShrinkHelper.defaultDropinApp(server, APP_NAME + ".war"); + + server.startServer(JSPJava21Test.class.getSimpleName() + ".log"); + } + + @AfterClass + public static void testCleanup() throws Exception { + // Stop the server + if (server != null && server.isStarted()) { + server.stopServer(); + } + } + + /** + * Simple test for index.jsp. Page uses Java 21's instanceof pattern matching + * + * @throws Exception + * if something goes horribly wrong + */ + @Test + public void testJava21JSP() throws Exception { + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: success", response.getText().contains("getFirst success!")); + assertTrue("The response did not contain: success", response.getText().contains("switch success!")); + } + + /** + * Same test as testJava21JSP, but using the runtime JDK (via JSP's useJDKCompiler option rather than the default Eclipse Compiler for Java (ECJ)) + * + * https://openliberty.io/docs/latest/reference/config/jspEngine.html + * + * @throws Exception if something goes horribly wrong + * + */ + @Test + public void testJava21viaUseJDKCompiler() throws Exception { + + ServerConfiguration configuration = server.getServerConfiguration(); + configuration.getJspEngine().setUseJDKCompiler(true); + LOG.info("New server configuration used: " + configuration); + + server.setMarkToEndOfLog(); + server.updateServerConfiguration(configuration); + server.restartApplication(APP_NAME); + server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava21.*"); + + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: success", response.getText().contains("getFirst success!")); + assertTrue("The response did not contain: success", response.getText().contains("switch success!")); + } +} diff --git a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava8Test.java b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava8Test.java index 8d8effad2be8..edce9f057aa7 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava8Test.java +++ b/dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava8Test.java @@ -6,15 +6,13 @@ * http://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation *******************************************************************************/ package com.ibm.ws.jsp23.fat.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.Collections; import java.util.logging.Logger; import org.junit.AfterClass; @@ -34,10 +32,11 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; +import com.ibm.websphere.simplicity.config.ServerConfiguration; /** * JSP 2.3 tests which use Java 1.8 specific features. * - * Tests must only run when Java 1.8 is in use. + * Tests must only run when Java 1.8 or later is in use. * * Tests that just need to drive a simple request using our WebBrowser object can be placed in this class. * @@ -71,7 +70,7 @@ public static void testCleanup() throws Exception { * Simple test for Index.jsp * * @throws Exception - * if something goes horribly wrong + * if something goes horribly wrong */ @Test public void testJava8JSP() throws Exception { @@ -89,4 +88,39 @@ public void testJava8JSP() throws Exception { 200, response.getResponseCode()); assertTrue("The response did not contain: onetwothreefour", response.getText().contains("onetwothreefour")); } + + /** + * Same test as testJava8JSP, but using the runtime JDK (via JSP's useJDKCompiler option rather than the default Eclipse Compiler for Java (ECJ)) + * + * https://openliberty.io/docs/latest/reference/config/jspEngine.html + * + * @throws Exception if something goes horribly wrong + * + */ + @Test + public void testJava8viaUseJDKCompiler() throws Exception { + + ServerConfiguration configuration = server.getServerConfiguration(); + configuration.getJspEngine().setUseJDKCompiler(true); + LOG.info("New server configuration used: " + configuration); + + server.setMarkToEndOfLog(); + server.updateServerConfiguration(configuration); + server.restartApplication(APP_NAME); + server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava8.*"); + + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus(false); + + String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); + LOG.info("url: " + url); + + WebRequest request = new GetMethodWebRequest(url); + WebResponse response = wc.getResponse(request); + LOG.info("Servlet response : " + response.getText()); + + assertEquals("Expected " + 200 + " status code was not returned!", + 200, response.getResponseCode()); + assertTrue("The response did not contain: onetwothreefour", response.getText().contains("onetwothreefour")); + } } diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/.gitignore b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/.gitignore new file mode 100644 index 000000000000..f3f483d82c07 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/.gitignore @@ -0,0 +1 @@ +/dropins diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/bootstrap.properties b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/bootstrap.properties new file mode 100644 index 000000000000..60261fb0a132 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/bootstrap.properties @@ -0,0 +1,11 @@ +############################################################################### +# Copyright (c) 2023 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### +bootstrap.include=../testports.properties +osgi.console=7777 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/server.xml b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/server.xml new file mode 100644 index 000000000000..9b51fb777a74 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/server.xml @@ -0,0 +1,23 @@ + + + + + + + jsp-2.3 + localConnector-1.0 + + + + + + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/.gitignore b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/.gitignore new file mode 100644 index 000000000000..f3f483d82c07 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/.gitignore @@ -0,0 +1 @@ +/dropins diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/bootstrap.properties b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/bootstrap.properties new file mode 100644 index 000000000000..60261fb0a132 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/bootstrap.properties @@ -0,0 +1,11 @@ +############################################################################### +# Copyright (c) 2023 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### +bootstrap.include=../testports.properties +osgi.console=7777 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/server.xml b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/server.xml new file mode 100644 index 000000000000..3d46d454d553 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/server.xml @@ -0,0 +1,23 @@ + + + + + + + jsp-2.3 + localConnector-1.0 + + + + + + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/.gitignore b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/.gitignore new file mode 100644 index 000000000000..f3f483d82c07 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/.gitignore @@ -0,0 +1 @@ +/dropins diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/bootstrap.properties b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/bootstrap.properties new file mode 100644 index 000000000000..60261fb0a132 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/bootstrap.properties @@ -0,0 +1,11 @@ +############################################################################### +# Copyright (c) 2023 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### +bootstrap.include=../testports.properties +osgi.console=7777 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/server.xml b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/server.xml new file mode 100644 index 000000000000..97b8034b4d1e --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava21Server/server.xml @@ -0,0 +1,23 @@ + + + + + + + jsp-2.3 + localConnector-1.0 + + + + + + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/bootstrap.properties b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/bootstrap.properties index 61f538a150a1..c0ee80dacbfc 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/bootstrap.properties +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/bootstrap.properties @@ -6,9 +6,6 @@ # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation ############################################################################### bootstrap.include=../testports.properties osgi.console=7777 diff --git a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/server.xml b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/server.xml index ef2192b8cf33..aee1afa843dc 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/server.xml +++ b/dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava8Server/server.xml @@ -1,14 +1,11 @@ @@ -16,10 +13,12 @@ jsp-2.3 + localConnector-1.0 + - - + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/WEB-INF/web.xml b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/WEB-INF/web.xml new file mode 100644 index 000000000000..2fc1b54f8a2e --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + + TestJSPWithJava11 + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/index.jsp b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/index.jsp new file mode 100644 index 000000000000..5c58680f3400 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/index.jsp @@ -0,0 +1,34 @@ + + + + + + + Test Java 11 Compilation + + + + Testing Java 11's String.strip function: + <% out.print(" success-strip ".strip()); %> +
+ + Testing Java 11's String.lines function: + <% out.println(" Hello World\n Good Bye\n success-lines".lines()); %> +
+ + Java 10's Map.copyOf static method + <% + java.util.Map map = new java.util.HashMap(); + map.put("key","success-copyof"); + out.println(java.util.Map.copyOf(map)); // {key=value} + %> + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/WEB-INF/web.xml b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/WEB-INF/web.xml new file mode 100644 index 000000000000..6c0fe3ace877 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + + TestJSPWithJava17 + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/index.jsp b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/index.jsp new file mode 100644 index 000000000000..8839c220f05d --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/index.jsp @@ -0,0 +1,36 @@ + + + + + + Java 17 + + + + + + <% + String block = """ + If this compiles, then the + test passes. " success-text-block" woo! + """; + out.print(block); + %> + + + <% + Object o = " success-pattern-matching "; + if (o instanceof String s) { + out.print(s.strip()); // no need to cast to String + } + %> + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/WEB-INF/web.xml b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/WEB-INF/web.xml new file mode 100644 index 000000000000..2b38942e9782 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + + TestJSPWithJava21 + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/index.jsp b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/index.jsp new file mode 100644 index 000000000000..368ca24bfeb4 --- /dev/null +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava21.war/resources/index.jsp @@ -0,0 +1,36 @@ + + + + + + Java 21 + + + + + + <% + java.util.ArrayList list = new java.util.ArrayList(); + list.add("getFirst success!"); + out.println(list.getFirst()); + %> + + + <% + Object test = "hello"; + switch(test){ + case Integer i -> out.println("switch fail!"); + case String s -> out.println("switch success!"); + default -> out.println("switch fail!"); + } + %> + + diff --git a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava8.war/resources/WEB-INF/web.xml b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava8.war/resources/WEB-INF/web.xml index 892a9c127a88..ae36211ec0d6 100644 --- a/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava8.war/resources/WEB-INF/web.xml +++ b/dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava8.war/resources/WEB-INF/web.xml @@ -7,9 +7,6 @@ http://www.eclipse.org/legal/epl-2.0/ SPDX-License-Identifier: EPL-2.0 - - Contributors: - IBM Corporation - initial API and implementation --> <%@page import="java.io.PrintWriter"%> <%@page import="java.io.Writer"%> diff --git a/dev/com.ibm.ws.jsp/resources/OSGI-INF/l10n/metatype.properties b/dev/com.ibm.ws.jsp/resources/OSGI-INF/l10n/metatype.properties index f9c2bb3adc9c..d4a9f78c6b79 100644 --- a/dev/com.ibm.ws.jsp/resources/OSGI-INF/l10n/metatype.properties +++ b/dev/com.ibm.ws.jsp/resources/OSGI-INF/l10n/metatype.properties @@ -1,14 +1,11 @@ ############################################################################### -# Copyright (c) 2011, 2021 IBM Corporation and others. +# Copyright (c) 2011, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# IBM Corporation - initial API and implementation ############################################################################### # #CMVCPATHNAME com.ibm.ws.jpa-2.2/resources/OSGI-INF/l10n/metatype.properties @@ -25,8 +22,8 @@ disableJspRuntimeCompilation=Disable compilation of JSPs at runtime. extendedDocumentRoot.name=Extended document root extendedDocumentRoot=Directory that the JSP engine will search for additional JSP files to serve. -jdkSourceLevel.name=JDK source level -jdkSourceLevel=Default Java source level for JSPs compiled by the JSP engine. +javaSourceLevel.name=Java source level +javaSourceLevel=Specifies the default Java source level for JSPs that are compiled by the JSP engine. Accepts one of the following LTS releases as a value: 8, 11, 17, and 21. keepGenerated.name=Keep generated Java source keepGenerated=Keep Java source files generated for JSPs. diff --git a/dev/com.ibm.ws.jsp/resources/OSGI-INF/metatype/metatype.xml b/dev/com.ibm.ws.jsp/resources/OSGI-INF/metatype/metatype.xml index 631c718af72e..3006fe6637a8 100644 --- a/dev/com.ibm.ws.jsp/resources/OSGI-INF/metatype/metatype.xml +++ b/dev/com.ibm.ws.jsp/resources/OSGI-INF/metatype/metatype.xml @@ -17,7 +17,15 @@ id="disableJspRuntimeCompilation" required="false" type="Boolean" default="false"/> - + + +