View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNull;
18  
19  import java.util.HashMap;
20  
21  import org.junit.Test;
22  import org.slf4j.MDC;
23  
24  public class MDCTest {
25  
26      @Test
27      public void test() throws InterruptedException {
28          MDCTestThread threadA = new MDCTestThread("a");
29          threadA.start();
30  
31          MDCTestThread threadB = new MDCTestThread("b");
32          threadB.start();
33  
34          threadA.join();
35          threadB.join();
36  
37          assertNull(threadA.x0);
38          assertEquals("a", threadA.x1);
39          assertNull(threadA.x2);
40  
41          assertNull(threadB.x0);
42          assertEquals("b", threadB.x1);
43          assertNull(threadB.x2);
44  
45      }
46  
47      @Test
48      public void testLBCLASSIC_98() {
49          MDC.setContextMap(new HashMap<String, String>());
50      }
51  
52  }