Package org.apache.maven.plugin.testing
Class AbstractMojoTestCase
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.codehaus.plexus.PlexusTestCase
org.apache.maven.plugin.testing.AbstractMojoTestCase
- All Implemented Interfaces:
junit.framework.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: standardize 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$
- Author:
- jesse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGuiceModules(List<com.google.inject.Module> modules) protected org.apache.maven.plugin.MojoconfigureMojo(org.apache.maven.plugin.Mojo mojo, String artifactId, File pom) Configure the mojoprotected org.apache.maven.plugin.MojoconfigureMojo(org.apache.maven.plugin.Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) Configure the mojo with the given plexus configurationprotected org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(String artifactId, File pom) protected org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) protected org.codehaus.plexus.PlexusContainerprotected Stringprotected Stringprotected InputStreamgetVariablesAndValuesFromObject(Class<?> clazz, Object object) Convenience 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.Convenience 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 ObjectgetVariableValueFromObject(Object object, String variable) Convenience method to obtain the value of a variable on a mojo that might not have a getter.protected org.apache.maven.plugin.MojolookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution) protected org.apache.maven.plugin.MojolookupConfiguredMojo(org.apache.maven.project.MavenProject project, String goal) protected org.apache.maven.plugin.MojolookupEmptyMojo(String goal, File pom) Lookup the mojo leveraging the actual subprojects pomprotected org.apache.maven.plugin.MojolookupEmptyMojo(String goal, String pluginPom) Lookup an empty mojoprotected org.apache.maven.plugin.MojolookupMojo(String goal, File pom) Lookup the mojo leveraging the actual subprojects pomprotected org.apache.maven.plugin.MojolookupMojo(String goal, String pluginPom) Lookup the mojo leveraging the subproject pomprotected org.apache.maven.plugin.MojolookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) lookup the mojo while we have all of the relavent informationprotected org.apache.maven.execution.MavenSessionnewMavenSession(org.apache.maven.project.MavenProject project) protected org.apache.maven.plugin.MojoExecutionnewMojoExecution(String goal) protected voidsetUp()protected voidprotected org.codehaus.plexus.ContainerConfigurationprotected voidsetVariableValueToObject(Object object, String variable, Object value) Convenience method to set values to variables in objects that don't have settersMethods 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, teardownContainerMethods 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
-
Constructor Details
-
AbstractMojoTestCase
public AbstractMojoTestCase()
-
-
Method Details
-
setUp
- Overrides:
setUpin classorg.codehaus.plexus.PlexusTestCase- Throws:
Exception
-
getPublicDescriptorStream
- Throws:
Exception
-
getPluginDescriptorPath
-
getPluginDescriptorLocation
-
setupContainer
protected void setupContainer()- Overrides:
setupContainerin classorg.codehaus.plexus.PlexusTestCase
-
addGuiceModules
- Since:
- 3.0.0
-
setupContainerConfiguration
protected org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration() -
getContainer
protected org.codehaus.plexus.PlexusContainer getContainer()- Overrides:
getContainerin classorg.codehaus.plexus.PlexusTestCase
-
lookupMojo
Lookup the mojo leveraging the subproject pom- Parameters:
goal-pluginPom-- Returns:
- a Mojo instance
- Throws:
Exception
-
lookupEmptyMojo
protected org.apache.maven.plugin.Mojo lookupEmptyMojo(String goal, String pluginPom) throws Exception Lookup an empty mojo- Parameters:
goal-pluginPom-- Returns:
- a Mojo instance
- Throws:
Exception
-
lookupMojo
Lookup the mojo leveraging the actual subprojects pom- Parameters:
goal-pom-- Returns:
- a Mojo instance
- Throws:
Exception
-
lookupEmptyMojo
Lookup the mojo leveraging the actual subprojects pom- Parameters:
goal-pom-- Returns:
- a Mojo instance
- Throws:
Exception
-
lookupMojo
protected org.apache.maven.plugin.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
-
lookupConfiguredMojo
protected org.apache.maven.plugin.Mojo lookupConfiguredMojo(org.apache.maven.project.MavenProject project, String goal) throws Exception - Parameters:
project-goal-- Returns:
- Throws:
Exception- Since:
- 2.0
-
lookupConfiguredMojo
protected org.apache.maven.plugin.Mojo lookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException - Parameters:
session-execution-- Returns:
- Throws:
Exceptionorg.codehaus.plexus.component.configurator.ComponentConfigurationException- Since:
- 2.0
-
newMavenSession
protected org.apache.maven.execution.MavenSession newMavenSession(org.apache.maven.project.MavenProject project) - Parameters:
project-- Returns:
- Since:
- 2.0
-
newMojoExecution
- Parameters:
goal-- Returns:
- Since:
- 2.0
-
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, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) throws Exception - Parameters:
artifactId-pomDom-- Returns:
- the plexus configuration
- Throws:
Exception
-
configureMojo
protected org.apache.maven.plugin.Mojo configureMojo(org.apache.maven.plugin.Mojo mojo, String artifactId, File pom) throws Exception Configure the mojo- Parameters:
mojo-artifactId-pom-- Returns:
- a Mojo instance
- Throws:
Exception
-
configureMojo
protected org.apache.maven.plugin.Mojo configureMojo(org.apache.maven.plugin.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 Convenience 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:
IllegalArgumentExceptionIllegalAccessException
-
getVariablesAndValuesFromObject
protected Map<String,Object> getVariablesAndValuesFromObject(Object object) throws IllegalAccessException Convenience 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<String,Object> getVariablesAndValuesFromObject(Class<?> clazz, Object object) throws IllegalAccessException Convenience 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 Convenience method to set values to variables in objects that don't have setters- Parameters:
object-variable-value-- Throws:
IllegalAccessException
-