blob: 0f00b7590946d76bd8cc7c0423bada49dadd5a31 [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.lib.util;
15
Ulf Adams795895a2015-03-06 15:58:35 +000016import static com.google.common.truth.Truth.assertThat;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010017import static org.junit.Assert.fail;
18
lberki78cfa8d2017-05-30 17:00:48 +020019import java.io.IOException;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020import org.junit.Test;
21import org.junit.runner.RunWith;
22import org.junit.runners.JUnit4;
23
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010024/**
25 * A test for {@link ResourceFileLoader}.
26 */
27@RunWith(JUnit4.class)
28public class ResourceFileLoaderTest {
29
30 @Test
31 public void loader() throws IOException {
32 String message = ResourceFileLoader.loadResource(
33 ResourceFileLoaderTest.class, "ResourceFileLoaderTest.message");
lberki78cfa8d2017-05-30 17:00:48 +020034 assertThat(message).isEqualTo("Hello, world.");
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010035 }
36
37 @Test
38 public void resourceNotFound() {
39 try {
40 ResourceFileLoader.loadResource(ResourceFileLoaderTest.class,
41 "does_not_exist.txt");
42 fail();
43 } catch (IOException e) {
Ulf Adams795895a2015-03-06 15:58:35 +000044 assertThat(e).hasMessage("does_not_exist.txt not found.");
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010045 }
46 }
47
48}