- better wording in the docs

- improved integration tests: Added integration tests consistent with the elective version check policy
This commit is contained in:
Ceki Gulcu 2008-10-17 15:42:18 +00:00
parent 2050a4db44
commit eb14bf4392
9 changed files with 122 additions and 38 deletions

View File

@ -21,6 +21,13 @@
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
</path >
<path id="pathIncompatible">
<pathelement location="xtarget/classes/" />
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
<pathelement location="./lib/slf4j-simple-INCOMPATIBLE.jar" />
</path >
<path id="pathCurrent">
<pathelement location="xtarget/classes/" />
<pathelement location="target/test-classes/" />
@ -38,15 +45,24 @@
</target>
<target name="testAll" depends="init,
testMismatch,
testPre155,
testMatch">
</target>
<target name="testMismatch">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="pathIncompatible" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMismatchTest" />
</junit>
</target>
<target name="testPre155">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path150" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.Pre155VersionMismatchTest" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.Pre155VersionTest" />
</junit>
</target>

Binary file not shown.

View File

@ -5,13 +5,13 @@ import java.util.Random;
import junit.framework.TestCase;
public class Pre155VersionMismatchTest extends TestCase {
public class Pre155VersionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
public Pre155VersionMismatchTest(String name) {
public Pre155VersionTest(String name) {
super(name);
}

View File

@ -0,0 +1,43 @@
package org.slf4j;
import java.io.PrintStream;
import java.util.Random;
import junit.framework.TestCase;
public class VersionMismatchTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
public VersionMismatchTest(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.matches("SLF4J: The requested version .* by your slf4j binding is not compatible with.*"));
String s1 = (String) sps.stringList.get(1);
assertTrue(s1.contains(LoggerFactory.VERSION_MISMATCH));
String s2 = (String) sps.stringList.get(2);
assertTrue(s2.contains(msg));
}
}

View File

@ -128,7 +128,7 @@ public final class LoggerFactory {
}
if (!match) {
Util.reportFailure("The requested version " + requested
+ " of your slf4j-binding does not match any of "
+ " by your slf4j binding is not compatible with "
+ Arrays.toString(API_COMPATIBILITY_LIST));
Util.reportFailure("See " + VERSION_MISMATCH + " for further details.");
}

View File

@ -177,6 +177,10 @@ prefix='';
mismatch problem, it emits a warning about the said mismatch.
</p>
<p>For the exact details of the version mismatch detection
mechanism, please refer to the <a
href="faq.html#version_checks">relevant entry</a> in the FAQ.
</p>
<h3><a name="substituteLogger" href="#substituteLogger">Substitute
loggers were created during the default configuration phase of the

View File

@ -42,6 +42,9 @@ prefix='';
to suspect incompatible changes not mentioned here, please kindly
contact the slf4j developers list.</p>
<h2><a href="#1_5_5" name="1_5_4">Version 1.5.5 compared to 1.5.4</a></h2>
<p>No breaking changes to report.</p>
<h2><a href="#1_5_4" name="1_5_4">Version 1.5.4 compared to 1.5.3</a></h2>

View File

@ -990,46 +990,51 @@ class MyClass {
SLF4J's version check mechanism work?</a></dt>
<dd>
<p>Given its huge installed user base, the version check
performed by SLF4J API during its initialization is an
elective process. Conforming SLF4J implementations may choose
<em>not</em> to participate, in which case, no version check
will be performed.
<p>The version check performed by SLF4J API during its
initialization is an elective process. Conforming SLF4J
implementations may choose <em>not</em> to participate, in
which case, no version check will be performed.
</p>
<p>However, if you decide to participate, your SLF4J binding
needs to declare a variable called REQUESTED_API_VERSION
within your copy of the <code>StaticLoggerBinder</code>
class. The value of this variable should be equal to the
version of the slf4j-api.jar you are compiling against. If you
ugrade to a newer version of slf4j-api, you also need to
update the value of REQUESTED_API_VERSION. (That is all you
have to do.)
<p>However, if an SLF4J implementation decides to participate,
than it needs to declare a variable called
REQUESTED_API_VERSION within its copy of the
<code>StaticLoggerBinder</code> class. The value of this
variable should be equal to the version of the slf4j-api.jar
it is compiled with. If the implementation is upgraded to a
newer version of slf4j-api, than you also need to update the
value of REQUESTED_API_VERSION.
</p>
<p>For earch version, SLF4J API maintains a list of compatible
<p>For each version, SLF4J API maintains a list of compatible
versions. SLF4J will emit a version mismatch warning only if
the requested version is not found in the compatibility
list. So even if your SLF4J binding has a different release
schedule than SLF4J, you can still participate in the version
check without incurring a mismatch warning. For example,
logback has a different release schedule but still
schedule than SLF4J, assuming you update the SLF4J version you
use every 6 to 12 months, you can still participate in the
version check without incurring a mismatch warning. For
example, logback has a different release schedule but still
participates in version checks.</p>
<p><b>As of SLF4J 1.5.5</b>, all bindings shipped within SLF4J
distribution, e.g. slf4j-logj12, slf4j-simple and slf4j-jdk14,
declare the REQUESTED_API_VERSION field with a value equal to
their SLF4J version. It follows that, for example if
slf4j-simple-1.5.6.jar is mixed with simple-api-1.5.5.jar,
then a version mismatch warning will be issued. Note that
SLF4J prior to 1.5.5 did not have a version check
mechanism. (Actually, version 1.5.4 offered a check policy
which was much too restritive and inconsistent with the size
of our user base. Consequently, SLF4J version 1.5.5 was
released just a day after 1.5.4.)
<p><b>As of SLF4J 1.5.5</b>, all bindings shipped within the
SLF4J distribution, e.g. slf4j-logj12, slf4j-simple and
slf4j-jdk14, declare the REQUESTED_API_VERSION field with a
value equal to their SLF4J version. It follows that, for
example if slf4j-simple-1.5.6.jar is mixed with
slf4j-api-1.5.5.jar, then a version mismatch warning will be
issued. Note that SLF4J versions prior to 1.5.5 did not have a
version check mechanism. Only slf4j-api-1.5.5.jar and later
can emit version mismatch warnings. (Actually, version 1.5.4
offered a check policy which was much too restrictive and
inconsistent with the size of our user base. Consequently,
SLF4J version 1.5.5 was released just a day after 1.5.4.)
</p>
<p>
<p>Given its huge installed user base and several external
implementations, it would have been unwise to expect all SLF4J
implementations to closely follow SLF4J's release schedule,
let alone align their release schedules with SLF4J. Hence, the
elective version check policy.
</p>
</dd>

View File

@ -27,13 +27,26 @@ prefix='';
<hr noshade="noshade" size="1"/>
<h3>October 17th, 2008 - Release of SLF4J 1.5.5</h3>
<p>The version check mechanims introduced in SLF4J 1.5.4 was
inconstent with the large size of SLF4J's installed user base. We
cannot expect external SLF4J to align their release schedule with
that of SLF4J. Consequently, this SLF4J version, namely 1.5.5,
retains versions checks but as an elective process. For further
details see the <a href="faq.html#version_checks">relevant entry</a>
in the FAQ.
</p>
<p>You are highly encouraged to upgrade to SLF4J version 1.5.5. The
upgrade should pose no problems. Nevertheless, you might still want
to refer to the SLF4J <a href="compatibility.html">compatibility
report</a>.
</p>
<h3>October 16th, 2008 - Release of SLF4J 1.5.4</h3>
<p>This version corrects critical bugs. You are highly encouraged to
upgrade to SLF4J version 1.5.4. The upgrade should pose no
problems. Nevertheless, you might still want to refer to the <a
href="compatibility.html#1_5_4">compatibility report</a> for this
version.
<p>This version corrects critical bugs.
</p>
<p>Fixed <a