View Javadoc

    1
    2   package net.sourceforge.pmd.jaxen;
    3
    4   import net.sourceforge.pmd.Rule;
    5   import net.sourceforge.pmd.lang.Language;
    6   import net.sourceforge.pmd.lang.rule.XPathRule;
    7   import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    8   import net.sourceforge.pmd.testframework.TestDescriptor;
    9
    10  import org.junit.Test;
    11
    12
    13  public class RegexpAcceptanceTest extends SimpleAggregatorTst {
    14
    15  	private static final String xPath = "//ClassOrInterfaceDeclaration[matches(@Image, 'F?o')]";
    16       @Test
    17       public void testSimple() throws Throwable {
    18           Rule r = new XPathRule(xPath);
    19           r.setLanguage(Language.JAVA);
    20           r.setMessage("");
    21           TestDescriptor[] testDescriptors = extractTestsFromXml(r, "RegexpAcceptance");
    22           for (TestDescriptor testDescriptor: testDescriptors) {
    23               testDescriptor.setReinitializeRule(false);
    24           }
    25           runTests(testDescriptors);
    26       }
    27
    28      public static junit.framework.Test suite() {
    29          return new junit.framework.JUnit4TestAdapter(RegexpAcceptanceTest.class);
    30      }
    31  }