Search in sources :

Example 1 with RemoveAllMetadataFilter

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

the class MessageTypeTranslatorCase method testMoveMetadataJmsMessageToAdaptrisMessage_RemoveAllFilter.

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

Example 2 with RemoveAllMetadataFilter

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

the class HttpProducer method init.

@Override
public void init() throws CoreException {
    try {
        if (getUserName() != null && getPassword() != null) {
            authString = buildBasicRfc2617(getUserName(), Password.decode(ExternalResolver.resolve(getPassword())));
            passwordAuth = new PasswordAuthentication(userName, Password.decode(ExternalResolver.resolve(getPassword())).toCharArray());
        }
        if (sendMetadataAsHeaders()) {
            if (getSendMetadataRegexp() == null && getMetadataFilter() instanceof RemoveAllMetadataFilter) {
                log.warn("No Metadata Regular expression configured, ignoring sendMetadataAsHeaders=true");
                setSendMetadataAsHeaders(Boolean.FALSE);
            } else {
                if (getSendMetadataRegexp() != null && getMetadataFilter() instanceof RemoveAllMetadataFilter) {
                    log.trace("Overriding metadata-filter with filter based on {}", getSendMetadataRegexp());
                    RegexMetadataFilter filter = new RegexMetadataFilter();
                    filter.addIncludePattern(getSendMetadataRegexp());
                    setMetadataFilter(filter);
                }
            }
        }
    } catch (Exception e) {
        throw new CoreException(e);
    }
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) CoreException(com.adaptris.core.CoreException) RemoveAllMetadataFilter(com.adaptris.core.metadata.RemoveAllMetadataFilter) ProduceException(com.adaptris.core.ProduceException) IOException(java.io.IOException) CoreException(com.adaptris.core.CoreException) PasswordAuthentication(java.net.PasswordAuthentication)

Example 3 with RemoveAllMetadataFilter

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

the class BytesMessageTranslatorTest method testMoveMetadataJmsMessageToAdaptrisMessage_RemoveAllFilter.

@Override
@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage_RemoveAllFilter() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator();
    trans.setMetadataFilter(new RemoveAllMetadataFilter());
    try {
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        BytesMessage jmsMsg = createMessage(session);
        addProperties(jmsMsg);
        start(trans, session);
        // We aren't actually producing the message, so we have to
        // switch to read-only mode.
        jmsMsg.reset();
        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertFalse(msg.containsKey(INTEGER_METADATA));
        assertFalse(msg.containsKey(STRING_METADATA));
        assertFalse(msg.containsKey(BOOLEAN_METADATA));
    } finally {
        stop(trans);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RemoveAllMetadataFilter(com.adaptris.core.metadata.RemoveAllMetadataFilter) BytesMessage(javax.jms.BytesMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 4 with RemoveAllMetadataFilter

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

the class MessageTypeTranslatorCase method testMoveMetadata_AdaptrisMessageToJmsMessage_RemoveAll.

@Test
public void testMoveMetadata_AdaptrisMessageToJmsMessage_RemoveAll() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator().withMetadataFilter(new RemoveAllMetadataFilter());
    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);
        assertNull(jmsMsg.getStringProperty(STRING_METADATA));
        assertNull(jmsMsg.getStringProperty(BOOLEAN_METADATA));
        assertNull(jmsMsg.getStringProperty(INTEGER_METADATA));
    } finally {
        stop(trans);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RemoveAllMetadataFilter(com.adaptris.core.metadata.RemoveAllMetadataFilter) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

RemoveAllMetadataFilter (com.adaptris.core.metadata.RemoveAllMetadataFilter)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 Session (javax.jms.Session)3 Test (org.junit.Test)3 MessageTypeTranslatorImp (com.adaptris.core.jms.MessageTypeTranslatorImp)2 Message (javax.jms.Message)2 CoreException (com.adaptris.core.CoreException)1 ProduceException (com.adaptris.core.ProduceException)1 RegexMetadataFilter (com.adaptris.core.metadata.RegexMetadataFilter)1 IOException (java.io.IOException)1 PasswordAuthentication (java.net.PasswordAuthentication)1 BytesMessage (javax.jms.BytesMessage)1