001package org.apache.log4j;
002
003import static org.junit.Assert.assertEquals;
004import static org.junit.Assert.assertNull;
005
006import java.util.Random;
007
008import org.junit.Test;
009import org.slf4j.impl.VersionUtil;
010
011public class MDCFriendTest {
012
013        
014    private static 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}