Package org.apache.avalon.framework.logger

Examples of org.apache.avalon.framework.logger.CommonsLogger


    /**
     * Test debug level.
     */
    public void testDebug()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isDebugEnabled").will(returnValue(true));
        mockLog.expects(once()).method("debug").with(eq("JUnit"));
        mockLog.expects(once()).method("debug").with(eq("JUnit"), same(exception));

        if(logger.isDebugEnabled())
        {
            logger.debug("JUnit");
            logger.debug("JUnit", exception);
        }
    }
View Full Code Here


    /**
     * Test info level.
     */
    public void testInfo()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isInfoEnabled").will(returnValue(true));
        mockLog.expects(once()).method("info").with(eq("JUnit"));
        mockLog.expects(once()).method("info").with(eq("JUnit"), same(exception));

        if(logger.isInfoEnabled())
        {
            logger.info("JUnit");
            logger.info("JUnit", exception);
        }
    }
View Full Code Here

    /**
     * Test warn level.
     */
    public void testWarn()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isWarnEnabled").will(returnValue(true));
        mockLog.expects(once()).method("warn").with(eq("JUnit"));
        mockLog.expects(once()).method("warn").with(eq("JUnit"), same(exception));

        if(logger.isWarnEnabled())
        {
            logger.warn("JUnit");
            logger.warn("JUnit", exception);
        }
    }
View Full Code Here

    /**
     * Test error level.
     */
    public void testError()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isErrorEnabled").will(returnValue(true));
        mockLog.expects(once()).method("error").with(eq("JUnit"));
        mockLog.expects(once()).method("error").with(eq("JUnit"), same(exception));

        if(logger.isErrorEnabled())
        {
            logger.error("JUnit");
            logger.error("JUnit", exception);
        }
    }
View Full Code Here

    /**
     * Test fatal error level.
     */
    public void testFatalError()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isFatalEnabled").will(returnValue(true));
        mockLog.expects(once()).method("fatal").with(eq("JUnit"));
        mockLog.expects(once()).method("fatal").with(eq("JUnit"), same(exception));

        if(logger.isFatalErrorEnabled())
        {
            logger.fatalError("JUnit");
            logger.fatalError("JUnit", exception);
        }
    }
View Full Code Here

            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            final PrintStream stream = new PrintStream(buffer, true);
            System.setProperty(Log.class.getName(), SimpleLog.class.getName());
            LogFactory.releaseAll();
            System.setErr(stream);
            final Logger logger = new CommonsLogger(LogFactory.getLog("JUnit"), "JUnit");
            final Logger child = logger.getChildLogger("test");
            child.fatalError("foo");
            assertEquals("[FATAL] JUnit.test - foo", buffer.toString().trim());
        }
        finally
        {
View Full Code Here

     * @return avalon loggger
     */
    protected Logger createLogger()
    {
        Log log = LogFactory.getLog(this.getBeanName());
        return new CommonsLogger(log, this.getBeanName());
    }
View Full Code Here

    /**
     * Test debug level.
     */
    public void testDebug()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isDebugEnabled").will(returnValue(true));
        mockLog.expects(once()).method("debug").with(eq("JUnit"));
        mockLog.expects(once()).method("debug").with(eq("JUnit"), same(exception));

        if(logger.isDebugEnabled())
        {
            logger.debug("JUnit");
            logger.debug("JUnit", exception);
        }
    }
View Full Code Here

    /**
     * Test info level.
     */
    public void testInfo()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isInfoEnabled").will(returnValue(true));
        mockLog.expects(once()).method("info").with(eq("JUnit"));
        mockLog.expects(once()).method("info").with(eq("JUnit"), same(exception));

        if(logger.isInfoEnabled())
        {
            logger.info("JUnit");
            logger.info("JUnit", exception);
        }
    }
View Full Code Here

    /**
     * Test warn level.
     */
    public void testWarn()
    {
        final Logger logger = new CommonsLogger((Log)mockLog.proxy(), "JUnit");

        mockLog.expects(once()).method("isWarnEnabled").will(returnValue(true));
        mockLog.expects(once()).method("warn").with(eq("JUnit"));
        mockLog.expects(once()).method("warn").with(eq("JUnit"), same(exception));

        if(logger.isWarnEnabled())
        {
            logger.warn("JUnit");
            logger.warn("JUnit", exception);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.logger.CommonsLogger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.