Refactoring unit test to match new package layout.
nb: If you have altered,in the last couple of week, some of the unit test just refactored, please do not hesitate to double check my modifications (i don't entirely trust svn, neither should you :) ) git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6412 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
1 parent
a27f71b55f
commit
39274e2f69
318 files changed
+1139
-1172
No files matched your search
@@ -19,8 +19,6 @@ TODO - Release blockers - Must implement before this release can be finished
|
||||
some logic.
|
||||
o Do we have a rule to style check for multiple declarations and chained
|
||||
assignments? (e.g. int a, b; int a = b = x;)
|
||||
o Need to refactor the regression test packages to reflect new packaging.
|
||||
(assigned to rpelisse).
|
||||
o Remove the type resolution specific rules. Merge these back into the
|
||||
standard rules. In general, a Rule should use TR when it can, and fall
|
||||
back on non-TR approach otherwise. No need for separate Rules for TR/non-TR.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
package test.net.sourceforge.pmd.lang.java.rule;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
|
||||
public class ScratchpadRulesTest extends SimpleAggregatorTst {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//addRule("scratchpad", "rulename");
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new junit.framework.JUnit4TestAdapter(ScratchpadRulesTest.class);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.lang.java.rule;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||
|
||||
public class ScratchpadRulesTest extends SimpleAggregatorTst {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//addRule("scratchpad", "rulename");
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new junit.framework.JUnit4TestAdapter(ScratchpadRulesTest.class);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
package test.net.sourceforge.pmd.lang.java.rule;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
+5
-7
@@ -1,4 +1,4 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
package test.net.sourceforge.pmd.lang.java.rule;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -33,8 +33,7 @@ import test.net.sourceforge.pmd.testframework.RuleTst;
|
||||
@Test
|
||||
public void testPluginname() throws Throwable {
|
||||
Rule rule = new XPathRule();
|
||||
// rule.addProperty("xpath", "//VariableDeclaratorId[string-length(@Image) < 3]");
|
||||
rule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//VariableDeclaratorId[string-length(@Image) < 3]");
|
||||
rule.addProperty("xpath", "//VariableDeclaratorId[string-length(@Image) < 3]");
|
||||
rule.setMessage("{0}");
|
||||
rule.addProperty("pluginname", "true");
|
||||
PMD p = new PMD();
|
||||
@@ -45,15 +44,14 @@ import test.net.sourceforge.pmd.testframework.RuleTst;
|
||||
RuleSet rules = new RuleSet();
|
||||
rules.addRule(rule);
|
||||
p.processFile(new StringReader(TEST1), new RuleSets(rules), ctx);
|
||||
RuleViolation rv = report.iterator().next();
|
||||
RuleViolation rv = (RuleViolation) report.iterator().next();
|
||||
assertEquals("a", rv.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVariables() throws Throwable {
|
||||
Rule rule = new XPathRule();
|
||||
// rule.addProperty("xpath", "//VariableDeclaratorId[@Image=$var]");
|
||||
rule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//VariableDeclaratorId[@Image=$var]");
|
||||
rule.addProperty("xpath", "//VariableDeclaratorId[@Image=$var]");
|
||||
rule.setMessage("Avoid vars");
|
||||
rule.addProperty("var", "fiddle");
|
||||
PMD p = new PMD();
|
||||
@@ -64,7 +62,7 @@ import test.net.sourceforge.pmd.testframework.RuleTst;
|
||||
RuleSet rules = new RuleSet();
|
||||
rules.addRule(rule);
|
||||
p.processFile(new StringReader(TEST2), new RuleSets(rules), ctx);
|
||||
RuleViolation rv = report.iterator().next();
|
||||
RuleViolation rv = (RuleViolation) report.iterator().next();
|
||||
assertEquals(3, rv.getBeginLine());
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package test.net.sourceforge.pmd.rules.basic;
|
||||
package test.net.sourceforge.pmd.lang.java.rule.basic;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
File renamed without changes.
+72
-72
@@ -1,72 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Simple duplicate typos
|
||||
]]></description>
|
||||
<expected-problems>4</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = + + 1;
|
||||
int j = - - 1;
|
||||
int k = ~~1;
|
||||
boolean b = !!true;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound
|
||||
]]></description>
|
||||
<expected-problems>8</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = + + + 1;
|
||||
int j = - - - 1;
|
||||
int k = ~~~1;
|
||||
boolean b = !!!true;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound with parentheses
|
||||
]]></description>
|
||||
<expected-problems>8</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +(+(+1));
|
||||
int j = -(-(-1));
|
||||
int k = ~(~(~1));
|
||||
boolean b = !(!(!true));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound with parentheses an mixed operators
|
||||
]]></description>
|
||||
<expected-problems>9</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +(~(-(~1)));
|
||||
int j = ~(-(+(-1)));
|
||||
int k = -(+(~(+1)));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Multiple levels of nested parentheses
|
||||
]]></description>
|
||||
<expected-problems>4</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +((+1));
|
||||
int j = -((-1));
|
||||
int k = ~((~1));
|
||||
boolean b = !((!true));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Simple duplicate typos
|
||||
]]></description>
|
||||
<expected-problems>4</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = + + 1;
|
||||
int j = - - 1;
|
||||
int k = ~~1;
|
||||
boolean b = !!true;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound
|
||||
]]></description>
|
||||
<expected-problems>8</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = + + + 1;
|
||||
int j = - - - 1;
|
||||
int k = ~~~1;
|
||||
boolean b = !!!true;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound with parentheses
|
||||
]]></description>
|
||||
<expected-problems>8</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +(+(+1));
|
||||
int j = -(-(-1));
|
||||
int k = ~(~(~1));
|
||||
boolean b = !(!(!true));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Compound with parentheses an mixed operators
|
||||
]]></description>
|
||||
<expected-problems>9</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +(~(-(~1)));
|
||||
int j = ~(-(+(-1)));
|
||||
int k = -(+(~(+1)));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Multiple levels of nested parentheses
|
||||
]]></description>
|
||||
<expected-problems>4</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
int i = +((+1));
|
||||
int j = -((-1));
|
||||
int k = ~((~1));
|
||||
boolean b = !((!true));
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -197,4 +197,4 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
</test-data>
|
||||
File renamed without changes.
+103
-103
@@ -1,103 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
_s.skip(n); // You are not sure that exactly n bytes are skipped
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case but obfuscated
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
(_s.skip(n));
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is assigned to a variable
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
while (n != 0) {
|
||||
long skipped = _s.skip(n);
|
||||
if (skipped == 0)
|
||||
throw new EOFException();
|
||||
n -= skipped;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is used in a function
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
System.out.println(_s.skip(n));
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is returned
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public int skip(int n) throws IOException {
|
||||
return _s.skip(n);
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
_s.skip(n); // You are not sure that exactly n bytes are skipped
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case but obfuscated
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
(_s.skip(n));
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is assigned to a variable
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
while (n != 0) {
|
||||
long skipped = _s.skip(n);
|
||||
if (skipped == 0)
|
||||
throw new EOFException();
|
||||
n -= skipped;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is used in a function
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public void skip(int n) throws IOException {
|
||||
System.out.println(_s.skip(n));
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
return value is returned
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class Foo {
|
||||
|
||||
private FileInputStream _s = new FileInputStream("file");
|
||||
|
||||
public int skip(int n) throws IOException {
|
||||
return _s.skip(n);
|
||||
}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
File renamed without changes.
+1
-1
@@ -50,4 +50,4 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
</test-data>
|
||||
File renamed without changes.
+33
-33
@@ -1,33 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo extends Object {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
extends nothing
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
extends not Object
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo extends Bar {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
failure case
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo extends Object {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
extends nothing
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
extends not Object
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo extends Bar {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
package test.net.sourceforge.pmd.rules.braces;
|
||||
package test.net.sourceforge.pmd.lang.java.rule.braces;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
+1
-1
@@ -71,4 +71,4 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
</test-data>
|
||||
+1
-1
@@ -122,4 +122,4 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
</test-data>
|
||||
+1
-1
@@ -43,4 +43,4 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
</test-data>
|
||||
Loaded 30 of 318 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user