Class MojoRule
java.lang.Object
org.apache.maven.plugin.testing.MojoRule
- All Implemented Interfaces:
org.junit.rules.TestRule
TestRule for usage with Junit-4.10ff. This is just a wrapper for an embedded
AbstractMojoTestCase, so all protected methods of the TestCase are
exhibited as public in the rule. You may annotate single tests methods with
WithoutMojo to prevent the rule from firing.- Since:
- 2.2
- Version:
- $Id$
- Author:
- Mirko Friedenhagen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()May be overridden in the implementation to do stuff after the current test was run.org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) protected voidbefore()May be overridden in the implementation to do stuff after the embedded test case is set up but before the current test is actually run.org.apache.maven.plugin.MojoconfigureMojo(org.apache.maven.plugin.Mojo mojo, String artifactId, File pom) org.apache.maven.plugin.MojoconfigureMojo(org.apache.maven.plugin.Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) voidexecuteMojo(File basedir, String goal) voidexecuteMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) voidexecuteMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, org.apache.maven.plugin.MojoExecution execution) voidexecuteMojo(org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(String artifactId, File pom) org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) org.codehaus.plexus.PlexusContainergetVariablesAndValuesFromObject(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.getVariableValueFromObject(Object object, String variable) Convenience method to obtain the value of a variable on a mojo that might not have a getter.final <T> Torg.apache.maven.plugin.MojolookupConfiguredMojo(File basedir, String goal) org.apache.maven.plugin.MojolookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution) org.apache.maven.plugin.MojolookupConfiguredMojo(org.apache.maven.project.MavenProject project, String goal) org.apache.maven.plugin.MojolookupEmptyMojo(String goal, File pom) Lookup the mojo leveraging the actual subprojects pomorg.apache.maven.plugin.MojolookupEmptyMojo(String goal, String pluginPom) Lookup an empty mojoorg.apache.maven.plugin.MojolookupMojo(String goal, File pom) Lookup the mojo leveraging the actual subprojects pomorg.apache.maven.plugin.MojolookupMojo(String goal, String pluginPom) Lookup the mojo leveraging the subproject pomorg.apache.maven.plugin.MojolookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) org.apache.maven.execution.MavenSessionnewMavenSession(org.apache.maven.project.MavenProject project) org.apache.maven.plugin.MojoExecutionnewMojoExecution(String goal) org.apache.maven.project.MavenProjectreadMavenProject(File basedir) voidorg.codehaus.plexus.ContainerConfigurationvoidsetVariableValueToObject(Object object, String variable, Object value) Convenience method to set values to variables in objects that don't have setters
-
Constructor Details
-
MojoRule
public MojoRule() -
MojoRule
-
-
Method Details
-
before
-
after
protected void after()May be overridden in the implementation to do stuff after the current test was run. -
getPublicDescriptorStream
- Throws:
Exception
-
getPluginDescriptorPath
-
getPluginDescriptorLocation
-
setupContainer
public void setupContainer() -
setupContainerConfiguration
public org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration() -
getContainer
public org.codehaus.plexus.PlexusContainer getContainer() -
lookupMojo
-
lookupEmptyMojo
-
lookupMojo
-
lookupEmptyMojo
-
lookupMojo
-
lookupConfiguredMojo
-
lookupConfiguredMojo
public 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 - Throws:
Exceptionorg.codehaus.plexus.component.configurator.ComponentConfigurationException
-
newMavenSession
public org.apache.maven.execution.MavenSession newMavenSession(org.apache.maven.project.MavenProject project) -
newMojoExecution
-
extractPluginConfiguration
-
extractPluginConfiguration
-
configureMojo
-
configureMojo
-
getVariableValueFromObject
public 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
public 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
public 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
public 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
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
applyin interfaceorg.junit.rules.TestRule
-
readMavenProject
-
executeMojo
-
lookupConfiguredMojo
-
lookup
public final <T> T lookup(Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException - Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException- Since:
- 3.1.0
-
executeMojo
-
executeMojo
-
executeMojo
-