You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by mw...@apache.org on 2006/01/18 05:51:13 UTC

svn commit: r370050 - in /logging/log4j/trunk/tests: ./ input/watchdog/ src/java/org/apache/log4j/watchdog/ witness/watchdog/

Author: mwomack
Date: Tue Jan 17 20:51:10 2006
New Revision: 370050

URL: http://svn.apache.org/viewcvs?rev=370050&view=rev
Log:
Updates to file watchdog test case

Added:
    logging/log4j/trunk/tests/witness/watchdog/
    logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt   (with props)
    logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt   (with props)
Modified:
    logging/log4j/trunk/tests/build.xml
    logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_1.xml
    logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_2.xml
    logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_1.properties
    logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_2.properties
    logging/log4j/trunk/tests/src/java/org/apache/log4j/watchdog/FileWatchdogTestCase.java

Modified: logging/log4j/trunk/tests/build.xml
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/build.xml?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/build.xml (original)
+++ logging/log4j/trunk/tests/build.xml Tue Jan 17 20:51:10 2006
@@ -201,6 +201,7 @@
                                      Rolling, 
                                      NDC,
                                      Plugins,
+                                     FileWatchdog,
                                      CachedDateFormat,
   	                                 Schema,
   	                                 Encoding,

Modified: logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_1.xml
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_1.xml?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_1.xml (original)
+++ logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_1.xml Tue Jan 17 20:51:10 2006
@@ -5,13 +5,17 @@
 
   <appender name="A1" class="org.apache.log4j.FileAppender">
   
-    <param name="Append" value="true" />
+    <param name="Append" value="false" />
     <param name="File"   value="output/watchdog.FileWatchdog.test1.txt" />
     
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%p - %m%n"/>
     </layout>
   </appender>
+  
+  <logger name="org.apache.log4j">
+    <level value="warn"/>
+  </logger>
   
   <logger name="org.apache.log4j.watchdog.FileWatchdogTestCase">
     <level value="debug"/>

Modified: logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_2.xml
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_2.xml?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_2.xml (original)
+++ logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test1_2.xml Tue Jan 17 20:51:10 2006
@@ -2,24 +2,9 @@
 <!DOCTYPE log4j:configuration >
 
 <log4j:configuration xmlns:log4j="http://logging.apache.org/">
-
-  <appender name="A1" class="org.apache.log4j.FileAppender">
-  
-    <param name="Append" value="true" />
-    <param name="File"   value="output/watchdog.FileWatchdog.test1.txt" />
-    
-    <layout class="org.apache.log4j.PatternLayout">
-      <param name="ConversionPattern" value="%p - %m%n"/>
-    </layout>
-  </appender>
   
   <logger name="org.apache.log4j.watchdog.FileWatchdogTestCase">
     <level value="info"/>
   </logger>
-  
-  <root>
-    <appender-ref ref="A1" />	       
-    <level value="debug" />
-  </root>
   
 </log4j:configuration>

Modified: logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_1.properties
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_1.properties?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_1.properties (original)
+++ logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_1.properties Tue Jan 17 20:51:10 2006
@@ -1,10 +1,13 @@
 log4j.debug=TRUE
 log4j.threshold=ON
-log4j.rootLogger=WARN,A
+
+log4j.rootLogger=DEBUG,A
+
 log4j.appender.A=org.apache.log4j.FileAppender
 log4j.appender.A.File=output/watchdog.FileWatchdog.test2.txt
-log4j.appender.A.Append=true
+log4j.appender.A.Append=false
 log4j.appender.A.layout=org.apache.log4j.PatternLayout
 log4j.appender.A.layout.ConversionPattern=%p - %m%n
 
+#log4j.logger.org.apache.log4j=WARN
 log4j.logger.org.apache.log4j.watchdog.FileWatchdogTestCase=DEBUG

Modified: logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_2.properties
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_2.properties?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_2.properties (original)
+++ logging/log4j/trunk/tests/input/watchdog/watchdog.FileWatchdog.test2_2.properties Tue Jan 17 20:51:10 2006
@@ -1,10 +1,4 @@
 log4j.debug=TRUE
 log4j.threshold=ON
-log4j.rootLogger=WARN,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/watchdog.FileWatchdog.test2.txt
-log4j.appender.A.Append=true
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p - %m%n
 
 log4j.logger.org.apache.log4j.watchdog.FileWatchdogTestCase=INFO

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/watchdog/FileWatchdogTestCase.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/src/java/org/apache/log4j/watchdog/FileWatchdogTestCase.java?rev=370050&r1=370049&r2=370050&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/watchdog/FileWatchdogTestCase.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/watchdog/FileWatchdogTestCase.java Tue Jan 17 20:51:10 2006
@@ -19,7 +19,6 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.net.URL;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -28,7 +27,7 @@
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.Configurator;
+import org.apache.log4j.util.Compare;
 import org.apache.log4j.spi.LoggerRepositoryEx;
 import org.apache.log4j.joran.JoranConfigurator;
 
@@ -39,7 +38,7 @@
     
     static String SOURCE_CONFIG = "input/watchdog/watchdog.FileWatchdog";
     static String FILE = "output/watchdog.FileWatchdog";
-    static String WITNESS = "witness/watchdog.FileWatchdog";
+    static String WITNESS = "witness/watchdog/watchdog.FileWatchdog";
 
     public FileWatchdogTestCase(String name) {
         super(name);
@@ -52,10 +51,10 @@
     }
 
     private void copyFile(File src, File dst) throws Exception {
-      FileInputStream in = in = new FileInputStream(src);
+      FileInputStream in = new FileInputStream(src);
       FileOutputStream out = new FileOutputStream(dst);
       byte[] buffer = new byte[1024];
-      int size = 0;
+      int size;
       do {
         size = in.read(buffer);
         if (size > 0) out.write(buffer,0,size);
@@ -129,16 +128,15 @@
       copyFile(sourceFile1, configFile);
       assertTrue(configFile.exists());
       
-      URL configURL = new URL("file:"+configFile.getAbsolutePath());
-      
       // configure environment to first config file
-      Configurator configurator = new JoranConfigurator();
-      configurator.doConfigure(configURL, LogManager.getLoggerRepository());
+      JoranConfigurator configurator = new JoranConfigurator();
+      configurator.doConfigure(configFile.getAbsolutePath(),
+          LogManager.getLoggerRepository());
       
       // now watch the file for changes
       FileWatchdog watchdog = new FileWatchdog();
-      watchdog.setURL(configURL);
-      watchdog.setInterval(2000);
+      watchdog.setFile(configFile.getAbsolutePath());
+      watchdog.setInterval(1000);
       watchdog.setConfigurator(JoranConfigurator.class.getName());
       ((LoggerRepositoryEx) LogManager.getLoggerRepository()).getPluginRegistry().addPlugin(watchdog);
       watchdog.activateOptions();
@@ -154,7 +152,7 @@
       copyFile(sourceFile2, configFile);
       
       // wait a few seconds for the watchdog to react
-      Thread.sleep(4000);
+      Thread.sleep(2000);
       
       // output some test messages
       logger.debug("debug message");
@@ -163,10 +161,8 @@
       logger.error("error message");
       logger.fatal("fatal message");
       
-      /*
-      assertTrue(Compare.compare(getOutputFile("test1"), 
+      assertTrue(Compare.compare(getOutputFile("test1"),
         getWitnessFile("test1")));
-      */
     }
     
     // basic test of plugin in standalone mode with PropertyConfigurator
@@ -184,16 +180,15 @@
       copyFile(sourceFile1, configFile);
       assertTrue(configFile.exists());
       
-      URL configURL = new URL("file:"+configFile.getAbsolutePath());
-      
       // configure environment to first config file
-      Configurator configurator = new PropertyConfigurator();
-      configurator.doConfigure(configURL, LogManager.getLoggerRepository());
+      PropertyConfigurator configurator = new PropertyConfigurator();
+      configurator.doConfigure(configFile.getAbsolutePath(),
+          LogManager.getLoggerRepository());
       
       // now watch the file for changes
       FileWatchdog watchdog = new FileWatchdog();
-      watchdog.setURL(configURL);
-      watchdog.setInterval(2000);
+      watchdog.setFile(configFile.getAbsolutePath());
+      watchdog.setInterval(1000);
       watchdog.setConfigurator(PropertyConfigurator.class.getName());
       ((LoggerRepositoryEx) LogManager.getLoggerRepository()).getPluginRegistry().addPlugin(watchdog);
       watchdog.activateOptions();
@@ -209,7 +204,7 @@
       copyFile(sourceFile2, configFile);
       
       // wait a few seconds for the watchdog to react
-      Thread.sleep(4000);
+      Thread.sleep(2000);
       
       // output some test messages
       logger.debug("debug message");
@@ -218,10 +213,8 @@
       logger.error("error message");
       logger.fatal("fatal message");
       
-      /*
-      assertTrue(Compare.compare(getOutputFile("test2"), 
+      assertTrue(Compare.compare(getOutputFile("test2"),
         getWitnessFile("test2")));
-      */
     }
 
     public static Test suite() {

Added: logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt?rev=370050&view=auto
==============================================================================
--- logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt (added)
+++ logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt Tue Jan 17 20:51:10 2006
@@ -0,0 +1,9 @@
+DEBUG - debug message
+INFO - info message
+WARN - warn message
+ERROR - error message
+FATAL - fatal message
+INFO - info message
+WARN - warn message
+ERROR - error message
+FATAL - fatal message

Propchange: logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test1.txt
------------------------------------------------------------------------------
    svn:executable = *

Added: logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt?rev=370050&view=auto
==============================================================================
--- logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt (added)
+++ logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt Tue Jan 17 20:51:10 2006
@@ -0,0 +1,9 @@
+DEBUG - debug message
+INFO - info message
+WARN - warn message
+ERROR - error message
+FATAL - fatal message
+INFO - info message
+WARN - warn message
+ERROR - error message
+FATAL - fatal message

Propchange: logging/log4j/trunk/tests/witness/watchdog/watchdog.FileWatchdog.test2.txt
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org