org.apache.maven.plugin.testing
Class AbstractMojoTestCase

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
All Implemented Interfaces:
Test

public abstract class AbstractMojoTestCase
extends org.codehaus.plexus.PlexusTestCase

TODO: add a way to use the plugin POM for the lookup so that the user doesn't have to provide the a:g:v:goal as the role hint for the mojo lookup. TODO: standarize the execution of the mojo and looking at the results, but could simply have a template method for verifying the state of the mojo post execution TODO: need a way to look at the state of the mojo without adding getters, this could be where we finally specify the expressions which extract values from the mojo. TODO: create a standard directory structure for picking up POMs to make this even easier, we really just need a testing descriptor and make this entirely declarative!

Version:
$Id: AbstractMojoTestCase.java 557799 2007-07-19 22:34:23Z handyande $
Author:
jesse

Field Summary
 
Fields inherited from class org.codehaus.plexus.PlexusTestCase
basedir, container
 
Constructor Summary
AbstractMojoTestCase()
           
 
Method Summary
protected  Mojo configureMojo(Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
          Configure the mojo with the given plexus configuration
protected  Mojo configureMojo(Mojo mojo, String artifactId, File pom)
          Configure the mojo
protected  org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, File pom)
           
protected  org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, Xpp3Dom pomDom)
           
protected  Map getVariablesAndValuesFromObject(Class clazz, Object object)
          convience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
protected  Map getVariablesAndValuesFromObject(Object object)
          convience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
protected  Object getVariableValueFromObject(Object object, String variable)
          convience method to obtain the value of a variable on a mojo that might not have a getter.
protected  Mojo lookupEmptyMojo(String goal, File pom)
          Lookup the mojo leveraging the actual subprojects pom
protected  Mojo lookupEmptyMojo(String goal, String pluginPom)
          Lookup an empty mojo
protected  Mojo lookupMojo(String goal, File pom)
          Lookup the mojo leveraging the actual subprojects pom
protected  Mojo lookupMojo(String goal, String pluginPom)
          Lookup the mojo leveraging the subproject pom
protected  Mojo lookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
          lookup the mojo while we have all of the relavent information
protected  void setUp()
           
protected  void setVariableValueToObject(Object object, String variable, Object value)
          convience method to set values to variables in objects that don't have setters
 
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
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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMojoTestCase

public AbstractMojoTestCase()
Method Detail

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class org.codehaus.plexus.PlexusTestCase
Throws:
Exception

lookupMojo

protected Mojo lookupMojo(String goal,
                          String pluginPom)
                   throws Exception
Lookup the mojo leveraging the subproject pom

Parameters:
goal -
pluginPom -
Returns:
a Mojo instance
Throws:
Exception

lookupEmptyMojo

protected Mojo lookupEmptyMojo(String goal,
                               String pluginPom)
                        throws Exception
Lookup an empty mojo

Parameters:
goal -
pluginPom -
Returns:
a Mojo instance
Throws:
Exception

lookupMojo

protected Mojo lookupMojo(String goal,
                          File pom)
                   throws Exception
Lookup the mojo leveraging the actual subprojects pom

Parameters:
goal -
pom -
Returns:
a Mojo instance
Throws:
Exception

lookupEmptyMojo

protected Mojo lookupEmptyMojo(String goal,
                               File pom)
                        throws Exception
Lookup the mojo leveraging the actual subprojects pom

Parameters:
goal -
pom -
Returns:
a Mojo instance
Throws:
Exception

lookupMojo

protected Mojo lookupMojo(String groupId,
                          String artifactId,
                          String version,
                          String goal,
                          org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
                   throws Exception
lookup the mojo while we have all of the relavent information

Parameters:
groupId -
artifactId -
version -
goal -
pluginConfiguration -
Returns:
a Mojo instance
Throws:
Exception

extractPluginConfiguration

protected org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId,
                                                                                           File pom)
                                                                                    throws Exception
Parameters:
artifactId -
pom -
Returns:
the plexus configuration
Throws:
Exception

extractPluginConfiguration

protected org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId,
                                                                                           Xpp3Dom pomDom)
                                                                                    throws Exception
Parameters:
artifactId -
pomDom -
Returns:
the plexus configuration
Throws:
Exception

configureMojo

protected Mojo configureMojo(Mojo mojo,
                             String artifactId,
                             File pom)
                      throws Exception
Configure the mojo

Parameters:
mojo -
artifactId -
pom -
Returns:
a Mojo instance
Throws:
Exception

configureMojo

protected Mojo configureMojo(Mojo mojo,
                             org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
                      throws Exception
Configure the mojo with the given plexus configuration

Parameters:
mojo -
pluginConfiguration -
Returns:
a Mojo instance
Throws:
Exception

getVariableValueFromObject

protected Object getVariableValueFromObject(Object object,
                                            String variable)
                                     throws IllegalAccessException
convience method to obtain the value of a variable on a mojo that might not have a getter. NOTE: the caller is responsible for casting to to what the desired type is.

Parameters:
object -
variable -
Returns:
object value of variable
Throws:
IllegalArgumentException
IllegalAccessException

getVariablesAndValuesFromObject

protected Map getVariablesAndValuesFromObject(Object object)
                                       throws IllegalAccessException
convience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.

Parameters:
object -
Returns:
map of variable names and values
Throws:
IllegalAccessException

getVariablesAndValuesFromObject

protected Map getVariablesAndValuesFromObject(Class clazz,
                                              Object object)
                                       throws IllegalAccessException
convience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.

Parameters:
clazz -
object -
Returns:
map of variable names and values
Throws:
IllegalAccessException

setVariableValueToObject

protected void setVariableValueToObject(Object object,
                                        String variable,
                                        Object value)
                                 throws IllegalAccessException
convience method to set values to variables in objects that don't have setters

Parameters:
object -
variable -
value -
Throws:
IllegalAccessException


Copyright © 2002-2011 Apache Software Foundation. All Rights Reserved.