@Test
public void testNodeFactoryProperties() throws Exception {
NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.newInstance();
factory.init();
UtilityExtensionPoint utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
Properties ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(0, ps.size());
Properties properties = new Properties();
properties.setProperty("defaultScheme", "vm");
properties.setProperty("foo.bla", "some value");
factory = (NodeFactoryImpl)NodeFactory.newInstance(properties);
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(2, ps.size());
Assert.assertEquals("some value", ps.getProperty("foo.bla"));
factory = (NodeFactoryImpl)NodeFactory.newInstance("properties:test.properties");
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(2, ps.size());
Assert.assertEquals("xyz", ps.getProperty("foo.bla"));
factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:foo?k1=v1&k2=v2&defaultScheme=vm");
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(4, ps.size());
Assert.assertEquals("vm", ps.getProperty("defaultScheme"));
Assert.assertEquals("foo", ps.getProperty("defaultDomainName"));
Assert.assertEquals("v1", ps.getProperty("k1"));
Assert.assertEquals("v2", ps.getProperty("k2"));
factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:");
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(1, ps.size());
Assert.assertEquals("", ps.getProperty("defaultDomainName"));
factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:?");
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(1, ps.size());
Assert.assertEquals("default", ps.getProperty("defaultDomainName"));
factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:?foo");
factory.init();
utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
ps = utilities.getUtility(RuntimeProperties.class).getProperties();
Assert.assertEquals(2, ps.size());
Assert.assertEquals("default", ps.getProperty("defaultDomainName"));
Assert.assertEquals("", ps.getProperty("foo"));
}