Search in sources :

Example 66 with ServiceException

use of com.adaptris.core.ServiceException in project interlok by adaptris.

the class XmlRuleValidatorTest method testMultipleContentValidation.

@Test
public void testMultipleContentValidation() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    ValidationStage vs = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new SimpleListContentValidation(CHILDREN_OF_HERA), new NotNullContentValidation());
    validator.addValidationStage(vs);
    ValidationStage vs2 = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_CRONOS, XPATH_CHILDREN_OF_RHEA, new SimpleListContentValidation(CHILDREN_OF_RHEA), new NotNullContentValidation());
    validator.addValidationStage(vs2);
    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) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 67 with ServiceException

use of com.adaptris.core.ServiceException in project interlok by adaptris.

the class XmlRuleValidatorTest method testNotNullContentValidation_DataIsNull.

@Test
public void testNotNullContentValidation_DataIsNull() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    // Hades had no children; poor god.
    ValidationStage vs = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_HADES, XPATH_CHILD_NAME, new NotNullContentValidation());
    validator.addValidationStage(vs);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
        fail("RuleValidationService success when expecting exception");
    } catch (ServiceException e) {
        // 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 68 with ServiceException

use of com.adaptris.core.ServiceException in project interlok by adaptris.

the class XmlRuleValidatorTest method testIsNullContentValidation_DataNotNull.

@Test
public void testIsNullContentValidation_DataNotNull() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILD_NAME, new IsNullContentValidation()));
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
        fail("RuleValidationService sucess when expecting failure");
    } catch (ServiceException e) {
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) IsNullContentValidation(com.adaptris.transform.validate.IsNullContentValidation) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 69 with ServiceException

use of com.adaptris.core.ServiceException in project interlok by adaptris.

the class XmlRuleValidatorTest method testNotInListContentValidation_DataNotInList.

@Test
public void testNotInListContentValidation_DataNotInList() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new NotInListContentValidation(CHILDREN_OF_RHEA)));
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
    } catch (ServiceException expected) {
        fail("RuleValidationService failure when expecting success");
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NotInListContentValidation(com.adaptris.transform.validate.NotInListContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 70 with ServiceException

use of com.adaptris.core.ServiceException in project interlok by adaptris.

the class XmlRuleValidatorTest method testListContentValidation_DataInList.

@Test
public void testListContentValidation_DataInList() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder.newInstance());
    validator.setValidationStages(Arrays.asList(new ValidationStage[] { new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new SimpleListContentValidation(CHILDREN_OF_HERA)) }));
    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) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Aggregations

ServiceException (com.adaptris.core.ServiceException)236 Test (org.junit.Test)172 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)161 CoreException (com.adaptris.core.CoreException)45 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)26 StandaloneProducer (com.adaptris.core.StandaloneProducer)18 MetadataElement (com.adaptris.core.MetadataElement)17 ValidationStage (com.adaptris.transform.validate.ValidationStage)16 Cache (com.adaptris.core.cache.Cache)15 DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)13 TimeInterval (com.adaptris.util.TimeInterval)13 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)11 Connection (java.sql.Connection)10 File (java.io.File)9 IOException (java.io.IOException)9 OutputStream (java.io.OutputStream)9 SQLException (java.sql.SQLException)9 InputStream (java.io.InputStream)8 Document (org.w3c.dom.Document)8 Channel (com.adaptris.core.Channel)7