Added some tools for DCAE CBS removal
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / utils / FileUtilsTest.java
1 /**
2  * Copyright 2021 ZTE Corporation.
3  * <p>
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
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
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.
15  */
16
17 package org.onap.holmes.common.utils;
18
19 import org.junit.Test;
20 import org.onap.holmes.common.ConfigFileScanner;
21 import org.onap.holmes.common.ConfigFileScannerTest;
22
23 import java.util.Map;
24
25 import static org.hamcrest.core.Is.is;
26 import static org.hamcrest.core.IsEqual.equalTo;
27 import static org.hamcrest.core.IsNull.nullValue;
28 import static org.junit.Assert.*;
29
30 public class FileUtilsTest {
31
32     @Test
33     public void readTextFile_normal() {
34         String path = FileUtilsTest.class.getResource("/ConfigFileScannerTestData.txt").getFile();
35         assertThat(FileUtils.readTextFile(path), equalTo("isTest=true"));
36     }
37
38     @Test
39     public void readTextFile_not_found_exception() {
40         assertThat(FileUtils.readTextFile("a-non-exist-path"), nullValue());
41     }
42
43     @Test
44     public void readTextFile_directory(){
45         assertThat(FileUtils.readTextFile("/"), nullValue());
46     }
47 }