blob: 071b4b17916b00a8ae7163b6149f04b4a1a03474 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.di;
import com.yahoo.config.subscription.ConfigSource;
import com.yahoo.config.subscription.DirSource;
import com.yahoo.config.subscription.FileSource;
import org.junit.jupiter.api.Assertions;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
/**
* @author Tony Vaagenes
* @author gjoranv
* @author ollivir
*/
class DirConfigSource {
private final File tempFolder;
DirConfigSource(File tmpDir) {
this.tempFolder = tmpDir;
}
void writeConfig(String name, String contents) {
try {
Files.writeString(tempFolder.toPath().resolve(name + ".cfg"), contents);
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
String configId() {
return "dir:" + tempFolder.getPath();
}
ConfigSource configSource() {
return new DirSource(tempFolder);
}
}
|