Search in sources :

Example 6 with SilentLog

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

the class KotlinCompilationFailureExceptionTest method testLocationWithLocation.

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

Example 7 with SilentLog

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

the class ReleaseUtilsTestCase method testMergeReleases.

public void testMergeReleases() throws Exception {
    Log log = new SilentLog();
    ReleaseUtils releaseUtils = new ReleaseUtils(log);
    List<Release> firstReleases = new ArrayList<Release>();
    List<Release> secondReleases = new ArrayList<Release>();
    List<Release> mergedReleases;
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Both empty", 0, mergedReleases.size());
    Release release = new Release();
    release.setVersion("1.0");
    firstReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("One release in first", 1, mergedReleases.size());
    release = new Release();
    release.setVersion("1.1");
    secondReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("One release each", 2, mergedReleases.size());
    release = new Release();
    release.setVersion("1.1");
    firstReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Two releases in first, one release in second with one version being the same", 2, mergedReleases.size());
    release = new Release();
    release.setVersion("1.2");
    secondReleases.add(release);
    mergedReleases = releaseUtils.mergeReleases(firstReleases, secondReleases);
    assertEquals("Two releases each with one version being the same", 3, mergedReleases.size());
}
Also used : ReleaseUtils(org.apache.maven.plugins.changes.ReleaseUtils) SilentLog(org.apache.maven.plugin.testing.SilentLog) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Example 8 with SilentLog

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

the class TestCollectMojo method testSilent.

public void testSilent() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
    CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom);
    mojo.setSilent(false);
    assertFalse(mojo.getLog() instanceof SilentLog);
}
Also used : CollectDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo) SilentLog(org.apache.maven.plugin.testing.SilentLog) File(java.io.File)

Example 9 with SilentLog

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

the class DependencyTestUtils method removeDirectory.

/**
     * Deletes a directory and its contents.
     *
     * @param dir
     * The base directory of the included and excluded files.
     *
     * @throws IOException
     * @throws MojoExecutionException
     * When a directory failed to get deleted.
     */
public static void removeDirectory(File dir) throws IOException {
    if (dir != null) {
        Log log = new SilentLog();
        FileSetManager fileSetManager = new FileSetManager(log, false);
        FileSet fs = new FileSet();
        fs.setDirectory(dir.getPath());
        fs.addInclude("**/**");
        fileSetManager.delete(fs);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) SilentLog(org.apache.maven.plugin.testing.SilentLog) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 10 with SilentLog

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

the class TestResolveMojo method testSilent.

public void testSilent() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
    ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);
    mojo.setSilent(false);
    assertFalse(mojo.getLog() instanceof SilentLog);
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) ResolveDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo) File(java.io.File)

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