1 package test.net.sourceforge.pmd.renderers; 2 3 import net.sourceforge.pmd.PMD; 4 import net.sourceforge.pmd.Report.ProcessingError; 5 import net.sourceforge.pmd.renderers.AbstractRenderer; 6 import net.sourceforge.pmd.renderers.PapariTextRenderer; 7 8 import java.io.File; 9 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.lastIndexOf(File.separator) + 1); 18 } 19 20 public AbstractRenderer getRenderer() { 21 return new PapariTextRenderer(){ 22 protected Reader getReader(String sourceFile) throws FileNotFoundException { 23 return new StringReader("public class Foo {}"); 24 } 25 }; 26 } 27 28 public String getExpected() { 29 return "* file: n/a" + PMD.EOL + " src: " + naString + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: msg" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + " : 1" + PMD.EOL + "* warnings: 1" + PMD.EOL; 30 } 31 32 public String getExpectedEmpty() { 33 return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + "* warnings: 0" + PMD.EOL; 34 } 35 36 public String getExpectedMultiple() { 37 return "* file: n/a" + PMD.EOL + " src: " + naString + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: msg" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + " src: " + naString + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: msg" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + " : 2" + PMD.EOL + "* warnings: 2" + PMD.EOL; 38 } 39 40 public String getExpectedError(ProcessingError error) { 41 return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + " err: Error" + PMD.EOL + PMD.EOL + "* errors: 0" + PMD.EOL + "* warnings: 0" + PMD.EOL; 42 } 43 44 public static junit.framework.Test suite() { 45 return new junit.framework.JUnit4TestAdapter(PapariTextRendererTest.class); 46 } 47 }