Search in sources :

Example 51 with MetadataCollection

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

the class FixedValuesMetadataFilterTest method testFilterMessage.

@Test
public void testFilterMessage() throws Exception {
    FixedValuesMetadataFilter filter = new FixedValuesMetadataFilter().withMetadata(new KeyValuePair("hello", "world"));
    MetadataCollection c = filter.filter(createMessage());
    assertEquals(1, c.size());
    Map<String, String> map = MetadataCollection.asMap(c);
    assertFalse(map.containsKey("someRandomKey"));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 52 with MetadataCollection

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

the class MappedKeyMetadataFilterTest method testFilter.

@Test
public void testFilter() {
    MappedKeyMetadataFilter filterer = new MappedKeyMetadataFilter("^key(.*)$", "actual$1");
    AdaptrisMessage message = newMessage();
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(message.getMetadata().size(), resultingCollection.size());
    assertTrue(message.getMessageHeaders().containsKey("key1"));
    assertFalse(resultingCollection.containsKey("key1"));
    assertFalse(message.getMessageHeaders().containsKey("actual1"));
    assertTrue(resultingCollection.containsKey("actual1"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 53 with MetadataCollection

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

the class MetadataRegexKeyFilterTest method testExcludes2Keys.

@Test
public void testExcludes2Keys() {
    filterer.addExcludePattern("Jill");
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(6, resultingCollection.size());
    assertTrue(resultingCollection.containsKey("key1"));
    assertTrue(resultingCollection.containsKey("key2"));
    assertTrue(resultingCollection.containsKey("key3"));
    assertTrue(resultingCollection.containsKey("key4"));
    assertTrue(resultingCollection.containsKey("key5"));
    assertTrue(resultingCollection.containsKey("someRandomKey"));
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 54 with MetadataCollection

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

the class MetadataRegexKeyFilterTest method testIncludesOnly5Keys.

@Test
public void testIncludesOnly5Keys() {
    filterer.addIncludePattern("key");
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(5, resultingCollection.size());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 55 with MetadataCollection

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

the class MetadataRegexKeyFilterTest method testIncludesKeyAndExcludes3.

@Test
public void testIncludesKeyAndExcludes3() {
    filterer.addIncludePattern("key");
    filterer.addExcludePattern("3");
    MetadataCollection resultingCollection = filterer.filter(message);
    assertEquals(4, resultingCollection.size());
    assertTrue(resultingCollection.containsKey("key1"));
    assertTrue(resultingCollection.containsKey("key2"));
    assertTrue(resultingCollection.containsKey("key4"));
    assertTrue(resultingCollection.containsKey("key5"));
}
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