[slf4j-dev] svn commit: r1176 - in slf4j/trunk: integration integration/src/test/java/org/slf4j slf4j-site/src/site/pages
ceki at slf4j.org
ceki at slf4j.org
Fri Oct 3 19:56:47 CEST 2008
Author: ceki
Date: Fri Oct 3 19:56:46 2008
New Revision: 1176
Added:
slf4j/trunk/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java
slf4j/trunk/integration/src/test/java/org/slf4j/StringPrintStream.java
slf4j/trunk/integration/src/test/java/org/slf4j/VersionMatchTest.java
Removed:
slf4j/trunk/integration/src/test/java/org/slf4j/VersionTest.java
Modified:
slf4j/trunk/integration/build.xml
slf4j/trunk/slf4j-site/src/site/pages/news.html
Log:
- added a new version checking test
- updates to the docs
Modified: slf4j/trunk/integration/build.xml
==============================================================================
--- slf4j/trunk/integration/build.xml (original)
+++ slf4j/trunk/integration/build.xml Fri Oct 3 19:56:46 2008
@@ -1,5 +1,14 @@
<project name="integration" default="testAll" basedir=".">
+ <!--
+ This build file is usually run indirectly via Maven.
+
+ When running this build file through Ant diretly, you must
+ define the currentVersion property on the command line, e.g.:
+
+ ant -DcurrentVersion=1.5.4-SNAPSHOT
+ -->
+
<echo message="compile classpath: ${compile_classpath}" />
<echo message="runtime classpath: ${runtime_classpath}" />
<echo message="test classpath: ${test_classpath}" />
@@ -12,27 +21,41 @@
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
</path >
+ <path id="pathCurrent">
+ <pathelement location="xtarget/classes/" />
+ <pathelement location="target/test-classes/" />
+ <pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
+ <pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
+ </path >
<!-- this is really very ugly, but it's the only way to circumvent
http://jira.codehaus.org/browse/MANTRUN-95
-->
<taskdef name="junit" classpath="${plugin_classpath};${compile_classpath}" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
-
- <target name="testAll">
- <echo>Running unit tests via Ant</echo>
- <echo>basedir=${basedir}</echo>
- <echo>user.home=${user.home}</echo>
+ <target name="init">
<mkdir dir="target/unit-reports" />
+ </target>
+ <target name="testAll" depends="init,
+ testPre154,
+ testMatch">
+ </target>
+
+ <target name="testPre154">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path150" />
<formatter type="plain" />
- <test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionTest" />
+ <test fork="yes" todir="target/unit-reports" name="org.slf4j.Pre154VersionMismatchTest" />
</junit>
-
</target>
-
+ <target name="testMatch">
+ <junit printsummary="yes" fork="no" haltonfailure="yes">
+ <classpath refid="pathCurrent" />
+ <formatter type="plain" />
+ <test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMatchTest" />
+ </junit>
+ </target>
</project>
\ No newline at end of file
Added: slf4j/trunk/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/integration/src/test/java/org/slf4j/Pre154VersionMismatchTest.java Fri Oct 3 19:56:46 2008
@@ -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));
+ }
+}
Added: slf4j/trunk/integration/src/test/java/org/slf4j/StringPrintStream.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/integration/src/test/java/org/slf4j/StringPrintStream.java Fri Oct 3 19:56:46 2008
@@ -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);
+ }
+}
+
Added: slf4j/trunk/integration/src/test/java/org/slf4j/VersionMatchTest.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/integration/src/test/java/org/slf4j/VersionMatchTest.java Fri Oct 3 19:56:46 2008
@@ -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));
+ }
+}
Modified: slf4j/trunk/slf4j-site/src/site/pages/news.html
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/pages/news.html (original)
+++ slf4j/trunk/slf4j-site/src/site/pages/news.html Fri Oct 3 19:56:46 2008
@@ -37,6 +37,11 @@
href="http://bugzilla.slf4j.org/show_bug.cgi?id=102">packaging
problems</a> related to <em>slf4j-ext</em> module.
</p>
+
+ <p>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.</p>
<p>We now say that markers contain <em>references</em> to other
markers. We no longer talk about child markers. The javadocs of the
@@ -47,6 +52,7 @@
</p>
+
<hr noshade="noshade" size="1"/>
<h3>September 12th, 2008 - Release of SLF4J 1.5.3</h3>
More information about the slf4j-dev
mailing list