View Javadoc

    1   package org.apache.log4j;
    2
    3   import static org.junit.Assert.assertEquals;
    4   import static org.junit.Assert.assertNull;
    5
    6   import java.util.Random;
    7
    8   import org.junit.Test;
    9   import org.slf4j.impl.VersionUtil;
    10
    11  public class MDCFriendTest {
    12
    13
    14      private static Random random = new Random();
    15  	int diff = random.nextInt(1024*8);
    16
    17  	@Test
    18  	public void smoke() {
    19  		if(VersionUtil.getJavaMajorVersion() < 9)
    20  			return;
    21
    22  		MDCFriend.fixForJava9();
    23  		String key = "MDCFriendTest.smoke"+diff;
    24  		String val = "val"+diff;
    25  		MDC.put(key, val);
    26  		assertEquals(val, MDC.get(key));
    27  		MDC.clear();
    28  		assertNull(MDC.get(key));
    29
    30  	}
    31
    32  }