org.apache.maven.monitor.logging.DefaultLog Java Examples

The following examples show how to use org.apache.maven.monitor.logging.DefaultLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaFXRunMojoTestCase.java    From javafx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private String execute(AbstractMojo mojo) throws MojoFailureException, MojoExecutionException, InterruptedException {
    PrintStream out = System.out;
    StringOutputStream stringOutputStream = new StringOutputStream();
    System.setOut(new PrintStream(stringOutputStream));
    mojo.setLog(new DefaultLog(new ConsoleLogger(Logger.LEVEL_ERROR, "javafx:run")));

    try {
        mojo.execute();
    } finally {
        Thread.sleep(300);
        System.setOut(out);
    }

    return stringOutputStream.toString();
}
 
Example #2
Source File: ExecMojoTest.java    From exec-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param pom the pom file
 * @param goal the goal to execute
 * @return output from System.out during mojo execution
 * @throws Exception if any exception occurs
 */
protected String execute( File pom, String goal )
    throws Exception
{

    ExecMojo mojo;
    mojo = (ExecMojo) lookupMojo( goal, pom );

    setUpProject( pom, mojo );

    MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );

    // why isn't this set up by the harness based on the default-value? TODO get to bottom of this!
    // setVariableValueToObject( mojo, "includeProjectDependencies", Boolean.TRUE );
    // setVariableValueToObject( mojo, "killAfter", new Long( -1 ) );

    assertNotNull( mojo );
    assertNotNull( project );

    // trap System.out
    PrintStream out = System.out;
    StringOutputStream stringOutputStream = new StringOutputStream();
    System.setOut( new PrintStream( stringOutputStream ) );
    // ensure we don't log unnecessary stuff which would interfere with assessing success of tests
    mojo.setLog( new DefaultLog( new ConsoleLogger( Logger.LEVEL_ERROR, "exec:exec" ) ) );

    try
    {
        mojo.execute();
    }
    catch ( Throwable e )
    {
        e.printStackTrace( System.err );
        fail( e.getMessage() );
    }
    finally
    {
        System.setOut( out );
    }

    return stringOutputStream.toString();
}
 
Example #3
Source File: ExecJavaMojoTest.java    From exec-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * @return output from System.out during mojo execution
 */
private String execute( File pom, String goal )
    throws Exception
{

    ExecJavaMojo mojo;
    mojo = (ExecJavaMojo) lookupMojo( goal, pom );

    setUpProject( pom, mojo );

    MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );

    // why isn't this set up by the harness based on the default-value? TODO get to bottom of this!
    setVariableValueToObject( mojo, "includeProjectDependencies", Boolean.TRUE );
    setVariableValueToObject( mojo, "killAfter", (long) -1 );
    setVariableValueToObject( mojo, "cleanupDaemonThreads", Boolean.TRUE );
    setVariableValueToObject( mojo, "classpathScope", "compile" );

    assertNotNull( mojo );
    assertNotNull( project );

    // trap System.out
    PrintStream out = System.out;
    StringOutputStream stringOutputStream = new StringOutputStream();
    System.setOut( new PrintStream( stringOutputStream ) );
    // ensure we don't log unnecessary stuff which would interfere with assessing success of tests
    mojo.setLog( new DefaultLog( new ConsoleLogger( Logger.LEVEL_ERROR, "exec:java" ) ) );

    try
    {
        mojo.execute();
    }
    finally
    {
        // see testUncooperativeThread() for explaination
        Thread.sleep( 300 ); // time seems about right
        System.setOut( out );
    }

    return stringOutputStream.toString();
}
 
Example #4
Source File: BaseMojoTest.java    From docker-maven-plugin with Apache License 2.0 4 votes vote down vote up
protected BaseMojoTest() {
    this.consoleLogger = new ConsoleLogger(1, "console");
    this.ansiLogger = new AnsiLogger(new DefaultLog(this.consoleLogger), false, null);
}
 
Example #5
Source File: LoggingRule.java    From deadcode4j with Apache License 2.0 4 votes vote down vote up
public LoggingRule() {
    this(new DefaultLog(new ConsoleLogger(Logger.LEVEL_DEBUG, "junit")));
}