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:
Tom Copeland
2002-06-28 15:24:03 +00:00
parent 91f3ee8cfe
commit a2da5c231e
2 changed files with 14 additions and 15 deletions

View File

@ -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;

View File

@ -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);
}