remove clunky dynamic proxy thing
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@111 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -15,6 +15,8 @@ public class MockRule implements Rule {
|
||||
private String name;
|
||||
private String desc;
|
||||
|
||||
public MockRule() {}
|
||||
|
||||
public MockRule(String name, String desc) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
|
@ -16,41 +16,38 @@ import java.lang.reflect.Method;
|
||||
|
||||
public class ReportTest extends TestCase {
|
||||
|
||||
private static class MyInv implements InvocationHandler {
|
||||
private String in;
|
||||
public MyInv() {}
|
||||
public MyInv(String in) {
|
||||
this.in = in;
|
||||
}
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
public ReportTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
Report r = new Report("xml", "foo");
|
||||
Rule rule = (Rule) Proxy.newProxyInstance(Rule.class.getClassLoader(), new Class[] {Rule.class }, new MyInv());
|
||||
Rule rule = new MockRule();
|
||||
r.addRuleViolation(new RuleViolation(rule, 5));
|
||||
assertTrue(!r.currentFileHasNoViolations());
|
||||
}
|
||||
|
||||
public void testRenderXML() {
|
||||
Report r = new Report("xml", "foo");
|
||||
InvocationHandler ih = new MyInv("foo");
|
||||
Rule rule = (Rule) Proxy.newProxyInstance(Rule.class.getClassLoader(), new Class[] {Rule.class }, ih);
|
||||
Rule rule = new MockRule();
|
||||
r.addRuleViolation(new RuleViolation(rule, 5));
|
||||
String rpt = r.render();
|
||||
assertTrue(rpt.indexOf("foo") != -1);
|
||||
assertTrue(rpt.indexOf("<pmd>") != -1);
|
||||
}
|
||||
|
||||
public void testRenderHTML() {
|
||||
Report r = new Report("html", "foo");
|
||||
Rule rule = new MockRule();
|
||||
r.addRuleViolation(new RuleViolation(rule, 5));
|
||||
String rpt = r.render();
|
||||
assertTrue(rpt.indexOf("foo") != -1);
|
||||
assertTrue(rpt.indexOf("<table>") != -1);
|
||||
}
|
||||
|
||||
public void testRenderText() {
|
||||
Report r = new Report("text", "foo");
|
||||
InvocationHandler ih = new MyInv("foo");
|
||||
Rule rule = (Rule) Proxy.newProxyInstance(Rule.class.getClassLoader(), new Class[] {Rule.class }, ih);
|
||||
Rule rule = new MockRule();
|
||||
r.addRuleViolation(new RuleViolation(rule, 5));
|
||||
assertTrue(r.render().indexOf("foo") != -1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user