diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
new file mode 100644
index 0000000000..4fa812ff2b
--- /dev/null
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
@@ -0,0 +1,81 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+package net.sourceforge.pmd.ant;
+
+import org.junit.Test;
+
+public class PMDTaskTest extends AbstractAntTestHelper {
+
+ public PMDTaskTest() {
+ super.antTestScriptFilename = "pmdtasktest.xml";
+ }
+
+ @Test
+ public void testNoFormattersValidation() {
+ executeTarget("testNoFormattersValidation");
+ assertOutputContaining("Fields should be declared at the top of the class");
+ }
+
+ @Test
+ public void testNestedRuleset() {
+ executeTarget("testNestedRuleset");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ }
+
+ @Test
+ public void testFormatterWithProperties() {
+ executeTarget("testFormatterWithProperties");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ assertOutputContaining("link_prefix");
+ assertOutputContaining("line_prefix");
+ }
+
+ @Test
+ public void testAbstractNames() {
+ executeTarget("testAbstractNames");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ }
+
+ @Test
+ public void testAbstractNamesInNestedRuleset() {
+ executeTarget("testAbstractNamesInNestedRuleset");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ }
+
+ @Test
+ public void testCommaInRulesetfiles() {
+ executeTarget("testCommaInRulesetfiles");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ }
+
+ @Test
+ public void testRelativeRulesets() {
+ executeTarget("testRelativeRulesets");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at the");
+ }
+
+ @Test
+ public void testRelativeRulesetsInRulesetfiles() {
+ executeTarget("testRelativeRulesetsInRulesetfiles");
+ assertOutputContaining("Avoid really long methods");
+ assertOutputContaining("Fields should be declared at");
+ }
+
+ @Test
+ public void testExplicitRuleInRuleSet() {
+ executeTarget("testExplicitRuleInRuleSet");
+ assertOutputContaining("Avoid really long methods");
+ }
+
+ @Test
+ public void testClasspath() {
+ executeTarget("testClasspath");
+ }
+}
diff --git a/pmd-java/src/test/resources/ant/java/PMDTaskTestExample.java b/pmd-java/src/test/resources/ant/java/PMDTaskTestExample.java
new file mode 100644
index 0000000000..cabdac5556
--- /dev/null
+++ b/pmd-java/src/test/resources/ant/java/PMDTaskTestExample.java
@@ -0,0 +1,110 @@
+package ant.java;
+
+public class PMDTaskTestExample {
+
+ // must be 100+ lines long
+ public void veryLongMethod() {
+ int a;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ a -= 1;
+ a += 1;
+ }
+
+ private int testField; // this will trigger a "Fields should be declared at top"
+}
\ No newline at end of file
diff --git a/pmd/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml
similarity index 100%
rename from pmd/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml
rename to pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml
diff --git a/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/custom_ruleset.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/xml/custom_ruleset.xml
similarity index 100%
rename from pmd/src/test/resources/net/sourceforge/pmd/ant/xml/custom_ruleset.xml
rename to pmd-java/src/test/resources/net/sourceforge/pmd/ant/xml/custom_ruleset.xml
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
new file mode 100644
index 0000000000..b84dc2f1d9
--- /dev/null
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+ ${pmd.home}/src/main/resources/rulesets/java/codesize.xml
+ ${pmd.home}/src/main/resources/rulesets/java/design.xml
+
+
+
+
+
+
+
+
+
+ ${pmd.home}/src/main/resources/rulesets/java/codesize.xml
+ ${pmd.home}/src/main/resources/rulesets/java/design.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ java-codesize
+ java-design
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ custom_ruleset.xml
+ rulesets/java/design.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ classpathtest/ruleset.xml
+
+
+
+
+
+
+
+
+
+
diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
new file mode 100644
index 0000000000..c57eff0a2d
--- /dev/null
+++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
@@ -0,0 +1,21 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+package net.sourceforge.pmd.ant;
+
+import org.junit.Test;
+
+public class PMDTaskTest extends AbstractAntTestHelper {
+
+ public PMDTaskTest() {
+ super.antTestScriptFilename = "pmdtasktest.xml";
+ }
+
+ @Test
+ public void testEcmascript() {
+ executeTarget("testEcmascript");
+ assertOutputContaining("A 'return', 'break', 'continue', or 'throw' statement should be the last in a block.");
+ assertOutputContaining("Avoid using global variables");
+ assertOutputContaining("Use ===/!== to compare with true/false or Numbers");
+ }
+}
diff --git a/pmd/src/test/resources/ant/ecmascript/fcoltable.js b/pmd-javascript/src/test/resources/ant/ecmascript/fcoltable.js
similarity index 100%
rename from pmd/src/test/resources/ant/ecmascript/fcoltable.js
rename to pmd-javascript/src/test/resources/ant/ecmascript/fcoltable.js
diff --git a/pmd/src/test/resources/ant/ecmascript/sorttable.js b/pmd-javascript/src/test/resources/ant/ecmascript/sorttable.js
similarity index 100%
rename from pmd/src/test/resources/ant/ecmascript/sorttable.js
rename to pmd-javascript/src/test/resources/ant/ecmascript/sorttable.js
diff --git a/pmd-javascript/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd-javascript/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
new file mode 100644
index 0000000000..34cd2ebfa7
--- /dev/null
+++ b/pmd-javascript/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml
index 71d066955c..10bf1b1760 100644
--- a/pmd-test/pom.xml
+++ b/pmd-test/pom.xml
@@ -20,5 +20,9 @@
junit
junit
+
+ org.apache.ant
+ ant-testutil
+
diff --git a/pmd/src/test/java/net/sourceforge/pmd/ant/AbstractAntTestHelper.java b/pmd-test/src/main/java/net/sourceforge/pmd/ant/AbstractAntTestHelper.java
similarity index 100%
rename from pmd/src/test/java/net/sourceforge/pmd/ant/AbstractAntTestHelper.java
rename to pmd-test/src/main/java/net/sourceforge/pmd/ant/AbstractAntTestHelper.java
diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
new file mode 100644
index 0000000000..6fc40c0602
--- /dev/null
+++ b/pmd-xml/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
@@ -0,0 +1,19 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+package net.sourceforge.pmd.ant;
+
+import org.junit.Test;
+
+public class PMDTaskTest extends AbstractAntTestHelper {
+
+ public PMDTaskTest() {
+ super.antTestScriptFilename = "pmdtasktest.xml";
+ }
+
+ @Test
+ public void testXML() {
+ executeTarget("testXML");
+ assertOutputContaining("Potentialy mistyped CDATA section with extra [ at beginning or ] at the end.");
+ }
+}
diff --git a/pmd/src/test/resources/ant/xml/mistypedcdata.xml b/pmd-xml/src/test/resources/ant/xml/mistypedcdata.xml
similarity index 100%
rename from pmd/src/test/resources/ant/xml/mistypedcdata.xml
rename to pmd-xml/src/test/resources/ant/xml/mistypedcdata.xml
diff --git a/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
new file mode 100644
index 0000000000..52ba35fc8c
--- /dev/null
+++ b/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pmd/src/test/java/net/sourceforge/pmd/ant/AntTests.java b/pmd/src/test/java/net/sourceforge/pmd/ant/AntTests.java
deleted file mode 100644
index 2213b697ba..0000000000
--- a/pmd/src/test/java/net/sourceforge/pmd/ant/AntTests.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
- */
-package net.sourceforge.pmd.ant;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-
-/**
- * Tests for the net.sourceforge.pmd.ant package
- *
- * @author Boris Gruschko ( boris at gruschko.org )
- */
-@RunWith(Suite.class)
-@SuiteClasses({FormatterTest.class, PMDTaskTest.class, CPDTaskTest.class})
-public class AntTests {
-}
-
diff --git a/pmd/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java b/pmd/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java
index 6ece20236f..3516b7006a 100644
--- a/pmd/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java
+++ b/pmd/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java
@@ -5,6 +5,7 @@ package net.sourceforge.pmd.ant;
import java.io.File;
+import org.apache.tools.ant.BuildFileTest;
import org.junit.Test;
/**
@@ -12,18 +13,20 @@ import org.junit.Test;
* @author Romain Pelisse
*
*/
-public class CPDTaskTest extends AbstractAntTestHelper {
+public class CPDTaskTest extends BuildFileTest {
- public CPDTaskTest() {
- super.antTestScriptFilename = "cpdtasktest.xml";
- }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/cpdtasktest.xml");
+ }
@Test
public void testBasic() {
executeTarget("testBasic");
- // FIXME: This clearly needs to be improved - but I don't like to write test,
- // so feel free to contribute :)
+ // FIXME: This clearly needs to be improved - but I don't like to write
+ // test,
+ // so feel free to contribute :)
assertTrue(new File("target/cpd.ant.tests").exists());
}
-
}
diff --git a/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
index f424760a24..d6979a3a34 100644
--- a/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
+++ b/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
@@ -3,18 +3,15 @@
*/
package net.sourceforge.pmd.ant;
+import org.apache.tools.ant.BuildFileTest;
import org.junit.Test;
-public class PMDTaskTest extends AbstractAntTestHelper {
+public class PMDTaskTest extends BuildFileTest {
- public PMDTaskTest() {
- super.antTestScriptFilename = "pmdtasktest.xml";
- }
-
- @Test
- public void testNoFormattersValidation() {
- executeTarget("testNoFormattersValidation");
- assertOutputContaining("Fields should be declared at the top of the class");
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml");
}
@Test
@@ -27,57 +24,6 @@ public class PMDTaskTest extends AbstractAntTestHelper {
expectBuildExceptionContaining("testNoRuleSets", "Valid Error Message", "No rulesets specified");
}
- @Test
- public void testNestedRuleset() {
- executeTarget("testNestedRuleset");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- }
-
- @Test
- public void testFormatterWithProperties() {
- executeTarget("testFormatterWithProperties");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- assertOutputContaining("link_prefix");
- assertOutputContaining("line_prefix");
- }
-
- @Test
- public void testAbstractNames() {
- executeTarget("testAbstractNames");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- }
-
- @Test
- public void testAbstractNamesInNestedRuleset() {
- executeTarget("testAbstractNamesInNestedRuleset");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- }
-
- @Test
- public void testCommaInRulesetfiles() {
- executeTarget("testCommaInRulesetfiles");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- }
-
- @Test
- public void testRelativeRulesets() {
- executeTarget("testRelativeRulesets");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at the");
- }
-
- @Test
- public void testRelativeRulesetsInRulesetfiles() {
- executeTarget("testRelativeRulesetsInRulesetfiles");
- assertOutputContaining("Avoid really long methods");
- assertOutputContaining("Fields should be declared at");
- }
-
@Test
public void testBasic() {
executeTarget("testBasic");
@@ -87,33 +33,4 @@ public class PMDTaskTest extends AbstractAntTestHelper {
public void testInvalidLanguageVersion() {
expectBuildExceptionContaining("testInvalidLanguageVersion", "Fail requested.", "The following language is not supported:.");
}
-
- @Test
- public void testExplicitRuleInRuleSet() {
- executeTarget("testExplicitRuleInRuleSet");
- assertOutputContaining("Avoid really long methods");
- }
-
- @Test
- public void testEcmascript() {
- executeTarget("testEcmascript");
- assertOutputContaining("A 'return', 'break', 'continue', or 'throw' statement should be the last in a block.");
- assertOutputContaining("Avoid using global variables");
- assertOutputContaining("Use ===/!== to compare with true/false or Numbers");
- }
-
- @Test
- public void testXML() {
- executeTarget("testXML");
- assertOutputContaining("Potentialy mistyped CDATA section with extra [ at beginning or ] at the end.");
- }
-
- @Test
- public void testClasspath() {
- executeTarget("testClasspath");
- }
-
- public static junit.framework.Test suite() {
- return new junit.framework.JUnit4TestAdapter(PMDTaskTest.class);
- }
}
diff --git a/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
index 7a5286423c..411297868b 100644
--- a/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
+++ b/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
@@ -1,153 +1,27 @@
-
-
+
+
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${pmd.home}/src/main/resources/rulesets/java/codesize.xml
- ${pmd.home}/src/main/resources/rulesets/java/design.xml
-
-
-
-
-
-
-
-
-
- ${pmd.home}/src/main/resources/rulesets/java/codesize.xml
- ${pmd.home}/src/main/resources/rulesets/java/design.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- java-codesize
- java-design
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- custom_ruleset.xml
- rulesets/java/design.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
- classpathtest/ruleset.xml
-
-
-
-
-
-
-
+
+
+
+
+
+
+