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) {
}
}
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"));
}
}
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"));
}
}
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) {
;
}
}
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);
}
Aggregations