17ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu/**
27ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * Copyright (c) 2004-2011 QOS.ch
37ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * All rights reserved.
47ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
57ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * Permission is hereby granted, free  of charge, to any person obtaining
67ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * a  copy  of this  software  and  associated  documentation files  (the
77ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * "Software"), to  deal in  the Software without  restriction, including
87ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * without limitation  the rights to  use, copy, modify,  merge, publish,
97ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * distribute,  sublicense, and/or sell  copies of  the Software,  and to
107ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * permit persons to whom the Software  is furnished to do so, subject to
117ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * the following conditions:
127ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
137ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * The  above  copyright  notice  and  this permission  notice  shall  be
147ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * included in all copies or substantial portions of the Software.
157ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
167ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
177ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
187ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
197ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
207ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
217ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
227ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu *
247ba0605dc97fb81bde8311510d27b3ccba170008Ceki Gulcu */
2552d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goerspackage org.slf4j.dummyExt;
2652d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
2752d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goersimport junit.framework.TestCase;
2852d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
2952d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goersimport org.slf4j.MDC;
3052d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goersimport org.slf4j.ext.MDCStrLookup;
3152d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
3252d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goerspublic class MDCStrLookupTest extends TestCase {
3352d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
3452d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    public MDCStrLookupTest(String name) {
3552d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        super(name);
3652d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    }
3752d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
3852d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    public void setUp() throws Exception {
3952d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        super.setUp();
4052d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    }
4152d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
4252d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    public void tearDown() throws Exception {
4352d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        super.tearDown();
4452d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    }
4552d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers
4652d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    public void testLookup() throws Exception {
4752d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        MDC.put("key", "value");
4852d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        MDC.put("number", "2");
4952d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        MDCStrLookup lookup = new MDCStrLookup();
5052d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        assertEquals("value", lookup.lookup("key"));
5152d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        assertEquals("2", lookup.lookup("number"));
5252d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        assertEquals(null, lookup.lookup(null));
5352d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        assertEquals(null, lookup.lookup(""));
5452d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers        assertEquals(null, lookup.lookup("other"));
5552d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers    }
5652d3f24c1aad4d40514404e576c3398bcc18d844Ralph Goers}
57