Search in sources :

Example 1 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class MetadataConverterCase method testSetProperty.

@Test
public void testSetProperty() throws Exception {
    MetadataConverter mc = createConverter();
    Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
    MetadataCollection metadataCollection = new MetadataCollection();
    metadataCollection.add(new MetadataElement(HEADER, getStringValue()));
    Message jmsMsg = session.createMessage();
    mc.moveMetadata(metadataCollection, jmsMsg);
    assertEquals(getStringValue(), jmsMsg.getStringProperty(HEADER));
    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 2 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class ConvertingMetadataConverterCase method testConvertFailure_Strict.

@Test
public void testConvertFailure_Strict() throws Exception {
    MetadataConverter mc = createConverter();
    mc.setStrictConversion(true);
    try {
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        MetadataCollection metadataCollection = new MetadataCollection();
        metadataCollection.add(new MetadataElement(HEADER, testName.getMethodName()));
        Message jmsMsg = session.createMessage();
        mc.moveMetadata(metadataCollection, jmsMsg);
        fail();
    } catch (JMSException expected) {
    }
}
Also used : Message(javax.jms.Message) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) JMSException(javax.jms.JMSException) Session(javax.jms.Session) Test(org.junit.Test)

Example 3 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class ConvertingMetadataConverterCase method testConvertFailure.

@Test
public void testConvertFailure() throws Exception {
    MetadataConverter mc = createConverter();
    Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
    MetadataCollection metadataCollection = new MetadataCollection();
    metadataCollection.add(new MetadataElement(HEADER, testName.getMethodName()));
    Message jmsMsg = session.createMessage();
    mc.moveMetadata(metadataCollection, jmsMsg);
    assertEquals(testName.getMethodName(), jmsMsg.getStringProperty(HEADER));
}
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 4 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class CompositeMetadataFilterTest method testFilter.

@Test
public void testFilter() {
    CompositeMetadataFilter filterer = new CompositeMetadataFilter(new NoOpMetadataFilter(), new RegexMetadataFilter());
    AdaptrisMessage message = newMessage();
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(message.getMetadata().size(), resultingCollection.size());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 5 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class DiscardEmptyValuesFilterTest method testFilterSet.

@Test
public void testFilterSet() throws Exception {
    DiscardEmptyValuesFilter filter = new DiscardEmptyValuesFilter();
    MetadataCollection c = filter.filter(createMessage().getMetadata());
    assertEquals(3, c.size());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

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