@Test void addDefaultAdditionalLocation() { String loc = ProjectForgeApplication.getAddtionalLocationArg(null); if (ProjectForgeApplication.addDefaultAdditionalLocation(null, null) == null) { log.warn("Found application{-default}.properties in current working directory (you should move it to ~/ProjectForge/projectforge.properties). Can't process with this text (OK)."); return; } checkArray(new String[]{loc}, null); checkArray(new String[]{loc}, new String[]{}); checkArray(new String[]{"spring.datasource.driver-class-name=org.postgresql.Driver", loc}, new String[]{"spring.datasource.driver-class-name=org.postgresql.Driver"}); checkArray(new String[]{"--spring.config.additional-location=file:/opt/projectforge/test.properties"}, new String[]{"--spring.config.additional-location=file:/opt/projectforge/test.properties"}); checkArray(new String[]{"hurzel", "--spring.config.additional-location=file:/opt/projectforge/test.properties"}, new String[]{"hurzel", "--spring.config.additional-location=file:/opt/projectforge/test.properties"}); }
static String[] addDefaultAdditionalLocation(File baseDir, String[] args) { checkConfiguration("config", "application-default.properties"); checkConfiguration("config", "application.properties"); checkConfiguration(".", "application-default.properties"); checkConfiguration(".", "application.properties"); if (baseDir == null || !checkConfiguration(CanonicalFileUtils.absolutePath(baseDir), PROPERTIES_FILENAME)) { return args; } boolean additionalLocationFound = false; if (args == null || args.length == 0) { args = new String[]{getAddtionalLocationArg(baseDir)}; } else { for (String arg : args) { if (arg != null && arg.startsWith(ADDITIONAL_LOCATION_ARG)) { additionalLocationFound = true; break; } } if (!additionalLocationFound) { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = getAddtionalLocationArg(baseDir); } } return args; }
ProjectForgeApplication { static String[] addDefaultAdditionalLocation(File baseDir, String[] args) { checkConfiguration("config", "application-default.properties"); checkConfiguration("config", "application.properties"); checkConfiguration(".", "application-default.properties"); checkConfiguration(".", "application.properties"); if (baseDir == null || !checkConfiguration(CanonicalFileUtils.absolutePath(baseDir), PROPERTIES_FILENAME)) { return args; } boolean additionalLocationFound = false; if (args == null || args.length == 0) { args = new String[]{getAddtionalLocationArg(baseDir)}; } else { for (String arg : args) { if (arg != null && arg.startsWith(ADDITIONAL_LOCATION_ARG)) { additionalLocationFound = true; break; } } if (!additionalLocationFound) { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = getAddtionalLocationArg(baseDir); } } return args; } }
ProjectForgeApplication { static String[] addDefaultAdditionalLocation(File baseDir, String[] args) { checkConfiguration("config", "application-default.properties"); checkConfiguration("config", "application.properties"); checkConfiguration(".", "application-default.properties"); checkConfiguration(".", "application.properties"); if (baseDir == null || !checkConfiguration(CanonicalFileUtils.absolutePath(baseDir), PROPERTIES_FILENAME)) { return args; } boolean additionalLocationFound = false; if (args == null || args.length == 0) { args = new String[]{getAddtionalLocationArg(baseDir)}; } else { for (String arg : args) { if (arg != null && arg.startsWith(ADDITIONAL_LOCATION_ARG)) { additionalLocationFound = true; break; } } if (!additionalLocationFound) { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = getAddtionalLocationArg(baseDir); } } return args; }  }
ProjectForgeApplication { static String[] addDefaultAdditionalLocation(File baseDir, String[] args) { checkConfiguration("config", "application-default.properties"); checkConfiguration("config", "application.properties"); checkConfiguration(".", "application-default.properties"); checkConfiguration(".", "application.properties"); if (baseDir == null || !checkConfiguration(CanonicalFileUtils.absolutePath(baseDir), PROPERTIES_FILENAME)) { return args; } boolean additionalLocationFound = false; if (args == null || args.length == 0) { args = new String[]{getAddtionalLocationArg(baseDir)}; } else { for (String arg : args) { if (arg != null && arg.startsWith(ADDITIONAL_LOCATION_ARG)) { additionalLocationFound = true; break; } } if (!additionalLocationFound) { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = getAddtionalLocationArg(baseDir); } } return args; }  static void main(String[] args); static File giveUpAndSystemExit(); static File giveUpAndSystemExit(String message); }
ProjectForgeApplication { static String[] addDefaultAdditionalLocation(File baseDir, String[] args) { checkConfiguration("config", "application-default.properties"); checkConfiguration("config", "application.properties"); checkConfiguration(".", "application-default.properties"); checkConfiguration(".", "application.properties"); if (baseDir == null || !checkConfiguration(CanonicalFileUtils.absolutePath(baseDir), PROPERTIES_FILENAME)) { return args; } boolean additionalLocationFound = false; if (args == null || args.length == 0) { args = new String[]{getAddtionalLocationArg(baseDir)}; } else { for (String arg : args) { if (arg != null && arg.startsWith(ADDITIONAL_LOCATION_ARG)) { additionalLocationFound = true; break; } } if (!additionalLocationFound) { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = getAddtionalLocationArg(baseDir); } } return args; }  static void main(String[] args); static File giveUpAndSystemExit(); static File giveUpAndSystemExit(String message); static final String PROPERTIES_FILENAME; static final String CLASSPATH_INITIAL_PROPERTIES_FILENAME; }