use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class GenericMessageTypeTranslatorCase method testMetadataConverter.
@Test
public void testMetadataConverter() throws Exception {
MessageTypeTranslatorImp trans = createTranslator().withMetadataConverters(new StringMetadataConverter(new RegexMetadataFilter().withIncludePatterns(STRING_METADATA)), new IntegerMetadataConverter(new RegexMetadataFilter().withIncludePatterns(INTEGER_METADATA)), new BooleanMetadataConverter(new RegexMetadataFilter().withIncludePatterns(BOOLEAN_METADATA)));
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
start(trans, session);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
addMetadata(msg);
Message jmsMsg = trans.translate(msg);
assertJmsProperties(jmsMsg);
} finally {
stop(trans);
}
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class BytesMessageTranslatorTest method testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter.
@Override
@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);
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);
assertMetadata(msg, new MetadataElement(STRING_METADATA, STRING_VALUE));
assertMetadata(msg, new MetadataElement(BOOLEAN_METADATA, BOOLEAN_VALUE));
assertFalse(msg.containsKey(INTEGER_METADATA));
} finally {
stop(trans);
}
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class CreateQueryStringFromMetadataTest method createService.
public CreateQueryStringFromMetadata createService() {
CreateQueryStringFromMetadata svc = new CreateQueryStringFromMetadata().withMetadataFilter(new RegexMetadataFilter().withIncludePatterns("param1", "param2", "param3")).withQuerySeparator(null);
svc.setResultKey("resultKey");
return svc;
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class MessageTypeTranslatorCase method testSetMetadataFilter.
@Test
public void testSetMetadataFilter() throws Exception {
MessageTypeTranslatorImp translator = createTranslator();
assertNull(translator.getMetadataFilter());
assertNotNull(translator.metadataFilter());
assertEquals(NoOpMetadataFilter.class, translator.metadataFilter().getClass());
RegexMetadataFilter filter = new RegexMetadataFilter();
translator.setMetadataFilter(filter);
assertEquals(filter, translator.getMetadataFilter());
assertEquals(filter, translator.metadataFilter());
translator.setMetadataFilter(null);
assertNull(translator.getMetadataFilter());
assertNotNull(translator.metadataFilter());
assertEquals(NoOpMetadataFilter.class, translator.metadataFilter().getClass());
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class StandardResponseProducerTest method testResponse_CompositeResponseHeaders.
@Test
public void testResponse_CompositeResponseHeaders() throws Exception {
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
responder.setSendPayload(false);
CompositeResponseHeaderProvider provider = new CompositeResponseHeaderProvider(new MetadataResponseHeaderProvider(new RegexMetadataFilter()), new ConfiguredResponseHeaderProvider(new KeyValuePair("Hello", "World")));
responder.setResponseHeaderProvider(provider);
AddMetadataService meta = new AddMetadataService();
meta.addMetadataElement(getName(), getName());
ServiceList sl = new ServiceList(new Service[] { meta, new StandaloneProducer(responder) });
HttpConnection httpConnection = createConnection();
Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), sl));
StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
AdaptrisMessage msg = createMessage();
try {
c.requestStart();
start(requestor);
requestor.doService(msg);
assertNotSame(TEXT, msg.getContent());
assertTrue(msg.containsKey(getName()));
assertTrue(msg.containsKey("Hello"));
} finally {
c.requestClose();
stop(requestor);
PortManager.release(httpConnection.getPort());
}
}
Aggregations