ApplicationConfig { public static String getXmlFromProps(Properties props) { String comment = null; String xml = new String(); ByteArrayOutputStream os = new ByteArrayOutputStream(); try { props.storeToXML(os, comment); os.flush(); xml = os.toString(); } catch (IOException e) { String error = "IO exception for props: '" + props + "':" + e.getMessage(); log.error(error); log.error(ExceptionUtil.getStackTraceAsString(e)); throw new RuntimeException(error, e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { String error = "Error closing xml stream: " + e.getMessage(); throw new RuntimeException(error, e); } } } return xml; } protected  ApplicationConfig(); static Properties getPropsFromResource(String resourceName); static Properties getPropsFromXml(String propsXml); static Properties getPropsFromXmlStream(InputStream propsXmlStream); static Properties getPropsFromXmlResource(String resourceName); static String getXmlFromProps(Properties props);  }
@Test public void testGetXmlFromProps() throws Exception { Properties props = new Properties(); props.put(key0, val0); props.put(key1, val1); String xml = ApplicationConfig.getXmlFromProps(props); assertNotNull(xml); System.out.println(xml); Properties propsNew = ApplicationConfig.getPropsFromXml(xml); assertNotNull(propsNew); assertEquals(val0, propsNew.getProperty(key0)); assertEquals(val1, propsNew.getProperty(key1)); }