diff --git a/pmd/regress/test/net/sourceforge/pmd/FunctionalTest.java b/pmd/regress/test/net/sourceforge/pmd/FunctionalTest.java index a9d9488b73..80690f1d2a 100644 --- a/pmd/regress/test/net/sourceforge/pmd/FunctionalTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/FunctionalTest.java @@ -23,11 +23,6 @@ public class FunctionalTest extends TestCase{ /* - public void testUnnecessaryTemporaries() { - Report report = process("UnnecessaryTemporary.java"); - assertEquals(6, report.countViolationsInCurrentFile()); - assertEquals(new UnnecessaryConversionTemporaryRule(), ((RuleViolation)report.violationsInCurrentFile().next()).getRule()); - } public void testProps() { Report report = process("ContainsSystemGetProps.java"); @@ -71,42 +66,6 @@ public class FunctionalTest extends TestCase{ assertEquals(new EmptyWhileStmtRule(), ((RuleViolation)report.violationsInCurrentFile().next()).getRule()); } - public void testUnusedPrivateInstanceVar1() { - Report report = process("UnusedPrivateInstanceVar1.java"); - assertEquals(1, report.countViolationsInCurrentFile()); - Iterator i = report.violationsInCurrentFile(); - assertEquals(new UnusedPrivateInstanceVariableRule(), ((RuleViolation)i.next()).getRule()); - } - - public void testUnusedPrivateInstanceVar2() { - Report report = process("UnusedPrivateInstanceVar2.java"); - assertTrue(report.currentFileHasNoViolations()); - } - - public void testUnusedPrivateInstanceVar3() { - Report report = process("UnusedPrivateInstanceVar3.java"); - assertEquals(1, report.countViolationsInCurrentFile()); - Iterator i = report.violationsInCurrentFile(); - assertEquals(new UnusedPrivateInstanceVariableRule(), ((RuleViolation)i.next()).getRule()); - } - - public void testUnusedPrivateInstanceVar4() { - Report report = process("UnusedPrivateInstanceVar4.java"); - assertTrue(report.currentFileHasNoViolations()); - } - - public void testUnusedPrivateInstanceVar6() { - Report report = process("UnusedPrivateInstanceVar6.java"); - assertTrue(report.currentFileHasNoViolations()); - } - public void testUnusedPrivateInstanceVar7() { - Report report = process("UnusedPrivateInstanceVar7.java"); - assertTrue(report.currentFileHasNoViolations()); - } - public void testUnusedPrivateInstanceVar8() { - Report report = process("UnusedPrivateInstanceVar8.java"); - assertTrue(report.currentFileHasNoViolations()); - } public void testIfElseStmtsMustUseBraces1() { Report report = process("IfElseStmtsNeedBraces1.java"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java new file mode 100644 index 0000000000..254aa1ac2f --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java @@ -0,0 +1,24 @@ +/* + * User: tom + * Date: Jun 28, 2002 + * Time: 2:34:20 PM + */ +package test.net.sourceforge.pmd.rules; + +import junit.framework.TestCase; +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.rules.UnnecessaryConversionTemporaryRule; + +public class UnnecessaryTemporariesRuleTest extends RuleTst{ + + public UnnecessaryTemporariesRuleTest(String name) { + super(name); + } + + public void testUnnecessaryTemporaries() { + Report report = process2("UnnecessaryTemporary.java", new UnnecessaryConversionTemporaryRule()); + assertEquals(6, report.countViolationsInCurrentFile()); + assertEquals(new UnnecessaryConversionTemporaryRule(), ((RuleViolation)report.violationsInCurrentFile().next()).getRule()); + } +} diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java new file mode 100644 index 0000000000..bef3387230 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java @@ -0,0 +1,56 @@ +/* + * User: tom + * Date: Jun 28, 2002 + * Time: 2:35:51 PM + */ +package test.net.sourceforge.pmd.rules; + +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.rules.UnusedPrivateInstanceVariableRule; + +import java.util.Iterator; + +public class UnusedPrivateInstanceVariableRuleTest extends RuleTst { + + public UnusedPrivateInstanceVariableRuleTest(String name) { + super(name); + } + + public void testUnusedPrivateInstanceVar1() { + Report report = process2("UnusedPrivateInstanceVar1.java", new UnusedPrivateInstanceVariableRule()); + assertEquals(1, report.countViolationsInCurrentFile()); + Iterator i = report.violationsInCurrentFile(); + assertEquals(new UnusedPrivateInstanceVariableRule(), ((RuleViolation)i.next()).getRule()); + } + + public void testUnusedPrivateInstanceVar2() { + Report report = process2("UnusedPrivateInstanceVar2.java", new UnusedPrivateInstanceVariableRule()); + assertTrue(report.currentFileHasNoViolations()); + } + + public void testUnusedPrivateInstanceVar3() { + Report report = process2("UnusedPrivateInstanceVar3.java", new UnusedPrivateInstanceVariableRule()); + assertEquals(1, report.countViolationsInCurrentFile()); + Iterator i = report.violationsInCurrentFile(); + assertEquals(new UnusedPrivateInstanceVariableRule(), ((RuleViolation)i.next()).getRule()); + } + + public void testUnusedPrivateInstanceVar4() { + Report report = process2("UnusedPrivateInstanceVar4.java", new UnusedPrivateInstanceVariableRule()); + assertTrue(report.currentFileHasNoViolations()); + } + + public void testUnusedPrivateInstanceVar6() { + Report report = process2("UnusedPrivateInstanceVar6.java", new UnusedPrivateInstanceVariableRule()); + assertTrue(report.currentFileHasNoViolations()); + } + public void testUnusedPrivateInstanceVar7() { + Report report = process2("UnusedPrivateInstanceVar7.java", new UnusedPrivateInstanceVariableRule()); + assertTrue(report.currentFileHasNoViolations()); + } + public void testUnusedPrivateInstanceVar8() { + Report report = process2("UnusedPrivateInstanceVar8.java", new UnusedPrivateInstanceVariableRule()); + assertTrue(report.currentFileHasNoViolations()); + } +}