ConfigurationUtils { public static void load(Configuration conf, InputStream is) throws IOException { conf.addResource(is); }  static void copy(Configuration source, Configuration target); static void injectDefaults(Configuration source, Configuration target); static Configuration resolve(Configuration conf); static void load(Configuration conf, InputStream is);  }
@Test public void constructors() throws Exception { Configuration conf = new Configuration(false); assertEquals(conf.size(), 0); byte[] bytes = "<configuration><property><name>a</name><value>A</value></property></configuration>".getBytes(); InputStream is = new ByteArrayInputStream(bytes); conf = new Configuration(false); ConfigurationUtils.load(conf, is); assertEquals(conf.size(), 1); assertEquals(conf.get("a"), "A"); }
@Test public void constructors3() throws Exception { InputStream is = new ByteArrayInputStream( "<xxx><property name=\"key1\" value=\"val1\"/></xxx>".getBytes()); Configuration conf = new Configuration(false); ConfigurationUtils.load(conf, is); assertEquals("val1", conf.get("key1")); }
@Test public void testCompactFormatProperty() throws IOException { final String testfile = "test-compact-format-property.xml"; Configuration conf = new Configuration(false); assertEquals(0, conf.size()); ConfigurationUtils.load(conf, Thread.currentThread() .getContextClassLoader().getResource(testfile).openStream()); assertEquals(2, conf.size()); assertEquals("val1", conf.get("key.1")); assertEquals("val2", conf.get("key.2")); }