use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testXSLT_XslMessageTerminate.
@Test
public void testXSLT_XslMessageTerminate() throws Exception {
MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
MultiPayloadXmlTransformService service = createBaseExample();
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);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MessageHelper method createMultiPayloadMessage.
public static MultiPayloadAdaptrisMessage createMultiPayloadMessage(String payloadId, String filename, String encoding) throws IOException {
MultiPayloadMessageFactory factory = new MultiPayloadMessageFactory();
factory.setDefaultPayloadId(payloadId);
if (encoding != null) {
factory.setDefaultCharEncoding(encoding);
}
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) factory.newMessage();
StreamUtil.copyAndClose(new FileInputStream(new File(filename)), message.getOutputStream(payloadId));
return message;
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadMessageSplitter method splitMessage.
@Override
public Iterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) {
List<AdaptrisMessage> splitMessages = new ArrayList<>();
if (!(msg instanceof MultiPayloadAdaptrisMessage)) {
log.warn("Message [{}] is not a multi-payload message!", msg.getUniqueId());
splitMessages.add(msg);
} else {
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) msg;
for (String id : message.getPayloadIDs()) {
message.switchPayload(id);
try {
AdaptrisMessage splitMessage = DefaultMessageFactory.getDefaultInstance().newMessage(message, null);
splitMessage.setPayload(message.getPayload());
splitMessages.add(splitMessage);
} catch (CloneNotSupportedException e) {
log.error("Could not clone message [{}]", id, e);
}
}
}
log.info("Split multi-payload message into {} standard messages", splitMessages.size());
return splitMessages;
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadStreamOutputParameterTest method testInsertSetId.
@Test
public void testInsertSetId() throws Exception {
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
try (InputStream in = new ByteArrayInputStream(PAYLOAD.getBytes())) {
InputStreamWithEncoding stream = new InputStreamWithEncoding(in, ENCODING);
MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
parameter.setPayloadId(ID);
parameter.insert(stream, message);
}
assertEquals(PAYLOAD, message.getContent(ID));
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadStreamOutputParameterTest method testInsertNoEncoding.
@Test
public void testInsertNoEncoding() throws Exception {
MultiPayloadMessageFactory messageFactory = new MultiPayloadMessageFactory();
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) messageFactory.newMessage();
try (InputStream in = new ByteArrayInputStream(PAYLOAD.getBytes())) {
InputStreamWithEncoding stream = new InputStreamWithEncoding(in, null);
MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
parameter.setContentEncoding(null);
parameter.insert(stream, ID, message);
}
assertEquals(PAYLOAD, message.getContent(ID));
}
Aggregations