forked from phoedos/pmd
cleanup of test using reinitialization in XML test-data file
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4850 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -5,32 +5,16 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
import test.net.sourceforge.pmd.testframework.TestDescriptor;
|
||||
|
||||
public class CloseResourceTest extends SimpleAggregatorTst {
|
||||
private Rule rule;
|
||||
private TestDescriptor[] tests;
|
||||
|
||||
public void setUp() {
|
||||
rule = findRule("design", "CloseResource");
|
||||
tests = extractTestsFromXml(rule);
|
||||
rule.addProperty("types", "Connection,Statement,ResultSet"); //Default
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
runTests(new TestDescriptor[] {tests[0], tests[1], tests[2], tests[3], tests[4]});
|
||||
runTests(rule);
|
||||
}
|
||||
|
||||
public void testMultipleProperties(){
|
||||
runTest(tests[5]);
|
||||
}
|
||||
|
||||
public void testTypes(){
|
||||
runTest(tests[6]);
|
||||
}
|
||||
|
||||
public void testPropertySetter(){
|
||||
runTest(tests[7]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,19 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
import test.net.sourceforge.pmd.testframework.TestDescriptor;
|
||||
|
||||
public class EmptyCatchBlockRuleTest extends SimpleAggregatorTst {
|
||||
private Rule rule;
|
||||
private TestDescriptor[] tests;
|
||||
|
||||
public void setUp() {
|
||||
rule = findRule("basic", "EmptyCatchBlock");
|
||||
tests = extractTestsFromXml(rule);
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
runTests(tests);
|
||||
}
|
||||
|
||||
public void testCommentedBlocksAllowed() {
|
||||
rule.addProperty("allowCommentedBlocks", "true");
|
||||
runTests(new TestDescriptor[]{
|
||||
new TestDescriptor(tests[7].getCode(), "single-line comment is OK", 0, rule),
|
||||
new TestDescriptor(tests[8].getCode(), "multiple-line comment is OK", 0, rule),
|
||||
new TestDescriptor(tests[9].getCode(), "Javadoc comment is OK", 0, rule),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
|
||||
public class EmptyCatchBlockRuleTest extends SimpleAggregatorTst {
|
||||
private Rule rule;
|
||||
|
||||
public void setUp() {
|
||||
rule = findRule("basic", "EmptyCatchBlock");
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
runTests(rule);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ Bad, no closeTargets properties for statements
|
||||
<expected-problems>2</expected-problems>
|
||||
<code-ref id="executeQuery"/>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<test-code reinitializeRule="true">
|
||||
<description><![CDATA[
|
||||
Ok, closeTargets properties for statements
|
||||
]]></description>
|
||||
@ -96,7 +96,7 @@ Ok, closeTargets properties for statements
|
||||
<expected-problems>0</expected-problems>
|
||||
<code-ref id="executeQuery"/>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<test-code reinitializeRule="true">
|
||||
<description><![CDATA[
|
||||
Add type param
|
||||
]]></description>
|
||||
@ -115,7 +115,7 @@ readExternal(aStream);
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<test-code reinitializeRule="true">
|
||||
<description><![CDATA[
|
||||
OK
|
||||
]]></description>
|
||||
|
@ -103,48 +103,75 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<!-- Commented blocks disallowed -->
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
single-line comment is not OK
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
<!-- Commented blocks -->
|
||||
<code-fragment id="single-line comment"><![CDATA[
|
||||
public class Foo {
|
||||
void bar() {
|
||||
try {} catch (Exception e) { // Commented
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
]]></code-fragment>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
multiple-line comment is not OK
|
||||
single-line comment is not OK
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
<code-ref id="single-line comment"/>
|
||||
</test-code>
|
||||
<test-code reinitializeRule="1">
|
||||
<description><![CDATA[
|
||||
single-line comment is OK
|
||||
]]></description>
|
||||
<rule-property name="allowCommentedBlocks">true</rule-property>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code-ref id="single-line comment"/>
|
||||
</test-code>
|
||||
<code-fragment id="multiple-line comment"><![CDATA[
|
||||
public class Foo {
|
||||
void bar() {
|
||||
try {} catch (Exception e) { /* Commented */
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
]]></code-fragment>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Javadoc comment is not OK
|
||||
multiple-line comment is not OK
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
<code-ref id="multiple-line comment"/>
|
||||
</test-code>
|
||||
<test-code reinitializeRule="true">
|
||||
<description><![CDATA[
|
||||
multiple-line comment is OK
|
||||
]]></description>
|
||||
<rule-property name="allowCommentedBlocks">true</rule-property>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code-ref id="multiple-line comment"/>
|
||||
</test-code>
|
||||
<code-fragment id="javadoc comment"><![CDATA[
|
||||
public class Foo {
|
||||
void bar() {
|
||||
try {} catch (Exception e) { /** Commented */
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
]]></code-fragment>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Javadoc comment is not OK
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code-ref id="javadoc comment"/>
|
||||
</test-code>
|
||||
<!-- END Commented blocks disallowed -->
|
||||
<test-code reinitializeRule="true">
|
||||
<description><![CDATA[
|
||||
Javadoc comment is OK
|
||||
]]></description>
|
||||
<rule-property name="allowCommentedBlocks">true</rule-property>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code-ref id="javadoc comment"/>
|
||||
</test-code>
|
||||
<!-- END Commented blocks -->
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user