aboutsummaryrefslogtreecommitdiff
path: root/slf4j-reload4j/src/test/java/org/slf4j/reload4j/Reload4jMDCAdapterTest.java
blob: fa343b452b31f4d395afe6f0f527e71de03d072b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.slf4j.reload4j;

import org.junit.Test;
import org.slf4j.helpers.MDCAdapterTestBase;
import org.slf4j.spi.MDCAdapter;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

public class Reload4jMDCAdapterTest extends MDCAdapterTestBase {
    
    protected MDCAdapter instantiateMDC() {
        return new Reload4jMDCAdapter();
    }
    
    
    @Test
    public void testClearingMDC() {
        mdc.put("testKey", "testValue");
        assertFalse(mdc.getCopyOfContextMap().isEmpty());
        mdc.clear();
        assertTrue(mdc.getCopyOfContextMap().isEmpty());
    }

    @Test
    public void testSetContextMap() {
        Map<String, String> map0 = new HashMap<>();
        map0.put("key0", "val0");

        mdc.setContextMap(map0);
        Map map1 = mdc.getCopyOfContextMap();

        assertEquals(map0, map1);
    }
    

}