2 * Copyright 2021 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.holmes.common;
19 import org.junit.Rule;
20 import org.junit.Test;
21 import org.junit.rules.ExpectedException;
22 import org.junit.runner.RunWith;
23 import org.powermock.modules.junit4.PowerMockRunner;
27 import static org.hamcrest.core.Is.is;
28 import static org.hamcrest.core.IsEqual.equalTo;
29 import static org.junit.Assert.assertThat;
31 @RunWith(PowerMockRunner.class)
32 public class ConfigFileScannerTest {
35 ExpectedException thrown = ExpectedException.none();
38 public void testScan_file_normal() {
39 ConfigFileScanner scanner = new ConfigFileScanner();
40 String file = ConfigFileScannerTest.class.getResource("/ConfigFileScannerTestData.txt").getFile();
41 Map<String, String> files = scanner.scan(file);
42 assertThat(files.values().iterator().next(), equalTo("isTest=true"));
46 public void testScan_file_empty() {
47 ConfigFileScanner scanner = new ConfigFileScanner();
48 String file = ConfigFileScannerTest.class.getResource("/ConfigFileScannerEmpty.txt").getFile();
49 Map<String, String> files = scanner.scan(file);
50 assertThat(files.size(), is(0));
54 public void testScan_directory_normal() {
55 ConfigFileScanner scanner = new ConfigFileScanner();
56 String file = ConfigFileScannerTest.class.getResource("/").getFile();
57 Map<String, String> files = scanner.scan(file);
58 assertThat(files.size(), is(5));