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.configuration2;
19  
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  
22  import java.util.List;
23  
24  import org.apache.commons.configuration2.convert.LegacyListDelimiterHandler;
25  import org.apache.commons.configuration2.io.FileHandler;
26  import org.junit.jupiter.api.BeforeEach;
27  import org.junit.jupiter.api.Test;
28  
29  /**
30   * A base class for testing {@link org.apache.commons.configuration2.BaseHierarchicalConfiguration} extensions.
31   */
32  public class TestThreesomeConfiguration {
33      protected Configuration conf;
34  
35      @BeforeEach
36      public void setUp() throws Exception {
37          final PropertiesConfiguration c = new PropertiesConfiguration();
38          c.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
39          final FileHandler handler = new FileHandler(c);
40          handler.setFileName("threesome.properties");
41          handler.load();
42          conf = c;
43      }
44  
45      @Test
46      public void testList1() throws Exception {
47          final List<Object> packages = conf.getList("test.threesome.one");
48          // we should get 3 packages here
49          assertEquals(3, packages.size());
50      }
51  
52      @Test
53      public void testList2() throws Exception {
54          final List<Object> packages = conf.getList("test.threesome.two");
55          // we should get 3 packages here
56          assertEquals(3, packages.size());
57      }
58  
59      @Test
60      public void testList3() throws Exception {
61          final List<Object> packages = conf.getList("test.threesome.three");
62          // we should get 3 packages here
63          assertEquals(3, packages.size());
64      }
65  }