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