Skip to content

Commit 2f5fa34

Browse files
committed
Add/update tests for the Jakarta EE 11 schema
1 parent 43b88db commit 2f5fa34

File tree

17 files changed

+435
-4
lines changed

17 files changed

+435
-4
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ public void setVersion(String version) {
194194
majorVersion = 6;
195195
minorVersion = 0;
196196
break;
197+
case "6.1":
198+
majorVersion = 6;
199+
minorVersion = 1;
200+
break;
197201
default:
198202
log.warn(sm.getString("webXml.version.unknown", version));
199203
}

test/jakarta/servlet/resources/TestSchemaValidation.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void testWebapp() throws Exception {
3939
digester.push(new WebXml());
4040
WebXml desc = (WebXml) digester.parse(
4141
new File("test/webapp/WEB-INF/web.xml"));
42-
Assert.assertEquals("6.0", desc.getVersion());
42+
Assert.assertEquals("6.1", desc.getVersion());
4343
Assert.assertEquals(0, handler.getErrors().size());
4444
Assert.assertEquals(0, handler.getWarnings().size());
4545
}
@@ -172,4 +172,19 @@ public void testWebapp_6_0() throws Exception {
172172
Assert.assertEquals(0, handler.getErrors().size());
173173
Assert.assertEquals(0, handler.getWarnings().size());
174174
}
175+
176+
177+
@Test
178+
public void testWebapp_6_1() throws Exception {
179+
XmlErrorHandler handler = new XmlErrorHandler();
180+
Digester digester = DigesterFactory.newDigester(
181+
true, true, new WebRuleSet(false), true);
182+
digester.setErrorHandler(handler);
183+
digester.push(new WebXml());
184+
WebXml desc = (WebXml) digester.parse(
185+
new File("test/webapp-6.1/WEB-INF/web.xml"));
186+
Assert.assertEquals("6.1", desc.getVersion());
187+
Assert.assertEquals(0, handler.getErrors().size());
188+
Assert.assertEquals(0, handler.getWarnings().size());
189+
}
175190
}

test/org/apache/jasper/TestJspC.java

+8
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ public void precompileWebapp_6_0() throws IOException {
119119
verify(webappOut);
120120
}
121121

122+
@Test
123+
public void precompileWebapp_6_1() throws IOException {
124+
File appDir = new File("test/webapp-6.1");
125+
File webappOut = new File(outputDir, appDir.getName());
126+
precompile(appDir, webappOut);
127+
verify(webappOut);
128+
}
129+
122130
private void verify(File webappOut) {
123131
// for now, just check some expected files exist
124132
Assert.assertTrue(new File(webappOut, "generated_web.xml").exists());

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

+17
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ public void testServlet60NoEL() throws Exception {
185185
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
186186
}
187187

188+
@Test
189+
public void testServlet61NoEL() throws Exception {
190+
Tomcat tomcat = getTomcatInstance();
191+
192+
File appDir = new File("test/webapp-6.1");
193+
// app dir is relative to server home
194+
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
195+
196+
tomcat.start();
197+
198+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/el-as-literal.jsp");
199+
200+
String result = res.toString();
201+
202+
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
203+
}
204+
188205
@Test
189206
public void testErrorOnELNotFound01() throws Exception {
190207
// Defaults

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

+26
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,32 @@ public void testTldVersions60() throws Exception {
251251
Assert.assertTrue(result.indexOf("<p>08-hello world</p>") > 0);
252252
}
253253

254+
@Test
255+
public void testTldVersions61() throws Exception {
256+
Tomcat tomcat = getTomcatInstance();
257+
258+
File appDir = new File("test/webapp-6.1");
259+
// app dir is relative to server home
260+
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
261+
262+
tomcat.start();
263+
264+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/tld-versions.jsp");
265+
266+
String result = res.toString();
267+
268+
Assert.assertTrue(result.indexOf("<p>00-hello world</p>") > 0);
269+
Assert.assertTrue(result.indexOf("<p>#{'01-hello world'}</p>") > 0);
270+
Assert.assertTrue(result.indexOf("<p>02-hello world</p>") > 0);
271+
Assert.assertTrue(result.indexOf("<p>#{'03-hello world'}</p>") > 0);
272+
Assert.assertTrue(result.indexOf("<p>04-hello world</p>") > 0);
273+
Assert.assertTrue(result.indexOf("<p>#{'05-hello world'}</p>") > 0);
274+
Assert.assertTrue(result.indexOf("<p>06-hello world</p>") > 0);
275+
Assert.assertTrue(result.indexOf("<p>07-hello world</p>") > 0);
276+
Assert.assertTrue(result.indexOf("<p>08-hello world</p>") > 0);
277+
Assert.assertTrue(result.indexOf("<p>09-hello world</p>") > 0);
278+
}
279+
254280
public static class Echo extends TagSupport {
255281

256282
private static final long serialVersionUID = 1L;

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testWebapp() throws Exception {
3535
JspCServletContext context = new JspCServletContext(
3636
null, appDir.toURI().toURL(), null, false, false);
3737
Assert.assertEquals(6, context.getEffectiveMajorVersion());
38-
Assert.assertEquals(0, context.getEffectiveMinorVersion());
38+
Assert.assertEquals(1, context.getEffectiveMinorVersion());
3939
JspConfigDescriptor jspConfigDescriptor =
4040
context.getJspConfigDescriptor();
4141
Assert.assertTrue(jspConfigDescriptor.getTaglibs().isEmpty());
@@ -143,6 +143,16 @@ public void testWebapp_6_0() throws Exception {
143143
}
144144

145145

146+
@Test
147+
public void testWebapp_6_1() throws Exception {
148+
File appDir = new File("test/webapp-6.1");
149+
JspCServletContext context = new JspCServletContext(
150+
null, appDir.toURI().toURL(), null, false, false);
151+
Assert.assertEquals(6, context.getEffectiveMajorVersion());
152+
Assert.assertEquals(1, context.getEffectiveMinorVersion());
153+
}
154+
155+
146156
@Test
147157
public void testWebresources() throws Exception {
148158
File appDir = new File("test/webresources/dir1");

test/webapp-6.1/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.1/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.1/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.1/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.1/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.1/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)