Skip to content

Commit 5674941

Browse files
committed
Add the Servlet/JSP version specific tests for Servlet 6.0 / JSP 3.1
1 parent 1fb7a2c commit 5674941

File tree

17 files changed

+406
-1
lines changed

17 files changed

+406
-1
lines changed

java/org/apache/tomcat/util/descriptor/DigesterFactory.java

+10
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ public class DigesterFactory {
135135
addSelf(systemIds, "jakartaee_web_services_2_0.xsd");
136136
addSelf(systemIds, "jakartaee_web_services_client_2_0.xsd");
137137

138+
// from JakartaEE 10
139+
add(systemIds, XmlIdentifiers.WEB_60_XSD, locationFor("web-app_6_0.xsd"));
140+
add(systemIds, XmlIdentifiers.WEB_FRAGMENT_60_XSD, locationFor("web-fragment_6_0.xsd"));
141+
add(systemIds, XmlIdentifiers.TLD_31_XSD, locationFor("web-jsptaglibrary_3_1.xsd"));
142+
addSelf(systemIds, "web-common_6_0.xsd");
143+
addSelf(systemIds, "jakartaee_10.xsd");
144+
addSelf(systemIds, "jsp_3_1.xsd");
145+
addSelf(systemIds, "jakartaee_web_services_2_0.xsd");
146+
addSelf(systemIds, "jakartaee_web_services_client_2_0.xsd");
147+
138148
SERVLET_API_PUBLIC_IDS = Collections.unmodifiableMap(publicIds);
139149
SERVLET_API_SYSTEM_IDS = Collections.unmodifiableMap(systemIds);
140150
}

java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public final class XmlIdentifiers {
8585
public static final String TLD_30_XSD = JAKARTAEE_9_NS + "/web-jsptaglibrary_3_0.xsd";
8686
public static final String WEBSERVICES_20_XSD = JAKARTAEE_9_NS + "/jakartaee_web_services_2_0.xsd";
8787

88+
// from Jakarta EE 10
89+
public static final String JAKARTAEE_10_NS = JAKARTAEE_9_NS;
90+
public static final String WEB_60_XSD = JAKARTAEE_10_NS + "/web-app_6_0.xsd";
91+
public static final String WEB_FRAGMENT_60_XSD = JAKARTAEE_10_NS + "/web-fragment_6_0.xsd";
92+
public static final String TLD_31_XSD = JAKARTAEE_10_NS + "/web-jsptaglibrary_3_1.xsd";
93+
8894
private XmlIdentifiers() {
8995
}
9096
}

java/org/apache/tomcat/util/descriptor/web/WebXml.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void setName(String name) {
237237
}
238238

239239
// Derived major and minor version attributes
240-
private int majorVersion = 5;
240+
private int majorVersion = 6;
241241
private int minorVersion = 0;
242242
public int getMajorVersion() { return majorVersion; }
243243
public int getMinorVersion() { return minorVersion; }

test/jakarta/servlet/resources/TestSchemaValidation.java

+14
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,18 @@ public void testWebapp_5_0() throws Exception {
158158
Assert.assertEquals(0, handler.getWarnings().size());
159159
}
160160

161+
162+
@Test
163+
public void testWebapp_6_0() throws Exception {
164+
XmlErrorHandler handler = new XmlErrorHandler();
165+
Digester digester = DigesterFactory.newDigester(
166+
true, true, new WebRuleSet(false), true);
167+
digester.setErrorHandler(handler);
168+
digester.push(new WebXml());
169+
WebXml desc = (WebXml) digester.parse(
170+
new File("test/webapp-6.0/WEB-INF/web.xml"));
171+
Assert.assertEquals("6.0", desc.getVersion());
172+
Assert.assertEquals(0, handler.getErrors().size());
173+
Assert.assertEquals(0, handler.getWarnings().size());
174+
}
161175
}

test/org/apache/jasper/TestJspC.java

+8
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ public void precompileWebapp_5_0() throws IOException {
111111
verify(webappOut);
112112
}
113113

114+
@Test
115+
public void precompileWebapp_6_0() throws IOException {
116+
File appDir = new File("test/webapp-6.0");
117+
File webappOut = new File(outputDir, appDir.getName());
118+
precompile(appDir, webappOut);
119+
verify(webappOut);
120+
}
121+
114122
private void verify(File webappOut) {
115123
// for now, just check some expected files exist
116124
Assert.assertTrue(new File(webappOut, "generated_web.xml").exists());

test/org/apache/jasper/compiler/TestJspConfig.java

+18
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,22 @@ public void testServlet50NoEL() throws Exception {
174174

175175
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
176176
}
177+
178+
@Test
179+
public void testServlet60NoEL() throws Exception {
180+
Tomcat tomcat = getTomcatInstance();
181+
182+
File appDir = new File("test/webapp-6.0");
183+
// app dir is relative to server home
184+
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
185+
186+
tomcat.start();
187+
188+
ByteChunk res = getUrl("http://localhost:" + getPort() +
189+
"/test/el-as-literal.jsp");
190+
191+
String result = res.toString();
192+
193+
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
194+
}
177195
}

test/org/apache/jasper/compiler/TestValidator.java

+27
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,33 @@ public void testTldVersions50() throws Exception {
243243
Assert.assertTrue(result.indexOf("<p>07-hello world</p>") > 0);
244244
}
245245

246+
@Test
247+
public void testTldVersions60() throws Exception {
248+
Tomcat tomcat = getTomcatInstance();
249+
250+
File appDir =
251+
new File("test/webapp-6.0");
252+
// app dir is relative to server home
253+
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
254+
255+
tomcat.start();
256+
257+
ByteChunk res = getUrl("http://localhost:" + getPort() +
258+
"/test/tld-versions.jsp");
259+
260+
String result = res.toString();
261+
262+
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
263+
Assert.assertTrue(result.indexOf("<p>#{'01-hello world'}</p>") > 0);
264+
Assert.assertTrue(result.indexOf("<p>02-hello world</p>") > 0);
265+
Assert.assertTrue(result.indexOf("<p>#{'03-hello world'}</p>") > 0);
266+
Assert.assertTrue(result.indexOf("<p>04-hello world</p>") > 0);
267+
Assert.assertTrue(result.indexOf("<p>#{'05-hello world'}</p>") > 0);
268+
Assert.assertTrue(result.indexOf("<p>06-hello world</p>") > 0);
269+
Assert.assertTrue(result.indexOf("<p>07-hello world</p>") > 0);
270+
Assert.assertTrue(result.indexOf("<p>08-hello world</p>") > 0);
271+
}
272+
246273
public static class Echo extends TagSupport {
247274

248275
private static final long serialVersionUID = 1L;

test/org/apache/jasper/servlet/TestJspCServletContext.java

+10
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ public void testWebapp_5_0() throws Exception {
133133
}
134134

135135

136+
@Test
137+
public void testWebapp_6_0() throws Exception {
138+
File appDir = new File("test/webapp-6.0");
139+
JspCServletContext context = new JspCServletContext(
140+
null, appDir.toURI().toURL(), null, false, false);
141+
Assert.assertEquals(6, context.getEffectiveMajorVersion());
142+
Assert.assertEquals(0, context.getEffectiveMinorVersion());
143+
}
144+
145+
136146
@Test
137147
public void testWebresources() throws Exception {
138148
File appDir = new File("test/webresources/dir1");

test/webapp-6.0/WEB-INF/tags11.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><!DOCTYPE taglib
18+
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
19+
"http://java.sun.com/dtd/web-jsptaglibrary_1_1.dtd">
20+
<taglib>
21+
<tlibversion>1.0</tlibversion>
22+
<jspversion>1.1</jspversion>
23+
<shortname>Tags11</shortname>
24+
<uri>http://tomcat.apache.org/tags11</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tagclass>org.apache.jasper.compiler.TestValidator$Echo</tagclass>
29+
<bodycontent>empty</bodycontent>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

test/webapp-6.0/WEB-INF/tags12.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><!DOCTYPE taglib
18+
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
19+
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
20+
<taglib>
21+
<tlib-version>1.0</tlib-version>
22+
<jsp-version>1.2</jsp-version>
23+
<short-name>Tags12</short-name>
24+
<uri>http://tomcat.apache.org/tags12</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tag-class>org.apache.jasper.compiler.TestValidator$Echo</tag-class>
29+
<body-content>empty</body-content>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

test/webapp-6.0/WEB-INF/tags20.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><taglib xmlns="http://java.sun.com/xml/ns/j2ee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
20+
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
21+
version="2.0">
22+
<tlib-version>1.0</tlib-version>
23+
<short-name>Tags20</short-name>
24+
<uri>http://tomcat.apache.org/tags20</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tag-class>org.apache.jasper.compiler.TestValidator$Echo</tag-class>
29+
<body-content>empty</body-content>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

test/webapp-6.0/WEB-INF/tags21.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><taglib xmlns="http://java.sun.com/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
20+
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
21+
version="2.1">
22+
<tlib-version>1.0</tlib-version>
23+
<short-name>Tags21</short-name>
24+
<uri>http://tomcat.apache.org/tags21</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tag-class>org.apache.jasper.compiler.TestValidator$Echo</tag-class>
29+
<body-content>empty</body-content>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

test/webapp-6.0/WEB-INF/tags30.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><taglib xmlns="http://java.sun.com/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
20+
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_3_0.xsd"
21+
version="3.0">
22+
<tlib-version>1.0</tlib-version>
23+
<short-name>Tags30</short-name>
24+
<uri>http://tomcat.apache.org/tags30</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tag-class>org.apache.jasper.compiler.TestValidator$Echo</tag-class>
29+
<body-content>empty</body-content>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

test/webapp-6.0/WEB-INF/tags31.tld

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
--><taglib xmlns="http://java.sun.com/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
20+
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_3_1.xsd"
21+
version="3.1">
22+
<tlib-version>1.0</tlib-version>
23+
<short-name>Tags31</short-name>
24+
<uri>http://tomcat.apache.org/tags31</uri>
25+
26+
<tag>
27+
<name>Echo</name>
28+
<tag-class>org.apache.jasper.compiler.TestValidator$Echo</tag-class>
29+
<body-content>empty</body-content>
30+
<attribute>
31+
<name>echo</name>
32+
<required>yes</required>
33+
<rtexprvalue>true</rtexprvalue>
34+
</attribute>
35+
</tag>
36+
37+
</taglib>

0 commit comments

Comments
 (0)