diff --git a/testsuite/integration/basic/src/test/java/org/wildfly/test/integration/jsp/JspELTestCase.java b/testsuite/integration/basic/src/test/java/org/wildfly/test/integration/jsp/JspELTestCase.java index 3f87a568c705..60baa7683d97 100644 --- a/testsuite/integration/basic/src/test/java/org/wildfly/test/integration/jsp/JspELTestCase.java +++ b/testsuite/integration/basic/src/test/java/org/wildfly/test/integration/jsp/JspELTestCase.java @@ -46,46 +46,90 @@ @RunAsClient public class JspELTestCase { + private static final String Servlet_No_Spec_War = "jsp-el-test-no-web-xml"; + private static final String Servlet_Spec_4_0_War = "jsp-el-test-4_0_servlet_spec"; private static final String Servlet_Spec_3_1_War = "jsp-el-test-3_1_servlet_spec"; private static final String Servlet_Spec_3_0_War = "jsp-el-test-3_0_servlet_spec"; - @Deployment(name = Servlet_Spec_3_1_War) + @Deployment(name = Servlet_No_Spec_War) public static WebArchive deploy() { return ShrinkWrap.create(WebArchive.class) .addClasses(DummyConstants.class, DummyEnum.class) - .addAsWebInfResource(JspELTestCase.class.getResource("web-app_3_1.xml"), "web.xml") .addAsWebResource(JspELTestCase.class.getResource("jsp-with-el.jsp"), "index.jsp"); } + @Deployment(name = Servlet_Spec_4_0_War) + public static WebArchive deploy40War() { + return deploy().addAsWebInfResource(JspELTestCase.class.getResource("web-app_4_0.xml"), "web.xml"); + } + + @Deployment(name = Servlet_Spec_3_1_War) + public static WebArchive deploy31War() { + return deploy().addAsWebInfResource(JspELTestCase.class.getResource("web-app_3_1.xml"), "web.xml"); + } + @Deployment(name = Servlet_Spec_3_0_War) public static WebArchive deploy30War() { - return ShrinkWrap.create(WebArchive.class) - .addClasses(DummyConstants.class, DummyEnum.class) - .addAsWebInfResource(JspELTestCase.class.getResource("web-app_3_0.xml"), "web.xml") - .addAsWebResource(JspELTestCase.class.getResource("jsp-with-el.jsp"), "index.jsp"); + return deploy().addAsWebInfResource(JspELTestCase.class.getResource("web-app_3_0.xml"), "web.xml"); } + final String POSSIBLE_ISSUES_LINKS = + "Might be caused by: https://issues.jboss.org/browse/WFLY-6939 or https://issues.jboss.org/browse/WFLY-11065"; /** - * Test that for web application using 3.1 version of servlet spec, EL expressions that use implicitly imported classes from java.lang - * package are evaluated correctly + * Test that for web application using default version of servlet spec, EL expressions that use implicitly imported + * classes from java.lang package are evaluated correctly * * @param url * @throws Exception */ - @OperateOnDeployment(Servlet_Spec_3_1_War) + @OperateOnDeployment(Servlet_No_Spec_War) @Test public void testJavaLangImplicitClassELEvaluation(@ArquillianResource URL url) throws Exception { + commonTestPart(url, POSSIBLE_ISSUES_LINKS); + } + + /** + * Test that for web application using 4.0 version of servlet spec, EL expressions that use implicitly imported + * classes from java.lang package are evaluated correctly + * + * @param url + * @throws Exception + */ + @OperateOnDeployment(Servlet_Spec_4_0_War) + @Test + public void testJavaLangImplicitClassELEvaluation40(@ArquillianResource URL url) throws Exception { + commonTestPart(url, POSSIBLE_ISSUES_LINKS); + } + + /** + * Test that for web application using 3.1 version of servlet spec, EL expressions that use implicitly imported + * classes from java.lang package are evaluated correctly + * + * @param url + * @throws Exception + */ + @OperateOnDeployment(Servlet_Spec_3_1_War) + @Test + public void testJavaLangImplicitClassELEvaluation31(@ArquillianResource URL url) throws Exception { + commonTestPart(url, POSSIBLE_ISSUES_LINKS); + } + + private void commonTestPart(final URL url, final String possibleCausingIssues) throws Exception { final String responseBody = HttpRequest.get(url + "index.jsp", 10, TimeUnit.SECONDS); - Assert.assertTrue("Unexpected EL evaluation for ${Boolean.TRUE}", responseBody.contains("Boolean.TRUE: --- " + Boolean.TRUE + " ---")); - Assert.assertTrue("Unexpected EL evaluation for ${Integer.MAX_VALUE}", responseBody.contains("Integer.MAX_VALUE: --- " + Integer.MAX_VALUE + " ---")); - Assert.assertTrue("Unexpected EL evaluation for ${DummyConstants.FOO}", responseBody.contains("DummyConstants.FOO: --- " + DummyConstants.FOO + " ---")); - Assert.assertTrue("Unexpected EL evaluation for ${DummyEnum.VALUE}", responseBody.contains("DummyEnum.VALUE: --- " + DummyEnum.VALUE + " ---")); + Assert.assertTrue("Unexpected EL evaluation for ${Boolean.TRUE}; " + possibleCausingIssues, + responseBody.contains("Boolean.TRUE: --- " + Boolean.TRUE + " ---")); + Assert.assertTrue("Unexpected EL evaluation for ${Integer.MAX_VALUE}; " + possibleCausingIssues, + responseBody.contains("Integer.MAX_VALUE: --- " + Integer.MAX_VALUE + " ---")); + Assert.assertTrue("Unexpected EL evaluation for ${DummyConstants.FOO}; " + possibleCausingIssues, + responseBody.contains("DummyConstants.FOO: --- " + DummyConstants.FOO + " ---")); + Assert.assertTrue("Unexpected EL evaluation for ${DummyEnum.VALUE}; " + possibleCausingIssues, + responseBody.contains("DummyEnum.VALUE: --- " + DummyEnum.VALUE + " ---")); } /** - * Test that for web application using servlet spec version lesser than 3.1, EL expressions can't consider classes belonging to java.lang - * package as implicitly imported and usable in the EL expressions + * Test that for web application using servlet spec version lesser than 3.1, EL expressions can't consider classes + * belonging to java.lang package as implicitly imported and usable in the EL expressions * * @param url * @throws Exception diff --git a/testsuite/integration/basic/src/test/resources/org/wildfly/test/integration/jsp/web-app_4_0.xml b/testsuite/integration/basic/src/test/resources/org/wildfly/test/integration/jsp/web-app_4_0.xml new file mode 100644 index 000000000000..3db2c3251671 --- /dev/null +++ b/testsuite/integration/basic/src/test/resources/org/wildfly/test/integration/jsp/web-app_4_0.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/undertow/src/main/java/org/wildfly/extension/undertow/deployment/JspInitializationListener.java b/undertow/src/main/java/org/wildfly/extension/undertow/deployment/JspInitializationListener.java index cd69c4b35e34..d01ec5cd4f63 100644 --- a/undertow/src/main/java/org/wildfly/extension/undertow/deployment/JspInitializationListener.java +++ b/undertow/src/main/java/org/wildfly/extension/undertow/deployment/JspInitializationListener.java @@ -47,7 +47,8 @@ public void contextInitialized(final ServletContextEvent sce) { // if the servlet version is 3.1 or higher, setup a ELResolver which allows usage of static fields java.lang.* final ServletContext servletContext = sce.getServletContext(); final JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext); - if (servletContext.getEffectiveMajorVersion() >= 3 && servletContext.getEffectiveMinorVersion() >= 1) { + if (servletContext.getEffectiveMajorVersion() > 3 + || (servletContext.getEffectiveMajorVersion() == 3 && servletContext.getEffectiveMinorVersion() >= 1)) { jspApplicationContext.addELResolver(new ImportedClassELResolver()); } // setup a wrapped JspApplicationContext if there are any EL expression factory wrappers for this servlet context