From ab2f5a6a4f44e47628b805bb9b6e2c8981b07bca Mon Sep 17 00:00:00 2001 From: Wouter Zelle Date: Thu, 30 Nov 2006 21:27:41 +0000 Subject: [PATCH] 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 --- .../pmd/rules/CloseResourceTest.java | 18 +----- .../pmd/rules/EmptyCatchBlockRuleTest.java | 50 ++++++--------- .../pmd/rules/xml/CloseResource.xml | 6 +- .../pmd/rules/xml/EmptyCatchBlock.xml | 61 +++++++++++++------ 4 files changed, 66 insertions(+), 69 deletions(-) diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/CloseResourceTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/CloseResourceTest.java index d6506eb333..679ae1c3fb 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/CloseResourceTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/CloseResourceTest.java @@ -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]); - } - } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java index 6e0abbb282..39a828f5d0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java @@ -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); + } +} diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/xml/CloseResource.xml b/pmd/regress/test/net/sourceforge/pmd/rules/xml/CloseResource.xml index bc3c08edf6..0d5f4bf274 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/xml/CloseResource.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/xml/CloseResource.xml @@ -88,7 +88,7 @@ Bad, no closeTargets properties for statements 2 - + @@ -96,7 +96,7 @@ Ok, closeTargets properties for statements 0 - + @@ -115,7 +115,7 @@ readExternal(aStream); } ]]> - + diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/xml/EmptyCatchBlock.xml b/pmd/regress/test/net/sourceforge/pmd/rules/xml/EmptyCatchBlock.xml index 8cdaf2b289..4ff6b0d71c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/xml/EmptyCatchBlock.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/xml/EmptyCatchBlock.xml @@ -103,48 +103,75 @@ public class Foo { } ]]> - - - - 1 - + - + ]]> 1 - + + + + true + 0 + + + - + ]]> 1 - + + + + true + 0 + + + + ]]> + + + 1 + - + + + true + 0 + + +