View Javadoc

    1   package net.sourceforge.pmd.renderers;
    2
    3   import net.sourceforge.pmd.PMD;
    4   import net.sourceforge.pmd.Report.ProcessingError;
    5
    6   public class SummaryHTMLRendererTest extends AbstractRendererTst {
    7
    8       @Override
    9       public Renderer getRenderer() {
    10  	Renderer result = new SummaryHTMLRenderer();
    11  	result.setProperty(HTMLRenderer.LINK_PREFIX, "link_prefix");
    12  	result.setProperty(HTMLRenderer.LINE_PREFIX, "line_prefix");
    13  	return result;
    14      }
    15
    16      @Override
    17      public String getExpected() {
    18          return "<html><head><title>PMD</title></head><body>" + PMD.EOL +
    19                  "<h2><center>Summary</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><th>Rule name</th><th>Number of violations</th><tr><td>Foo</td><td align=center>1</td></tr></table><h2><center>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    20                  "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    21                  "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL +
    22                  "<tr bgcolor=\"lightgrey\"> " + PMD.EOL +
    23                  "<td align=\"center\">1</td>" + PMD.EOL +
    24                  "<td width=\"*%\"><a href=\"link_prefixn/a.html#line_prefix1\">n/a</a></td>" + PMD.EOL +
    25                  "<td align=\"center\" width=\"5%\">1</td>" + PMD.EOL +
    26                  "<td width=\"*\">msg</td>" + PMD.EOL +
    27                  "</tr>" + PMD.EOL +
    28                  "</table></table></body></html>" + PMD.EOL;
    29
    30      }
    31
    32      @Override
    33      public String getExpectedEmpty() {
    34          return "<html><head><title>PMD</title></head><body>" + PMD.EOL +
    35          "<h2><center>Summary</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><th>Rule name</th><th>Number of violations</th></table><h2><center>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    36          "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    37          "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL +
    38          "</table></table></body></html>" + PMD.EOL;
    39      }
    40
    41      @Override
    42      public String getExpectedMultiple() {
    43          return "<html><head><title>PMD</title></head><body>" + PMD.EOL +
    44          "<h2><center>Summary</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><th>Rule name</th><th>Number of violations</th><tr><td>Foo</td><td align=center>2</td></tr></table><h2><center>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    45          "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    46          "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL +
    47          "<tr bgcolor=\"lightgrey\"> " + PMD.EOL +
    48          "<td align=\"center\">1</td>" + PMD.EOL +
    49          "<td width=\"*%\"><a href=\"link_prefixn/a.html#line_prefix1\">n/a</a></td>" + PMD.EOL +
    50          "<td align=\"center\" width=\"5%\">1</td>" + PMD.EOL +
    51          "<td width=\"*\">msg</td>" + PMD.EOL +
    52          "</tr>" + PMD.EOL +
    53          "<tr> " + PMD.EOL +
    54          "<td align=\"center\">2</td>" + PMD.EOL +
    55          "<td width=\"*%\"><a href=\"link_prefixn/a.html#line_prefix1\">n/a</a></td>" + PMD.EOL +
    56          "<td align=\"center\" width=\"5%\">1</td>" + PMD.EOL +
    57          "<td width=\"*\">msg</td>" + PMD.EOL +
    58          "</tr>" + PMD.EOL +
    59          "</table></table></body></html>" + PMD.EOL;
    60      }
    61
    62      @Override
    63      public String getExpectedError(ProcessingError error) {
    64          return "<html><head><title>PMD</title></head><body>" + PMD.EOL +
    65          "<h2><center>Summary</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><th>Rule name</th><th>Number of violations</th></table><h2><center>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    66          "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    67          "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL +
    68          "</table><hr/><center><h3>Processing errors</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL +
    69          "<th>File</th><th>Problem</th></tr>" + PMD.EOL +
    70          "<tr bgcolor=\"lightgrey\"> " + PMD.EOL +
    71          "<td>file</td>" + PMD.EOL +
    72          "<td>Error</td>" + PMD.EOL +
    73          "</tr>" + PMD.EOL +
    74          "</table></table></body></html>" + PMD.EOL;
    75      }
    76
    77      public static junit.framework.Test suite() {
    78          return new junit.framework.JUnit4TestAdapter(SummaryHTMLRendererTest.class);
    79      }
    80  }
    81
    82
    83