Search in sources :

Example 36 with ServiceException

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

the class ValidateMetadataServiceTest method testNoRequirements.

@Test
public void testNoRequirements() throws Exception {
    ValidateMetadataService service = new ValidateMetadataService();
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("asdfghjk");
    msg.addMetadata("key", "val");
    try {
        execute(service, msg);
    } catch (ServiceException e) {
        fail();
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 37 with ServiceException

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

the class ValidateMetadataServiceTest method testOneRequirementMet.

@Test
public void testOneRequirementMet() throws Exception {
    ValidateMetadataService service = new ValidateMetadataService(Arrays.asList(new String[] { "key" }));
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("asdfghjk");
    msg.addMetadata("key", "val");
    try {
        execute(service, msg);
    } catch (ServiceException e) {
        fail();
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 38 with ServiceException

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

the class ValidateMetadataServiceTest method testtwoRequirementsOnePresent.

@Test
public void testtwoRequirementsOnePresent() throws Exception {
    ValidateMetadataService service = new ValidateMetadataService(Arrays.asList(new String[] { "key", "key2" }));
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("asdfghjk");
    msg.addMetadata("key", "val");
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException e) {
    // expected
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 39 with ServiceException

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

the class PayloadHashingServiceTest method testServiceException.

@Test
public void testServiceException() throws Exception {
    PayloadHashingService service = new PayloadHashingService(SHA256, METADATA_KEY);
    AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(PAYLOAD);
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException e) {
        ;
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 40 with ServiceException

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

the class XpathMetadataServiceTest method testDoService_DocType_DefaultBehaviour.

@Test
public void testDoService_DocType_DefaultBehaviour() throws CoreException {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_DOCTYPE);
    // Default document factory should disable doctyps.
    XpathMetadataService service = new XpathMetadataService();
    // Shouldn't matter what the query actually is.
    service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) MetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathQuery) MultiItemMetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) 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