public void testRead() throws Exception { InputStream carStream = getClass() .getClassLoader() .getResourceAsStream("org/eclipse/persistence/testing/oxm/inheritance/car.xml"); Object car = unmarshaller.unmarshal(carStream); assertTrue("Wrong object returned for subclass", car instanceof Car); InputStream vehicleStream = getClass() .getClassLoader() .getResourceAsStream("org/eclipse/persistence/testing/oxm/inheritance/vehicle.xml"); Object vehicle = unmarshaller.unmarshal(vehicleStream); assertTrue("Wrong object returned for superclass", vehicle.getClass().equals(Vehicle.class)); }
public void testReadMailingAddress() { try { InputStream inputStream = ClassLoader.getSystemResourceAsStream(XML_RESOURCE_MAILING); MailingAddress testObject = (MailingAddress) unmarshaller.unmarshal(inputStream); } catch (ClassCastException e) { fail(); } }
public void testReadBillingAddress() { try { InputStream inputStream = ClassLoader.getSystemResourceAsStream(XML_RESOURCE_BILLING); Object testObject = unmarshaller.unmarshal(inputStream); fail(); } catch (XMLMarshalException e) { // PASS - an XMLMarshalException should be caught } }