blob: 2e2c9c0a0a9b3f5b07daacb7ae0af9085ddd1e4e (
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 org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* @author lulf
* @since 5.1
*/
public class ConfigURITest {
@Test
public void testDefaultUri() {
ConfigURI uri = ConfigURI.createFromId("foo");
assertThat(uri.getConfigId(), is("foo"));
assertTrue(uri.getSource() instanceof ConfigSourceSet);
}
@Test
public void testFileUri() throws IOException {
File file = File.createTempFile("foo", ".cfg");
ConfigURI uri = ConfigURI.createFromId("file:" + file.getAbsolutePath());
assertThat(uri.getConfigId(), is(""));
assertTrue(uri.getSource() instanceof FileSource);
}
@Test
public void testDirUri() throws IOException {
ConfigURI uri = ConfigURI.createFromId("dir:.");
assertThat(uri.getConfigId(), is(""));
assertTrue(uri.getSource() instanceof DirSource);
}
@Test
public void testCustomUri() {
ConfigURI uri = ConfigURI.createFromIdAndSource("foo", new ConfigSet());
assertThat(uri.getConfigId(), is("foo"));
assertTrue(uri.getSource() instanceof ConfigSet);
}
}
|