@Test public void testOpenJPASample() throws IOException { File props = new File(root, "/openjpa-sample.properties"); File hocon = Properties2HoconConverter.convert(props, true); Config config = load(hocon); assertThat(config.isEmpty()).isFalse(); assertThat(config.getString("application.secret")).isEqualTo ("8pHS=Y/GI>fmUU=LVPKfrgilk^hBk?aOB0a4CFLCg@JX=JHwTvsc7g;QQWl?;IDO"); assertThat(config.getBoolean("monitor.http.enabled")).isTrue(); assertThat(config.getBoolean("monitor.jmx.enabled")).isTrue(); assertThat(config.getBoolean("monitor.auth.enabled")).isTrue(); assertThat(config.getString("monitor.auth.username")).isEqualTo("admin"); assertThat(config.getString("monitor.auth.password")).isEqualTo("admin"); assertThat(config.getBoolean("documentation.standalone")).isFalse(); assertThat(config.getString("db.todo.driver")).isEqualTo("org.h2.Driver"); assertThat(config.getString("db.todo.url")).isEqualTo("jdbc:h2:database/todo.db"); }
public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException("The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } if (backup) { try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; }
Properties2HoconConverter { public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException("The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } if (backup) { try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; } }
Properties2HoconConverter { public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException("The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } if (backup) { try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; } private  Properties2HoconConverter(); }
Properties2HoconConverter { public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException("The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } if (backup) { try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; } private  Properties2HoconConverter(); static File convert(File props, boolean backup); static String convertToHocon(File props); }
Properties2HoconConverter { public static File convert(File props, boolean backup) throws IOException { if (!props.isFile()) { throw new IllegalArgumentException("The given properties file does not exist : " + props.getAbsolutePath()); } Properties properties; try { properties = readFileAsProperties(props); } catch (IOException e) { throw new IllegalArgumentException("Cannot convert " + props.getName() + " to hocon - the file is not a " + "valid properties file", e); } if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Cannot convert an empty file : " + props.getAbsolutePath()); } if (backup) { try { generateBackup(props); } catch (IOException e) { throw new IllegalStateException("Cannot generate the backup for " + props.getName(), e); } } String hocon = convertToHocon(props); File output = props; if (!props.getName().endsWith(".conf")) { output = new File(props.getParentFile(), props.getName().substring(0, props.getName().lastIndexOf(".")) + ".conf"); } FileUtils.write(output, hocon); return output; } private  Properties2HoconConverter(); static File convert(File props, boolean backup); static String convertToHocon(File props);  }