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 ce...@apache.org on 2004/12/08 22:03:13 UTC

cvs commit: logging-log4j/tests/witness/rolling sbr-test3.0.gz sbr-test3.1.gz sbr-test3.log

ceki        2004/12/08 13:03:13

  Modified:    tests/src/java/org/apache/log4j/rolling
                        SizeBasedRollingTest.java
  Added:       tests/witness/rolling sbr-test3.0.gz sbr-test3.1.gz
                        sbr-test3.log
  Log:
  Work in progress.
  
  Revision  Changes    Path
  1.7       +27 -16    logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java
  
  Index: SizeBasedRollingTest.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SizeBasedRollingTest.java	8 Dec 2004 20:23:35 -0000	1.6
  +++ SizeBasedRollingTest.java	8 Dec 2004 21:03:12 -0000	1.7
  @@ -44,7 +44,7 @@
     }
   
     public void setUp() {
  -    Appender ca = new ConsoleAppender(new PatternLayout());
  +    Appender ca = new ConsoleAppender(new PatternLayout("%d %level %c -%m%n"));
       ca.setName("CONSOLE");
       root.addAppender(ca);    
     }
  @@ -77,8 +77,10 @@
       }
     }
   
  +    /** 
  +     * Test basic rolling functionality. 
  +     */ 
     public void test2() throws Exception {
  -
       PatternLayout layout = new PatternLayout("%m\n");
       RollingFileAppender rfa = new RollingFileAppender();
       rfa.setName("ROLLING"); 
  @@ -122,36 +124,45 @@
        }
     }
   
  +    /**
  +     * Same as testBasic but also with GZ compression.
  +     */
     public void test3() throws Exception {
  -     Logger root = Logger.getRootLogger();
  -     root.addAppender(new ConsoleAppender(new PatternLayout()));
  -
        PatternLayout layout = new PatternLayout("%m\n");
        RollingFileAppender rfa = new RollingFileAppender();
        rfa.setLayout(layout);
   
  -     FixedWindowRollingPolicy swrp = new FixedWindowRollingPolicy();
  +     FixedWindowRollingPolicy  fwrp = new FixedWindowRollingPolicy();
        SizeBasedTriggeringPolicy sbtp = new SizeBasedTriggeringPolicy();
   
  -     //swrp.setCompressionMode("GZ");
        sbtp.setMaxFileSize(100);
  -     swrp.setActiveFileName("output/sizeBased-test3");
  -     swrp.setFileNamePattern("output/sizeBased-test3.%i.gz");
  -     swrp.activateOptions();
  -     rfa.setRollingPolicy(swrp);
  +     fwrp.setMinIndex(0);
  +     fwrp.setActiveFileName("output/sbr-test3.log");
  +     fwrp.setFileNamePattern("output/sbr-test3.%i.gz");
  +     fwrp.activateOptions();
  +     rfa.setRollingPolicy(fwrp);
        rfa.setTriggeringPolicy(sbtp);
        rfa.activateOptions();
        root.addAppender(rfa);
   
        // Write exactly 10 bytes with each log
        for (int i = 0; i < 25; i++) {
  -       Thread.sleep(500);
  +       Thread.sleep(100);
          if (i < 10) {
  -         logger.debug("Hello   " + i);
  +         logger.debug("Hello---" + i);
          } else if (i < 100) {
  -         logger.debug("Hello  " + i);
  +         logger.debug("Hello--" + i);
          }
        }
  +
  +     if(!isWindows()) {
  +
  +      assertTrue(Compare.compare("output/sbr-test3.log",  "witness/rolling/sbr-test3.log"));
  +      assertTrue(Compare.compare("output/sbr-test3.0.gz", "witness/rolling/sbr-test3.0.gz"));
  +      assertTrue(Compare.compare("output/sbr-test3.1.gz", "witness/rolling/sbr-test3.1.gz"));
  +     }
  +
  +
     }
   
     boolean isWindows() {
  @@ -162,8 +173,8 @@
       TestSuite suite = new TestSuite();
   
       //suite.addTest(new SizeBasedRollingTest("test1"));
  -    suite.addTest(new SizeBasedRollingTest("test2"));
  -    //suite.addTest(new SizeBasedRollingTestCase("test3"));
  +    //suite.addTest(new SizeBasedRollingTest("test2"));
  +    suite.addTest(new SizeBasedRollingTest("test3"));
   
       return suite;
     }
  
  
  
  1.1                  logging-log4j/tests/witness/rolling/sbr-test3.0.gz
  
  	<<Binary file>>
  
  
  1.1                  logging-log4j/tests/witness/rolling/sbr-test3.1.gz
  
  	<<Binary file>>
  
  
  1.1                  logging-log4j/tests/witness/rolling/sbr-test3.log
  
  Index: sbr-test3.log
  ===================================================================
  Hello--20
  Hello--21
  Hello--22
  Hello--23
  Hello--24
  
  
  

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