View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.csv;
19  
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  
22  import org.junit.jupiter.api.Test;
23  
24  /**
25   * Tests {@link CSVFormat.Predefined}.
26   */
27  public class CSVFormatPredefinedTest {
28  
29      private void test(final CSVFormat format, final String enumName) {
30          assertEquals(format, CSVFormat.Predefined.valueOf(enumName).getFormat());
31          assertEquals(format, CSVFormat.valueOf(enumName));
32      }
33  
34      @Test
35      public void testDefault() {
36          test(CSVFormat.DEFAULT, "Default");
37      }
38  
39      @Test
40      public void testExcel() {
41          test(CSVFormat.EXCEL, "Excel");
42      }
43  
44      @Test
45      public void testMongoDbCsv() {
46          test(CSVFormat.MONGODB_CSV, "MongoDBCsv");
47      }
48  
49      @Test
50      public void testMongoDbTsv() {
51          test(CSVFormat.MONGODB_TSV, "MongoDBTsv");
52      }
53  
54      @Test
55      public void testMySQL() {
56          test(CSVFormat.MYSQL, "MySQL");
57      }
58  
59      @Test
60      public void testOracle() {
61          test(CSVFormat.ORACLE, "Oracle");
62      }
63  
64      @Test
65      public void testPostgreSqlCsv() {
66          test(CSVFormat.POSTGRESQL_CSV, "PostgreSQLCsv");
67      }
68  
69      @Test
70      public void testPostgreSqlText() {
71          test(CSVFormat.POSTGRESQL_TEXT, "PostgreSQLText");
72      }
73  
74      @Test
75      public void testRFC4180() {
76          test(CSVFormat.RFC4180, "RFC4180");
77      }
78  
79      @Test
80      public void testTDF() {
81          test(CSVFormat.TDF, "TDF");
82      }
83  }