View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.db.names;
15  
16  import org.junit.Before;
17  import org.junit.Test;
18  
19  import static org.assertj.core.api.Assertions.assertThat;
20  
21  /**
22   * @author Tomasz Nurkiewicz
23   * @since 2010-03-18
24   */
25  public class DefaultDBNameResolverTest {
26  
27      private DefaultDBNameResolver resolver;
28  
29      @Before
30      public void setUp() throws Exception {
31          resolver = new DefaultDBNameResolver();
32      }
33  
34      @Test
35      public void testGetLoggingEventColumnName() throws Exception {
36          // when
37          String columnName = resolver.getColumnName(ColumnName.LOGGER_NAME);
38  
39          // then
40          assertThat(columnName).isEqualTo("logger_name");
41      }
42  
43      @Test
44      public void testGetLoggingEventPropertyColumnName() throws Exception {
45          // when
46          String columnName = resolver.getColumnName(ColumnName.MAPPED_KEY);
47  
48          // then
49          assertThat(columnName).isEqualTo("mapped_key");
50      }
51  
52      @Test
53      public void testGetLoggingEventExceptionColumnName() throws Exception {
54          // when
55          String columnName = resolver.getColumnName(ColumnName.TRACE_LINE);
56  
57          // then
58          assertThat(columnName).isEqualTo("trace_line");
59      }
60  
61      @Test
62      public void testGetTableName() throws Exception {
63          // when
64          String tableName = resolver.getTableName(TableName.LOGGING_EVENT_EXCEPTION);
65  
66          // then
67          assertThat(tableName).isEqualTo("logging_event_exception");
68      }
69  
70  }