01: package test.net.sourceforge.pmd.renderers;
02:
03: import net.sourceforge.pmd.PMD;
04: import net.sourceforge.pmd.Report.ProcessingError;
05: import net.sourceforge.pmd.renderers.AbstractRenderer;
06: import net.sourceforge.pmd.renderers.PapariTextRenderer;
07:
08: import java.io.File;
09: import java.io.FileNotFoundException;
10: import java.io.Reader;
11: import java.io.StringReader;
12:
13: public class PapariTextRendererTest extends AbstractRendererTst {
14:
15: private static String naString = "n/a";
16: static {
17: naString = naString.substring(naString
18: .lastIndexOf(File.separator) + 1);
19: }
20:
21: public AbstractRenderer getRenderer() {
22: return new PapariTextRenderer() {
23: protected Reader getReader(String sourceFile)
24: throws FileNotFoundException {
25: return new StringReader("public class Foo {}");
26: }
27: };
28: }
29:
30: public String getExpected() {
31: return "* file: n/a" + PMD.EOL + " src: " + naString
32: + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL
33: + " msg: msg" + PMD.EOL
34: + " code: public class Foo {}" + PMD.EOL + PMD.EOL
35: + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL
36: + " : 1" + PMD.EOL + "* warnings: 1" + PMD.EOL;
37: }
38:
39: public String getExpectedEmpty() {
40: return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL
41: + "* warnings: 0" + PMD.EOL;
42: }
43:
44: public String getExpectedMultiple() {
45: return "* file: n/a" + PMD.EOL + " src: " + naString
46: + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL
47: + " msg: msg" + PMD.EOL
48: + " code: public class Foo {}" + PMD.EOL + PMD.EOL
49: + " src: " + naString + ":1:1" + PMD.EOL
50: + " rule: Foo" + PMD.EOL + " msg: msg" + PMD.EOL
51: + " code: public class Foo {}" + PMD.EOL + PMD.EOL
52: + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL
53: + " : 2" + PMD.EOL + "* warnings: 2" + PMD.EOL;
54: }
55:
56: public String getExpectedError(ProcessingError error) {
57: return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL
58: + " err: Error" + PMD.EOL + PMD.EOL
59: + "* errors: 0" + PMD.EOL + "* warnings: 0" + PMD.EOL;
60: }
61:
62: public static junit.framework.Test suite() {
63: return new junit.framework.JUnit4TestAdapter(
64: PapariTextRendererTest.class);
65: }
66: }
|