001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.db.names;
015
016import org.junit.Before;
017import org.junit.Test;
018
019import static org.assertj.core.api.Assertions.assertThat;
020
021/**
022 * @author Tomasz Nurkiewicz
023 * @since 2010-03-18
024 */
025public class DefaultDBNameResolverTest {
026
027    private DefaultDBNameResolver resolver;
028
029    @Before
030    public void setUp() throws Exception {
031        resolver = new DefaultDBNameResolver();
032    }
033
034    @Test
035    public void testGetLoggingEventColumnName() throws Exception {
036        // when
037        String columnName = resolver.getColumnName(ColumnName.LOGGER_NAME);
038
039        // then
040        assertThat(columnName).isEqualTo("logger_name");
041    }
042
043    @Test
044    public void testGetLoggingEventPropertyColumnName() throws Exception {
045        // when
046        String columnName = resolver.getColumnName(ColumnName.MAPPED_KEY);
047
048        // then
049        assertThat(columnName).isEqualTo("mapped_key");
050    }
051
052    @Test
053    public void testGetLoggingEventExceptionColumnName() throws Exception {
054        // when
055        String columnName = resolver.getColumnName(ColumnName.TRACE_LINE);
056
057        // then
058        assertThat(columnName).isEqualTo("trace_line");
059    }
060
061    @Test
062    public void testGetTableName() throws Exception {
063        // when
064        String tableName = resolver.getTableName(TableName.LOGGING_EVENT_EXCEPTION);
065
066        // then
067        assertThat(tableName).isEqualTo("logging_event_exception");
068    }
069
070}