From a2da5c231e5b3af8c43ce9915838db22c300e9a7 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Fri, 28 Jun 2002 15:24:03 +0000 Subject: [PATCH] remove clunky dynamic proxy thing git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@111 51baf565-9d33-0410-a72c-fc3788e3496d --- .../test/net/sourceforge/pmd/MockRule.java | 2 ++ .../test/net/sourceforge/pmd/ReportTest.java | 27 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pmd/regress/test/net/sourceforge/pmd/MockRule.java b/pmd/regress/test/net/sourceforge/pmd/MockRule.java index 8799129315..d8e4ff7535 100644 --- a/pmd/regress/test/net/sourceforge/pmd/MockRule.java +++ b/pmd/regress/test/net/sourceforge/pmd/MockRule.java @@ -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; diff --git a/pmd/regress/test/net/sourceforge/pmd/ReportTest.java b/pmd/regress/test/net/sourceforge/pmd/ReportTest.java index e53190fd38..4fa6b0112f 100644 --- a/pmd/regress/test/net/sourceforge/pmd/ReportTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/ReportTest.java @@ -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("") != -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("") != -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); }