1 package org.slf4j;
2
3 import java.io.PrintStream;
4 import java.util.Random;
5
6 import junit.framework.TestCase;
7
8 public class VersionMatchTest extends TestCase {
9
10
11 StringPrintStream sps = new StringPrintStream(System.err);
12 PrintStream old = System.err;
13 int diff = 1024 + new Random().nextInt(10000);
14
15 public VersionMatchTest(String name) {
16 super(name);
17 }
18
19 protected void setUp() throws Exception {
20 super.setUp();
21 System.setErr(sps);
22 }
23
24 protected void tearDown() throws Exception {
25 super.tearDown();
26 System.setErr(old);
27 }
28
29
30 public void test() throws Exception {
31 Logger logger = LoggerFactory.getLogger(this.getClass());
32 String msg = "hello world "+diff;
33 logger.info(msg);
34 assertEquals(1, sps.stringList.size());
35 String s0 = (String) sps.stringList.get(0);
36 assertTrue(s0.contains(msg));
37 }
38 }