View Javadoc

    1   /*
    2    * Copyright 1999,2005 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16
    17  package org.apache.log4j.nt;
    18  import junit.framework.TestCase;
    19  import org.apache.log4j.Logger;
    20  import org.apache.log4j.LogManager;
    21  import org.apache.log4j.Level;
    22  import org.apache.log4j.BasicConfigurator;
    23
    24
    25  /***
    26   *
    27   * NTEventLogAppender tests.
    28   *
    29   * @author Curt Arnold
    30   */
    31  public class NTEventLogAppenderTest extends TestCase {
    32
    33    /***
    34     *   Clean up configuration after each test.
    35     */
    36    public void tearDown() {
    37      LogManager.shutdown();
    38    }
    39
    40    /***
    41     *   Simple test of NTEventLogAppender.
    42     */
    43    public void testSimple() {
    44      BasicConfigurator.configure(new NTEventLogAppender());
    45      Logger logger = Logger.getLogger("org.apache.log4j.nt.NTEventLogAppenderTest");
    46      int i  = 0;
    47      logger.debug( "Message " + i++);
    48      logger.info( "Message " + i++);
    49      logger.warn( "Message " + i++);
    50      logger.error( "Message " + i++);
    51      logger.log(Level.FATAL, "Message " + i++);
    52      logger.debug("Message " + i++,  new Exception("Just testing."));
    53    }
    54  }