xsw.close();
String expect = sw.toString();
StAXStreamBuilder sbuilder = new StAXStreamBuilder();
Content backagain = sbuilder.fragment(
sinfactory.createXMLStreamReader(new StringReader(expect)));
// convert the input to a SAX Stream
sw.getBuffer().setLength(0);
xsw = soutfactory.createXMLStreamWriter(sw);
switch(content.getCType()) {
case CDATA :
xout.output((CDATA)backagain, xsw);
break;
case Text:
xout.output((Text)backagain, xsw);
break;
case Comment:
xout.output((Comment)backagain, xsw);
break;
case DocType:
xout.output((DocType)backagain, xsw);
break;
case Element:
xout.output((Element)backagain, xsw);
break;
case EntityRef:
xout.output((EntityRef)backagain, xsw);
break;
case ProcessingInstruction:
xout.output((ProcessingInstruction)backagain, xsw);
break;
default:
throw new IllegalStateException(backagain.getCType().toString());
}
xsw.close();
String actual = sw.toString();
assertEquals(expect, actual);