    1   package test.net.sourceforge.pmd.jsp.rules;
    2
    3   import net.sourceforge.pmd.Rule;
    4   import net.sourceforge.pmd.RuleSetFactory;
    5   import net.sourceforge.pmd.RuleSetNotFoundException;
    6   import net.sourceforge.pmd.SourceType;
    7   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    8   import test.net.sourceforge.pmd.testframework.TestDescriptor;
    9
    10  public class NoScriptlets extends SimpleAggregatorTst {
    11
    12      public void testAll() throws RuleSetNotFoundException {
    13          Rule rule = new RuleSetFactory()
    14                  .createSingleRuleSet("rulesets/basic-jsp.xml").getRuleByName("NoScriptlets");
    15          runTests(new TestDescriptor[]{
    16              new TestDescriptor(VIOLATION1, "Two scriptlets.", 2, rule),
    17              new TestDescriptor(NO_VIOLATION1, "No scriptlets.", 0, rule),
    18          }, SourceType.JSP);
    19      }
    20
    21      private static final String VIOLATION1 =
    22              "<HTML>" +
    23              "<HEAD>" +
    24              "<% response.setHeader(\"Pragma\", \"No-cache\"); %>" +
    25              "</HEAD>" +
    26              "<BODY>" +
    27              "	<jsp:scriptlet>String title = \"Hello world!\";</jsp:scriptlet>" +
    28              "</BODY>" +
    29              "</HTML>";
    30
    31
    32      private static final String NO_VIOLATION1 =
    33              "<html><body><p>text</p></body></html>";
    34  }