use of com.adaptris.transform.validate.ValidationStage in project interlok by adaptris.
the class XmlRuleValidatorTest method testContentValidation_XmlMessage_BadXpath.
@Test
public void testContentValidation_XmlMessage_BadXpath() throws Exception {
XmlRuleValidator validator = new XmlRuleValidator();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
ValidationStage vs = new ValidationStage("/path/to/something/that/does/not/exist", XPATH_CHILDREN_OF_HERA, new NotNullContentValidation());
vs.setFailOnIterateFailure(true);
validator.addValidationStage(vs);
XmlValidationService service = new XmlValidationService(validator);
try {
ExampleServiceCase.execute(service, msg);
fail("RuleValidationService success when expecting failure");
} catch (ServiceException expected) {
}
}
use of com.adaptris.transform.validate.ValidationStage in project interlok by adaptris.
the class XmlRuleValidatorTest method testNotNullContentValidation_DataNotNull.
@Test
public void testNotNullContentValidation_DataNotNull() throws Exception {
XmlRuleValidator validator = new XmlRuleValidator();
validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILD_NAME, new NotNullContentValidation()));
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
XmlValidationService service = new XmlValidationService(validator);
try {
ExampleServiceCase.execute(service, msg);
} catch (ServiceException e) {
fail("RuleValidationService failure when expecting success");
}
}
use of com.adaptris.transform.validate.ValidationStage in project interlok by adaptris.
the class XmlValidationServiceTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
ValidationStage vs = new ValidationStage();
vs.setIterationXpath("/document/names");
vs.setElementXpath("fullName");
vs.addRule(new NotNullContentValidation());
KeyValuePair disableExternalEntities = new KeyValuePair("http://xml.org/sax/features/external-general-entities", "false");
KeyValuePair disableDoctypeDecl = new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true");
return new XmlValidationService(new XmlBasicValidator(new DocumentBuilderFactoryBuilder().withNamespaceAware(true).withFeatures(new KeyValuePairSet(Arrays.asList(disableExternalEntities, disableDoctypeDecl)))), new BasicXmlSchemaValidator().withSchema("http://host/schema.xsd or %message{metadatKey}"), new XmlRuleValidator(vs));
}
Aggregations