package encoding; import junit.framework.TestCase; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.HierarchicalStreamDriver; import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.XppDriver; public class EncodingTest extends TestCase { // TODO fixe encoding issue for other drivers (eg : XppDriver) public void testEncodingXppDriver() { doTestEncoding(new XppDriver()); } public void testEncodingDomDriver() { doTestEncoding(new DomDriver()); } public void doTestEncoding(HierarchicalStreamDriver driver) { XStream xstream = new XStream(driver); xstream.alias("person", Person.class); Person utf8 = (Person) xstream.fromXML(this.getClass().getResourceAsStream("xml_utf8.xml")); Person iso = (Person) xstream.fromXML(this.getClass().getResourceAsStream("xml_iso-8859-1.xml")); assertEquals(utf8.name, iso.name); } public static class Person { public String name; } }