XmlValidatorFactory { public static XmlValidator createValidator(Resource schemaResource, String schemaLanguage) throws IOException { return createValidator(new Resource[] { schemaResource }, schemaLanguage); }  static XmlValidator createValidator(Resource schemaResource, String schemaLanguage); static XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage); static final String SCHEMA_W3C_XML; static final String SCHEMA_RELAX_NG; }
@Test public void testCreateValidator() throws Exception { Resource resource = new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class); XmlValidator validator = XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); Assert.assertNotNull("No validator returned", validator); }
@Test public void testNonExistentResource() throws Exception { Resource resource = new NonExistentResource(); try { XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML); Assert.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { } }
@Test public void testInvalidSchemaLanguage() throws Exception { Resource resource = new ClassPathResource("schema.xsd", AbstractValidatorFactoryTestCase.class); try { XmlValidatorFactory.createValidator(resource, "bla"); Assert.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { } }