1 16 17 18 package org.apache.commons.betwixt.dotbetwixt; 19 20 import java.io.StringWriter ; 21 22 import org.apache.commons.betwixt.AbstractTestCase; 23 import org.apache.commons.betwixt.io.BeanWriter; 24 25 29 public class TestDotBetwixtNamespace extends AbstractTestCase { 30 31 public TestDotBetwixtNamespace(String name) { 32 super(name); 33 } 34 35 36 public void testWriteSimpleDotBetwixtWithNamespaces() throws Exception { 37 PersonWithNamespace bean = new PersonWithNamespace("Robert", "Burrell", "Donkin"); 38 StringWriter out = new StringWriter (); 39 out.write("<?xml version='1.0'?>"); 40 BeanWriter writer = new BeanWriter(out); 41 writer.getBindingConfiguration().setMapIDs(false); 42 writer.getXMLIntrospector().getConfiguration().getPrefixMapper() 43 .setPrefix("http://jakarta.apache.org/commons/betwixt/PersonWithNamespaceExample", "pn"); 44 writer.write(bean); 45 46 String xml = out.getBuffer().toString(); 47 48 String expected = "<?xml version='1.0'?>" + 49 "<pn:person " + 50 "xmlns:pn='http://jakarta.apache.org/commons/betwixt/PersonWithNamespaceExample' " + 51 "pn:middle='Burrell'>" + 52 "<forename>Robert</forename>" + 53 "<pn:surname>Donkin</pn:surname></pn:person>"; 54 55 xmlAssertIsomorphicContent(parseString(xml), parseString(expected)); 56 } 57 } 58 | Popular Tags |