Search in sources :

Example 1 with SilentLog

use of org.apache.maven.plugin.testing.SilentLog in project byte-buddy by raphw.

the class ByteBuddyMojoTest method execute.

private void execute(String goal, String target) throws Exception {
    Mojo mojo = mojoRule.lookupMojo(goal, new File("src/test/resources/net/bytebuddy/test/" + target + ".pom.xml"));
    if (goal.equals("transform")) {
        mojoRule.setVariableValueToObject(mojo, "outputDirectory", project.getAbsolutePath());
        mojoRule.setVariableValueToObject(mojo, "compileClasspathElements", Collections.emptyList());
    } else if (goal.equals("transform-test")) {
        mojoRule.setVariableValueToObject(mojo, "testOutputDirectory", project.getAbsolutePath());
        mojoRule.setVariableValueToObject(mojo, "testClasspathElements", Collections.emptyList());
    } else {
        throw new AssertionError("Unknown goal: " + goal);
    }
    mojoRule.setVariableValueToObject(mojo, "repositorySystem", repositorySystem);
    mojoRule.setVariableValueToObject(mojo, "groupId", FOO);
    mojoRule.setVariableValueToObject(mojo, "artifactId", BAR);
    mojoRule.setVariableValueToObject(mojo, "version", QUX);
    mojo.setLog(new SilentLog());
    mojo.execute();
}
Also used : Mojo(org.apache.maven.plugin.Mojo) SilentLog(org.apache.maven.plugin.testing.SilentLog) File(java.io.File)

Example 2 with SilentLog

use of org.apache.maven.plugin.testing.SilentLog in project kotlin by JetBrains.

the class KotlinCompilationFailureExceptionTest method testLocationNoColumn.

@Test
public void testLocationNoColumn() throws Exception {
    MavenPluginLogMessageCollector collector = new MavenPluginLogMessageCollector(new SilentLog());
    collector.report(CompilerMessageSeverity.ERROR, "Error in file", CompilerMessageLocation.create("myfile.txt", 777, -1, "nothing"));
    try {
        collector.throwKotlinCompilerException();
        fail();
    } catch (KotlinCompilationFailureException e) {
        assertEquals("myfile.txt:[777] Error in file", e.getLongMessage().trim());
    }
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) Test(org.junit.Test)

Example 3 with SilentLog

use of org.apache.maven.plugin.testing.SilentLog in project kotlin by JetBrains.

the class KotlinCompilationFailureExceptionTest method testLocationNoLineNoColumn.

@Test
public void testLocationNoLineNoColumn() throws Exception {
    MavenPluginLogMessageCollector collector = new MavenPluginLogMessageCollector(new SilentLog());
    collector.report(CompilerMessageSeverity.ERROR, "Error in file", CompilerMessageLocation.create("myfile.txt", -1, -1, "nothing"));
    try {
        collector.throwKotlinCompilerException();
        fail();
    } catch (KotlinCompilationFailureException e) {
        assertEquals("myfile.txt: Error in file", e.getLongMessage().trim());
    }
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) Test(org.junit.Test)

Example 4 with SilentLog

use of org.apache.maven.plugin.testing.SilentLog in project sling by apache.

the class ValidateMojoTest method getMojo.

private ValidateMojo getMojo(File baseDir, String pomFile) throws Exception {
    SilentLog log = new SilentLog();
    DefaultBuildContext buildContext = new DefaultBuildContext();
    File pom = new File(baseDir, pomFile);
    ValidateMojo validateMojo = new ValidateMojo();
    mojoRule.configureMojo(validateMojo, mojoRule.extractPluginConfiguration("htl-maven-plugin", pom));
    MavenProject mavenProject = new ProjectStub(pom);
    mojoRule.setVariableValueToObject(validateMojo, "project", mavenProject);
    validateMojo.setLog(log);
    buildContext.enableLogging(log);
    validateMojo.setBuildContext(buildContext);
    return validateMojo;
}
Also used : DefaultBuildContext(org.sonatype.plexus.build.incremental.DefaultBuildContext) MavenProject(org.apache.maven.project.MavenProject) SilentLog(org.apache.maven.plugin.testing.SilentLog) File(java.io.File)

Example 5 with SilentLog

use of org.apache.maven.plugin.testing.SilentLog in project kotlin by JetBrains.

the class KotlinCompilationFailureExceptionTest method testNoLocation.

@Test
public void testNoLocation() throws Exception {
    MavenPluginLogMessageCollector collector = new MavenPluginLogMessageCollector(new SilentLog());
    collector.report(CompilerMessageSeverity.ERROR, "Something went wrong", CompilerMessageLocation.NO_LOCATION);
    try {
        collector.throwKotlinCompilerException();
        fail();
    } catch (KotlinCompilationFailureException e) {
        assertEquals("Something went wrong", e.getLongMessage().trim());
    }
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) Test(org.junit.Test)

Aggregations

SilentLog (org.apache.maven.plugin.testing.SilentLog)10 File (java.io.File)4 Test (org.junit.Test)4 Log (org.apache.maven.plugin.logging.Log)2 ArrayList (java.util.ArrayList)1 Mojo (org.apache.maven.plugin.Mojo)1 ReleaseUtils (org.apache.maven.plugins.changes.ReleaseUtils)1 Release (org.apache.maven.plugins.changes.model.Release)1 CollectDependenciesMojo (org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo)1 ResolveDependenciesMojo (org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo)1 MavenProject (org.apache.maven.project.MavenProject)1 FileSet (org.apache.maven.shared.model.fileset.FileSet)1 FileSetManager (org.apache.maven.shared.model.fileset.util.FileSetManager)1 DefaultBuildContext (org.sonatype.plexus.build.incremental.DefaultBuildContext)1