/*
 * Copyright 2015 yihtserns.
 *
 * Licensed 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 com.github.yihtserns.logback.spring.config;

import com.github.yihtserns.logback.spring.config.util.MockAppender;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author yihtserns
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class LogbackNamespaceHandlerTest {

    private Logger log = LoggerFactory.getLogger(getClass());
    @Autowired
    private MockAppender mock;

    @Before
    public void resetMock() {
        mock.reset();
    }

    @Test
    public void canConfigureAppenderInSpringXml() {
        final String expectedMessage = "Configured successfully!";
        log.info(expectedMessage);

        mock.assertLogged(expectedMessage);
    }
}

@@ -641,16 +641,52 @@
 onfig;%0A%0A
+import ch.qos.logback.core.Context;%0A
 import c
@@ -742,24 +742,24 @@
 ckAppender;%0A
-
 import org.j
@@ -1080,16 +1080,108 @@
 sRunner;
+%0Aimport static org.hamcrest.Matchers.*;%0Aimport static org.hamcrest.MatcherAssert.assertThat;
 %0A%0A/**%0A *
@@ -1654,16 +1654,16 @@
 sage);%0A%0A
-
         
@@ -1703,11 +1703,296 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void shouldInjectLoggerContextIntoAppender() throws Exception %7B%0A        Context loggerContext = mock.getContext();%0A%0A        assertThat(loggerContext, is(not(nullValue())));%0A        assertThat(loggerContext, is((Context) LoggerFactory.getILoggerFactory()));%0A    %7D
 %0A%7D%0A

Add test case to ensure logger context is set into appender.