View Javadoc

    1   package net.sourceforge.pmd.renderers;
    2
    3   import java.io.File;
    4   import java.io.FileNotFoundException;
    5   import java.io.Reader;
    6   import java.io.StringReader;
    7
    8   import net.sourceforge.pmd.PMD;
    9   import net.sourceforge.pmd.Report.ProcessingError;
    10
    11  public class PapariTextRendererTest extends AbstractRendererTst {
    12
    13      private static String naString = "n/a";
    14      static {
    15          naString = naString.substring(naString.lastIndexOf(File.separator) + 1);
    16      }
    17
    18      public Renderer getRenderer() {
    19          TextColorRenderer result = new TextColorRenderer(){
    20              protected Reader getReader(String sourceFile) throws FileNotFoundException {
    21                  return new StringReader("public class Foo {}");
    22              }
    23          };
    24          result.setProperty(TextColorRenderer.COLOR, "false");
    25          return result;
    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  }