From 44227db56e3669b6b1575bf750df815e6903c906 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 20 Jan 2024 18:54:10 +0800 Subject: feature: config file support JSON comment --- .../kbackupfabric/config/KBackupConfigTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/java/com/keuin/kbackupfabric/config/KBackupConfigTest.java (limited to 'src/test/java/com/keuin/kbackupfabric/config/KBackupConfigTest.java') diff --git a/src/test/java/com/keuin/kbackupfabric/config/KBackupConfigTest.java b/src/test/java/com/keuin/kbackupfabric/config/KBackupConfigTest.java new file mode 100644 index 0000000..811156a --- /dev/null +++ b/src/test/java/com/keuin/kbackupfabric/config/KBackupConfigTest.java @@ -0,0 +1,29 @@ +package com.keuin.kbackupfabric.config; + +import com.keuin.kbackupfabric.TestUtils; +import org.junit.Test; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; + +public class KBackupConfigTest { + + @Test + public void load() throws Exception { + String tempDir = TestUtils.getTempDirectory("config_test"); + Files.createDirectories(Paths.get(tempDir)); + Path configPath = Paths.get(tempDir, "test_config.json"); + Files.write( + configPath, + "{\n//comment\n}".getBytes(StandardCharsets.UTF_8), + StandardOpenOption.CREATE, + StandardOpenOption.WRITE, + StandardOpenOption.TRUNCATE_EXISTING + ); + System.out.println(configPath.toFile().getAbsolutePath()); + KBackupConfig.load(configPath.toFile()); + } +} \ No newline at end of file -- cgit v1.2.3