forked from phoedos/pmd
Moving test cases from xml deffinition into JUnit test
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4778 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
import test.net.sourceforge.pmd.testframework.TestDescriptor;
|
||||
|
||||
public class BrokenNullCheckTest extends SimpleAggregatorTst {
|
||||
private Rule rule;
|
||||
@ -11,6 +13,27 @@ public class BrokenNullCheckTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
runTests(rule);
|
||||
runTests(new TestDescriptor[]{
|
||||
new TestDescriptor(TEST1, "should be ||", 1, rule),
|
||||
new TestDescriptor(TEST2, "should be &&", 1, rule),
|
||||
});
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" List bar(List list) {" + PMD.EOL +
|
||||
" if (list != null || !list.equals(buz)) {" + PMD.EOL +
|
||||
" return list;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" List bar(List list) {" + PMD.EOL +
|
||||
" if (list == null && list.equals(buz)) {" + PMD.EOL +
|
||||
" return list;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
should be ||
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
List bar(List list) {
|
||||
if (list != null || !list.equals(buz)) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}]]> </code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
should be &&
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
List bar(List list) {
|
||||
if (list == null && list.equals(buz)) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}]]> </code>
|
||||
</test-code>
|
||||
</test-data>
|
Reference in New Issue
Block a user