Search in sources :

Example 41 with MetadataCollection

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());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 42 with MetadataCollection

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());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 43 with MetadataCollection

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);
}
Also used : Message(javax.jms.Message) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) Session(javax.jms.Session) Test(org.junit.Test)

Example 44 with MetadataCollection

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"));
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 45 with MetadataCollection

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;
}
Also used : InternetHeaders(javax.mail.internet.InternetHeaders) MetadataCollection(com.adaptris.core.MetadataCollection) MimeBodyPart(javax.mail.internet.MimeBodyPart)

Aggregations

MetadataCollection (com.adaptris.core.MetadataCollection)66 Test (org.junit.Test)43 MetadataElement (com.adaptris.core.MetadataElement)18 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 KeyValuePair (com.adaptris.util.KeyValuePair)4 Message (javax.jms.Message)4 Session (javax.jms.Session)4 MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)3 InternetHeaders (javax.mail.internet.InternetHeaders)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 Event (com.adaptris.core.Event)1 AdapterCloseEvent (com.adaptris.core.event.AdapterCloseEvent)1 MetadataFilterImpl (com.adaptris.core.metadata.MetadataFilterImpl)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Properties (java.util.Properties)1 JMSException (javax.jms.JMSException)1