use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testXSLT_RecoverableError.
@Test
public void testXSLT_RecoverableError() throws Exception {
MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
String oldName = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
MultiPayloadXmlTransformService service = createBaseExample();
try {
execute(service, m1);
// INTERLOK-1850 - Saxon 9.7 won't report exceptions, so even if we throw, it'll just eat it.
// fail("Exception expected but none thrown");
} catch (ServiceException e) {
assertTrue(e.getCause() instanceof TransformerException);
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObjectMetadataParameter_NoRegexp.
@Test
public void testObjectMetadataParameter_NoRegexp() throws Exception {
MultiPayloadAdaptrisMessage msg = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
msg.addObjectHeader("myDocumentObject", XmlHelper.createDocument("<data>World</data>"));
msg.addObjectHeader("anotherDocument", XmlHelper.createDocument("<data>GoodBye</data>"));
MultiPayloadXmlTransformService service = createBaseExample();
service.setUrl(PROPERTIES.getProperty(KEY_XML_NODE_TRANSFORM_URL));
service.setTransformParameter(new ObjectMetadataParameter());
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
// expected
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class CommonsSystemCommandExecutorServiceTest method testDoService_ExceedsTimeout.
@Test
public void testDoService_ExceedsTimeout() throws Exception {
Thread.currentThread().setName(getName());
SystemCommandExecutorService service = new SystemCommandExecutorService(createTimeoutCommand(), new OverwritePayload());
service.setTimeout(new TimeInterval(2L, TimeUnit.SECONDS));
AdaptrisMessage msg = createMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
System.err.println(getName() + "=" + msg.getContent());
expected.printStackTrace(System.err);
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class XmlTransformServiceTest method testObjectMetadataParameter_NoRegexp.
@Test
public void testObjectMetadataParameter_NoRegexp() throws Exception {
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
msg.addObjectHeader("myDocumentObject", XmlHelper.createDocument("<data>World</data>"));
msg.addObjectHeader("anotherDocument", XmlHelper.createDocument("<data>GoodBye</data>"));
XmlTransformService service = new XmlTransformService();
service.setUrl(PROPERTIES.getProperty(KEY_XML_NODE_TRANSFORM_URL));
service.setTransformParameter(new ObjectMetadataParameter());
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class XmlTransformServiceTest method testXSLT_XslMessageTerminate.
@Test
public void testXSLT_XslMessageTerminate() throws Exception {
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
XmlTransformService service = new XmlTransformService();
XsltTransformerFactory fac = new XsltTransformerFactory();
fac.getTransformerFactoryAttributes().add(new KeyValuePair("http://saxon.sf.net/feature/messageEmitterClass", MessageWarner.class.getCanonicalName()));
fac.getTransformerFactoryFeatures().add(new KeyValuePair(XMLConstants.FEATURE_SECURE_PROCESSING, "true"));
service.setXmlTransformerFactory(fac);
service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL_XSL_MESSAGE));
try {
execute(service, m1);
fail();
} catch (ServiceException expected) {
assertExceptionCause(expected, TransformerException.class, UncheckedXPathException.class);
}
}
Aggregations