public class MojoRule
extends java.lang.Object
implements 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.Modifier and Type | Field and Description |
---|---|
private AbstractMojoTestCase |
testCase |
Constructor and Description |
---|
MojoRule() |
MojoRule(AbstractMojoTestCase testCase) |
Modifier and Type | Method and Description |
---|---|
protected void |
after()
May be overridden in the implementation to do stuff after the current test was run.
|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
protected void |
before()
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.Mojo |
configureMojo(org.apache.maven.plugin.Mojo mojo,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
org.apache.maven.plugin.Mojo |
configureMojo(org.apache.maven.plugin.Mojo mojo,
java.lang.String artifactId,
java.io.File pom) |
void |
executeMojo(java.io.File basedir,
java.lang.String goal) |
void |
executeMojo(org.apache.maven.project.MavenProject project,
java.lang.String goal,
org.codehaus.plexus.util.xml.Xpp3Dom... parameters) |
void |
executeMojo(org.apache.maven.execution.MavenSession session,
org.apache.maven.project.MavenProject project,
org.apache.maven.plugin.MojoExecution execution) |
void |
executeMojo(org.apache.maven.execution.MavenSession session,
org.apache.maven.project.MavenProject project,
java.lang.String goal,
org.codehaus.plexus.util.xml.Xpp3Dom... parameters) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(java.lang.String artifactId,
java.io.File pom) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(java.lang.String artifactId,
org.codehaus.plexus.util.xml.Xpp3Dom pomDom) |
org.codehaus.plexus.PlexusContainer |
getContainer() |
java.lang.String |
getPluginDescriptorLocation() |
java.lang.String |
getPluginDescriptorPath() |
java.io.InputStream |
getPublicDescriptorStream() |
java.util.Map<java.lang.String,java.lang.Object> |
getVariablesAndValuesFromObject(java.lang.Class<?> clazz,
java.lang.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.
|
java.util.Map<java.lang.String,java.lang.Object> |
getVariablesAndValuesFromObject(java.lang.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.
|
java.lang.Object |
getVariableValueFromObject(java.lang.Object object,
java.lang.String variable)
Convenience method to obtain the value of a variable on a mojo that might not have a getter.
|
<T> T |
lookup(java.lang.Class<T> role) |
org.apache.maven.plugin.Mojo |
lookupConfiguredMojo(java.io.File basedir,
java.lang.String goal) |
org.apache.maven.plugin.Mojo |
lookupConfiguredMojo(org.apache.maven.project.MavenProject project,
java.lang.String goal) |
org.apache.maven.plugin.Mojo |
lookupConfiguredMojo(org.apache.maven.execution.MavenSession session,
org.apache.maven.plugin.MojoExecution execution) |
org.apache.maven.plugin.Mojo |
lookupEmptyMojo(java.lang.String goal,
java.io.File pom)
Lookup the mojo leveraging the actual subprojects pom
|
org.apache.maven.plugin.Mojo |
lookupEmptyMojo(java.lang.String goal,
java.lang.String pluginPom)
Lookup an empty mojo
|
org.apache.maven.plugin.Mojo |
lookupMojo(java.lang.String goal,
java.io.File pom)
Lookup the mojo leveraging the actual subprojects pom
|
org.apache.maven.plugin.Mojo |
lookupMojo(java.lang.String goal,
java.lang.String pluginPom)
Lookup the mojo leveraging the subproject pom
|
org.apache.maven.plugin.Mojo |
lookupMojo(java.lang.String groupId,
java.lang.String artifactId,
java.lang.String version,
java.lang.String goal,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
org.apache.maven.execution.MavenSession |
newMavenSession(org.apache.maven.project.MavenProject project) |
org.apache.maven.plugin.MojoExecution |
newMojoExecution(java.lang.String goal) |
org.apache.maven.project.MavenProject |
readMavenProject(java.io.File basedir) |
void |
setupContainer() |
org.codehaus.plexus.ContainerConfiguration |
setupContainerConfiguration() |
void |
setVariableValueToObject(java.lang.Object object,
java.lang.String variable,
java.lang.Object value)
Convenience method to set values to variables in objects that don't have setters
|
private final AbstractMojoTestCase testCase
public MojoRule()
public MojoRule(AbstractMojoTestCase testCase)
protected void before() throws java.lang.Throwable
java.lang.Throwable
protected void after()
public java.io.InputStream getPublicDescriptorStream() throws java.lang.Exception
java.lang.Exception
public java.lang.String getPluginDescriptorPath()
public java.lang.String getPluginDescriptorLocation()
public void setupContainer()
public org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration()
public org.codehaus.plexus.PlexusContainer getContainer()
public org.apache.maven.plugin.Mojo lookupMojo(java.lang.String goal, java.lang.String pluginPom) throws java.lang.Exception
goal
- pluginPom
- java.lang.Exception
public org.apache.maven.plugin.Mojo lookupEmptyMojo(java.lang.String goal, java.lang.String pluginPom) throws java.lang.Exception
goal
- pluginPom
- java.lang.Exception
public org.apache.maven.plugin.Mojo lookupMojo(java.lang.String goal, java.io.File pom) throws java.lang.Exception
goal
- pom
- java.lang.Exception
public org.apache.maven.plugin.Mojo lookupEmptyMojo(java.lang.String goal, java.io.File pom) throws java.lang.Exception
goal
- pom
- java.lang.Exception
public org.apache.maven.plugin.Mojo lookupMojo(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws java.lang.Exception
java.lang.Exception
public org.apache.maven.plugin.Mojo lookupConfiguredMojo(org.apache.maven.project.MavenProject project, java.lang.String goal) throws java.lang.Exception
java.lang.Exception
public org.apache.maven.plugin.Mojo lookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution) throws java.lang.Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
java.lang.Exception
org.codehaus.plexus.component.configurator.ComponentConfigurationException
public org.apache.maven.execution.MavenSession newMavenSession(org.apache.maven.project.MavenProject project)
public org.apache.maven.plugin.MojoExecution newMojoExecution(java.lang.String goal)
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(java.lang.String artifactId, java.io.File pom) throws java.lang.Exception
java.lang.Exception
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(java.lang.String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) throws java.lang.Exception
java.lang.Exception
public org.apache.maven.plugin.Mojo configureMojo(org.apache.maven.plugin.Mojo mojo, java.lang.String artifactId, java.io.File pom) throws java.lang.Exception
java.lang.Exception
public org.apache.maven.plugin.Mojo configureMojo(org.apache.maven.plugin.Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws java.lang.Exception
java.lang.Exception
public java.lang.Object getVariableValueFromObject(java.lang.Object object, java.lang.String variable) throws java.lang.IllegalAccessException
object
- variable
- java.lang.IllegalArgumentException
java.lang.IllegalAccessException
public java.util.Map<java.lang.String,java.lang.Object> getVariablesAndValuesFromObject(java.lang.Object object) throws java.lang.IllegalAccessException
object
- java.lang.IllegalAccessException
public java.util.Map<java.lang.String,java.lang.Object> getVariablesAndValuesFromObject(java.lang.Class<?> clazz, java.lang.Object object) throws java.lang.IllegalAccessException
clazz
- object
- java.lang.IllegalAccessException
public void setVariableValueToObject(java.lang.Object object, java.lang.String variable, java.lang.Object value) throws java.lang.IllegalAccessException
object
- variable
- value
- java.lang.IllegalAccessException
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
public org.apache.maven.project.MavenProject readMavenProject(java.io.File basedir) throws java.lang.Exception
java.lang.Exception
public void executeMojo(java.io.File basedir, java.lang.String goal) throws java.lang.Exception
java.lang.Exception
public org.apache.maven.plugin.Mojo lookupConfiguredMojo(java.io.File basedir, java.lang.String goal) throws java.lang.Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
java.lang.Exception
org.codehaus.plexus.component.configurator.ComponentConfigurationException
public final <T> T lookup(java.lang.Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
org.codehaus.plexus.component.repository.exception.ComponentLookupException
public void executeMojo(org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws java.lang.Exception
java.lang.Exception
public void executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws java.lang.Exception
java.lang.Exception
public void executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, org.apache.maven.plugin.MojoExecution execution) throws java.lang.Exception
java.lang.Exception