public void testValidateRootNull() { boolean caughtException = false; try { validator.validateRoot(null); } catch (IllegalArgumentException e) { caughtException = true; } catch (Exception e) { } assertTrue( "JAXBValidator did not throw IllegalArgumentException as expected.", caughtException); }
public void testValidateRootException() { boolean caughtException = false; try { Car car = new Car(); validator.validateRoot(car); } catch (ValidationException e) { assertTrue(true); return; } catch (Exception e) { fail("JAXBValidator did not throw ValidationException as expected."); return; } assertTrue( "JAXBValidator did not any exceptions, expected a ValidationException.", caughtException); }
public void testValidateRoot() throws Exception { File file = new File(ClassLoader.getSystemResource(CONTROL_XML_FILE_NAME).getFile()); Object testObject = unmarshaller.unmarshal(file); assertTrue("Object did not validate.", validator.validateRoot(testObject)); }