niclas 2004/02/29 06:31:28
Added: logging/test/conf/log4j logging2.xml
logging/test/src/test/org/apache/avalon/logging/log4j/test
AlternateLoggingManagerTestCase.java
Log:
Added testcase. Showing that the 'hack' didn't work.
Revision Changes Path
1.1 avalon/logging/test/conf/log4j/logging2.xml
Index: logging2.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<logging>
<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false"
>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<category name="org.apache.avalon.logging">
<priority value="DEBUG"/>
</category>
<category name="kernel.logger">
<priority value="WARN"/>
</category>
<category name="kernel.logger.test">
<priority value="DEBUG"/>
</category>
<root>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
</logging>
1.1
avalon/logging/test/src/test/org/apache/avalon/logging/log4j/test/AlternateLoggingManagerTestCase.java
Index: AlternateLoggingManagerTestCase.java
===================================================================
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.avalon.logging.log4j.test;
import java.io.File;
import java.net.URL;
import java.util.Map;
import junit.framework.TestCase;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.logging.LoggingManagerHelper;
import org.apache.avalon.logging.provider.LoggingManager;
import org.apache.avalon.logging.provider.LoggingException;
import org.apache.avalon.repository.Artifact;
import org.apache.avalon.repository.provider.Factory;
import org.apache.avalon.repository.provider.InitialContext;
import org.apache.avalon.repository.provider.Builder;
import org.apache.avalon.repository.main.DefaultInitialContext;
import org.apache.avalon.repository.main.DefaultBuilder;
import org.apache.avalon.util.env.Env;
import org.apache.avalon.util.exception.ExceptionHelper;
/**
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision: 1.1 $
*/
public class AlternateLoggingManagerTestCase extends TestCase
{
//-------------------------------------------------------------------
// state
//-------------------------------------------------------------------
LoggingManager m_manager;
//-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
/**
* Constructor for DefaultInitialContextTest.
* @param name the test name
*/
public AlternateLoggingManagerTestCase( String name )
{
super( name );
}
//-------------------------------------------------------------------
// utilities
//-------------------------------------------------------------------
protected void setUp() throws Exception
{
m_manager =
LoggingManagerHelper.setUpLoggingManager(
"avalon-log4j-impl", "log4j/logging2.xml" );
}
public void testKernelLogging() throws Exception
{
Logger logger = m_manager.getLoggerForCategory( "kernel.logger" );
logger.debug( "ERROR: SHOULD NOT SHOW! - this is a debug message from the
kernel" );
logger.info( "ERROR: SHOULD NOT SHOW! - this is a info message from the
kernel" );
logger.warn( "this is a warning message from the kernel" );
logger.error(
"this is an error message from the kernel",
new LoggingException(
"Intentional Exception for TestCase.",
new LoggingException(
"This is not a problem.",
new LoggingException( "It is used to test the Logging framework." ) )
) );
logger.fatalError( "If the TestCase does not fail, everything is OK." );
}
public void testKernelTestLogging() throws Exception
{
Logger logger = m_manager.getLoggerForCategory( "kernel.logger.test" );
logger.debug( "this is a debug message from test" );
logger.info( "this is a info message from test" );
logger.warn( "this is a warning message from test" );
logger.error(
"this is an error message from test",
new LoggingException(
"Intentional Exception for TestCase.",
new LoggingException(
"nested level 1",
new LoggingException( "nested level 2" ) ) ) );
logger.fatalError( "this is a fatal message from test" );
}
public void testRogerRamjetLogging() throws Exception
{
Logger logger = m_manager.getLoggerForCategory( "kernel.roger-ramjet" );
logger.debug( "this is a debug message from roger ramjet" );
logger.info( "this is a info message from roger ramjet" );
logger.warn( "this is a warning message from roger ramjet" );
logger.error(
"this is an error message from roger ramjet",
new LoggingException(
"Intentional Exception for TestCase.",
new LoggingException(
"nested level 1",
new LoggingException( "nested level 2" ) ) ) );
logger.fatalError( "this is a fatal message from roger ramjet" );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]