001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic;
015
016import static org.junit.Assert.assertEquals;
017import static org.junit.Assert.assertNull;
018
019import java.util.HashMap;
020
021import org.junit.Test;
022import org.slf4j.MDC;
023
024public class MDCTest {
025
026    @Test
027    public void test() throws InterruptedException {
028        MDCTestThread threadA = new MDCTestThread("a");
029        threadA.start();
030
031        MDCTestThread threadB = new MDCTestThread("b");
032        threadB.start();
033
034        threadA.join();
035        threadB.join();
036
037        assertNull(threadA.x0);
038        assertEquals("a", threadA.x1);
039        assertNull(threadA.x2);
040
041        assertNull(threadB.x0);
042        assertEquals("b", threadB.x1);
043        assertNull(threadB.x2);
044
045    }
046
047    @Test
048    public void testLBCLASSIC_98() {
049        MDC.setContextMap(new HashMap<String, String>());
050    }
051
052}