/** * Constructs the AbstractConfigurable by either reading from a previously stored set of properties, * or by using the default values which results in them being stored for subsequent usage. */ public AbstractConfigurable() { try { ConfigurationManager.getInstance().populate(this); } catch (Exception e) { logger.error("There was an error reading the properties for the Configurable:"+getName(),e); } }
protected void store() { try { ConfigurationManager.getInstance().store(this); } catch (Exception e) { logger.error("There was an error storing the new configuration for: "+this.getName(),e); } }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); }
@Before public void setup() { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File d = new File(f, UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); }
@Before public void setup() { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File d = new File(f, UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); }
@BeforeClass public static void setup() { ConfigurationManager.getInstance().setBaseConfigLocation(new File(System.getProperty("java.io.tmpdir"))); }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); DummyConfigurable.getInstance().restoreDefaults(); }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); DummyConfigurable.getInstance().restoreDefaults(); }
@Before public void setup() { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File d = new File(f,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); conf=ActivityPaletteConfiguration.getInstance(); conf.restoreDefaults(); }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); configFile = new File(d,manager.generateFilename(DummyConfigurable.getInstance())); DummyConfigurable.getInstance().restoreDefaults(); }
@Before public void setup() throws Exception { ConfigurationManager manager = ConfigurationManager.getInstance(); File f = new File(System.getProperty("java.io.tmpdir")); File configTestsDir = new File(f,"configTests"); if (!configTestsDir.exists()) configTestsDir.mkdir(); File d = new File(configTestsDir,UUID.randomUUID().toString()); d.mkdir(); manager.setBaseConfigLocation(d); configFile = new File(d,manager.generateFilename(DummyConfigurable.getInstance())); DummyConfigurable.getInstance().restoreDefaults(); }
@Test public void createConfigManager() { ConfigurationManager instance = ConfigurationManager.getInstance(); assertNotNull("Config Manager should not be null", instance); }
@Test public void createConfigManager() { ConfigurationManager instance = ConfigurationManager.getInstance(); assertNotNull("Config Manager should not be null", instance); }
@SuppressWarnings("unchecked") @Test public void testSingleItem() throws Exception { List<String> list = new ArrayList<String>(); list.add("fred"); conf.setPropertyStringList("single", list); ConfigurationManager.getInstance().store(conf); ConfigurationManager.getInstance().populate(conf); assertTrue("should be an ArrayList",conf.getPropertyStringList("single") instanceof List); List<String> l = conf.getPropertyStringList("single"); assertEquals("There should be 1 element",1,l.size()); assertEquals("Its value should be fred","fred",l.get(0)); }
@Test public void testStore() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); manager.store(conf); assertTrue(configFile.exists()); }
@Test public void testStore() throws Exception { Configurable conf = DummyConfigurable.getInstance(); ConfigurationManager manager = ConfigurationManager.getInstance(); manager.store(conf); assertTrue(configFile.exists()); }
@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 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")); }
@SuppressWarnings("unchecked") @Test public void testEmptyList() throws Exception { conf.setPropertyStringList("list", new ArrayList<String>()); assertTrue("Result was not a list but was:"+conf.getProperty("list"),conf.getPropertyStringList("list") instanceof List); ConfigurationManager.getInstance().store(conf); ConfigurationManager.getInstance().populate(conf); assertTrue("Result was not a list but was:"+conf.getPropertyStringList("list"),conf.getPropertyStringList("list") instanceof List); List<String> list = conf.getPropertyStringList("list"); assertEquals("There should be 0 elements",0,list.size()); }