public void testToFromXML ()
{
try
{
EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
final StringWriter writer = new StringWriter() ;
final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
final QName header = new QName("header") ;
final String origHeaderURI = StreamHelper.writeStartElement(out, header) ;
PortReferenceHelper.toXML(out, XMLUtil.QNAME_FROM_TAG, email.getAddr()) ;
StreamHelper.writeEndElement(out, header.getPrefix(), origHeaderURI) ;
out.flush() ;
final String content = writer.toString() ;
log.debug("Exported XML: "+content);
final StringReader reader = new StringReader(content) ;
final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
StreamHelper.checkNextStartTag(in, header) ;
StreamHelper.checkNextStartTag(in, XMLUtil.QNAME_FROM_TAG) ;
PortReference pr = PortReferenceHelper.fromXML(in);
StreamHelper.checkEndTag(in, XMLUtil.QNAME_FROM_TAG) ;
StreamHelper.checkParentFinished(in) ;
EPR basicEpr = new EPR(pr);
EmailEpr nEpr = new EmailEpr(basicEpr);
assertEquals(nEpr.getAddr().getAddress(), email.getAddr().getAddress());
}
catch (Exception ex)
{
fail();
}