当前位置: 首页>>代码示例>>Java>>正文


Java DefaultLog类代码示例

本文整理汇总了Java中org.apache.maven.monitor.logging.DefaultLog的典型用法代码示例。如果您正苦于以下问题:Java DefaultLog类的具体用法?Java DefaultLog怎么用?Java DefaultLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultLog类属于org.apache.maven.monitor.logging包,在下文中一共展示了DefaultLog类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SetupsMojoTestHelper

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
public SetupsMojoTestHelper( AbstractSetupsMojo mojo ) throws IOException {
   this.workingDir = new File( System.getProperty( "java.io.tmpdir" ), "unit_test_working" );

   this.mojo = mojo;

   this.mojo.workingDir = this.workingDir.getCanonicalPath();
   this.mojo.root = FitNesseHelper.DEFAULT_ROOT;
   this.mojo.project = new MavenProject();
   this.mojo.project.setFile( new File( getClass().getResource( "pom.xml" ).getPath() ) );
   this.mojo.pluginDescriptor = new PluginDescriptor();
   this.mojo.pluginManager = mock( BuildPluginManager.class );
   this.mojo.session = mock( MavenSession.class );

   this.logStream = new ByteArrayOutputStream();
   this.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( this.logStream ) ) ) );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:17,代码来源:SetupsMojoTestHelper.java

示例2: tearDown

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
@After
public void tearDown() {
   ByteArrayOutputStream logStream = new ByteArrayOutputStream();
   Log log = new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( logStream ) ) );
   new FitNesseHelper( log ).shutdownFitNesseServer( PORT );
   assertThat( new FitNesseThreadLocator( log ).findFitNesseServerThread(), nullValue() );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:8,代码来源:FitNesseMainTest.java

示例3: setUp

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
@Before public void setUp() {
   logStream = new ByteArrayOutputStream();
   Log log = new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( logStream ) ) );

   fitNesseHelper = new FitNesseHelper( log );

   baseDir = new File( "/tmp", BASE_DIR );
   baseDir.mkdir();

   baseDirWhitespace = new File( "/tmp", BASE_DIR.replace( "BASEDIR", "BASE DIR" ) );
   baseDirWhitespace.mkdir();
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:13,代码来源:CreateSymLinkTest.java

示例4: init

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
/**
 * Initialize logging.
 * @throws Exception If something wrong inside
 */
@BeforeClass
public static void init() throws Exception {
    StaticLoggerBinder.getSingleton().setMavenLog(
        new DefaultLog(
            new ConsoleLogger(
                Logger.LEVEL_DEBUG,
                StaticLoggerBinderTest.class.getName()
            )
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-maven-slf4j,代码行数:16,代码来源:StaticLoggerBinderTest.java

示例5: init

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
/**
 * Initialize loggers.
 * @throws Exception If something wrong inside
 */
@BeforeClass
public static void init() throws Exception {
    StaticLoggerBinder.getSingleton().setMavenLog(
        new DefaultLog(
            new ConsoleLogger(
                Logger.LEVEL_DEBUG,
                JcabiLoggersTest.class.getName()
            )
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-maven-slf4j,代码行数:16,代码来源:JcabiLoggersTest.java

示例6: testArtifactResolutionExceptions

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
@Test
public void testArtifactResolutionExceptions() throws MojoExecutionException {

   helper.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_DEBUG, "test", new PrintStream( helper.logStream ) ) ) );

   Artifact g1a1 = helper.createArtifact( "g1", "a1" );
   Artifact g1a2 = helper.createArtifact( "g1", "a2" );
   Artifact g1a3 = helper.createArtifact( "g1", "a3" );
   Artifact g2a1 = helper.createArtifact( "g2", "a1" );
   Artifact g3a1 = helper.createArtifact( "g3", "a1" );
   Artifact g3a2 = helper.createArtifact( "g3", "a2" );
   Artifact g3a3 = helper.createArtifact( "g3", "a3" );
   Artifact g3a4 = helper.createArtifact( "g3", "a4" );
   Artifact g3a5 = helper.createArtifact( "g3", "a5" );
   List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1, g2a1, g3a3 );

   helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
   helper.plugin.addDependency( createDependecy( "g2", "a1" ) );
   helper.plugin.addDependency( createDependecy( "g3", "a3" ) );
   helper.mojo.pluginDescriptor.setArtifacts( artifacts );

   when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
         .thenReturn( helper.createArtifactResolutionResult( asList( g1a1, g1a3 ), new ArtifactResolutionException( "TEST", g1a2 ) ) )
         .thenReturn( helper.createArtifactResolutionResult( asList( g2a1 ) ) )
         .thenReturn( helper.createArtifactResolutionResult( asList( g3a1, g3a3, g3a4 ), new MultipleArtifactsNotFoundException( g3a3, asList( g3a1, g3a4 ), asList( g3a2, g3a5 ), null ) ) );

   assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
   // System.out.print(logStream.toString());
   assertTrue( helper.logStream.toString().contains( format( "org.apache.maven.artifact.resolver.ArtifactResolutionException: TEST%n  g1:a2:jar:1.0.0" ) ) );
   assertTrue( helper.logStream.toString().contains( format( "org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:\n----------\n1) g3:a2:jar:1.0.0%n%n" ) ) );
   assertTrue( helper.logStream.toString().contains( format( "1) g3:a2:jar:1.0.0%n%n  Try downloading the file manually from the project website." ) ) );
   assertTrue( helper.logStream.toString().contains( format( "2) g3:a5:jar:1.0.0%n%n  Try downloading the file manually from the project website." ) ) );
   assertTrue( helper.logStream.toString().contains( format( "\n----------\n2 required artifacts are missing.\n\nfor artifact: %n  g3:a3:jar:1.0.0" ) ) );

   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
   verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a2 ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a3 ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g2a1 ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a1 ) );
   verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a2 ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a3 ) );
   verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a4 ) );
   verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a5 ) );

   helper.classRealmAssertions( 7 );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:48,代码来源:CalcWikiFormatClasspathTest.java

示例7: FitNesseMojoTestHelper

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
FitNesseMojoTestHelper() {
   this.artifactHandler = mock( ArtifactHandler.class );
   this.artifactResolver = mock( ArtifactResolver.class );
   this.realm = mock( ClassRealm.class );

   this.pluginArtifact = new DefaultArtifact( getClass().getPackage().getName(), getClass().getSimpleName(), "version", "scope", "type", "classifier", this.artifactHandler );

   this.fitnesseArtifact = new DefaultArtifact( "org.fitnesse", "fitnesse", "20151230", "compile", "jar", null, this.artifactHandler );
   this.fitnesseArtifact.setFile( new File( getClass().getResource( "/dummy.jar" ).getPath() ) );

   when( this.artifactResolver.resolve( argThat( new ResolutionRequestForArtifact( this.fitnesseArtifact ) ) ) ).thenReturn( createArtifactResolutionResult( this.fitnesseArtifact ) );

   this.plugin = new Plugin();
   this.plugin.setGroupId( this.pluginArtifact.getGroupId() );
   this.plugin.setArtifactId( this.pluginArtifact.getArtifactId() );

   Build build = new Build();
   build.addPlugin( this.plugin );

   this.mojo = new TestFitNesseMojo();
   this.mojo.project = new MavenProject();
   this.mojo.resolver = this.artifactResolver;
   this.mojo.fitNesseHelper = mock( FitNesseHelper.class );
   this.mojo.useProjectDependencies = new HashSet<String>();

   this.mojo.pluginDescriptor = new PluginDescriptor();
   this.mojo.pluginDescriptor.setGroupId( this.pluginArtifact.getGroupId() );
   this.mojo.pluginDescriptor.setArtifactId( this.pluginArtifact.getArtifactId() );
   this.mojo.pluginDescriptor.setArtifacts( Collections.singletonList( this.fitnesseArtifact ) );
   this.mojo.pluginDescriptor.setClassRealm( this.realm );
   this.mojo.project.setPluginArtifacts( Collections.singleton( this.pluginArtifact ) );
   this.mojo.project.setBuild( build );
   this.mojo.project.setFile( new File( getClass().getResource( "pom.xml" ).getPath() ) );
   this.mojo.project.setArtifactId( "ARTIFACT_ID" );
   this.mojo.project.setVersion( "VERSION" );
   this.mojo.project.getBuild().setTestOutputDirectory( "target/test-classes" );
   this.mojo.project.getBuild().setOutputDirectory( "target/classes" );
   this.mojo.project.setDependencyArtifacts( new HashSet<Artifact>() );

   this.systemProperties = new Properties();
   this.mojo.session = mock( MavenSession.class );
   when( this.mojo.session.getSystemProperties() ).thenReturn( this.systemProperties );

   addDependency( "cg1", "ca1", Artifact.SCOPE_COMPILE );
   addDependency( "cg1", "ca2", Artifact.SCOPE_COMPILE );
   addDependency( "cg2", "ca3", Artifact.SCOPE_COMPILE );

   addDependency( "tg1", "ta1", Artifact.SCOPE_TEST );
   addDependency( "tg1", "ta2", Artifact.SCOPE_TEST );
   addDependency( "tg2", "ta3", Artifact.SCOPE_TEST );

   addDependency( "rg1", "ra1", Artifact.SCOPE_RUNTIME );
   addDependency( "rg1", "ra2", Artifact.SCOPE_RUNTIME );
   addDependency( "rg2", "ra3", Artifact.SCOPE_RUNTIME );

   addDependency( "pg1", "pa1", Artifact.SCOPE_PROVIDED );
   addDependency( "pg1", "pa2", Artifact.SCOPE_PROVIDED );
   addDependency( "pg2", "pa3", Artifact.SCOPE_PROVIDED );

   addDependency( "sg1", "sa1", Artifact.SCOPE_SYSTEM );
   addDependency( "sg1", "sa2", Artifact.SCOPE_SYSTEM );
   addDependency( "sg2", "sa3", Artifact.SCOPE_SYSTEM );

   addDependency( "og1", "oa1", Artifact.SCOPE_COMPILE, true );
   addDependency( "og1", "oa2", Artifact.SCOPE_COMPILE, true );
   addDependency( "og2", "oa3", Artifact.SCOPE_COMPILE, true );

   this.logStream = new ByteArrayOutputStream();
   this.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( this.logStream ) ) ) );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:71,代码来源:FitNesseMojoTestHelper.java

示例8: createDebugLog

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
public static Log createDebugLog() {
   return new DefaultLog( new PrintStreamLogger() );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:4,代码来源:PrintStreamLogger.java

示例9: createDefaultLog

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
public static Log createDefaultLog(ByteArrayOutputStream logStream) {
   return new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( logStream ) ) );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:4,代码来源:PrintStreamLogger.java

示例10: execute

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
/**
 * 
 * @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();
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:49,代码来源:ExecMojoTest.java

示例11: execute

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
/**
 * @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();
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:44,代码来源:ExecJavaMojoTest.java

示例12: ConcretetMSBuildPluginMojo

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
public ConcretetMSBuildPluginMojo()
{
    setLog( new DefaultLog( new ConsoleLogger() ) );
}
 
开发者ID:andi12,项目名称:msbuild-maven-plugin,代码行数:5,代码来源:AbstractMSBuildPluginMojoTest.java

示例13: sendsLogMessagesThrough

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
/**
 * Slf4jAdapter can send log messages through.
 * @throws Exception If something wrong inside
 * @checkstyle NoWhitespaceAfter (100 lines)
 * @checkstyle ExecutableStatementCount (100 lines)
 */
@Test
public void sendsLogMessagesThrough() throws Exception {
    final Slf4jAdapter logger = new Slf4jAdapter(
        new DefaultLog(
            new ConsoleLogger(
                Logger.LEVEL_DEBUG,
                Slf4jAdapterTest.class.getName()
            )
        ),
        "com.jcabi.test"
    );
    logger.isTraceEnabled();
    logger.isDebugEnabled();
    logger.isInfoEnabled();
    logger.isWarnEnabled();
    logger.isErrorEnabled();
    MatcherAssert.assertThat(
        Slf4jAdapter.class.getName(),
        Matchers.equalTo(logger.getName())
    );
    logger.trace("trace-test message");
    logger.trace("trace-test-2", new IllegalArgumentException("trace-ex"));
    logger.trace("trace-test {}", "trace-message");
    logger.trace("trace-test {} {}", "trc1", "trc2");
    logger.trace("trace-test-2 {} {}", "trace-1", "trace-2");
    logger.debug("debug-test message");
    logger.debug("debug-test-2", new IllegalArgumentException("debug-ex"));
    logger.debug("debug-test {}", "debug-message");
    logger.debug("debug-test {} {}", "dbg1", "dbg2");
    logger.debug("debug-test-2 {} {}", "debug-1", "debug-2");
    logger.info("info-test message");
    logger.info("info-test-2", new IllegalArgumentException("info-ex"));
    logger.info("info-test {}", "info-message");
    logger.info("info-test {} {}", "inf1", "inf2");
    logger.info("info-test-2 {} {}", "info-1", "info-2");
    logger.warn("warn-test message");
    logger.warn("warn-test-2", new IllegalArgumentException("warn-ex"));
    logger.warn("warn-test {}", "warn-message");
    logger.warn("warn-test {} {}", "warn--1", "warn--2");
    logger.warn("warn-test-2 {} {}", "warn-1", "warn-2");
    logger.error("error-test message");
    logger.error("error-test-2", new IllegalArgumentException("error-ex"));
    logger.error("error-test {}", "error-message");
    logger.error("error-test {} {}", "error-1", "error-2");
    logger.error("error-test-2 {} {}", "err-1", "err-2");
}
 
开发者ID:jcabi,项目名称:jcabi-maven-slf4j,代码行数:53,代码来源:Slf4jAdapterTest.java

示例14: LoggingRule

import org.apache.maven.monitor.logging.DefaultLog; //导入依赖的package包/类
public LoggingRule() {
    this(new DefaultLog(new ConsoleLogger(Logger.LEVEL_DEBUG, "junit")));
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:4,代码来源:LoggingRule.java


注:本文中的org.apache.maven.monitor.logging.DefaultLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。