Esempio n. 1
0
 @Test
 public void shouldFailOnBrokenSchema() {
   JAXPValidator v = new JAXPValidator(Languages.W3C_XML_SCHEMA_NS_URI);
   v.setSchemaSource(new StreamSource(this.getClass().getResourceAsStream("/broken.xsd")));
   ValidationResult r = v.validateSchema();
   assertFalse(r.isValid());
   assertTrue(r.getProblems().iterator().hasNext());
 }
Esempio n. 2
0
 @Test
 public void shouldSuccessfullyValidateInstance() {
   JAXPValidator v = new JAXPValidator(Languages.W3C_XML_SCHEMA_NS_URI);
   v.setSchemaSource(new StreamSource(this.getClass().getResourceAsStream("/Book.xsd")));
   ValidationResult r =
       v.validateInstance(
           new StreamSource(this.getClass().getResourceAsStream("/BookXsdGenerated.xml")));
   assertTrue(r.isValid());
   assertFalse(r.getProblems().iterator().hasNext());
 }