List of usage examples for org.apache.commons.configuration XMLConfiguration setRootElementName
public void setRootElementName(String name)
From source file:org.onosproject.net.driver.XmlDriverLoader.java
/** * Loads the specified drivers resource as an XML stream and parses it to * produce a ready-to-register driver provider. * * @param driversStream stream containing the drivers definitions * @param resolver driver resolver//from w w w . j a va 2 s .co m * @return driver provider * @throws java.io.IOException if issues are encountered reading the stream * or parsing the driver definitions within */ public DefaultDriverProvider loadDrivers(InputStream driversStream, DriverResolver resolver) throws IOException { try { XMLConfiguration cfg = new XMLConfiguration(); cfg.setRootElementName(DRIVERS); cfg.setAttributeSplittingDisabled(true); cfg.load(driversStream); return loadDrivers(cfg, resolver); } catch (ConfigurationException e) { throw new IOException("Unable to load drivers", e); } }
From source file:org.pivot4j.ui.condition.ExpressionConditionTest.java
@Test public void testSettingsManagement() throws ConfigurationException { TableRenderContext context = createDummyRenderContext(); context.setColIndex(2);/* ww w .ja va 2 s. co m*/ context.setRowIndex(1); context.setAxis(Axis.ROWS); String expression = "<#if columnIndex = 2 && rowIndex = 1>true</#if>"; ExpressionCondition condition = new ExpressionCondition(conditionFactory); condition.setExpression(expression); XMLConfiguration configuration = new XMLConfiguration(); configuration.setRootElementName("condition"); condition.saveSettings(configuration); condition = new ExpressionCondition(conditionFactory); condition.restoreSettings(configuration); assertThat("Expression has been changed.", condition.getExpression(), is(equalTo(expression))); assertThat("Expression '" + expression + "' should be true.", condition.matches(context), is(true)); System.out.println("Saved configuration : "); configuration.save(System.out); }
From source file:org.pivot4j.ui.property.ConditionalPropertyTest.java
@Test public void testSettingsManagement() throws ConfigurationException { XMLConfiguration configuration = new XMLConfiguration(); configuration.setRootElementName("property"); property.saveSettings(configuration); System.out.println("Saved configuration : "); configuration.save(System.out); ConditionalRenderProperty property2 = new ConditionalRenderProperty(new DefaultConditionFactory()); property2.restoreSettings(configuration); assertThat("RenderProperty name has been changed.", property2.getName(), is(equalTo(property.getName()))); assertThat("Default value has been changed.", property2.getDefaultValue(), is(equalTo(property.getDefaultValue()))); TableRenderContext context = createDummyRenderContext(); context.setColIndex(2);/* w ww . j ava 2 s .c om*/ context.setRowIndex(4); String result = property2.getValue(context); assertThat("Wrong property value.", result, is(equalTo("blue"))); System.out.println("Saved configuration : "); configuration.save(System.out); }
From source file:org.pivot4j.ui.property.SimplePropertyTest.java
@Test public void testSettingsManagement() throws ConfigurationException { SimpleRenderProperty property = new SimpleRenderProperty("bgColor", "red"); XMLConfiguration configuration = new XMLConfiguration(); configuration.setRootElementName("property"); property.saveSettings(configuration); SimpleRenderProperty property2 = new SimpleRenderProperty(); property2.restoreSettings(configuration); assertThat("RenderProperty name has been changed.", property2.getName(), is(equalTo(property.getName()))); assertThat("RenderProperty value has been changed.", property2.getValue(), is(equalTo(property.getValue()))); System.out.println("Saved configuration : "); configuration.save(System.out); }