org.apache.maven.plugin.war
Class AbstractWarExplodedMojoTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.codehaus.plexus.PlexusTestCase
              extended by org.apache.maven.plugin.testing.AbstractMojoTestCase
                  extended by org.apache.maven.plugin.war.AbstractWarMojoTest
                      extended by org.apache.maven.plugin.war.AbstractWarExplodedMojoTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
WarDependenciesAnalysisTest, WarExplodedMojoFilteringTest, WarExplodedMojoTest, WarOverlaysTest

public abstract class AbstractWarExplodedMojoTest
extends AbstractWarMojoTest

Author:
Stephane Nicoll

Field Summary
protected  WarExplodedMojo mojo
           
 
Fields inherited from class org.apache.maven.plugin.war.AbstractWarMojoTest
MANIFEST_PATH, OVERLAYS_ROOT_DIR, OVERLAYS_TEMP_DIR
 
Fields inherited from class org.codehaus.plexus.PlexusTestCase
basedir, container
 
Constructor Summary
AbstractWarExplodedMojoTest()
           
 
Method Summary
protected  List assertCustomContent(File webAppDirectory, String[] filePaths, String customMessage)
          Asserts custom content of the war based on the specified webapp directory.
protected  List assertDefaultContent(File webAppDirectory)
          Asserts the default content of the war based on the specified webapp directory.
protected  void assertWebAppContent(File webAppDirectory, List expectedFiles, FileFilter filter)
          Asserts that the webapp contains only the specified files.
protected  List assertWebXml(File webAppDirectory)
          Asserts the web.xml file of the war based on the specified webapp directory.
protected  void cleanDirectory(File directory)
          Cleans up a directory.
protected abstract  File getPomFile()
          Returns the pom configuration to use.
protected abstract  File getTestDirectory()
          Returns the test directory to use.
 void setUp()
           
protected  File setUpMojo(String testId, ArtifactStub[] artifactStubs)
          Configures the exploded mojo for the specified test.
protected  File setUpMojo(String testId, ArtifactStub[] artifactStubs, String[] sourceFiles)
          Configures the exploded mojo for the specified test.
 
Methods inherited from class org.apache.maven.plugin.war.AbstractWarMojoTest
buildWarOverlayStub, configureMojo, createArchive, createClassesDir, createDir, createFile, createFile, createWebAppSource, createWebAppSource, createXMLConfigDir, generateFullOverlayWar, getOverlayFile, getWebAppSource
 
Methods inherited from class org.apache.maven.plugin.testing.AbstractMojoTestCase
configureMojo, configureMojo, extractPluginConfiguration, extractPluginConfiguration, getVariablesAndValuesFromObject, getVariablesAndValuesFromObject, getVariableValueFromObject, lookupEmptyMojo, lookupEmptyMojo, lookupMojo, lookupMojo, lookupMojo, setVariableValueToObject
 
Methods inherited from class org.codehaus.plexus.PlexusTestCase
createContainerInstance, customizeContext, customizeContext, getBasedir, getClassLoader, getConfiguration, getConfiguration, getContainer, getCustomConfiguration, getResourceAsStream, getTestFile, getTestFile, getTestPath, getTestPath, lookup, lookup, release, tearDown
 
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mojo

protected WarExplodedMojo mojo
Constructor Detail

AbstractWarExplodedMojoTest

public AbstractWarExplodedMojoTest()
Method Detail

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class AbstractMojoTestCase
Throws:
Exception

getPomFile

protected abstract File getPomFile()
Returns the pom configuration to use.

Returns:
the pom configuration

getTestDirectory

protected abstract File getTestDirectory()
Returns the test directory to use.

Specified by:
getTestDirectory in class AbstractWarMojoTest
Returns:
the test directory

setUpMojo

protected File setUpMojo(String testId,
                         ArtifactStub[] artifactStubs,
                         String[] sourceFiles)
                  throws Exception
Configures the exploded mojo for the specified test.

If the sourceFiles parameter is null, sample JSPs are created by default.

Parameters:
testId - the id of the test
artifactStubs - the dependencies (may be null)
sourceFiles - the source files to create (may be null)
Returns:
the webapp directory
Throws:
Exception - if an error occurs while configuring the mojo

setUpMojo

protected File setUpMojo(String testId,
                         ArtifactStub[] artifactStubs)
                  throws Exception
Configures the exploded mojo for the specified test.

Parameters:
testId - the id of the test
artifactStubs - the dependencies (may be null)
Returns:
the webapp directory
Throws:
Exception - if an error occurs while configuring the mojo

cleanDirectory

protected void cleanDirectory(File directory)
                       throws IOException
Cleans up a directory.

Parameters:
directory - the directory to remove
Throws:
IOException - if an error occurred while removing the directory

assertDefaultContent

protected List assertDefaultContent(File webAppDirectory)
Asserts the default content of the war based on the specified webapp directory.

Parameters:
webAppDirectory - the webapp directory
Returns:
a list of File objects that have been asserted

assertWebXml

protected List assertWebXml(File webAppDirectory)
Asserts the web.xml file of the war based on the specified webapp directory.

Parameters:
webAppDirectory - the webapp directory
Returns:
a list with the web.xml File object

assertCustomContent

protected List assertCustomContent(File webAppDirectory,
                                   String[] filePaths,
                                   String customMessage)
Asserts custom content of the war based on the specified webapp directory.

Parameters:
webAppDirectory - the webapp directory
filePaths - an array of file paths relative to the webapp directory
customMessage - a custom message if an assertion fails
Returns:
a list of File objects that have been inspected

assertWebAppContent

protected void assertWebAppContent(File webAppDirectory,
                                   List expectedFiles,
                                   FileFilter filter)
Asserts that the webapp contains only the specified files.

Parameters:
webAppDirectory - the webapp directory
expectedFiles - the expected files
filter - an optional filter to ignore some resources


Copyright © 2002–2013 The Apache Software Foundation. All rights reserved.