Search in sources :

Example 21 with MetadataCollection

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

the class MetadataRegexKeyFilterTest method testExcludes5Keys.

@Test
public void testExcludes5Keys() {
    filterer.addExcludePattern("key");
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(3, resultingCollection.size());
    assertTrue(resultingCollection.containsKey("someRandomKey"));
    assertTrue(resultingCollection.containsKey("JackAndJill"));
    assertTrue(resultingCollection.containsKey("JillAndJack"));
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 22 with MetadataCollection

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

the class MetadataRegexKeyFilterTest method testNoIncludesOrExcludes.

@Test
public void testNoIncludesOrExcludes() {
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(message.getMetadata().size(), resultingCollection.size());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 23 with MetadataCollection

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

the class CreateQueryStringFromMetadataTest method testService_WithException.

@Test
public void testService_WithException() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    CreateQueryStringFromMetadata service = createService().withMetadataFilter(new MetadataFilterImpl() {

        @Override
        public MetadataCollection filter(MetadataCollection original) {
            throw new RuntimeException();
        }
    });
    try {
        execute(service, msg);
        fail();
    } catch (Exception expected) {
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataFilterImpl(com.adaptris.core.metadata.MetadataFilterImpl) Test(org.junit.Test)

Example 24 with MetadataCollection

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

the class MetadataHelperTest method testToSet.

@Test
public void testToSet() {
    Set<MetadataElement> elements = new HashSet<>();
    elements.add(new MetadataElement("test", "value"));
    MetadataCollection c = new MetadataCollection(elements);
    assertEquals(elements, c.toSet());
}
Also used : MetadataElement(com.adaptris.core.MetadataElement) MetadataCollection(com.adaptris.core.MetadataCollection) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 25 with MetadataCollection

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

the class MetadataRequestHeaders method addHeaders.

@Override
public HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target) {
    MetadataCollection metadataSubset = getFilter().filter(msg);
    for (MetadataElement me : metadataSubset) {
        String value = unfold(me.getValue());
        log.trace("Adding Request Property [{}: {}]", me.getKey(), value);
        target.addRequestProperty(me.getKey(), value);
    }
    return target;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

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