Search in sources :

Example 11 with RegexMetadataFilter

use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.

the class MetadataKeyToCapitalCaseTest method createService.

@Override
protected MetadataKeyToCapitalCase createService() {
    MetadataKeyToCapitalCase service = new MetadataKeyToCapitalCase();
    RegexMetadataFilter filter = new RegexMetadataFilter();
    filter.addIncludePattern(KEY_MATCH);
    service.setKeysToModify(filter);
    return service;
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter)

Example 12 with RegexMetadataFilter

use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.

the class MimePartBuilderTest method testBuild_WithPartHeader.

@Test
public void testBuild_WithPartHeader() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
    msg.addMetadata("X-Interlok-Mime", "yes");
    InlineMimePartBuilder builder = new InlineMimePartBuilder().withContentId("%message{%uniqueId}").withPartHeaderFilter(new RegexMetadataFilter().withIncludePatterns("X-Interlok.*"));
    MimeBodyPart part = builder.build(msg);
    assertNotNull(part);
    assertEquals(msg.getUniqueId(), part.getContentID());
    assertEquals(1, part.getHeader("X-Interlok-Mime").length);
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 13 with RegexMetadataFilter

use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.

the class StringMetadataParameterTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    StringMetadataParameter p = new StringMetadataParameter();
    assertNotNull(p.getMetadataFilter());
    p = new StringMetadataParameter(new String[] { "abc" }, new String[] { "def" });
    assertNotNull(p.getMetadataFilter());
    RegexMetadataFilter filter = p.getMetadataFilter();
    assertEquals(1, filter.getIncludePatterns().size());
    assertEquals(1, filter.getExcludePatterns().size());
    assertEquals("abc", filter.getIncludePatterns().get(0));
    assertEquals("def", filter.getExcludePatterns().get(0));
    try {
        p.setMetadataFilter(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertNotNull(p.getMetadataFilter());
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) Test(org.junit.Test)

Example 14 with RegexMetadataFilter

use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.

the class MessageTypeTranslatorCase method testMoveMetadata_AdaptrisMessageToJmsMessage_WithFilter.

@Test
public void testMoveMetadata_AdaptrisMessageToJmsMessage_WithFilter() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator();
    RegexMetadataFilter regexp = new RegexMetadataFilter();
    regexp.addExcludePattern("IntegerMetadataKey");
    trans.setMetadataFilter(regexp);
    try {
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        addMetadata(msg);
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        start(trans, session);
        Message jmsMsg = trans.translate(msg);
        assertEquals(STRING_VALUE, jmsMsg.getStringProperty(STRING_METADATA));
        assertEquals(BOOLEAN_VALUE, jmsMsg.getStringProperty(BOOLEAN_METADATA));
        assertEquals(Boolean.valueOf(BOOLEAN_VALUE).booleanValue(), jmsMsg.getBooleanProperty(BOOLEAN_METADATA));
        assertNull(jmsMsg.getStringProperty(INTEGER_METADATA));
    } finally {
        stop(trans);
    }
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Example 15 with RegexMetadataFilter

use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.

the class MessageTypeTranslatorCase method testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter.

@Test
public void testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator();
    RegexMetadataFilter regexp = new RegexMetadataFilter();
    regexp.addExcludePattern("IntegerMetadataKey");
    trans.setMetadataFilter(regexp);
    try {
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Message jmsMsg = createMessage(session);
        addProperties(jmsMsg);
        start(trans, session);
        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertMetadata(msg, new MetadataElement(STRING_METADATA, STRING_VALUE));
        assertMetadata(msg, new MetadataElement(BOOLEAN_METADATA, BOOLEAN_VALUE));
        assertFalse(msg.containsKey(INTEGER_METADATA));
    } finally {
        stop(trans);
    }
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

RegexMetadataFilter (com.adaptris.core.metadata.RegexMetadataFilter)33 Test (org.junit.Test)25 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)19 Channel (com.adaptris.core.Channel)8 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 Session (javax.jms.Session)5 StandaloneProducer (com.adaptris.core.StandaloneProducer)4 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)4 Message (javax.jms.Message)4 MetadataElement (com.adaptris.core.MetadataElement)3 MessageTypeTranslatorImp (com.adaptris.core.jms.MessageTypeTranslatorImp)3 HttpURLConnection (java.net.HttpURLConnection)3 URL (java.net.URL)3 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 ServiceList (com.adaptris.core.ServiceList)2 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)2 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)2 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 CoreException (com.adaptris.core.CoreException)1