@Test void loadProperties_shouldThrowIOE_ifPropertyFileNotExist() { Path pluginsDirWithoutPropertyFile = Paths.get(TEST_DIRECTORY.getAbsolutePath(), "without-property-file"); IOException exception = assertThrows(IOException.class, () -> PropertyLoader.loadProperties(pluginsDirWithoutPropertyFile.toFile())); assertLinesMatch(singletonList("^File '.*' not found$"), singletonList(exception.getMessage())); }
static Properties loadProperties(@Nonnull File pluginsDirectory) throws IOException { if (!pluginsDirectory.exists()) { throw new IOException(format(DIRECTORY_NOT_FOUND_ERROR_MESSAGE, pluginsDirectory.getAbsolutePath())); } File propertyFile = new File(pluginsDirectory, PROPERTY_FILE); if (!propertyFile.exists()) { throw new IOException(format(FILE_NOT_FOUND_ERROR_MESSAGE, propertyFile.getAbsolutePath())); } Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { properties.load(fis); } return properties; }
PropertyLoader { static Properties loadProperties(@Nonnull File pluginsDirectory) throws IOException { if (!pluginsDirectory.exists()) { throw new IOException(format(DIRECTORY_NOT_FOUND_ERROR_MESSAGE, pluginsDirectory.getAbsolutePath())); } File propertyFile = new File(pluginsDirectory, PROPERTY_FILE); if (!propertyFile.exists()) { throw new IOException(format(FILE_NOT_FOUND_ERROR_MESSAGE, propertyFile.getAbsolutePath())); } Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { properties.load(fis); } return properties; } }
PropertyLoader { static Properties loadProperties(@Nonnull File pluginsDirectory) throws IOException { if (!pluginsDirectory.exists()) { throw new IOException(format(DIRECTORY_NOT_FOUND_ERROR_MESSAGE, pluginsDirectory.getAbsolutePath())); } File propertyFile = new File(pluginsDirectory, PROPERTY_FILE); if (!propertyFile.exists()) { throw new IOException(format(FILE_NOT_FOUND_ERROR_MESSAGE, propertyFile.getAbsolutePath())); } Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { properties.load(fis); } return properties; } private  PropertyLoader(); }
PropertyLoader { static Properties loadProperties(@Nonnull File pluginsDirectory) throws IOException { if (!pluginsDirectory.exists()) { throw new IOException(format(DIRECTORY_NOT_FOUND_ERROR_MESSAGE, pluginsDirectory.getAbsolutePath())); } File propertyFile = new File(pluginsDirectory, PROPERTY_FILE); if (!propertyFile.exists()) { throw new IOException(format(FILE_NOT_FOUND_ERROR_MESSAGE, propertyFile.getAbsolutePath())); } Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { properties.load(fis); } return properties; } private  PropertyLoader();  }
PropertyLoader { static Properties loadProperties(@Nonnull File pluginsDirectory) throws IOException { if (!pluginsDirectory.exists()) { throw new IOException(format(DIRECTORY_NOT_FOUND_ERROR_MESSAGE, pluginsDirectory.getAbsolutePath())); } File propertyFile = new File(pluginsDirectory, PROPERTY_FILE); if (!propertyFile.exists()) { throw new IOException(format(FILE_NOT_FOUND_ERROR_MESSAGE, propertyFile.getAbsolutePath())); } Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { properties.load(fis); } return properties; } private  PropertyLoader();   }