diff options
author | jonmv <venstad@gmail.com> | 2022-11-01 23:39:22 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-11-01 23:39:22 +0100 |
commit | 2619a4060c8b0e5cbb653942762313394ec6c59e (patch) | |
tree | 90ed40b9e7f1d8f6b62fab13b7bd414b3da9ed42 /container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java | |
parent | 116afffc4920705f8d0ce2b016700216a2a0cbb3 (diff) |
Cleanup, no effective changes
Diffstat (limited to 'container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java')
-rw-r--r-- | container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java b/container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java index 39b50c66244..7704827311c 100644 --- a/container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java +++ b/container-core/src/test/java/com/yahoo/container/di/DirConfigSource.java @@ -19,30 +19,24 @@ import static java.nio.charset.StandardCharsets.UTF_8; * @author gjoranv * @author ollivir */ -public class DirConfigSource { +class DirConfigSource { private final File tempFolder; - public final ConfigSource configSource; // TODO jonmv: remove, unused - public DirConfigSource(File tmpDir, String testSourcePrefix) { + DirConfigSource(File tmpDir) { this.tempFolder = tmpDir; - this.configSource = new ConfigSourceSet(testSourcePrefix + new Random().nextLong()); } - public void writeConfig(String name, String contents) { - File file = new File(tempFolder, name + ".cfg"); - if (!file.exists()) { - try { - file.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } + void writeConfig(String name, String contents) { + try { + Files.writeString(tempFolder.toPath().resolve(name + ".cfg"), contents); + } + catch (IOException e) { + throw new UncheckedIOException(e); } - - printFile(file, contents + "\n"); } - public String configId() { + String configId() { return "dir:" + tempFolder.getPath(); } @@ -50,12 +44,5 @@ public class DirConfigSource { return configSource; } - private static void printFile(File f, String content) { - try (OutputStream out = new FileOutputStream(f)) { - out.write(content.getBytes(UTF_8)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } } |