public class MojoRule extends Object implements 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.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.
|
Statement |
apply(Statement base,
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.
|
Mojo |
configureMojo(Mojo mojo,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
Mojo |
configureMojo(Mojo mojo,
String artifactId,
File pom) |
void |
executeMojo(File basedir,
String goal) |
void |
executeMojo(MavenProject project,
String goal,
Xpp3Dom... parameters) |
void |
executeMojo(MavenSession session,
MavenProject project,
MojoExecution execution) |
void |
executeMojo(MavenSession session,
MavenProject project,
String goal,
Xpp3Dom... parameters) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(String artifactId,
File pom) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(String artifactId,
Xpp3Dom pomDom) |
org.codehaus.plexus.PlexusContainer |
getContainer() |
String |
getPluginDescriptorLocation() |
String |
getPluginDescriptorPath() |
InputStream |
getPublicDescriptorStream() |
Map<String,Object> |
getVariablesAndValuesFromObject(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.
|
Map<String,Object> |
getVariablesAndValuesFromObject(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.
|
Object |
getVariableValueFromObject(Object object,
String variable)
Convenience method to obtain the value of a variable on a mojo that might not have a getter.
|
<T> T |
lookup(Class<T> role) |
Mojo |
lookupConfiguredMojo(File basedir,
String goal) |
Mojo |
lookupConfiguredMojo(MavenProject project,
String goal) |
Mojo |
lookupConfiguredMojo(MavenSession session,
MojoExecution execution) |
Mojo |
lookupEmptyMojo(String goal,
File pom)
Lookup the mojo leveraging the actual subprojects pom
|
Mojo |
lookupEmptyMojo(String goal,
String pluginPom)
Lookup an empty mojo
|
Mojo |
lookupMojo(String goal,
File pom)
Lookup the mojo leveraging the actual subprojects pom
|
Mojo |
lookupMojo(String goal,
String pluginPom)
Lookup the mojo leveraging the subproject pom
|
Mojo |
lookupMojo(String groupId,
String artifactId,
String version,
String goal,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
MavenSession |
newMavenSession(MavenProject project) |
MojoExecution |
newMojoExecution(String goal) |
MavenProject |
readMavenProject(File basedir) |
void |
setupContainer() |
org.codehaus.plexus.ContainerConfiguration |
setupContainerConfiguration() |
void |
setVariableValueToObject(Object object,
String variable,
Object value)
Convenience method to set values to variables in objects that don't have setters
|
public MojoRule()
public MojoRule(AbstractMojoTestCase testCase)
protected void before() throws Throwable
Throwable
protected void after()
public InputStream getPublicDescriptorStream() throws Exception
Exception
public String getPluginDescriptorPath()
public String getPluginDescriptorLocation()
public void setupContainer()
public org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration()
public org.codehaus.plexus.PlexusContainer getContainer()
public Mojo lookupMojo(String goal, String pluginPom) throws Exception
goal
- pluginPom
- Exception
public Mojo lookupEmptyMojo(String goal, String pluginPom) throws Exception
goal
- pluginPom
- Exception
public Mojo lookupMojo(String goal, File pom) throws Exception
goal
- pom
- Exception
public Mojo lookupEmptyMojo(String goal, File pom) throws Exception
goal
- pom
- Exception
public Mojo lookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
Exception
public Mojo lookupConfiguredMojo(MavenProject project, String goal) throws Exception
Exception
public Mojo lookupConfiguredMojo(MavenSession session, MojoExecution execution) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
Exception
org.codehaus.plexus.component.configurator.ComponentConfigurationException
public MavenSession newMavenSession(MavenProject project)
public MojoExecution newMojoExecution(String goal)
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, File pom) throws Exception
Exception
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, Xpp3Dom pomDom) throws Exception
Exception
public Mojo configureMojo(Mojo mojo, String artifactId, File pom) throws Exception
Exception
public Mojo configureMojo(Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
Exception
public Object getVariableValueFromObject(Object object, String variable) throws IllegalAccessException
object
- variable
- IllegalArgumentException
IllegalAccessException
public Map<String,Object> getVariablesAndValuesFromObject(Object object) throws IllegalAccessException
object
- IllegalAccessException
public Map<String,Object> getVariablesAndValuesFromObject(Class<?> clazz, Object object) throws IllegalAccessException
clazz
- object
- IllegalAccessException
public void setVariableValueToObject(Object object, String variable, Object value) throws IllegalAccessException
object
- variable
- value
- IllegalAccessException
public Statement apply(Statement base, Description description)
public MavenProject readMavenProject(File basedir) throws Exception
Exception
public void executeMojo(File basedir, String goal) throws Exception
Exception
public Mojo lookupConfiguredMojo(File basedir, String goal) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
Exception
org.codehaus.plexus.component.configurator.ComponentConfigurationException
public final <T> T lookup(Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
org.codehaus.plexus.component.repository.exception.ComponentLookupException
public void executeMojo(MavenProject project, String goal, Xpp3Dom... parameters) throws Exception
Exception
public void executeMojo(MavenSession session, MavenProject project, String goal, Xpp3Dom... parameters) throws Exception
Exception
public void executeMojo(MavenSession session, MavenProject project, MojoExecution execution) throws Exception
Exception
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.