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.utils;
19 import org.junit.Test;
20 import org.onap.holmes.common.ConfigFileScanner;
21 import org.onap.holmes.common.ConfigFileScannerTest;
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.*;
30 public class FileUtilsTest {
33 public void readTextFile_normal() {
34 String path = FileUtilsTest.class.getResource("/ConfigFileScannerTestData.txt").getFile();
35 assertThat(FileUtils.readTextFile(path), equalTo("isTest=true"));
39 public void readTextFile_not_found_exception() {
40 assertThat(FileUtils.readTextFile("a-non-exist-path"), nullValue());
44 public void readTextFile_directory(){
45 assertThat(FileUtils.readTextFile("/"), nullValue());