/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache license, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the license for the specific language governing permissions and
 * limitations under the license.
 */
package org.apache.logging.log4j;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 *
 */
public class ThreadContextTest {

    @Test
    public void testPush() {
        ThreadContext.push("Hello");
        ThreadContext.push("{} is {}", ThreadContextTest.class.getSimpleName(), "running");
        assertEquals("Incorrect parameterized stack value", ThreadContext.pop(), "ThreadContextTest is running");
        assertEquals("Incorrect simple stack value", ThreadContext.pop(), "Hello");
    }
}

@@ -897,16 +897,59 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0A/**%0A *
@@ -1358,11 +1358,1172 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testInheritance() throws Exception %7B%0A        ThreadContext.clear();%0A        ThreadContext.put(%22Greeting%22, %22Hello%22);%0A        StringBuilder sb = new StringBuilder();%0A        TestThread thread = new TestThread(sb);%0A        thread.start();%0A        thread.join();%0A        String str = sb.toString();%0A        assertTrue(%22Unexpected ThreadContext value. Expected Hello. Actual %22 + str, %22Hello%22.equals(str));%0A        sb = new StringBuilder();%0A        thread = new TestThread(sb);%0A        thread.start();%0A        thread.join();%0A        str = sb.toString();%0A        assertTrue(%22Unexpected ThreadContext value. Expected Hello. Actual %22 + str, %22Hello%22.equals(str));%0A    %7D%0A%0A%0A    private class TestThread extends Thread %7B%0A%0A        private final StringBuilder sb;%0A%0A        public TestThread(StringBuilder sb) %7B%0A            this.sb = sb;%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A            String greeting = ThreadContext.get(%22Greeting%22);%0A            if (greeting == null) %7B%0A                sb.append(%22null%22);%0A            %7D else %7B%0A                sb.append(greeting);%0A            %7D%0A            ThreadContext.clear();%0A        %7D%0A    %7D
 %0A%7D%0A

Add unit test for ThreadContext inheritance