1 package com.thoughtworks.xstream.converters.collections; 2 3 import com.thoughtworks.xstream.XStream; 4 import com.thoughtworks.xstream.io.xml.XppDriver; 5 import junit.framework.TestCase; 6 7 import java.util.Properties ; 8 9 public class PropertiesConverterTest extends TestCase { 10 11 public void testConvertsPropertiesObjectToShortKeyValueElements() { 12 Properties in = new Properties (); 13 in.setProperty("hello", "world"); 14 in.setProperty("foo", "cheese"); 15 16 XStream xStream = new XStream(new XppDriver()); 17 18 String expectedXML = "" + 19 "<properties>\n" + 20 " <property name=\"hello\" value=\"world\"/>\n" + 21 " <property name=\"foo\" value=\"cheese\"/>\n" + 22 "</properties>"; 23 String actualXML = xStream.toXML(in); 24 assertEquals(expectedXML, actualXML); 25 26 Properties expectedOut = new Properties (); 27 expectedOut.setProperty("hello", "world"); 28 expectedOut.setProperty("foo", "cheese"); 29 Properties actualOut = (Properties ) xStream.fromXML(actualXML); 30 assertEquals(in, actualOut); 31 assertEquals(in.toString(), actualOut.toString()); 32 33 } 34 35 } 36 | Popular Tags |