{
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));