public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
Properties props = new Properties(); props.load(new FileInputStream(configFile)); configurable.clear(); for (Object key : props.keySet()) { configurable.setProperty(key.toString(), props.getProperty(key.toString())); logger.info("Config file for "+configurable.getName()+" not yet created. Creating with default values."); configurable.restoreDefaults(); store(configurable); logger.error("There was a error reading the configuration file for "+configurable.getName()+", using defaults",e); configurable.restoreDefaults();
@Test public void testRemoveNotDefaultValue() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); conf.setProperty("hhh", "iii"); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertEquals("The stored file should contain the new entry","iii",props.get("hhh")); conf.deleteProperty("hhh"); manager.store(conf); manager.populate(conf); assertNull("The removed value should no longer exist",conf.getProperty("hhh")); props.clear(); props.load(new FileInputStream(configFile)); assertNull("The stored file should no longer contain the deleted entry",props.get("hhh")); }
@Test public void testNewValues() throws Exception { Configurable conf = DummyConfigurable.getInstance(); conf.setProperty("country", "france"); ConfigurationManager manager = ConfigurationManager.getInstance(); assertEquals("country should equal france","france",conf.getProperty("country")); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertTrue("stored properties should contain the default value",props.containsKey("country")); assertEquals("stored property country should equal france","france",props.getProperty("country")); manager.populate(conf); assertEquals("default property name should still exist after re-populating","france",conf.getProperty("country")); }
@Test public void testDefaultValues() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); assertEquals("name should equal john","john",conf.getProperty("name")); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertFalse("stored properties should not contain the default value",props.containsKey("name")); manager.populate(conf); assertEquals("default property name should still exist after re-populating","john",conf.getProperty("name")); }
@Test public void testRemoveNotDefaultValue() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); conf.setProperty("hhh", "iii"); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertEquals("The stored file should contain the new entry","iii",props.get("hhh")); conf.deleteProperty("hhh"); manager.store(conf); manager.populate(conf); assertNull("The removed value should no longer exist",conf.getProperty("hhh")); props.clear(); props.load(new FileInputStream(configFile)); assertNull("The stored file should no longer contain the deleted entry",props.get("hhh")); }
@Test public void testNewValues() throws Exception { Configurable conf = DummyConfigurable.getInstance(); conf.setProperty("country", "france"); ConfigurationManager manager = ConfigurationManager.getInstance(); assertEquals("country should equal france","france",conf.getProperty("country")); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertTrue("stored properties should contain the default value",props.containsKey("country")); assertEquals("stored property country should equal france","france",props.getProperty("country")); manager.populate(conf); assertEquals("default property name should still exist after re-populating","france",conf.getProperty("country")); }
@Test public void testDefaultValues() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); assertEquals("name should equal john","john",conf.getProperty("name")); manager.store(conf); Properties props = new Properties(); props.load(new FileInputStream(configFile)); assertFalse("stored properties should not contain the default value",props.containsKey("name")); manager.populate(conf); assertEquals("default property name should still exist after re-populating","john",conf.getProperty("name")); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public boolean canHandle(String uuid) { return uuid.equals(getConfigurable().getUUID()); }
public List<ConfigurationUIFactory> getConfigurationUIFactoriesForConfigurable(Configurable configurable) { List<ConfigurationUIFactory> result = new ArrayList<ConfigurationUIFactory>(); for (ConfigurationUIFactory factory : getConfigurationUIFactories()) { if (factory.canHandle(configurable.getUUID())) { result.add(factory); } } return result; }
public boolean canHandle(String uuid) { return getConfigurable().getUUID().equals(uuid); }
public boolean canHandle(String uuid) { return getConfigurable().getUUID().equals(uuid); }
public boolean canHandle(String uuid) { return getConfigurable().getUUID().equals(uuid); }
public boolean canHandle(String uuid) { return getConfigurable().getUUID().equals(uuid); }