Search in sources :

Example 36 with CoreException

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

the class ConfiguredXpathQueryTest method testResolveXpath_EmptyResults_NotAllowed.

@Test
public void testResolveXpath_EmptyResults_NotAllowed() throws Exception {
    ConfiguredXpathQuery query = init(create(), "//@MissingAttribute");
    Document doc = XmlHelper.createDocument(XML);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML);
    try {
        MetadataElement result = query.resolveXpath(doc, new XPath(), query.createXpathQuery(msg));
        fail();
    } catch (CoreException expected) {
    }
}
Also used : XPath(com.adaptris.util.text.xml.XPath) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 37 with CoreException

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

the class XpathDocumentCopierTest method testSplit_DocTypeNotAllowed.

@Test
public void testSplit_DocTypeNotAllowed() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.setContent(XML_WITH_DOCTYPE, msg.getContentEncoding());
    XpathDocumentCopier splitter = new XpathDocumentCopier(XPATH_DOCUMENT_COUNT);
    DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
    builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
    splitter.setXmlDocumentFactoryConfig(builder);
    try {
        List<AdaptrisMessage> result = splitToList(splitter, msg);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test)

Example 38 with CoreException

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

the class XpathSplitterTest method testSplit_DocTypeNotAllowed.

@Test
public void testSplit_DocTypeNotAllowed() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.setContent(XML_WITH_DOCTYPE, msg.getContentEncoding());
    XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8);
    DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
    builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
    splitter.setXmlDocumentFactoryConfig(builder);
    try {
        splitter.splitMessage(msg);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test) XpathMetadataServiceTest(com.adaptris.core.services.metadata.XpathMetadataServiceTest)

Example 39 with CoreException

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

the class SimpleRegexpMessageSplitterTest method testInvalidPattern.

@Test
public void testInvalidPattern() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(SIMPLE_MSG);
    SimpleRegexpMessageSplitter splitter = new SimpleRegexpMessageSplitter("[");
    try {
        List<AdaptrisMessage> result = splitter.splitMessage(msg);
        fail();
    } catch (CoreException expected) {
        ;
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 40 with CoreException

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

the class DecodingServiceTest method testInit.

@Test
public void testInit() throws Exception {
    DecodingService service = new DecodingService();
    try {
        LifecycleHelper.init(service);
        fail();
    } catch (CoreException expected) {
    }
    service.setEncoder(new MockEncoder());
    LifecycleHelper.init(service);
    service = new DecodingService(new MockEncoder());
    LifecycleHelper.init(service);
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Aggregations

CoreException (com.adaptris.core.CoreException)186 Test (org.junit.Test)110 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)44 Adapter (com.adaptris.core.Adapter)32 ObjectName (javax.management.ObjectName)29 Channel (com.adaptris.core.Channel)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)20 File (java.io.File)19 ServiceException (com.adaptris.core.ServiceException)14 TimeInterval (com.adaptris.util.TimeInterval)13 Document (org.w3c.dom.Document)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)10 StandardWorkflow (com.adaptris.core.StandardWorkflow)9 URLString (com.adaptris.util.URLString)9 TimeoutException (java.util.concurrent.TimeoutException)9 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 Workflow (com.adaptris.core.Workflow)8 XPath (com.adaptris.util.text.xml.XPath)8