Search in sources :

Example 6 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation 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) {
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 7 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation 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");
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 8 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation 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));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) BasicXmlSchemaValidator(com.adaptris.core.transform.schema.BasicXmlSchemaValidator) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) ValidationStage(com.adaptris.transform.validate.ValidationStage)

Aggregations

NotNullContentValidation (com.adaptris.transform.validate.NotNullContentValidation)8 ValidationStage (com.adaptris.transform.validate.ValidationStage)8 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)6 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)6 ServiceException (com.adaptris.core.ServiceException)6 Test (org.junit.Test)6 SimpleListContentValidation (com.adaptris.transform.validate.SimpleListContentValidation)4 BasicXmlSchemaValidator (com.adaptris.core.transform.schema.BasicXmlSchemaValidator)1 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)1 NotInListContentValidation (com.adaptris.transform.validate.NotInListContentValidation)1 KeyValuePair (com.adaptris.util.KeyValuePair)1 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)1