Class AbstractPmdReportTestCase

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.codehaus.plexus.PlexusTestCase
org.apache.maven.plugin.testing.AbstractMojoTestCase
org.apache.maven.plugins.pmd.AbstractPmdReportTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
CpdReportTest, CpdViolationCheckMojoTest, PmdReportTest, PmdViolationCheckMojoTest

public abstract class AbstractPmdReportTestCase extends org.apache.maven.plugin.testing.AbstractMojoTestCase
Since:
2.5
Version:
$Id$
Author:
Vincent Siveton
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createReportMojo(String goal, File pluginXmlFile)
     
    protected File
    generateReport(String goal, String pluginXml)
    Generate the report and return the generated file
    protected File
    generateReport(AbstractPmdReport mojo, File pluginXmlFile)
     
    protected File
    Get the generated report as file in the test maven project.
    protected org.apache.maven.project.MavenProject
    Get the current Maven project
    static boolean
    lowerCaseContains(String text, String contains)
    Checks, whether the string contained is contained in the given text ignoring case.
    protected String
    readFile(File pmdTestDir, String fileName)
    Read the contents of the specified file object into a string
    protected void
     

    Methods inherited from class org.apache.maven.plugin.testing.AbstractMojoTestCase

    addGuiceModules, configureMojo, configureMojo, extractPluginConfiguration, extractPluginConfiguration, getContainer, getPluginDescriptorLocation, getPluginDescriptorPath, getPublicDescriptorStream, getVariablesAndValuesFromObject, getVariablesAndValuesFromObject, getVariableValueFromObject, lookupConfiguredMojo, lookupConfiguredMojo, lookupEmptyMojo, lookupEmptyMojo, lookupMojo, lookupMojo, lookupMojo, newMavenSession, newMojoExecution, setupContainer, setupContainerConfiguration, setVariableValueToObject

    Methods inherited from class org.codehaus.plexus.PlexusTestCase

    customizeContainerConfiguration, customizeContext, getBasedir, getClassLoader, getConfigurationName, getCustomConfigurationName, getResourceAsStream, getTestConfiguration, getTestConfiguration, getTestFile, getTestFile, getTestPath, getTestPath, lookup, lookup, lookup, lookup, release, tearDown, teardownContainer

    Methods inherited from class junit.framework.TestCase

    countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString

    Methods inherited from class junit.framework.Assert

    assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AbstractPmdReportTestCase

      public AbstractPmdReportTestCase()
  • Method Details

    • setUp

      protected void setUp() throws Exception
      Overrides:
      setUp in class org.apache.maven.plugin.testing.AbstractMojoTestCase
      Throws:
      Exception
    • getTestMavenProject

      protected org.apache.maven.project.MavenProject getTestMavenProject()
      Get the current Maven project
      Returns:
      the maven project
    • getGeneratedReport

      protected File getGeneratedReport(String name) throws IOException
      Get the generated report as file in the test maven project.
      Parameters:
      name - the name of the report.
      Returns:
      the generated report as file
      Throws:
      IOException - if the return file doesnt exist
    • generateReport

      protected File generateReport(String goal, String pluginXml) throws Exception
      Generate the report and return the generated file
      Parameters:
      goal - the mojo goal.
      pluginXml - the name of the xml file in "src/test/resources/plugin-configs/".
      Returns:
      the generated HTML file
      Throws:
      Exception - if any
    • createReportMojo

      protected AbstractPmdReport createReportMojo(String goal, File pluginXmlFile) throws Exception
      Throws:
      Exception
    • generateReport

      protected File generateReport(AbstractPmdReport mojo, File pluginXmlFile) throws Exception
      Throws:
      Exception
    • readFile

      protected String readFile(File pmdTestDir, String fileName) throws IOException
      Read the contents of the specified file object into a string
      Throws:
      IOException
    • lowerCaseContains

      public static boolean lowerCaseContains(String text, String contains)
      Checks, whether the string contained is contained in the given text ignoring case.
      Parameters:
      text - the string in which the search is executed
      contains - the string, the should be searched
      Returns:
      true if the string is contained, otherwise false.