use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class DiscardValuesTooLongFilterTest method testFilterMessage_EmptyMetadata.
@Test
public void testFilterMessage_EmptyMetadata() throws Exception {
DiscardValuesTooLongFilter filter = new DiscardValuesTooLongFilter(36);
MetadataCollection c = filter.filter(AdaptrisMessageFactory.getDefaultInstance().newMessage());
assertEquals(0, c.size());
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class ExcludeJmsHeadersTest method testFilter.
@Test
public void testFilter() {
ExcludeJmsHeaders filter = new ExcludeJmsHeaders();
AdaptrisMessage msg = addSomeMetadata(DefaultMessageFactory.getDefaultInstance().newMessage());
int origSize = msg.getMetadata().size();
MetadataCollection resultingCollection = filter.filter(msg);
assertEquals(origSize - 2, resultingCollection.size());
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MetadataConverterCase method testSetPropertyWithReserved.
@Test
public void testSetPropertyWithReserved() throws Exception {
MetadataConverter mc = createConverter();
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
MetadataCollection metadataCollection = new MetadataCollection();
metadataCollection.add(new MetadataElement(HEADER, getStringValue()));
metadataCollection.add(new MetadataElement("JMSCorrelationID", "1234"));
Message jmsMsg = session.createMessage();
mc.moveMetadata(metadataCollection, jmsMsg);
assertEquals(getStringValue(), jmsMsg.getStringProperty(HEADER));
assertNull(jmsMsg.getStringProperty("JMSCorrelationID"));
assertValue(jmsMsg);
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MetadataHelperTest method testConvertToProperties.
@Test
public void testConvertToProperties() {
MetadataCollection c = new MetadataCollection();
c.add(new MetadataElement("test", "value"));
assertNotNull(convertToProperties(c));
assertTrue(convertToProperties(c).containsKey("test"));
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class InlineMimePartBuilder method build.
@Override
public MimeBodyPart build(AdaptrisMessage msg) throws Exception {
InternetHeaders hdrs = new InternetHeaders();
byte[] encodedData = MimeUtils.encodeData(body().wrap(msg), contentEncoding(msg), hdrs);
hdrs.addHeader(HEADER_CONTENT_TYPE, contentType(msg));
// This allows the metadata filter to override the content-type.
MetadataCollection metadata = partHeaderFilter().filter(msg);
metadata.forEach((e) -> {
hdrs.addHeader(e.getKey(), e.getValue());
});
MimeBodyPart part = new MimeBodyPart(hdrs, encodedData);
// This means the content-id is always from the configured contentID expression.
part.setContentID(contentId(msg));
return part;
}
Aggregations