@Test
public void testSerialization() throws Exception {
setupClientAndRhino("simple-dlwu-proxy-factory");
testUtilities.readResourceIntoRhino("/serializationTests.js");
DataBinding dataBinding = clientProxyFactory.getServiceFactory().getDataBinding();
assertNotNull(dataBinding);
Object serialized = testUtilities.rhinoCallInContext("serializeTestBean1_1");
assertTrue(serialized instanceof String);
String xml = (String)serialized;
DataReader<XMLStreamReader> reader = dataBinding.createReader(XMLStreamReader.class);
StringReader stringReader = new StringReader(xml);
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(stringReader);
QName testBeanQName = new QName("uri:org.apache.cxf.javascript.testns", "TestBean1");
Object bean = reader.read(testBeanQName, xmlStreamReader, TestBean1.class);
assertNotNull(bean);
assertTrue(bean instanceof TestBean1);
TestBean1 testBean = (TestBean1)bean;
assertEquals("bean1<stringItem", testBean.stringItem);
assertEquals(64, testBean.intItem);
assertEquals(64000000, testBean.longItem);
assertEquals(101, testBean.optionalIntItem);
assertNotNull(testBean.optionalIntArrayItem);
assertEquals(1, testBean.optionalIntArrayItem.length);
assertEquals(543, testBean.optionalIntArrayItem[0]);
serialized = testUtilities.rhinoCallInContext("serializeTestBean1_2");
assertTrue(serialized instanceof String);
xml = (String)serialized;
reader = dataBinding.createReader(XMLStreamReader.class);
stringReader = new StringReader(xml);
xmlStreamReader = xmlInputFactory.createXMLStreamReader(stringReader);
bean = reader.read(testBeanQName, xmlStreamReader, TestBean1.class);
assertNotNull(bean);
assertTrue(bean instanceof TestBean1);
testBean = (TestBean1)bean;
assertEquals("bean1<stringItem", testBean.stringItem);
assertEquals(64, testBean.intItem);
assertEquals(64000000, testBean.longItem);
assertEquals(0, testBean.optionalIntItem);
assertNotNull(testBean.optionalIntArrayItem);
assertEquals(3, testBean.optionalIntArrayItem.length);
assertEquals(543, testBean.optionalIntArrayItem[0]);
assertEquals(0, testBean.optionalIntArrayItem[1]);
assertEquals(345, testBean.optionalIntArrayItem[2]);
serialized = testUtilities.rhinoCallInContext("serializeTestBean1_3");
assertTrue(serialized instanceof String);
xml = (String)serialized;
reader = dataBinding.createReader(XMLStreamReader.class);
stringReader = new StringReader(xml);
xmlStreamReader = xmlInputFactory.createXMLStreamReader(stringReader);
bean = reader.read(testBeanQName, xmlStreamReader, TestBean1.class);
assertNotNull(bean);
assertTrue(bean instanceof TestBean1);