@Test public void initCalledForConfigurable() { Properties properties = unitilsConfiguration.getProperties(); properties.setProperty( TestInterface.class.getName() + ".implClassName", TestClass.class.getName()); TestInterface result = unitilsConfiguration.getInstanceOf(TestInterface.class); assertSame(properties, ((TestClass) result).configuration); }
@Test public void foundWithDefault() { StringBuffer defaultInstance = new StringBuffer(); StringBuffer result = unitilsConfiguration.getInstance("instanceProperty", defaultInstance); assertNotNull(result); assertNotSame(defaultInstance, result); }
@Test public void invalidClassNameWithoutDefault() { try { unitilsConfiguration.getInstance("invalidClassNameProperty"); fail("Expected UnitilsException"); } catch (UnitilsException e) { // expected } }
@Test public void notFoundNoDefault() { try { unitilsConfiguration.getInstance("xxx"); fail("Expected UnitilsException"); } catch (UnitilsException e) { // expected } }
@Test public void nullDefault() { String result = unitilsConfiguration.getInstance("xxx", null); assertNull(result); }
@Test public void notFoundWithDefault() { StringBuffer defaultInstance = new StringBuffer(); StringBuffer result = unitilsConfiguration.getInstance("xxx", defaultInstance); assertSame(defaultInstance, result); }
@Test public void trimmedWithDefault() { StringBuffer result = unitilsConfiguration.getInstance("propertyWithSpaces", new StringBuffer()); assertNotNull(result); }
@Test public void foundWithoutDefault() { StringBuffer result = unitilsConfiguration.getInstance("instanceProperty"); assertNotNull(result); }