PropertyLoader { public void loadProperties() { properties = propertiesFactory.createProperties(); try { checkPropertyFileArgument(configFile); loadExternalProperties(configFile, properties); propertyReader.setProperties(properties); logger.debug("Properties loaded from external configuration."); } catch (IOException e) { throw new PropertiesNotAvailableException("Configuration file " + configFile + " cannot be loaded", e); } }  void loadProperties(); void loadValidationProperties();  }
@Test(expectedExceptions = PropertiesNotAvailableException.class) public void testLoadPropertiesWhenProgramArgumentEmptyShouldThrowException() { Whitebox.setInternalState(underTest, "configFile", ""); underTest.loadProperties(); }
@Test(expectedExceptions = PropertiesNotAvailableException.class) public void testLoadPropertiesWhenProgramArgumentInvalidShouldThrowException() { Whitebox.setInternalState(underTest, "configFile", "wilma.conf.prop"); underTest.loadProperties(); }
@Test public void testLoadPropertiesWhenArgumentsAreValidShouldLoadProperties() throws IOException { underTest.loadProperties(); verify(properties).load(inputStream); }
@Test public void testLoadPropertiesWhenArgumentsAreValidShouldCallPropertyReader() { underTest.loadProperties(); verify(propertyReader).setProperties(properties); }
@Test(expectedExceptions = PropertiesNotAvailableException.class) public void testLoadPropertiesWhenFileNotFoundShouldThrowException() throws Exception { given(inputStreamFactory.createFileInputStream(configFile)).willThrow(new FileNotFoundException()); underTest.loadProperties(); }
@Test(expectedExceptions = PropertiesNotAvailableException.class) public void testLoadPropertiesWhenIOExcpetionShouldThrowException() throws Exception { willThrow(new IOException()).given(properties).load(inputStream); underTest.loadProperties(); }