diff --git a/integration/build.xml b/integration/build.xml index 1b782a07..0de3c99b 100644 --- a/integration/build.xml +++ b/integration/build.xml @@ -1,5 +1,14 @@ + + @@ -12,27 +21,41 @@ + + + + + + - - - Running unit tests via Ant - basedir=${basedir} - user.home=${user.home} + + + + + + - + - - + + + + + + + \ No newline at end of file diff --git a/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java b/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java new file mode 100644 index 00000000..d36a3a58 --- /dev/null +++ b/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java @@ -0,0 +1,43 @@ +package org.slf4j; + +import java.io.PrintStream; +import java.util.Random; + +import junit.framework.TestCase; + +public class Pre154VersionMismatchTest extends TestCase { + + + StringPrintStream sps = new StringPrintStream(System.err); + PrintStream old = System.err; + int diff = 1024 + new Random().nextInt(10000); + + public Pre154VersionMismatchTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + System.setErr(sps); + } + + protected void tearDown() throws Exception { + super.tearDown(); + System.setErr(old); + } + + + public void test() throws Exception { + Logger logger = LoggerFactory.getLogger(this.getClass()); + String msg = "hello world "+diff; + logger.info(msg); + String s0 = (String) sps.stringList.get(0); + assertTrue(s0.startsWith("SLF4J: The version of your slf4j-binding is probably older than 1.5.4")); + + String s1 = (String) sps.stringList.get(1); + assertTrue(s1.contains(LoggerFactory.VERSION_MISMATCH)); + + String s2 = (String) sps.stringList.get(2); + assertTrue(s2.contains(msg)); + } +} diff --git a/integration/src/test/java/org/slf4j/StringPrintStream.java b/integration/src/test/java/org/slf4j/StringPrintStream.java new file mode 100644 index 00000000..22d16dac --- /dev/null +++ b/integration/src/test/java/org/slf4j/StringPrintStream.java @@ -0,0 +1,34 @@ +package org.slf4j; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; + +public class StringPrintStream extends PrintStream { + + public static final String LINE_SEP = System.getProperty("line.separator"); + PrintStream other; + List stringList = new ArrayList(); + + public StringPrintStream(PrintStream ps) { + super(ps); + other = ps; + } + + public void print(String s) { + other.print(s); + stringList.add(s); + } + + public void println(String s) { + other.println(s); + stringList.add(s); + + } + + public void println(Object o) { + other.println(o); + stringList.add(o); + } +} + diff --git a/integration/src/test/java/org/slf4j/VersionMatchTest.java b/integration/src/test/java/org/slf4j/VersionMatchTest.java new file mode 100644 index 00000000..5e6ff789 --- /dev/null +++ b/integration/src/test/java/org/slf4j/VersionMatchTest.java @@ -0,0 +1,38 @@ +package org.slf4j; + +import java.io.PrintStream; +import java.util.Random; + +import junit.framework.TestCase; + +public class VersionMatchTest extends TestCase { + + + StringPrintStream sps = new StringPrintStream(System.err); + PrintStream old = System.err; + int diff = 1024 + new Random().nextInt(10000); + + public VersionMatchTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + System.setErr(sps); + } + + protected void tearDown() throws Exception { + super.tearDown(); + System.setErr(old); + } + + + public void test() throws Exception { + Logger logger = LoggerFactory.getLogger(this.getClass()); + String msg = "hello world "+diff; + logger.info(msg); + assertEquals(1, sps.stringList.size()); + String s0 = (String) sps.stringList.get(0); + assertTrue(s0.contains(msg)); + } +} diff --git a/integration/src/test/java/org/slf4j/VersionTest.java b/integration/src/test/java/org/slf4j/VersionTest.java deleted file mode 100644 index e15b7608..00000000 --- a/integration/src/test/java/org/slf4j/VersionTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.slf4j; - -import junit.framework.TestCase; - -public class VersionTest extends TestCase { - - public VersionTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - - public void test() throws Exception { - Logger logger = LoggerFactory.getLogger(this.getClass()); - logger.info("hello world"); - } -} diff --git a/slf4j-site/src/site/pages/news.html b/slf4j-site/src/site/pages/news.html index a5a33d15..4eb543fc 100644 --- a/slf4j-site/src/site/pages/news.html +++ b/slf4j-site/src/site/pages/news.html @@ -37,6 +37,11 @@ prefix=''; href="http://bugzilla.slf4j.org/show_bug.cgi?id=102">packaging problems related to slf4j-ext module.

+ +

At initialization time, LoggerFactory will check that the version + of the slf4j-binding matches that of slf4j-api. If there is a + mismatch a warning will be issued on the console. This should help + our users identify SLF4J related problems more quickly.

We now say that markers contain references to other markers. We no longer talk about child markers. The javadocs of the @@ -47,6 +52,7 @@ prefix='';

+

September 12th, 2008 - Release of SLF4J 1.5.3