}
public void testXBeanSerialization() throws Exception
{
XmlPurchaseOrderDocumentBean doc = XmlPurchaseOrderDocumentBean.Factory.newInstance();
PurchaseOrder order = doc.addNewPurchaseOrder();
order.addNewCustomer().setName("David Bau");
order.getCustomer().setAddress("Gladwyne, PA");
XmlLineItemBean li;
li = order.addNewLineItem();
li.setDescription("Burnham's Celestial Handbook, Vol 1");
li.setPrice(new BigDecimal("21.79"));
li.setQuantity(BigInteger.valueOf(2));
li.setPerUnitOunces(new BigDecimal("5"));
li = order.addNewLineItem();
li.setDescription("Burnham's Celestial Handbook, Vol 2");
li.setPrice(new BigDecimal("19.89"));
li.setQuantity(BigInteger.valueOf(2));
li.setPerUnitOunces(new BigDecimal("5"));
li = order.addNewLineItem();
li.setDescription("Burnham's Celestial Handbook, Vol 3");
li.setPrice(new BigDecimal("19.89"));
li.setQuantity(BigInteger.valueOf(1));
li.setPerUnitOunces(new BigDecimal("5"));
XmlShipperBean sh = order.addNewShipper();
sh.setName("UPS");
sh.setPerOunceRate(new BigDecimal("0.74"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(doc.getPurchaseOrder().getLineItemArray(1));
oos.writeObject(doc);
oos.writeObject(doc.getPurchaseOrder().getLineItemArray(2));
oos.close();
byte[] byteArray = out.toByteArray();
ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(in);
XmlLineItemBean newli1 = (XmlLineItemBean)ois.readObject();
XmlPurchaseOrderDocumentBean newdoc = (XmlPurchaseOrderDocumentBean)ois.readObject();
XmlLineItemBean newli2 = (XmlLineItemBean)ois.readObject();
ois.close();
PurchaseOrder neworder = newdoc.getPurchaseOrder();
Assert.assertEquals(newli1, neworder.getLineItemArray(1));
Assert.assertEquals(newli2, neworder.getLineItemArray(2));
Assert.assertEquals("David Bau", neworder.getCustomer().getName());
Assert.assertEquals("Gladwyne, PA", neworder.getCustomer().getAddress());
Assert.assertEquals(3, neworder.sizeOfLineItemArray());
Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", neworder.getLineItemArray(0).getDescription());
Assert.assertEquals(new BigDecimal("21.79"), neworder.getLineItemArray(0).getPrice());
Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(0).getQuantity());
Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(0).getPerUnitOunces());
Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", neworder.getLineItemArray(1).getDescription());
Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(1).getPrice());
Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(1).getQuantity());
Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(1).getPerUnitOunces());
Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", neworder.getLineItemArray(2).getDescription());
Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(2).getPrice());
Assert.assertEquals(new BigInteger("1"), neworder.getLineItemArray(2).getQuantity());
Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(2).getPerUnitOunces());
Assert.assertEquals(true, neworder.isSetShipper());
Assert.assertEquals("UPS", neworder.getShipper().getName());
Assert.assertEquals(new BigDecimal("0.74"), neworder.getShipper().getPerOunceRate());
}