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;
}
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);
}
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());
}
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);
}
}
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);
}
}
Aggregations