use of com.adaptris.core.transform.schema.BasicXmlSchemaValidator in project interlok by adaptris.
the class XmlValidationServiceTest method testSchemaValidator_InvalidXmlSchemaInMetadata.
@Test
public void testSchemaValidator_InvalidXmlSchemaInMetadata() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_INVALID_SCHEMA_URL);
// if (!ExternalResourcesHelper.isExternalServerAvailable(new URLString(schemaUrl))) {
// log.debug(schemaUrl + " not available, ignoring testInvalidXmlSchemaInMetadata test");
// return;
// }
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator();
validator.setSchema("%message{schema-key}");
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
msg.addMetadata("schema-key", schemaUrl);
XmlValidationService service = new XmlValidationService(validator);
try {
execute(service, msg);
fail("Success with an invalid schema");
} catch (ServiceException e) {
;
}
}
use of com.adaptris.core.transform.schema.BasicXmlSchemaValidator in project interlok by adaptris.
the class XmlValidationServiceTest method testSchemaValidator_InitDefault.
@Test
public void testSchemaValidator_InitDefault() {
XmlValidationService service = new XmlValidationService(new BasicXmlSchemaValidator());
try {
LifecycleHelper.init(service);
fail();
} catch (Exception expected) {
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.transform.schema.BasicXmlSchemaValidator in project interlok by adaptris.
the class XmlValidationServiceTest method testValidXmlSchema_Expression.
@Test
public void testValidXmlSchema_Expression() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
// if (!ExternalResourcesHelper.isExternalServerAvailable(new URLString(schemaUrl))) {
// log.debug(schemaUrl + " not available, ignoring testMetadataSchemaKeyIsEmpty test");
// return;
// }
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema("%message{schema-key}").withSchemaCache(new CacheConnection(new ExpiringMapCache().withMaxEntries(1)));
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
msg.addMetadata("schema-key", schemaUrl);
XmlValidationService service = new XmlValidationService(validator);
try {
LifecycleHelper.initAndStart(service);
service.doService(msg);
// Hits the cache the 2nd time round
service.doService(msg);
} finally {
LifecycleHelper.stopAndClose(service);
}
}
Aggregations