blob: 00f7d23bedf83d31236799b30e43f427cebe1a96 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription;
import com.yahoo.foo.SimpletypesConfig;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Ulf Lilleengen
*/
public class ConfigSourceTest {
@Test(expected = IllegalArgumentException.class)
public void require_that_FileSource_throws_exception_on_invalid_file() {
new FileSource(new File("invalid"));
}
@Test(expected = IllegalArgumentException.class)
public void require_that_DirSource_throws_exception_on_invalid_dir() {
new DirSource(new File("invalid"));
}
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
@Test
public void require_that_DirSource_throws_exception_on_missing_file() throws IOException {
File folder = tmpDir.newFolder();
DirSource dirSource = new DirSource(folder);
try {
ConfigGetter.getConfig(SimpletypesConfig.class, "dir:" + tmpDir, dirSource);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Could not find a config file for '" + SimpletypesConfig.getDefName() + "' in '" + folder + "/'",
e.getMessage());
}
}
}
|