View Javadoc
1 package test.net.sourceforge.pmd.rules.strictexception; 2 3 import net.sourceforge.pmd.PMD; 4 import net.sourceforge.pmd.rules.strictexception.ExceptionTypeChecking; 5 import test.net.sourceforge.pmd.rules.SimpleAggregatorTst; 6 import test.net.sourceforge.pmd.rules.TestDescriptor; 7 8 public class ExceptionTypeCheckingRuleTest extends SimpleAggregatorTst { 9 10 public void testAll() { 11 runTests(new TestDescriptor[] { 12 new TestDescriptor(TEST1, "checks for NPE", 1, new ExceptionTypeChecking()), 13 new TestDescriptor(TEST2, "ok", 0, new ExceptionTypeChecking()), 14 }); 15 } 16 17 private static final String TEST1 = 18 "public class Foo {" + PMD.EOL + 19 " void foo() {" + PMD.EOL + 20 " try {} catch (Exception e) {" + PMD.EOL + 21 " if (e instanceof NullPointerException) {}" + PMD.EOL + 22 " }" + PMD.EOL + 23 " }" + PMD.EOL + 24 "}"; 25 26 private static final String TEST2 = 27 "public class Foo {" + PMD.EOL + 28 " void foo() {" + PMD.EOL + 29 " try {} catch (Exception e) {}" + PMD.EOL + 30 " }" + PMD.EOL + 31 "}"; 32 33 }

This page was automatically generated by Maven