List of usage examples for org.apache.commons.configuration.resolver CatalogResolver CatalogResolver
public CatalogResolver()
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests modifying an XML document and saving it with schema validation * enabled./*from w w w.j ava2 s .c o m*/ */ @Test @Ignore public void testSaveWithValidation() throws Exception { CatalogResolver resolver = new CatalogResolver(); resolver.setCatalogFiles(CATALOG_FILES); conf = new XMLConfiguration(); conf.setEntityResolver(resolver); conf.setFileName(testFile2); conf.setSchemaValidation(true); conf.load(); conf.setProperty("Employee.SSN", "123456789"); conf.validate(); conf.save(testSaveConf); conf = new XMLConfiguration(testSaveConf); assertEquals("123456789", conf.getString("Employee.SSN")); }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests modifying an XML document and validating it against the schema. *//*from w w w . j a v a 2s.co m*/ @Test @Ignore public void testSaveWithValidationFailure() throws Exception { CatalogResolver resolver = new CatalogResolver(); resolver.setCatalogFiles(CATALOG_FILES); conf = new XMLConfiguration(); conf.setEntityResolver(resolver); conf.setFileName(testFile2); conf.setSchemaValidation(true); conf.load(); conf.setProperty("Employee.Email", "JohnDoe@apache.org"); try { conf.validate(); fail("No validation failure on save"); } catch (Exception e) { Throwable cause = e.getCause(); assertNotNull("No cause for exception on save", cause); assertTrue("Incorrect exception on save", cause instanceof SAXParseException); } }