blob: 1072d965e78ac582ffd81ad3afdf948b674f901c (
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
|
// Copyright Vespa.ai. 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.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
*/
public class ConfigURITest {
@Test
public void testDefaultUri() {
ConfigURI uri = ConfigURI.createFromId("foo");
assertEquals("foo", uri.getConfigId());
assertTrue(uri.getSource() instanceof ConfigSourceSet);
}
@Test
public void testFileUri() throws IOException {
File file = File.createTempFile("foo", ".cfg");
ConfigURI uri = ConfigURI.createFromId("file:" + file.getAbsolutePath());
assertTrue(uri.getConfigId().isEmpty());
assertTrue(uri.getSource() instanceof FileSource);
}
@Test
public void testDirUri() throws IOException {
ConfigURI uri = ConfigURI.createFromId("dir:.");
assertTrue(uri.getConfigId().isEmpty());
assertTrue(uri.getSource() instanceof DirSource);
}
@Test
public void testCustomUri() {
ConfigURI uri = ConfigURI.createFromIdAndSource("foo", new ConfigSet());
assertEquals("foo", uri.getConfigId());
assertTrue(uri.getSource() instanceof ConfigSet);
}
}
|