Author: jboynes Date: Sat Jul 20 20:46:58 2013 New Revision: 1505204 URL: http://svn.apache.org/r1505204 Log: Fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=55262 Duplicate prelude and coda entries in same <jsp-property-group> are preserved.
Added: tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java (with props) tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf (with props) tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf (with props) tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp (with props) Modified: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java tomcat/trunk/test/webapp/WEB-INF/web.xml Modified: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java?rev=1505204&r1=1505203&r2=1505204&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/JspPropertyGroup.java Sat Jul 20 20:46:58 2013 @@ -16,6 +16,8 @@ */ package org.apache.tomcat.util.descriptor.web; +import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; @@ -35,17 +37,17 @@ public class JspPropertyGroup { } public Boolean getElIgnored() { return elIgnored; } - private final Set<String> includeCodas = new LinkedHashSet<>(); + private final Collection<String> includeCodas = new ArrayList<>(); public void addIncludeCoda(String includeCoda) { includeCodas.add(includeCoda); } - public Set<String> getIncludeCodas() { return includeCodas; } + public Collection<String> getIncludeCodas() { return includeCodas; } - private final Set<String> includePreludes = new LinkedHashSet<>(); + private final Collection<String> includePreludes = new ArrayList<>(); public void addIncludePrelude(String includePrelude) { includePreludes.add(includePrelude); } - public Set<String> getIncludePreludes() { return includePreludes; } + public Collection<String> getIncludePreludes() { return includePreludes; } private Boolean isXml = null; public void setIsXml(String isXml) { Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java?rev=1505204&r1=1505203&r2=1505204&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java (original) +++ tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java Sat Jul 20 20:46:58 2013 @@ -21,6 +21,7 @@ import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -220,6 +221,27 @@ public class TestCompiler extends Tomcat // it fails } + @Test + public void testBug55262() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + File appDir = new File("test/webapp"); + tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); + tomcat.start(); + + ByteChunk res = getUrl("http://localhost:" + getPort() + + "/test/bug5nnnn/bug55262.jsp"); + String result = res.toString(); + Pattern prelude = Pattern.compile( + "(.*This is a prelude\\.){2}.*", + Pattern.MULTILINE | Pattern.DOTALL); + Pattern coda = Pattern.compile( + "(.*This is a coda\\.){2}.*", + Pattern.MULTILINE|Pattern.DOTALL); + assertTrue(prelude.matcher(result).matches()); + assertTrue(coda.matcher(result).matches()); + } + /** Assertion for text printed by tags:echo */ private static void assertEcho(String result, String expected) { assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0); Modified: tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java?rev=1505204&r1=1505203&r2=1505204&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java (original) +++ tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java Sat Jul 20 20:46:58 2013 @@ -40,9 +40,12 @@ public class TestJspCServletContext { Assert.assertTrue(jspConfigDescriptor.getTaglibs().isEmpty()); Collection<JspPropertyGroupDescriptor> propertyGroups = jspConfigDescriptor.getJspPropertyGroups(); - Assert.assertEquals(1, propertyGroups.size()); - JspPropertyGroupDescriptor groupDescriptor = - propertyGroups.iterator().next(); + Assert.assertEquals(2, propertyGroups.size()); + Iterator<JspPropertyGroupDescriptor> groupIterator = + propertyGroups.iterator(); + JspPropertyGroupDescriptor groupDescriptor; + + groupDescriptor = groupIterator.next(); Assert.assertEquals("text/plain", groupDescriptor.getDefaultContentType()); Collection<String> urlPatterns =groupDescriptor.getUrlPatterns(); @@ -50,6 +53,10 @@ public class TestJspCServletContext { Iterator<String> iterator = urlPatterns.iterator(); Assert.assertEquals("/bug49nnn/bug49726a.jsp", iterator.next()); Assert.assertEquals("/bug49nnn/bug49726b.jsp", iterator.next()); + + groupDescriptor = groupIterator.next(); + Assert.assertEquals(2, groupDescriptor.getIncludePreludes().size()); + Assert.assertEquals(2, groupDescriptor.getIncludeCodas().size()); } @Test Added: tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java?rev=1505204&view=auto ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java (added) +++ tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java Sat Jul 20 20:46:58 2013 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomcat.util.descriptor.web; + +import org.junit.Assert; +import org.junit.Test; + +public class TestJspPropertyGroup { + + private JspPropertyGroup group = new JspPropertyGroup(); + + @Test + public void testBug55262() { + group.addIncludePrelude("/prelude"); + group.addIncludePrelude("/prelude"); + group.addIncludeCoda("/coda"); + group.addIncludeCoda("/coda"); + Assert.assertEquals(2, group.getIncludePreludes().size()); + Assert.assertEquals(2, group.getIncludeCodas().size()); + } +} Propchange: tomcat/trunk/test/org/apache/tomcat/util/descriptor/web/TestJspPropertyGroup.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/test/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/web.xml?rev=1505204&r1=1505203&r2=1505204&view=diff ============================================================================== --- tomcat/trunk/test/webapp/WEB-INF/web.xml (original) +++ tomcat/trunk/test/webapp/WEB-INF/web.xml Sat Jul 20 20:46:58 2013 @@ -102,6 +102,14 @@ <url-pattern>/bug49nnn/bug49726b.jsp</url-pattern> <default-content-type>text/plain</default-content-type> </jsp-property-group> + <jsp-property-group> + <url-pattern>/bug5nnnn/bug55262.jsp</url-pattern> + <include-prelude>/bug5nnnn/bug55262-prelude.jspf</include-prelude> + <include-prelude>/bug5nnnn/bug55262-prelude.jspf</include-prelude> + <include-coda>/bug5nnnn/bug55262-coda.jspf</include-coda> + <include-coda>/bug5nnnn/bug55262-coda.jspf</include-coda> + <default-content-type>text/plain</default-content-type> + </jsp-property-group> </jsp-config> <servlet> Added: tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf?rev=1505204&view=auto ============================================================================== --- tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf (added) +++ tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf Sat Jul 20 20:46:58 2013 @@ -0,0 +1,17 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> +This is a coda. Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug55262-coda.jspf ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf?rev=1505204&view=auto ============================================================================== --- tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf (added) +++ tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf Sat Jul 20 20:46:58 2013 @@ -0,0 +1,17 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> +This is a prelude. Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug55262-prelude.jspf ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp?rev=1505204&view=auto ============================================================================== --- tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp (added) +++ tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp Sat Jul 20 20:46:58 2013 @@ -0,0 +1,17 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> +There should be two preludes before and two codas after this line. Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug55262.jsp ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org