Permalink
Show file tree
Hide file tree
1 comment
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8264766: ClassCastException during template compilation (Variable can…
…not be cast to Param) Reviewed-by: naoto
- Loading branch information
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package transform; | ||
|
||
import java.io.StringReader; | ||
import javax.xml.transform.TransformerFactory; | ||
import javax.xml.transform.stream.StreamSource; | ||
import org.testng.annotations.Test; | ||
|
||
/* | ||
* @test | ||
* @bug 8264766 | ||
* @run testng transform.SymbolTableTest | ||
* @summary Tests SymbolTable | ||
*/ | ||
public class SymbolTableTest { | ||
/** | ||
* Verifies that the SymbolTable processes (adds) variables and params | ||
* properly. The SymbolTable holds variables and params in a map, it shall | ||
* therefore perform a type check before cast, or else result in a | ||
* ClassCastException when variables and/or params have the same name (in | ||
* which case the later ones shadow the previous ones). | ||
* | ||
* @throws Exception if the test fails | ||
*/ | ||
@Test | ||
public void test() throws Exception { | ||
TransformerFactory transformerFactory = TransformerFactory.newInstance(); | ||
String stylesheet = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + | ||
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n" + | ||
" <xsl:variable name=\"background-color\">#f4f4f4</xsl:variable>\n" + | ||
" <xsl:param name=\"background-color\">pp</xsl:param>\n" + | ||
" <xsl:template name=\"tName\"><xsl:param name=\"background-color\">black</xsl:param>\n" + | ||
" OK <xsl:value-of select=\"$background-color\"/>\n" + | ||
" </xsl:template>\n" + | ||
" <xsl:template match=\"/root\">\n" + | ||
" <xsl:call-template name=\"tName\">\n" + | ||
" <xsl:with-param name=\"background-color\" select=\"$background-color\"/>\n" + | ||
" </xsl:call-template>\n" + | ||
" </xsl:template>\n" + | ||
"</xsl:stylesheet>\n"; | ||
transformerFactory.newTransformer(new StreamSource(new StringReader(stylesheet))); | ||
} | ||
} |
1c3932f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues