001package org.slf4j.log4j12;
002
003import static org.junit.Assert.assertEquals;
004import static org.junit.Assert.assertNull;
005
006import java.util.Random;
007
008import org.apache.log4j.MDC;
009import org.apache.log4j.MDCFriend;
010import org.junit.Test;
011
012public class MDCFriendTest {
013
014    private static final Random random = new Random();
015    int diff = random.nextInt(1024 * 8);
016
017    @Test
018    public void smoke() {
019        if (VersionUtil.getJavaMajorVersion() < 9)
020            return;
021
022        MDCFriend.fixForJava9();
023        String key = "MDCFriendTest.smoke" + diff;
024        String val = "val" + diff;
025        MDC.put(key, val);
026        assertEquals(val, MDC.get(key));
027        MDC.clear();
028        assertNull(MDC.get(key));
029
030    }
031
032}