Search in sources :

Example 6 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class CheckstyleViolationCheckMojoTest method testNoOutputFile.

public void testNoOutputFile() throws Exception {
    File pluginXmlFile = new File(getBasedir(), "src/test/plugin-configs/check-plugin-config.xml");
    Mojo mojo = lookupMojo("check", pluginXmlFile);
    assertNotNull("Mojo found.", mojo);
    mojoSetup(mojo);
    setVariableValueToObject(mojo, "outputFile", new File("target/NoSuchFile.xml"));
    mojo.execute();
}
Also used : Mojo(org.apache.maven.plugin.Mojo) CheckstyleViolationCheckMojo(org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo) File(java.io.File)

Example 7 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class TestSkip method doConfigTest.

private void doConfigTest(String mojoName, String configFile) throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile);
    Mojo mojo = lookupMojo(mojoName, testPom);
    assertNotNull(mojo);
    CapturingLog log = new CapturingLog();
    mojo.setLog(log);
    mojo.execute();
    assertTrue(log.getContent().contains("Skipping plugin execution"));
}
Also used : Mojo(org.apache.maven.plugin.Mojo) File(java.io.File)

Example 8 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class CheckstyleViolationCheckMojoTest method testInvalidFormatWithSkipExec.

public void testInvalidFormatWithSkipExec() throws Exception {
    File pluginXmlFile = new File(getBasedir(), "src/test/plugin-configs/check-plugin-config.xml");
    Mojo mojo = lookupMojo("check", pluginXmlFile);
    assertNotNull("Mojo found.", mojo);
    mojoSetup(mojo);
    setVariableValueToObject(mojo, "outputFileFormat", "plain");
    try {
        mojo.execute();
        fail("Must throw an exception invalid format: plain");
    } catch (MojoExecutionException e) {
    //expected
    }
}
Also used : Mojo(org.apache.maven.plugin.Mojo) CheckstyleViolationCheckMojo(org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File)

Example 9 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class CheckstyleViolationCheckMojoTest method doTestPlainOutputFile.

private void doTestPlainOutputFile(boolean failsOnError) throws Exception {
    File pluginXmlFile = new File(getBasedir(), "src/test/plugin-configs/check-plugin-plain-output.xml");
    Mojo mojo = lookupMojo("check", pluginXmlFile);
    assertNotNull("Mojo found.", mojo);
    PluginDescriptor descriptorStub = new PluginDescriptor();
    descriptorStub.setGroupId("org.apache.maven.plugins");
    descriptorStub.setArtifactId("maven-checkstyle-plugin");
    setVariableValueToObject(mojo, "plugin", descriptorStub);
    setVariableValueToObject(mojo, "failsOnError", failsOnError);
    mojo.execute();
}
Also used : PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) Mojo(org.apache.maven.plugin.Mojo) CheckstyleViolationCheckMojo(org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo) File(java.io.File)

Example 10 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class CheckstyleViolationCheckMojoTest method testNoFail.

public void testNoFail() throws Exception {
    File pluginXmlFile = new File(getBasedir(), "src/test/plugin-configs/check-plugin-config.xml");
    Mojo mojo = lookupMojo("check", pluginXmlFile);
    assertNotNull("Mojo found.", mojo);
    mojoSetup(mojo);
    setVariableValueToObject(mojo, "failOnViolation", Boolean.FALSE);
    mojo.execute();
}
Also used : Mojo(org.apache.maven.plugin.Mojo) CheckstyleViolationCheckMojo(org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo) File(java.io.File)

Aggregations

Mojo (org.apache.maven.plugin.Mojo)10 File (java.io.File)8 CheckstyleViolationCheckMojo (org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1