public static void init(Path config) { HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setPath(config).build(); if (!Files.exists(config)) { CommentedConfigurationNode node = loader.createEmptyNode(); createDefaults(node); try {
@Test public void testHeaderSaved(@TempDirectory.TempDir Path tempDir) throws IOException { final Path saveTo = tempDir.resolve("text3.txt"); HoconConfigurationLoader loader = HoconConfigurationLoader.builder() .setPath(saveTo) .build(); CommentedConfigurationNode node = loader.createEmptyNode(ConfigurationOptions.defaults().setHeader("Hi! I am a header!\n" + "Look at meeeeeee!!!")); node.getNode("node").setComment("I have a comment").getNode("party").setValue("now"); loader.save(node); assertEquals(Resources.readLines(getClass().getResource("/header.conf"), UTF_8), Files.readAllLines(saveTo, UTF_8)); }
@Test public void testBooleansNotShared(@TempDirectory.TempDir Path tempDir) throws IOException { URL url = getClass().getResource("/comments-test.conf"); final Path saveTo = tempDir.resolve("text4.txt"); HoconConfigurationLoader loader = HoconConfigurationLoader.builder() .setPath(saveTo).setURL(url).build(); CommentedConfigurationNode node = loader.createEmptyNode(ConfigurationOptions.defaults()); node.getNode("test", "third").setValue(false).setComment("really?"); node.getNode("test", "apple").setComment("fruit").setValue(false); node.getNode("test", "donut").setValue(true).setComment("tasty"); node.getNode("test", "guacamole").setValue(true).setComment("and chips?"); loader.save(node); assertEquals(Resources.readLines(url, UTF_8), Files.readAllLines(saveTo, UTF_8)); }