diff --git a/src/test/input/xml/newAsyncAppender0.xml b/src/test/input/xml/newAsyncAppender0.xml index f5ff856e..f964ed28 100644 --- a/src/test/input/xml/newAsyncAppender0.xml +++ b/src/test/input/xml/newAsyncAppender0.xml @@ -20,7 +20,9 @@ xmlns:log4j='http://jakarta.apache.org/log4j/'> - + + + @@ -28,8 +30,8 @@ - - + + \ No newline at end of file diff --git a/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java b/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java index 33b30fd4..b3a63d5f 100644 --- a/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java +++ b/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java @@ -150,8 +150,8 @@ public void testLocationInfoTrue() { layout.setConversionPattern("%C:%L %m%n"); layout.activateOptions(); String initialStr = layout.format(initialEvent); - assertEquals(AsyncAppenderTestCase.class.getName(), - initialStr.substring(0, AsyncAppenderTestCase.class.getName().length())); + assertEquals(Greeter.class.getName(), + initialStr.substring(0, Greeter.class.getName().length())); String discardStr = layout.format(discardEvent); assertEquals("?:? ", discardStr.substring(0, 4)); } diff --git a/src/test/java/org/apache/log4j/VectorAppender.java b/src/test/java/org/apache/log4j/VectorAppender.java index 726d7a12..e9bbb979 100644 --- a/src/test/java/org/apache/log4j/VectorAppender.java +++ b/src/test/java/org/apache/log4j/VectorAppender.java @@ -28,10 +28,9 @@ */ public class VectorAppender extends AppenderSkeleton { - public Vector vector; + public Vector vector = new Vector(); long delay = 100; public VectorAppender() { - vector = new Vector(); } public long getDelay() { @@ -46,14 +45,14 @@ public void setDelay(long delay) { * Does nothing. */ public void activateOptions() { + //System.out.println("activateOptions called"); } /** * This method is called by the {@link AppenderSkeleton#doAppend} method. */ public void append(LoggingEvent event) { - // System.out.println("---Vector appender called with message - // ["+event.getRenderedMessage()+"]."); + //System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"]."); // System.out.flush(); try { if(delay > 0) { @@ -61,10 +60,10 @@ public void append(LoggingEvent event) { } } catch (Exception e) { } - vector.addElement(event); + vector.add(event); } - public Vector getVector() { + public Vector getVector() { return vector; } diff --git a/src/test/java/org/apache/log4j/xml/DOM_NewAsyncAppenderTestCase.java b/src/test/java/org/apache/log4j/xml/DOM_NewAsyncAppenderTestCase.java index ac5038db..fa7742f6 100644 --- a/src/test/java/org/apache/log4j/xml/DOM_NewAsyncAppenderTestCase.java +++ b/src/test/java/org/apache/log4j/xml/DOM_NewAsyncAppenderTestCase.java @@ -1,6 +1,7 @@ package org.apache.log4j.xml; import org.apache.log4j.*; +import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.util.Compare; import org.junit.After; import org.junit.Before; @@ -8,8 +9,7 @@ import static org.apache.log4j.TestConstants.TEST_INPUT_PREFIX; import static org.apache.log4j.TestConstants.TEST_WITNESS_PREFIX; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class DOM_NewAsyncAppenderTestCase { Logger root; @@ -21,13 +21,17 @@ public void setUp() { @After public void tearDown() { + System.out.println("----tearing down "); root.getLoggerRepository().resetConfiguration(); } @Test - public void test1() throws Exception { + public void smoke() throws Exception { + String msg = "hello"; DOMConfigurator.configure(TEST_INPUT_PREFIX + "xml/newAsyncAppender0.xml"); + root.info(msg); + Appender appender = root.getAppender("ASYNC"); assertTrue(appender instanceof NewAsyncAppender); @@ -35,7 +39,16 @@ public void test1() throws Exception { VectorAppender vectorAppender = (VectorAppender) newAsyncAppender.getAppender("V1"); assertNotNull(vectorAppender); - + + + Thread.currentThread().sleep(100); + + assertEquals(1, vectorAppender.getVector().size()); + + LoggingEvent event = (LoggingEvent) vectorAppender.vector.elementAt(0); + + assertEquals(msg, event.getMessage()); + } }