예제 #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());
 }
예제 #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());
 }