DSpaceConfigurationService implements ConfigurationService { @Override public <T> T getPropertyAsType(String name, Class<T> type) { return convert(name, type); } DSpaceConfigurationService();  DSpaceConfigurationService(String providedHome); @Override Properties getProperties(); @Override List<String> getPropertyKeys(); @Override List<String> getPropertyKeys(String prefix); @Override Configuration getConfiguration(); @Override Object getPropertyValue(String name); @Override String getProperty(String name); @Override String getProperty(String name, String defaultValue); @Override String[] getArrayProperty(String name); @Override String[] getArrayProperty(String name, String[] defaultValue); @Override boolean getBooleanProperty(String name); @Override boolean getBooleanProperty(String name, boolean defaultValue); @Override int getIntProperty(String name); @Override int getIntProperty(String name, int defaultValue); @Override long getLongProperty(String name); @Override long getLongProperty(String name, long defaultValue); @Override T getPropertyAsType(String name, Class<T> type); @Override T getPropertyAsType(String name, T defaultValue); @Override T getPropertyAsType(String name, T defaultValue, boolean setDefaultIfNotFound); @Override boolean hasProperty(String name); @Override synchronized boolean setProperty(String name, Object value); String[] loadConfiguration(Map<String, Object> properties); boolean loadConfig(String key, Object value); void clear(); void clearConfig(String key); @Override synchronized void reloadConfig(); @Override String toString(); static final String DSPACE; static final String EXT_CONFIG; static final String DOT_CONFIG; static final String DSPACE_HOME; static final String DEFAULT_CONFIG_DIR; static final String DEFAULT_CONFIG_DEFINITION_FILE; static final String DSPACE_CONFIG_DEFINITION_PATH; static final String DSPACE_CONFIG_PATH; static final String DSPACE_SERVER_ID; }
@Test public void testGetPropertyAsTypeStringT() { String prop = configurationService.getPropertyAsType("service.name", "DeeSpace"); assertNotNull(prop); assertEquals("DSpace", prop); String[] array = configurationService.getPropertyAsType("sample.array", new String[] {"A","B"}); assertNotNull(array); assertEquals("itemA", array[0]); assertEquals("itemB", array[1]); assertEquals("itemC", array[2]); Integer number = configurationService.getPropertyAsType("sample.number", new Integer(12345)); assertNotNull(number); assertEquals(new Integer(123), number); Boolean bool = configurationService.getPropertyAsType("sample.boolean", Boolean.FALSE); assertNotNull(bool); assertEquals(Boolean.TRUE, bool); boolean b = configurationService.getPropertyAsType("sample.boolean", false); assertTrue(b); prop = configurationService.getPropertyAsType("XXXXX", "XXX"); assertEquals("XXX", prop); prop = null; }
@Test public void testGetPropertyAsTypeStringClassOfT() { String prop = configurationService.getPropertyAsType("service.name", String.class); assertNotNull(prop); assertEquals("DSpace", prop); String[] array = configurationService.getPropertyAsType("sample.array", String[].class); assertNotNull(array); assertEquals("itemA", array[0]); assertEquals("itemB", array[1]); assertEquals("itemC", array[2]); Integer number = configurationService.getPropertyAsType("sample.number", Integer.class); assertNotNull(number); assertEquals(new Integer(123), number); Boolean bool = configurationService.getPropertyAsType("sample.boolean", Boolean.class); assertNotNull(bool); assertEquals(Boolean.TRUE, bool); Boolean bool2 = configurationService.getPropertyAsType("INVALID.PROPERTY", Boolean.class); assertNotNull(bool2); assertEquals(Boolean.FALSE, bool2); boolean bool3 = configurationService.getPropertyAsType("INVALID.PROPERTY", boolean.class); assertNotNull(bool3); assertEquals(false, bool3); assertEquals(123, (int) configurationService.getPropertyAsType("sample.number", int.class) ); assertEquals(true, (boolean) configurationService.getPropertyAsType("sample.boolean", boolean.class) ); prop = configurationService.getPropertyAsType("XXXXX", String.class); assertNull(prop); prop = null; }