use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MetadataLoggerTest method testDefaultMethods.
@Test
public void testDefaultMethods() {
AdaptrisMessage msg = MessageLoggerTest.createMessage();
MetadataElement e1 = msg.getMetadata("LENGTH_39");
MetadataElement e2 = msg.getMetadata("LENGTH_43");
String s = new MetadataKeysOnly().toString(e1, e2);
System.err.println("testDefaultMethods:: " + s);
assertNotNull(s);
assertFalse(s.contains("The quick brown fox jumps over the lazy dog"));
assertFalse(s.contains("Pack my box with five dozen liquor jugs"));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class SimpleHttpProducer method readResponse.
private void readResponse(HttpSession httpReply, AdaptrisMessage reply) throws IOException, CoreException {
int responseCode = httpReply.getResponseLine().getResponseCode();
if (!ignoreServerResponseCode()) {
if (responseCode < 200 || responseCode > 299) {
throw new ProduceException("Failed to send payload, got " + responseCode);
}
}
if (getEncoder() != null) {
copy(getEncoder().readMessage(httpReply), reply);
} else {
OutputStream out = reply.getOutputStream();
InputStream in = httpReply.getResponseMessage().getInputStream();
StreamUtil.copyStream(in, out);
reply.addMetadata(new MetadataElement(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE, String.valueOf(responseCode)));
out.close();
in.close();
}
return;
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MessageTypeTranslatorCase method assertMetadata.
public static void assertMetadata(AdaptrisMessage msg) {
assertMetadata(msg, new MetadataElement(STRING_METADATA, STRING_VALUE));
assertMetadata(msg, new MetadataElement(BOOLEAN_METADATA, BOOLEAN_VALUE));
assertMetadata(msg, new MetadataElement(INTEGER_METADATA, INTEGER_VALUE));
}
use of com.adaptris.core.MetadataElement 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);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MetadataRequestHeaders method addHeaders.
@Override
public HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target) {
MetadataCollection metadataSubset = getFilter().filter(msg);
for (MetadataElement me : metadataSubset) {
String value = unfold(me.getValue());
log.trace("Adding Request Property [{}: {}]", me.getKey(), value);
target.addRequestProperty(me.getKey(), value);
}
return target;
}
Aggregations