List of usage examples for org.apache.commons.configuration INIConfiguration INIConfiguration
public INIConfiguration()
From source file:com.intel.cosbench.config.common.INIConfigParser.java
public static Config getEmptyConfig() { INIConfiguration config = new INIConfiguration(); return new COSBConfigApator(config); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Test of save method, of class {@link INIConfiguration}. *//*from ww w. j a v a2 s.c o m*/ @Test public void testSave() throws Exception { Writer writer = new StringWriter(); INIConfiguration instance = new INIConfiguration(); instance.addProperty("section1.var1", "foo"); instance.addProperty("section1.var2", "451"); instance.addProperty("section2.var1", "123.45"); instance.addProperty("section2.var2", "bar"); instance.addProperty("section3.var1", "true"); instance.addProperty("section3.interpolated", "${section3.var1}"); instance.addProperty("section3.multi", "foo"); instance.addProperty("section3.multi", "bar"); instance.save(writer); assertEquals("Wrong content of ini file", INI_DATA, writer.toString()); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Helper method for testing the load operation. Loads the specified content * into a configuration and then checks some properties. * * @param data the data to load//w w w.ja v a2s. com */ private void checkLoad(String data) throws ConfigurationException, IOException { Reader reader = new StringReader(data); INIConfiguration instance = new INIConfiguration(); instance.load(reader); reader.close(); assertTrue(instance.getString("section1.var1").equals("foo")); assertTrue(instance.getInt("section1.var2") == 451); assertTrue(instance.getDouble("section2.var1") == 123.45); assertTrue(instance.getString("section2.var2").equals("bar")); assertTrue(instance.getBoolean("section3.var1")); assertTrue(instance.getSections().size() == 3); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Test of isCommentLine method, of class {@link INIConfiguration}. *//*from w ww . j a va2 s. c om*/ @Test public void testIsCommentLine() { INIConfiguration instance = new INIConfiguration(); // assertTrue(instance.isCommentLine("#comment1")); // assertTrue(instance.isCommentLine(";comment1")); // assertFalse(instance.isCommentLine("nocomment=true")); // assertFalse(instance.isCommentLine(null)); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Test of isSectionLine method, of class {@link INIConfiguration}. *///from w ww. j a v a 2 s . c om @Test public void testIsSectionLine() { INIConfiguration instance = new INIConfiguration(); // assertTrue(instance.isSectionLine("[section]")); // assertFalse(instance.isSectionLine("nosection=true")); // assertFalse(instance.isSectionLine(null)); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Test of getSections method, of class {@link INIConfiguration}. *///from w w w . j a v a 2 s. c om @Test public void testGetSections() { INIConfiguration instance = new INIConfiguration(); instance.addProperty("test1.foo", "bar"); instance.addProperty("test2.foo", "abc"); Set<String> expResult = new HashSet<String>(); expResult.add("test1"); expResult.add("test2"); Set<String> result = instance.getSections(); assertEquals(expResult, result); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testQuotedValue() throws Exception { INIConfiguration config = new INIConfiguration(); config.load(new StringReader(INI_DATA2)); assertEquals("value", "quoted value", config.getString("section4.var1")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testQuotedValueWithQuotes() throws Exception { INIConfiguration config = new INIConfiguration(); config.load(new StringReader(INI_DATA2)); assertEquals("value", "quoted value\\nwith \"quotes\"", config.getString("section4.var2")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testValueWithComment() throws Exception { INIConfiguration config = new INIConfiguration(); config.load(new StringReader(INI_DATA2)); assertEquals("value", "123", config.getString("section4.var3")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testQuotedValueWithComment() throws Exception { INIConfiguration config = new INIConfiguration(); config.load(new StringReader(INI_DATA2)); assertEquals("value", "1;2;3", config.getString("section4.var4")); }