protected TypeConverter converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(),
new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new DefaultClassResolver()));
protected String expectedBody = "<hello>world!</hello>";
public void testSerialization() throws Exception {
StringSource expected = new StringSource(expectedBody, "mySystemID", "utf-8");
expected.setPublicId("myPublicId");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(buffer);
output.writeObject(expected);
output.close();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
Object object = in.readObject();
assertTrue("is a StringSource", object instanceof StringSource);
StringSource actual = (StringSource) object;
assertEquals("source.text", expected.getPublicId(), actual.getPublicId());
assertEquals("source.text", expected.getSystemId(), actual.getSystemId());
assertEquals("source.text", expected.getEncoding(), actual.getEncoding());
assertEquals("source.text", expected.getText(), actual.getText());
String value = converter.convertTo(String.class, actual);
assertEquals("text value of StringSource", expectedBody, value);
}