use of com.adaptris.core.transform.XmlValidationService in project interlok by adaptris.
the class BasicSchemaValidationTest method testBasicSchemaValidator_Exception.
@Test(expected = ServiceException.class)
public void testBasicSchemaValidator_Exception() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl).withSchemaCache(new CacheConnection().withCacheInstance(new ExpiringMapCache()));
XmlValidationService service = new XmlValidationService(validator);
try {
LifecycleHelper.initAndStart(service);
AdaptrisMessage m1 = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
service.doService(m1);
} finally {
LifecycleHelper.stopAndClose(service);
}
}
use of com.adaptris.core.transform.XmlValidationService in project interlok by adaptris.
the class ExtendedSchemaValidatorTest method testExtendedValidator_Invalid.
@Test
public void testExtendedValidator_Invalid() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_NOT_VALIDATE);
ExtendedXmlSchemaValidator validator = new ExtendedXmlSchemaValidator().withSchemaViolationHandler(new ViolationsAsMetadata()).withSchema(schemaUrl);
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
XmlValidationService service = new XmlValidationService(validator);
execute(service, msg);
assertTrue(msg.headersContainsKey(ViolationHandlerImpl.DEFAULT_KEY));
SchemaViolations v = (SchemaViolations) new XStreamMarshaller().unmarshal(msg.getMetadataValue(ViolationHandlerImpl.DEFAULT_KEY));
assertEquals(2, v.getViolations().size());
}
use of com.adaptris.core.transform.XmlValidationService in project interlok by adaptris.
the class BasicSchemaValidationTest method testBasicSchemaValidator_Invalid.
@Test(expected = ServiceException.class)
public void testBasicSchemaValidator_Invalid() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_NOT_VALIDATE);
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl);
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
XmlValidationService service = new XmlValidationService(validator);
execute(service, msg);
}
use of com.adaptris.core.transform.XmlValidationService in project interlok by adaptris.
the class BasicSchemaValidationTest method testBasicSchemaValidator.
@Test
public void testBasicSchemaValidator() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl).withSchemaCache(new CacheConnection().withCacheInstance(new ExpiringMapCache()));
XmlValidationService service = new XmlValidationService(validator);
try {
LifecycleHelper.initAndStart(service);
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
AdaptrisMessage m2 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
service.doService(m1);
service.doService(m2);
} finally {
LifecycleHelper.stopAndClose(service);
}
}
use of com.adaptris.core.transform.XmlValidationService in project interlok by adaptris.
the class ExtendedSchemaValidatorTest method testExtendedValidator_Valid.
@Test
public void testExtendedValidator_Valid() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
ExtendedXmlSchemaValidator validator = new ExtendedXmlSchemaValidator().withSchemaViolationHandler(new ViolationsAsMetadata()).withSchema(schemaUrl);
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
XmlValidationService service = new XmlValidationService(validator);
execute(service, msg);
assertFalse(msg.headersContainsKey(ViolationHandlerImpl.DEFAULT_KEY));
}
Aggregations