View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.jsp;
5   
6   import java.io.StringReader;
7   
8   import net.sourceforge.pmd.lang.LanguageVersion;
9   import net.sourceforge.pmd.lang.LanguageVersionHandler;
10  import net.sourceforge.pmd.lang.Parser;
11  import net.sourceforge.pmd.lang.ast.Node;
12  
13  import org.junit.Assert;
14  import org.junit.Test;
15  
16  /**
17   * Unit test for JSP parsing.
18   *
19   */
20  public class JspParserTest {
21  
22      /**
23       * Verifies bug #939 Jsp parser fails on $
24       */
25      @Test
26      public void testParseDollar() {
27          Node node = parse("<span class=\"CostUnit\">$</span><span class=\"CostMain\">129</span><span class=\"CostFrac\">.00</span>");
28          Assert.assertNotNull(node);
29      }
30  
31      private Node parse(String code) {
32          LanguageVersionHandler jspLang = LanguageVersion.JSP.getLanguageVersionHandler();
33          Parser parser = jspLang.getParser(jspLang.getDefaultParserOptions());
34          Node node = parser.parse(null, new StringReader(code));
35          return node;
36      }
37  }