### Question:
ServletContextPropertyWroConfigurationFactory implements ObjectFactory<WroConfiguration> { public final WroConfiguration create() { return new PropertyWroConfigurationFactory(createProperties()).create(); } ServletContextPropertyWroConfigurationFactory(final ServletContext servletContext); final WroConfiguration create(); Properties createProperties();  }### Answer:
@Test public void shouldBuildDefaultConfigurationWhenConfigStreamIsUnavailable() { Mockito.when(mockServletContext.getResourceAsStream(Mockito.anyString())).thenThrow(new RuntimeException("BOOM!")); victim = new ServletContextPropertyWroConfigurationFactory(mockServletContext); Assert.assertNotNull(victim.create()); }
@Test public void shouldBuildDefaultConfigurationWhenConfigStreamIsNull() { Mockito.when(mockServletContext.getResourceAsStream(Mockito.anyString())).thenReturn(null); victim = new ServletContextPropertyWroConfigurationFactory(mockServletContext); Assert.assertNotNull(victim.create()); }
@Test public void shouldCreateConfigFromValidLocation() { Assert.assertNotNull(victim.create()); }
@Test public void shouldCreateConfigOverridenPath() { victim = new ServletContextPropertyWroConfigurationFactory(mockServletContext) { @Override protected String getConfigPath() { return "/path/to/another/config.properties"; } }; Assert.assertNotNull(victim.create()); }
@Test public void shouldCreateConfigFromValidLocationAndOverrideAProperty() throws Exception { final long connectionTimeout = 10000; final Properties props = new Properties(); props.setProperty(ConfigConstants.connectionTimeout.name(), String.valueOf(connectionTimeout)); final StringWriter propertiesWriter = new StringWriter(); props.store(new WriterOutputStream(propertiesWriter), ""); Mockito.when(mockServletContext.getResourceAsStream(Mockito.anyString())).thenReturn( new ByteArrayInputStream(propertiesWriter.toString().getBytes())); Assert.assertEquals(connectionTimeout, victim.create().getConnectionTimeout()); }