use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObtainUrlWithEmptyMetadataValueInMessage.
@Test
public void testObtainUrlWithEmptyMetadataValueInMessage() throws Exception {
MultiPayloadXmlTransformService service = new MultiPayloadXmlTransformService();
MultiPayloadAdaptrisMessage msg = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
msg.addMetadata("key", "");
try {
service.setUrl(URL);
service.setMetadataKey("key");
LifecycleHelper.init(service);
assertEquals(URL, service.obtainUrlToUse(msg));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.
the class MultiPayloadStreamInputParameterTest method testExtract.
@Test
public void testExtract() throws Exception {
MultiPayloadStreamInputParameter parameter = new MultiPayloadStreamInputParameter();
parameter.setPayloadId(ID);
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage(ID, PAYLOAD);
try (InputStream stream = parameter.extract(message)) {
for (byte b : PAYLOAD) {
assertEquals(b, stream.read());
}
}
try (InputStream stream = parameter.extract(ID, message)) {
for (byte b : PAYLOAD) {
assertEquals(b, stream.read());
}
}
try (InputStream stream = parameter.extract(null, message)) {
for (byte b : PAYLOAD) {
assertEquals(b, stream.read());
}
}
}
use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.
the class MultiPayloadStreamOutputParameterTest method testInsertNullStream.
@Test
public void testInsertNullStream() throws Exception {
MultiPayloadMessageFactory messageFactory = new MultiPayloadMessageFactory();
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) messageFactory.newMessage();
try {
InputStreamWithEncoding stream = new InputStreamWithEncoding(null, ENCODING);
MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
parameter.insert(stream, ID, message);
} catch (Exception e) {
// expected
}
}
use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.
the class MultiPayloadStreamOutputParameterTest method testInsert.
@Test
public void testInsert() 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.insert(stream, ID, message);
}
assertEquals(PAYLOAD, message.getContent(ID));
}
use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.
the class MultiPayloadStreamOutputParameterTest method testInsertUseDefaultId.
@Test
public void testInsertUseDefaultId() throws Exception {
MultiPayloadMessageFactory messageFactory = new MultiPayloadMessageFactory();
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) messageFactory.newMessage();
try (InputStream in = new ByteArrayInputStream(PAYLOAD.getBytes())) {
InputStreamWithEncoding stream = new InputStreamWithEncoding(in, ENCODING);
MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
parameter.insert(stream, null, message);
}
assertEquals(PAYLOAD, message.getContent(messageFactory.getDefaultPayloadId()));
}
Aggregations