1
2 /***
3 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
4 */
5 package test/net/sourceforge/pmd/rules/design/package-summary.html">> test.net.sourceforge.pmd.rules.design;
6
7 import net.sourceforge.pmd.IRuleViolation;
8 import net.sourceforge.pmd.Report;
9 import net.sourceforge.pmd.ReportListener;
10 import net.sourceforge.pmd.Rule;
11 import net.sourceforge.pmd.stat.Metric;
12 import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
13 import test.net.sourceforge.pmd.testframework.TestDescriptor;
14
15 public class UseSingletonTest extends SimpleAggregatorTst implements ReportListener {
16
17 private int callbacks;
18 private Rule rule;
19 private TestDescriptor[] tests;
20
21 public void setUp() {
22 rule = findRule("design", "UseSingleton");
23 tests = extractTestsFromXml(rule);
24 }
25
26 public void testAll() {
27 runTests(tests);
28 }
29
30 public void testResetState() throws Throwable {
31 callbacks = 0;
32 Report report = new Report();
33 report.addListener(this);
34 runTestFromString(tests[2].getCode(), rule, report);
35 runTestFromString(tests[3].getCode(), rule, report);
36 assertEquals(1, callbacks);
37 }
38
39 public void ruleViolationAdded(IRuleViolation ruleViolation) {
40 callbacks++;
41 }
42
43 public void metricAdded(Metric metric) {
44 }
45 }