Search in sources :

Example 46 with DefaultMessageFactory

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

the class XmlTransformServiceTest method testObtainUrlWithEmptyMetadataValue.

@Test
public void testObtainUrlWithEmptyMetadataValue() throws Exception {
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
    msg.addMetadata("key", "");
    XmlTransformService service = new XmlTransformService();
    try {
        service.setUrl("url");
        service.setMetadataKey("key");
        service.setAllowOverride(true);
        LifecycleHelper.init(service);
        assertTrue(service.obtainUrlToUse(msg).equals("url"));
    } finally {
        LifecycleHelper.close(service);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 47 with DefaultMessageFactory

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

the class XmlValidationServiceTest method testSimpleValidator_IsInvalidXml_LessThan.

@Test
public void testSimpleValidator_IsInvalidXml_LessThan() throws Exception {
    XmlBasicValidator validator = new XmlBasicValidator(new DocumentBuilderFactoryBuilder());
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("<?xml version=\"1.0\"?><Root><</Root>");
    XmlValidationService service = new XmlValidationService(validator);
    try {
        execute(service, msg);
        fail("Success with invalid XML");
    } catch (ServiceException e) {
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test)

Example 48 with DefaultMessageFactory

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

the class XmlValidationServiceTest method testSchemaValidator_InvalidXml.

@Test
public void testSchemaValidator_InvalidXml() throws Exception {
    String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
    // if (!ExternalResourcesHelper.isExternalServerAvailable(new URLString(schemaUrl))) {
    // log.debug(schemaUrl + " not available, ignoring testInvalidXml test");
    // return;
    // }
    BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator();
    validator.setSchema(schemaUrl);
    XmlValidationService service = new XmlValidationService(validator);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("<?xml version=\"1.0\"?><Root></Root>");
    try {
        execute(service, msg);
        fail("Success on a file that isn't valid XML!");
    } catch (ServiceException e) {
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) BasicXmlSchemaValidator(com.adaptris.core.transform.schema.BasicXmlSchemaValidator) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 49 with DefaultMessageFactory

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

the class XmlValidationServiceTest method testSimpleValidator_IsInvalidXml_AmpersandNoEntity.

@Test
public void testSimpleValidator_IsInvalidXml_AmpersandNoEntity() throws Exception {
    XmlBasicValidator validator = new XmlBasicValidator();
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("<?xml version=\"1.0\"?><Root>&</Root>");
    XmlValidationService service = new XmlValidationService(validator);
    try {
        execute(service, msg);
        fail("Success with invalid XML");
    } catch (ServiceException e) {
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 50 with DefaultMessageFactory

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

the class XmlRuleValidatorTest method testNotInListContentValidation_DataInList.

@Test
public void testNotInListContentValidation_DataInList() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new NotInListContentValidation(CHILDREN_OF_HERA)));
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    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) NotInListContentValidation(com.adaptris.transform.validate.NotInListContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10