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

This page was automatically generated by Maven