[logback-dev] svn commit: r1797 - in logback/trunk/logback-core/src/test: java/ch/qos/logback/core/layout java/ch/qos/logback/core/rolling witness/rolling

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Sep 8 19:53:34 CEST 2008


Author: ceki
Date: Mon Sep  8 19:53:33 2008
New Revision: 1797

Modified:
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.0
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.1
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.l
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.0.gz
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.1.gz
   logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.l

Log:
SizeBasedRolling test now passes

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java	Mon Sep  8 19:53:33 2008
@@ -14,9 +14,18 @@
 public class DummyLayout<E> extends LayoutBase<E> {
 
   public static final String DUMMY = "dummy"+LINE_SEP;
+  String val = DUMMY;
+  
+  public DummyLayout() {
+  }
+  
+  public DummyLayout(String val) {
+    this.val = val;
+  }
   
   public String doLayout(E event) {
-    return DUMMY;
+    return val;
   }
 
+  
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java	Mon Sep  8 19:53:33 2008
@@ -1,5 +1,6 @@
 package ch.qos.logback.core.rolling;
 
+import junit.framework.JUnit4TestAdapter;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -9,7 +10,7 @@
   public static Test suite() {
     TestSuite suite = new TestSuite();
     suite.addTestSuite(RenamingTest.class);
-    suite.addTestSuite(SizeBasedRollingTest.class);
+    suite.addTest(new JUnit4TestAdapter(SizeBasedRollingTest.class));
     suite.addTestSuite(TimeBasedRollingTest.class);
     suite.addTest(ch.qos.logback.core.rolling.helper.PackageTest.suite());
     return suite;

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java	Mon Sep  8 19:53:33 2008
@@ -16,11 +16,15 @@
 
 package ch.qos.logback.core.rolling;
 
+import static org.junit.Assert.*;
+
 import java.io.File;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.Layout;
@@ -36,12 +40,10 @@
  * @author S&eacute;bastien Pennec
  * 
  */
-public class SizeBasedRollingTest extends TestCase {
+public class SizeBasedRollingTest  {
 
-  public SizeBasedRollingTest(String name) {
-    super(name);
-  }
 
+  @Before
   public void setUp() {
     {
       File target = new File(Constants.OUTPUT_DIR_PREFIX
@@ -56,6 +58,7 @@
     }
   }
 
+  @After
   public void tearDown() {
   }
 
@@ -63,6 +66,7 @@
    * Test whether FixedWindowRollingPolicy throws an exception when the
    * ActiveFileName is not set.
    */
+  @Test
   public void test1() throws Exception {
     // We purposefully use the \n as the line separator.
     // This makes the regression test system independent.
@@ -95,10 +99,11 @@
   /**
    * Test basic rolling functionality.
    */
+  @Test
   public void test2() throws Exception {
     Context context = new ContextBase();
 
-    DummyLayout<Object> layout = new DummyLayout<Object>();
+    DummyLayout<Object> layout = new DummyLayout<Object>("0123456789");
     RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
     rfa.setName("ROLLING");
     rfa.setLayout(layout);
@@ -170,9 +175,10 @@
   /**
    * Same as testBasic but also with GZ compression.
    */
+  @Test
   public void test3() throws Exception {
     Context context = new ContextBase();
-    DummyLayout<Object> layout = new DummyLayout<Object>();
+    DummyLayout<Object> layout = new DummyLayout<Object>("0123456789");
     RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
     rfa.setLayout(layout);
     rfa.setContext(context);
@@ -206,7 +212,7 @@
     // }
     // }
 
-    for (int i = 0; i < 45; i++) {
+    for (int i = 0; i < 25; i++) {
       Thread.sleep(10);
       rfa.doAppend("hello");
     }
@@ -221,13 +227,13 @@
     if (!isWindows()) {
 
       assertTrue(Compare.compare(
-          "Constants.TEST_DIR_PREFIXoutput/sbr-test3.log",
+          Constants.OUTPUT_DIR_PREFIX+"sbr-test3.log",
           Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.l"));
       assertTrue(Compare.gzCompare(
-          "Constants.TEST_DIR_PREFIXoutput/sbr-test3.0.gz",
+          Constants.OUTPUT_DIR_PREFIX+"sbr-test3.0.gz",
           Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.0.gz"));
       assertTrue(Compare.gzCompare(
-          "Constants.TEST_DIR_PREFIXoutput/sbr-test3.1.gz",
+          Constants.OUTPUT_DIR_PREFIX+"sbr-test3.1.gz",
           Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.1.gz"));
     }
 
@@ -237,10 +243,4 @@
   boolean isWindows() {
     return System.getProperty("os.name").indexOf("Windows") != -1;
   }
-
-  public static Test suite() {
-    TestSuite suite = new TestSuite();
-    suite.addTestSuite(SizeBasedRollingTest.class);
-    return suite;
-  }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	Mon Sep  8 19:53:33 2008
@@ -242,7 +242,7 @@
       tbrp.setCurrentTime(addTime(tbrp.getCurrentTime(), 500));
     }
 
-    tbrp.future.get(1000, TimeUnit.MILLISECONDS);
+    tbrp.future.get(2000, TimeUnit.MILLISECONDS);
 
     for (int i = 0; i < 2; i++) {
       assertTrue(Compare.gzCompare(filenames[i], Constants.TEST_DIR_PREFIX

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.0
==============================================================================
--- logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.0	(original)
+++ logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.0	Mon Sep  8 19:53:33 2008
@@ -1,15 +1 @@
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
\ No newline at end of file

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.1
==============================================================================
--- logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.1	(original)
+++ logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.1	Mon Sep  8 19:53:33 2008
@@ -1,15 +1 @@
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
\ No newline at end of file

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.l
==============================================================================
--- logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.l	(original)
+++ logback/trunk/logback-core/src/test/witness/rolling/sbr-test2.l	Mon Sep  8 19:53:33 2008
@@ -1,15 +1 @@
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
-dummy
+01234567890123456789012345678901234567890123456789
\ No newline at end of file

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.0.gz
==============================================================================
Binary files. No diff available.

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.1.gz
==============================================================================
Binary files. No diff available.

Modified: logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.l
==============================================================================
--- logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.l	(original)
+++ logback/trunk/logback-core/src/test/witness/rolling/sbr-test3.l	Mon Sep  8 19:53:33 2008
@@ -1,5 +1 @@
-dummy
-dummy
-dummy
-dummy
-dummy
+01234567890123456789012345678901234567890123456789
\ No newline at end of file


More information about the logback-dev mailing list