@Test public void testOpenSystemSpecifiedConfigFileMalformed() throws Exception { System.setProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY, TEST_TXT); final InputStream is = DriverConfig.openConfigFile(); assertNotNull(is); final String line = readFirstLine(is); assertTrue(line.contains("HELLO")); is.close(); }
static InputStream openConfigFile() { String location = System.getProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY); if (location == null) { LOGGER.debug("No System property " + PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY + " defined, looking for config at " + PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION); location = PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION; } InputStream configFileStream = openConfigFile(location); if (configFileStream == null) { location = PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION; configFileStream = openConfigFile(location); if (configFileStream == null) { throw new RuntimeException( "Unexpected: cannot find " + PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION); } } LOGGER.info("Using config file " + location); return configFileStream; }
DriverConfig { static InputStream openConfigFile() { String location = System.getProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY); if (location == null) { LOGGER.debug("No System property " + PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY + " defined, looking for config at " + PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION); location = PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION; } InputStream configFileStream = openConfigFile(location); if (configFileStream == null) { location = PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION; configFileStream = openConfigFile(location); if (configFileStream == null) { throw new RuntimeException( "Unexpected: cannot find " + PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION); } } LOGGER.info("Using config file " + location); return configFileStream; } }
DriverConfig { static InputStream openConfigFile() { String location = System.getProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY); if (location == null) { LOGGER.debug("No System property " + PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY + " defined, looking for config at " + PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION); location = PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION; } InputStream configFileStream = openConfigFile(location); if (configFileStream == null) { location = PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION; configFileStream = openConfigFile(location); if (configFileStream == null) { throw new RuntimeException( "Unexpected: cannot find " + PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION); } } LOGGER.info("Using config file " + location); return configFileStream; }  }
DriverConfig { static InputStream openConfigFile() { String location = System.getProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY); if (location == null) { LOGGER.debug("No System property " + PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY + " defined, looking for config at " + PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION); location = PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION; } InputStream configFileStream = openConfigFile(location); if (configFileStream == null) { location = PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION; configFileStream = openConfigFile(location); if (configFileStream == null) { throw new RuntimeException( "Unexpected: cannot find " + PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION); } } LOGGER.info("Using config file " + location); return configFileStream; }  @Nullable Integer getServerPort(); List<InetSocketAddress> getClientAddresses(); @Nullable String getClassNameForJdbcUrl(final String jdbcUrl); }
DriverConfig { static InputStream openConfigFile() { String location = System.getProperty(PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY); if (location == null) { LOGGER.debug("No System property " + PerfLoggerConstants.CONFIG_FILE_LOCATION_PROP_KEY + " defined, looking for config at " + PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION); location = PerfLoggerConstants.CONFIG_FILE_DEFAULT_LOCATION; } InputStream configFileStream = openConfigFile(location); if (configFileStream == null) { location = PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION; configFileStream = openConfigFile(location); if (configFileStream == null) { throw new RuntimeException( "Unexpected: cannot find " + PerfLoggerConstants.CONFIG_FILE_FALLBACK_LOCATION); } } LOGGER.info("Using config file " + location); return configFileStream; }  @Nullable Integer getServerPort(); List<InetSocketAddress> getClientAddresses(); @Nullable String getClassNameForJdbcUrl(final String jdbcUrl); final static DriverConfig INSTANCE; }