[logback-dev] svn commit: r2048 - in logback/trunk/logback-core: . src/test/java/ch/qos/logback/core src/test/java/ch/qos/logback/core/appender src/test/java/ch/qos/logback/core/helpers src/test/java/ch/qos/logback/core/joran src/test/java/ch/qos/logback/core/joran/action src/test/java/ch/qos/logback/core/joran/event src/test/java/ch/qos/logback/core/joran/implicitAction src/test/java/ch/qos/logback/core/joran/replay src/test/java/ch/qos/logback/core/joran/spi src/test/java/ch/qos/logback/core/pattern src/test/java/ch/qos/logback/core/pattern/parser src/test/java/ch/qos/logback/core/rolling src/test/java/ch/qos/logback/core/rolling/helper src/test/java/ch/qos/logback/core/util
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Wed Dec 3 15:53:30 CET 2008
Author: ceki
Date: Wed Dec 3 15:53:30 2008
New Revision: 2048
Modified:
logback/trunk/logback-core/pom.xml
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.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/RenamingTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java
Log:
- added references to easymock in pom.xml
- converted all tests in logback-core to JUnit 4
Modified: logback/trunk/logback-core/pom.xml
==============================================================================
--- logback/trunk/logback-core/pom.xml (original)
+++ logback/trunk/logback-core/pom.xml Wed Dec 3 15:53:30 2008
@@ -7,12 +7,12 @@
<artifactId>logback-parent</artifactId>
<version>0.9.12-SNAPSHOT</version>
</parent>
-
+
<modelVersion>4.0.0</modelVersion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
- <version>${parent.version}</version>
+ <version>${parent.version}</version>
<packaging>jar</packaging>
<name>Logback Core Module</name>
@@ -51,6 +51,15 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+
</dependencies>
@@ -92,7 +101,7 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java Wed Dec 3 15:53:30 2008
@@ -9,22 +9,19 @@
*/
package ch.qos.logback.core;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class AllCoreTest extends TestCase {
+ at RunWith(Suite.class)
+ at SuiteClasses({ch.qos.logback.core.util.PackageTest.class,
+ ch.qos.logback.core.helpers.PackageTest.class,
+ ch.qos.logback.core.pattern.PackageTest.class,
+ ch.qos.logback.core.PackageTest.class,
+ ch.qos.logback.core.joran.PackageTest.class,
+ ch.qos.logback.core.appender.PackageTest.class,
+ ch.qos.logback.core.spi.PackageTest.class,
+ ch.qos.logback.core.rolling.PackageTest.class})
+public class AllCoreTest {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(ch.qos.logback.core.util.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.helpers.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.pattern.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.appender.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.spi.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.rolling.PackageTest.suite());
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -1,15 +1,10 @@
package ch.qos.logback.core;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(WriterAppenderTest.class));
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({WriterAppenderTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -10,18 +10,14 @@
package ch.qos.logback.core.appender;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class PackageTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(DummyAppenderTest.class));
- suite.addTest(new JUnit4TestAdapter(ConsoleAppenderTest.class));
- suite.addTest(new JUnit4TestAdapter(FileAppenderTest.class));
- return suite;
- }
+
+ at RunWith(Suite.class)
+ at Suite.SuiteClasses( { DummyAppenderTest.class, ConsoleAppenderTest.class,
+ FileAppenderTest.class})
+
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -1,15 +1,11 @@
package ch.qos.logback.core.helpers;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
+ at RunWith(Suite.class)
+ at SuiteClasses({ThrowableToStringArrayTest.class})
+public class PackageTest {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(ch.qos.logback.core.helpers.ThrowableToStringArrayTest.class));
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,22 +9,17 @@
*/
package ch.qos.logback.core.joran;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
+ at RunWith(Suite.class)
+ at SuiteClasses({SkippingInInterpreterTest.class, TrivialcConfiguratorTest.class, ch.qos.logback.core.joran.action.PackageTest.class,
+ ch.qos.logback.core.joran.event.PackageTest.class,
+ ch.qos.logback.core.joran.spi.PackageTest.class,
+ ch.qos.logback.core.joran.replay.PackageTest.class,
+ ch.qos.logback.core.joran.implicitAction.PackageTest.class
+ })
+public class PackageTest {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(SkippingInInterpreterTest.class));
- suite.addTest(new JUnit4TestAdapter(TrivialcConfiguratorTest.class));
- suite.addTest(ch.qos.logback.core.joran.action.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.event.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.spi.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.replay.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.implicitAction.PackageTest.suite());
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,18 +9,11 @@
*/
package ch.qos.logback.core.joran.action;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(PropertyActionTest.class));
- suite.addTest(new JUnit4TestAdapter(IncludeActionTest.class));
-
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({PropertyActionTest.class, IncludeActionTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java Wed Dec 3 15:53:30 2008
@@ -9,24 +9,19 @@
*/
package ch.qos.logback.core.joran.event;
+import static org.junit.Assert.*;
+
import java.io.FileInputStream;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.junit.Test;
import org.xml.sax.Attributes;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.event.BodyEvent;
-import ch.qos.logback.core.joran.event.SaxEvent;
-import ch.qos.logback.core.joran.event.SaxEventRecorder;
-import ch.qos.logback.core.joran.event.StartEvent;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
import ch.qos.logback.core.util.Constants;
@@ -36,30 +31,16 @@
*
* @author Ceki Gulcu
*/
-public class EventRecorderTest extends TestCase {
+public class EventRecorderTest {
Context context = new ContextBase();
- public EventRecorderTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
SAXParser createParser() throws Exception {
SAXParserFactory spf = SAXParserFactory.newInstance();
return spf.newSAXParser();
}
-
+
public List<SaxEvent> doTest(String filename) throws Exception {
SaxEventRecorder recorder = new SaxEventRecorder();
recorder.setContext(context);
@@ -82,6 +63,7 @@
*
* @throws Exception
*/
+ @Test
public void test1() throws Exception {
List<SaxEvent> seList = doTest("event1.xml");
StatusManager sm = context.getStatusManager();
@@ -91,6 +73,7 @@
}
+ @Test
public void test2() throws Exception {
List<SaxEvent> seList = doTest("ampEvent.xml");
StatusManager sm = context.getStatusManager();
@@ -102,6 +85,7 @@
assertEquals("xxx & yyy", be.getText());
}
+ @Test
public void test3() throws Exception {
List<SaxEvent> seList = doTest("inc.xml");
StatusManager sm = context.getStatusManager();
@@ -115,11 +99,4 @@
assertEquals("1", attr.getValue("increment"));
}
- public static Test XXXsuite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new EventRecorderTest("test2"));
- // suite.addTestSuite(SkippingInInterpreterTest.class);
- return suite;
- }
-
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Wed Dec 3 15:53:30 2008
@@ -9,9 +9,13 @@
*/
package ch.qos.logback.core.joran.event;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
-import junit.framework.TestCase;
+import org.junit.Test;
+
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.TrivialConfigurator;
@@ -20,11 +24,12 @@
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.util.Constants;
-public class InPlayFireTest extends TestCase {
+public class InPlayFireTest {
Context context = new ContextBase();
HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
+ @Test
public void testBasic() throws JoranException {
ListenAction listenAction = new ListenAction();
@@ -44,6 +49,7 @@
assertTrue(listenAction.getSeList().get(3) instanceof EndEvent);
}
+ @Test
public void testReplay() throws JoranException {
ListenAction listenAction = new ListenAction();
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,16 +9,11 @@
*/
package ch.qos.logback.core.joran.event;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(EventRecorderTest.class);
- suite.addTestSuite(InPlayFireTest.class);
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({EventRecorderTest.class, InPlayFireTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,16 +9,11 @@
*/
package ch.qos.logback.core.joran.implicitAction;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(ImplicitActionTest.class));
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({ImplicitActionTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,16 +9,12 @@
*/
package ch.qos.logback.core.joran.replay;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
+ at RunWith(Suite.class)
+ at SuiteClasses({FruitConfigurationTest.class})
+public class PackageTest {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(FruitConfigurationTest.class));
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,18 +9,11 @@
*/
package ch.qos.logback.core.joran.spi;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(PatternTest.class));
- suite.addTestSuite(SimpleStoreTest.class);
- suite.addTestSuite(PropertySetterTest.class);
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({PatternTest.class, SimpleStoreTest.class, PropertySetterTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java Wed Dec 3 15:53:30 2008
@@ -1,9 +1,12 @@
package ch.qos.logback.core.joran.spi;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.Test;
+
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.action.IADataForComplexProperty;
@@ -13,8 +16,9 @@
import ch.qos.logback.core.util.FileSize;
import ch.qos.logback.core.util.StatusPrinter;
-public class PropertySetterTest extends TestCase {
+public class PropertySetterTest {
+ @Test
public void testCanAggregateComponent() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
@@ -41,6 +45,7 @@
System.out.println();
}
+ @Test
public void testSetProperty() {
{
House house = new House();
@@ -67,6 +72,7 @@
}
}
+ @Test
public void testSetCamelProperty() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
@@ -78,6 +84,7 @@
assertEquals("gh", house.getCamelCase());
}
+ @Test
public void testSetComplexProperty() {
House house = new House();
Door door = new Door();
@@ -86,6 +93,7 @@
assertEquals(door, house.getDoor());
}
+ @Test
public void testSetComplexProperty2() {
House house = new House();
//Door door = new Door();
@@ -100,6 +108,8 @@
//setter.setComplexProperty("door", door);
//assertEquals(door, house.getDoor());
}
+
+ @Test
public void testPropertyCollection() {
House house = new House();
Context context = new ContextBase();
@@ -113,6 +123,7 @@
assertEquals("big", house.adjectiveList.get(1));
}
+ @Test
public void testComplexCollection() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
@@ -128,6 +139,7 @@
assertEquals(20, house.windowList.get(1).handle);
}
+ @Test
public void testSetComplexWithCamelCaseName() {
House house = new House();
SwimmingPool pool = new SwimmingPool();
@@ -136,6 +148,7 @@
assertEquals(pool, house.getSwimmingPool());
}
+ @Test
public void testDuration() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
@@ -143,6 +156,7 @@
assertEquals(1400, house.getDuration().getMilliseconds());
}
+ @Test
public void testFileSize() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
@@ -150,6 +164,7 @@
assertEquals(2*1024, house.getFs().getSize());
}
+ @Test
public void testFilterReply() {
//test case reproducing bug #52
House house = new House();
@@ -158,6 +173,7 @@
assertEquals(FilterReply.ACCEPT, house.getFilterReply());
}
+ @Test
public void testEnum() {
House house = new House();
PropertySetter setter = new PropertySetter(house);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java Wed Dec 3 15:53:30 2008
@@ -1,19 +1,23 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2008, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-
package ch.qos.logback.core.joran.spi;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.util.List;
+import org.junit.Test;
import org.xml.sax.Attributes;
import ch.qos.logback.core.ContextBase;
@@ -23,23 +27,9 @@
*
* @author Ceki Gulcu
*/
-public class SimpleStoreTest extends TestCase {
-
- public SimpleStoreTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+public class SimpleStoreTest {
+ @Test
public void test1() throws Exception {
// Document doc = getW3Document("file:input/joran/parser1.xml");
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
@@ -71,6 +61,7 @@
}
+ @Test
public void testSlashSuffix() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
Pattern pa = new Pattern("a/");
@@ -86,6 +77,8 @@
}
+
+ @Test
public void testTail1() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("*/b"), new XAction());
@@ -101,6 +94,7 @@
}
+ @Test
public void testTail2() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("*/c"), new XAction());
@@ -115,6 +109,7 @@
}
}
+ @Test
public void testTail3() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("*/b"), new XAction());
@@ -131,6 +126,7 @@
}
}
+ @Test
public void testTail4() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("*/b"), new XAction());
@@ -148,6 +144,7 @@
}
}
+ @Test
public void testSuffix() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("a"), new XAction());
@@ -159,6 +156,7 @@
assertTrue(r.get(0) instanceof YAction);
}
+ @Test
public void testDeepSuffix() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("a"), new XAction(1));
@@ -168,6 +166,7 @@
assertNull(r);
}
+ @Test
public void testPrefixSuffixInteraction1() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("a"), new ZAction());
@@ -184,6 +183,7 @@
assertEquals(3, xaction.id);
}
+ @Test
public void testPrefixSuffixInteraction2() throws Exception {
SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
srs.addRule(new Pattern("testGroup"), new XAction());
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -1,16 +1,10 @@
package ch.qos.logback.core.pattern;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(ch.qos.logback.core.pattern.SpacePadderTest.class));
- suite.addTest(ch.qos.logback.core.pattern.parser.PackageTest.suite());
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({SpacePadderTest.class, ch.qos.logback.core.pattern.parser.PackageTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java Wed Dec 3 15:53:30 2008
@@ -9,10 +9,15 @@
*/
package ch.qos.logback.core.pattern.parser;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
+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.pattern.Converter;
@@ -22,24 +27,16 @@
import ch.qos.logback.core.util.StatusPrinter;
-public class CompilerTest extends TestCase {
+public class CompilerTest {
Map<String, String> converterMap = new HashMap<String, String>();
Context context = new ContextBase();
- public CompilerTest(String arg0) {
- super(arg0);
+ @Before public void setUp() {
converterMap.put("OTT", Converter123.class.getName());
converterMap.put("hello", ConverterHello.class.getName());
}
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
String write(final Converter<Object> head, Object event) {
StringBuffer buf = new StringBuffer();
@@ -51,6 +48,7 @@
return buf.toString();
}
+ @Test
public void testLiteral() throws Exception {
Parser<Object> p = new Parser<Object>("hello");
Node t = p.parse();
@@ -59,6 +57,7 @@
assertEquals("hello", result);
}
+ @Test
public void testBasic() throws Exception {
{
Parser<Object> p = new Parser<Object>("abc %hello");
@@ -78,6 +77,7 @@
}
}
+ @Test
public void testFormat() throws Exception {
{
Parser<Object> p = new Parser<Object>("abc %7hello");
@@ -149,6 +149,7 @@
}
}
+ @Test
public void testComposite() throws Exception {
// {
// Parser<Object> p = new Parser<Object>("%(ABC)");
@@ -178,6 +179,7 @@
}
}
+ @Test
public void testCompositeFormatting() throws Exception {
{
Parser<Object> p = new Parser<Object>("xyz %4.10(ABC)");
@@ -225,6 +227,7 @@
}
}
+ @Test
public void testUnknownWord() throws Exception {
Parser<Object> p = new Parser<Object>("%unknown");
p.setContext(context);
@@ -235,6 +238,7 @@
.containsMatch("\\[unknown] is not a valid conversion word"));
}
+ @Test
public void testWithNopEscape() throws Exception {
{
Parser<Object> p = new Parser<Object>("xyz %hello\\_world");
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java Wed Dec 3 15:53:30 2008
@@ -9,12 +9,17 @@
*/
package ch.qos.logback.core.pattern.parser;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
import ch.qos.logback.core.pattern.FormatInfo;
-import junit.framework.TestCase;
-public class FormatInfoTest extends TestCase {
+public class FormatInfoTest {
+ @Test
public void testEndingInDot() {
try {
FormatInfo.valueOf("45.");
@@ -24,6 +29,7 @@
}
}
+ @Test
public void testBasic() {
{
FormatInfo fi = FormatInfo.valueOf("45");
@@ -41,6 +47,7 @@
}
}
+ @Test
public void testRightPad() {
{
FormatInfo fi = FormatInfo.valueOf("-40");
@@ -70,6 +77,7 @@
}
}
+ @Test
public void testMinOnly() {
{
FormatInfo fi = FormatInfo.valueOf("49");
@@ -88,6 +96,7 @@
}
+ @Test
public void testMaxOnly() {
{
FormatInfo fi = FormatInfo.valueOf(".49");
@@ -103,7 +112,5 @@
witness.setLeftTruncate(false);
assertEquals(witness, fi);
}
-
}
-
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java Wed Dec 3 15:53:30 2008
@@ -10,16 +10,16 @@
package ch.qos.logback.core.pattern.parser;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
-import ch.qos.logback.core.pattern.parser.OptionTokenizer;
-import ch.qos.logback.core.pattern.parser.ScanException;
-
-import junit.framework.TestCase;
+import org.junit.Test;
-public class OptionTokenizerTest extends TestCase {
+public class OptionTokenizerTest {
+ @Test
public void testEmpty() throws ScanException {
{
List ol = new OptionTokenizer("").tokenize();
@@ -34,6 +34,7 @@
}
}
+ @Test
public void testSimple() throws ScanException {
{
List ol = new OptionTokenizer("abc").tokenize();
@@ -43,6 +44,7 @@
}
}
+ @Test
public void testSingleQuote() throws ScanException {
{
List ol = new OptionTokenizer("' '").tokenize();
@@ -73,6 +75,7 @@
}
}
+ @Test
public void testDoubleQuote() throws ScanException {
{
List ol = new OptionTokenizer("\" \"").tokenize();
@@ -103,6 +106,7 @@
}
}
+ @Test
public void testMultiple() throws ScanException {
{
List ol = new OptionTokenizer("a, b").tokenize();
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -10,21 +10,16 @@
package ch.qos.logback.core.pattern.parser;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(TokenStreamTest.class);
- suite.addTestSuite(OptionTokenizerTest.class);
- suite.addTestSuite(ParserTest.class);
- suite.addTestSuite(FormatInfoTest.class);
- suite.addTestSuite(CompilerTest.class);
- suite.addTest(new JUnit4TestAdapter(SamplePatternLayoutTest.class));
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({TokenStreamTest.class,
+ OptionTokenizerTest.class,
+ ParserTest.class,
+ FormatInfoTest.class,
+ CompilerTest.class,
+ SamplePatternLayoutTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java Wed Dec 3 15:53:30 2008
@@ -9,45 +9,18 @@
*/
package ch.qos.logback.core.pattern.parser;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
import ch.qos.logback.core.pattern.FormatInfo;
-import ch.qos.logback.core.pattern.parser.CompositeNode;
-import ch.qos.logback.core.pattern.parser.FormattingNode;
-import ch.qos.logback.core.pattern.parser.KeywordNode;
-import ch.qos.logback.core.pattern.parser.Node;
-import ch.qos.logback.core.pattern.parser.Parser;
-
-public class ParserTest extends TestCase {
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
- /**
- * Constructor for PatternTest.
- *
- * @param arg0
- */
- public ParserTest(String arg0) {
- super(arg0);
- }
+public class ParserTest {
+ @Test
public void testBasic() throws Exception {
Parser p = new Parser("hello");
Node t = p.parse();
@@ -55,6 +28,7 @@
assertEquals("hello", t.getValue());
}
+ @Test
public void testKeyword() throws Exception {
{
@@ -78,6 +52,7 @@
}
}
+ @Test
public void testComposite() throws Exception {
{
Parser p = new Parser("hello%(%child)");
@@ -156,7 +131,8 @@
}
}
-
+
+ @Test
public void testNested() throws Exception {
{
Parser p = new Parser("%top %(%child%(%h))");
@@ -175,6 +151,7 @@
}
}
+ @Test
public void testFormattingInfo() throws Exception {
{
Parser p = new Parser("%45x");
@@ -218,6 +195,7 @@
}
}
+ @Test
public void testOptions() throws Exception {
{
Parser p = new Parser("%45x{'test '}");
@@ -243,6 +221,7 @@
}
}
+ @Test
public void testCompositeFormatting() throws Exception {
{
@@ -259,10 +238,4 @@
assertEquals(witness, t);
}
}
-
- public static Test Xsuite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new ParserTest("testFormattingInfo"));
- return suite;
- }
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java Wed Dec 3 15:53:30 2008
@@ -10,33 +10,28 @@
package ch.qos.logback.core.pattern.parser;
-import java.util.ArrayList;
-import java.util.List;
-import ch.qos.logback.core.pattern.util.AlmostAsIsEscapeUtil;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
-public class TokenStreamTest extends TestCase {
+import org.junit.Test;
- public TokenStreamTest(String arg0) {
- super(arg0);
- }
+import ch.qos.logback.core.pattern.util.AlmostAsIsEscapeUtil;
- protected void setUp() throws Exception {
- super.setUp();
- }
+public class TokenStreamTest {
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ @Test
public void testEmpty() throws ScanException {
List tl = new TokenStream("").tokenize();
List witness = new ArrayList();
assertEquals(witness, tl);
}
+ @Test
public void testSingleLiteral() throws ScanException {
List tl = new TokenStream("hello").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -44,6 +39,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testLiteralWithPercent() throws ScanException {
{
List tl = new TokenStream("hello\\%world").tokenize();
@@ -67,6 +63,7 @@
}
}
+ @Test
public void testBasic() throws ScanException {
// test "%c"
@@ -101,6 +98,7 @@
}
}
+ @Test
public void testComplexNR() throws ScanException {
List tl = new TokenStream("%d{1234} [%34.-67toto] %n").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -117,6 +115,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testEmptyP() throws ScanException {
List tl = new TokenStream("()").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -125,6 +124,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testEmptyP2() throws ScanException {
List tl = new TokenStream("%()").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -134,6 +134,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testEscape() throws ScanException {
{
List tl = new TokenStream("\\%").tokenize();
@@ -186,6 +187,7 @@
}
}
+ @Test
public void testOptions() throws ScanException {
{
List tl = new TokenStream("%x{t}").tokenize();
@@ -224,6 +226,7 @@
}
}
+ @Test
public void testSimpleP() throws ScanException {
List tl = new TokenStream("%(hello %class{.4?})").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -237,6 +240,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testSimpleP2() throws ScanException {
List tl = new TokenStream("X %a %-12.550(hello %class{.4?})").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -255,6 +259,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testMultipleRecursion() throws ScanException {
List tl = new TokenStream("%-1(%d %45(%class %file))").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -278,6 +283,7 @@
assertEquals(witness, tl);
}
+ @Test
public void testNested() throws ScanException {
List tl = new TokenStream("%(%a%(%b))").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -296,6 +302,7 @@
}
+ @Test
public void testEscapedParanteheses() throws ScanException {
{
List tl = new TokenStream("\\(%h\\)").tokenize();
@@ -317,6 +324,7 @@
}
}
+ @Test
public void testWindowsLikeBackSlashes() throws ScanException {
{
List tl = new TokenStream("c:\\hello\\world.%i", new AlmostAsIsEscapeUtil())
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 Wed Dec 3 15:53:30 2008
@@ -1,18 +1,11 @@
package ch.qos.logback.core.rolling;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(RenamingTest.class);
- suite.addTest(new JUnit4TestAdapter(SizeBasedRollingTest.class));
- suite.addTest(new JUnit4TestAdapter(TimeBasedRollingTest.class));
- suite.addTest(ch.qos.logback.core.rolling.helper.PackageTest.suite());
- return suite;
- }
+ at RunWith(Suite.class)
+ at Suite.SuiteClasses( { RenamingTest.class, SizeBasedRollingTest.class,
+ TimeBasedRollingTest.class,
+ ch.qos.logback.core.rolling.helper.PackageTest.class })
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java Wed Dec 3 15:53:30 2008
@@ -1,7 +1,7 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2008, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -10,17 +10,21 @@
package ch.qos.logback.core.rolling;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+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;
import ch.qos.logback.core.layout.EchoLayout;
import ch.qos.logback.core.util.Compare;
import ch.qos.logback.core.util.Constants;
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
/**
*
@@ -30,17 +34,13 @@
* @author Ceki
*
*/
-public class RenamingTest extends TestCase {
+public class RenamingTest {
Layout<Object> layout;
Context context = new ContextBase();
- public RenamingTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
layout = new EchoLayout<Object>();
File target = new File(Constants.OUTPUT_DIR_PREFIX + "test.log");
@@ -48,25 +48,23 @@
target.delete();
}
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
+ @Test
public void testRename() throws Exception {
RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
rfa.setLayout(layout);
rfa.setContext(context);
rfa.setFile(Constants.OUTPUT_DIR_PREFIX + "test.log");
-
+
// rollover by the second
String datePattern = "yyyy-MM-dd_HH_mm_ss";
SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
String[] filenames = new String[2];
TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
- tbrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX + "test-%d{" + datePattern + "}");
- //tbrp.setActiveFileName("src/test/output/test.log");
+ tbrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX + "test-%d{"
+ + datePattern + "}");
+ // tbrp.setActiveFileName("src/test/output/test.log");
tbrp.setContext(context);
tbrp.setParent(rfa);
tbrp.start();
@@ -74,21 +72,22 @@
rfa.setRollingPolicy(tbrp);
rfa.start();
- //StatusPrinter.print(context.getStatusManager());
+ // StatusPrinter.print(context.getStatusManager());
Calendar cal = Calendar.getInstance();
rfa.doAppend("Hello 0");
DelayerUtil.delayUntilNextSecond(50);
rfa.doAppend("Hello 1");
- filenames[0] = Constants.OUTPUT_DIR_PREFIX + "test-" + sdf.format(cal.getTime());
+ filenames[0] = Constants.OUTPUT_DIR_PREFIX + "test-"
+ + sdf.format(cal.getTime());
filenames[1] = Constants.OUTPUT_DIR_PREFIX + "test.log";
for (int i = 0; i < filenames.length; i++) {
- //System.out.println("before i=" + i);
- assertTrue(Compare.compare(filenames[i],
- Constants.TEST_DIR_PREFIX + "witness/rolling/renaming." + i));
- //System.out.println("post i=" + i);
+ // System.out.println("before i=" + i);
+ assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX
+ + "witness/rolling/renaming." + i));
+ // System.out.println("post i=" + i);
}
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java Wed Dec 3 15:53:30 2008
@@ -9,6 +9,9 @@
*/
package ch.qos.logback.core.rolling.helper;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -16,7 +19,9 @@
import java.io.InputStream;
import java.io.OutputStream;
-import junit.framework.TestCase;
+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.util.Compare;
@@ -26,10 +31,11 @@
/**
* @author Ceki Gulcu
*/
-public class CompressTest extends TestCase {
+public class CompressTest {
Context context = new ContextBase();
+ @Before
public void setUp() throws IOException {
// Copy source files
// Delete output files
@@ -63,9 +69,8 @@
}
}
- public void tearDown() {
- }
+ @Test
public void test1() throws Exception {
Compressor compressor = new Compressor(CompressionMode.GZ,
Constants.TEST_DIR_PREFIX + "input/compress1.txt",
@@ -80,6 +85,7 @@
+ "witness/compress1.txt.gz"));
}
+ @Test
public void test2() throws Exception {
Compressor compressor = new Compressor(CompressionMode.GZ,
Constants.TEST_DIR_PREFIX + "input/compress2.txt",
@@ -94,6 +100,7 @@
+ "witness/compress2.txt.gz"));
}
+ @Test
public void test3() throws Exception {
Compressor compressor = new Compressor(CompressionMode.ZIP,
Constants.TEST_DIR_PREFIX + "input/compress3.txt",
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java Wed Dec 3 15:53:30 2008
@@ -9,30 +9,26 @@
*/
package ch.qos.logback.core.rolling.helper;
+import static org.junit.Assert.*;
+
import java.util.Calendar;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
+
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.rolling.helper.FileNamePattern;
import ch.qos.logback.core.util.StatusPrinter;
/**
* @author Ceki
*
*/
-public class FileNamePatternTest extends TestCase {
+public class FileNamePatternTest {
Context context = new ContextBase();
- public FileNamePatternTest(String arg) {
- super(arg);
- }
-
-
+ @Test
public void testSmoke() {
// System.out.println("Testing [t]");
FileNamePattern pp = new FileNamePattern("t", context);
@@ -67,6 +63,7 @@
assertEquals("%foo", pp.convertInt(3));
}
+ @Test
// test ways for dealing with flowing i converter, as in "foo%ix"
public void testFlowingI() {
// System.out.println("Testing [foo%ibar%i]");
@@ -81,6 +78,7 @@
}
}
+ @Test
public void testDate() {
Calendar cal = Calendar.getInstance();
cal.set(2003, 4, 20, 17, 55);
@@ -96,18 +94,12 @@
assertEquals("2003.05.20 17:55 foo", pp.convertDate(cal.getTime()));
}
-
+
+ @Test
public void testWithBackslash() {
FileNamePattern pp = new FileNamePattern("c:\\foo\\bar.%i", context);
assertEquals("c:\\foo\\bar.3", pp.convertInt(3));
}
- public static Test xsuite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new FileNamePatternTest("test1"));
- suite.addTest(new FileNamePatternTest("test2"));
- // suite.addTest(new FileNamePatternTestCase("test3"));
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -1,27 +1,23 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2008, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-package ch.qos.logback.core.rolling.helper;
-
+package ch.qos.logback.core.rolling.helper;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+ at RunWith(Suite.class)
+ at Suite.SuiteClasses( { CompressTest.class, FileNamePatternTest.class,
+ RollingCalendarTest.class })
public class PackageTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(CompressTest.class);
- suite.addTestSuite(FileNamePatternTest.class);
- suite.addTestSuite(RollingCalendarTest.class);
- return suite;
- }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java Wed Dec 3 15:53:30 2008
@@ -10,25 +10,18 @@
package ch.qos.logback.core.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class DurationTest extends TestCase {
+import org.junit.Test;
+
+
+public class DurationTest {
static long HOURS_CO = 60*60;
static long DAYS_CO = 24*60*60;
- public DurationTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ @Test
public void test() {
{
Duration d = Duration.valueOf("12");
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java Wed Dec 3 15:53:30 2008
@@ -10,26 +10,19 @@
package ch.qos.logback.core.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class FileSizeTest extends TestCase {
+import org.junit.Test;
+
+
+public class FileSizeTest{
static long KB_CO = 1024;
static long MB_CO = 1024*1024;
static long GB_CO = 1024*MB_CO;
- public FileSizeTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ @Test
public void test() {
{
FileSize fs = FileSize.valueOf("8");
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java Wed Dec 3 15:53:30 2008
@@ -1,14 +1,19 @@
package ch.qos.logback.core.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.util.HashMap;
import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import junit.framework.TestCase;
-public class OptionHelperTest extends TestCase {
+public class OptionHelperTest {
String text = "Testing ${v1} variable substitution ${v2}";
String expected = "Testing if variable substitution works";
@@ -17,24 +22,19 @@
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
secondaryMap = new HashMap<String, String>();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
}
+ @Test
public void testLiteral() {
String noSubst = "hello world";
String result = OptionHelper.substVars(noSubst, context);
assertEquals(noSubst, result);
}
-
+ @Test
public void testUndefinedValues() {
String withUndefinedValues = "${axyz}";
@@ -42,6 +42,7 @@
assertEquals("axyz"+OptionHelper._IS_UNDEFINED, result);
}
+ @Test
public void testSubstVarsVariableNotClosed() {
String noSubst = "testing if ${v1 works";
@@ -53,7 +54,7 @@
//ok
}
}
-
+ @Test
public void testSubstVarsContextOnly() {
context.putProperty("v1", "if");
context.putProperty("v2", "works");
@@ -62,7 +63,7 @@
assertEquals(expected, result);
}
-
+ @Test
public void testSubstVarsSystemProperties() {
System.setProperty("v1", "if");
System.setProperty("v2", "works");
@@ -74,6 +75,7 @@
System.clearProperty("v2");
}
+ @Test
public void testSubstVarsWithDefault() {
context.putProperty("v1", "if");
String textWithDefault = "Testing ${v1} variable substitution ${v2:-toto}";
@@ -83,6 +85,7 @@
assertEquals(resultWithDefault, result);
}
+ @Test
public void testSubstVarsRecursive() {
context.putProperty("v1", "if");
context.putProperty("v2", "${v3}");
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java Wed Dec 3 15:53:30 2008
@@ -9,22 +9,17 @@
*/
package ch.qos.logback.core.util;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-
-public class PackageTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(DurationTest.class);
- suite.addTestSuite(FileSizeTest.class);
- suite.addTest(new JUnit4TestAdapter(FileUtilTest.class));
- suite.addTestSuite(OptionHelperTest.class);
- suite.addTestSuite(StatusPrinterTest.class);
- suite.addTestSuite(TimeUtilTest.class);
- return suite;
- }
+ at RunWith(Suite.class)
+ at SuiteClasses({
+ DurationTest.class,
+ FileSizeTest.class,
+ FileUtilTest.class,
+ OptionHelperTest.class,
+ StatusPrinterTest.class,
+ TimeUtilTest.class})
+public class PackageTest {
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java Wed Dec 3 15:53:30 2008
@@ -1,9 +1,14 @@
package ch.qos.logback.core.util;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import junit.framework.TestCase;
+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.status.ErrorStatus;
@@ -11,37 +16,35 @@
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.WarnStatus;
-public class StatusPrinterTest extends TestCase {
+public class StatusPrinterTest {
ByteArrayOutputStream outputStream;
PrintStream ps;
- public StatusPrinterTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
outputStream = new ByteArrayOutputStream();
ps = new PrintStream(outputStream);
StatusPrinter.setPrintStream(ps);
- super.setUp();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
StatusPrinter.setPrintStream(System.out);
ps = null;
outputStream = null;
- super.tearDown();
}
+ @Test
public void testBasic() {
Context context = new ContextBase();
context.getStatusManager().add(new InfoStatus("test", this));
StatusPrinter.print(context);
String result = outputStream.toString();
- assertTrue(result.contains("|-INFO in testBasic"));
+ assertTrue(result.contains("|-INFO in "+this.getClass().getName()));
}
+ @Test
public void testNested() {
Status s0 = new ErrorStatus("test0", this);
Status s1 = new InfoStatus("test1", this);
@@ -67,11 +70,12 @@
StatusPrinter.print(context);
String result = outputStream.toString();
- assertTrue(result.contains("+ INFO in testNested"));
- assertTrue(result.contains("+ WARN in testNested"));
- assertTrue(result.contains(" |-WARN in testNested"));
+ assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
+ assertTrue(result.contains("+ WARN in "+this.getClass().getName()));
+ assertTrue(result.contains(" |-WARN in "+this.getClass().getName()));
}
-
+
+ @Test
public void testWithException() {
Status s0 = new ErrorStatus("test0", this);
Status s1 = new InfoStatus("test1", this, new Exception("testEx"));
@@ -95,8 +99,8 @@
context.getStatusManager().add(s2);
StatusPrinter.print(context);
String result = outputStream.toString();
- assertTrue(result.contains("|-ERROR in testWithException"));
- assertTrue(result.contains("+ INFO in testWithException"));
+ assertTrue(result.contains("|-ERROR in "+this.getClass().getName()));
+ assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
assertTrue(result.contains("ch.qos.logback.core.util.StatusPrinterTest.testWithException"));
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java Wed Dec 3 15:53:30 2008
@@ -1,25 +1,16 @@
package ch.qos.logback.core.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
-public class TimeUtilTest extends TestCase {
+import org.junit.Test;
- public TimeUtilTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+public class TimeUtilTest {
+ @Test
public void testSecond() {
// Mon Nov 20 18:05:17,522 CET 2006
long now = 1164042317522L;
@@ -29,7 +20,8 @@
assertEquals(expected - now, 478);
assertEquals(expected, computed);
}
-
+
+ @Test
public void testMinute() {
// Mon Nov 20 18:05:17,522 CET 2006
long now = 1164042317522L;
@@ -40,7 +32,8 @@
assertEquals(expected - now, 1000 * 42 + 478);
assertEquals(expected, computed);
}
-
+
+ @Test
public void testHour() {
// Mon Nov 20 18:05:17,522 GMT 2006
long now = 1164045917522L;
@@ -53,7 +46,8 @@
assertEquals(expected - now, 1000 * (42 + 60 * 54) + 478);
assertEquals(expected, computed);
}
-
+
+ @Test
public void testDay() {
// Mon Nov 20 18:05:17 GMT 2006
long now = 1164045917522L;
@@ -66,7 +60,8 @@
assertEquals(expected - now, 1000 * (3600 * 5 + 60 * 54 + 42) + 478);
assertEquals(expected, computed);
}
-
+
+ @Test
public void testWeek() {
// Mon Nov 20 18:05:17 GMT 2006
long now = 1164045917522L;
@@ -91,7 +86,8 @@
1000 * (3600 * (5 + 24 * (5 + dayOffset)) + 60 * 54 + 42) + 478);
assertEquals(expected, computed);
}
-
+
+ @Test
public void testMonth() {
// Mon Nov 20 18:05:17 GMT 2006
long now = 1164045917522L;
More information about the logback-dev
mailing list