List of usage examples for org.apache.commons.configuration INIConfiguration load
public void load(Reader reader) throws ConfigurationException
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")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testQuotedValueWithSingleQuotes() throws Exception { INIConfiguration config = new INIConfiguration(); config.load(new StringReader(INI_DATA2)); assertEquals("value", "'quoted' \"value\"", config.getString("section4.var5")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Tests whether whitespace is left unchanged for quoted values. *//*from ww w . j ava2 s. c o m*/ @Test public void testQuotedValueWithWhitespace() throws Exception { final String content = "CmdPrompt = \" [test@cmd ~]$ \""; INIConfiguration config = new INIConfiguration(); config.load(new StringReader(content)); assertEquals("Wrong propert value", " [test@cmd ~]$ ", config.getString("CmdPrompt")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
/** * Tests a quoted value with space and a comment. *//*from w w w. j a v a2 s .com*/ @Test public void testQuotedValueWithWhitespaceAndComment() throws Exception { final String content = "CmdPrompt = \" [test@cmd ~]$ \" ; a comment"; INIConfiguration config = new INIConfiguration(); config.load(new StringReader(content)); assertEquals("Wrong propert value", " [test@cmd ~]$ ", config.getString("CmdPrompt")); }
From source file:io.datalayer.conf.IniConfigurationTest.java
@Test public void testWriteValueWithCommentChar() throws Exception { INIConfiguration config = new INIConfiguration(); config.setProperty("section.key1", "1;2;3"); StringWriter writer = new StringWriter(); config.save(writer);//from w ww. j a v a 2 s . c o m INIConfiguration config2 = new INIConfiguration(); config2.load(new StringReader(writer.toString())); assertEquals("value", "1;2;3", config2.getString("section.key1")); }
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//from ww w . j ava 2s .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); }