assertNotNull(msg.getAttachment("id"));
assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
}
public void testDisplay() throws Exception {
Exchange e = new ExchangeImpl(Pattern.InOnly);
e.setOperation(new QName("op"));
e.setProperty("key", "value");
e.setStatus(Status.Done);
Message msg = e.getIn();
msg.setHeader("header", "value");
msg.addAttachment("id", new BufferedInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 })));
msg.setBody(new StringSource("<hello/>"));
String str = e.display(false);
LOG.info(str);
assertNotNull(msg.getBody());
assertTrue(msg.getBody() instanceof StringSource);
assertNotNull(msg.getAttachment("id"));
assertTrue(msg.getAttachment("id") instanceof BufferedInputStream);
assertTrue(str.indexOf("<hello/>") == -1);
str = e.display(true);
LOG.info(str);
assertNotNull(msg.getBody());
assertTrue(msg.getBody() instanceof StringSource);
assertNotNull(msg.getAttachment("id"));
assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
assertTrue(str.indexOf("<hello/>") != -1);
// now switch to suppression mode
System.setProperty(ExchangeUtils.SYSTEM_PROPERTY_SUPPRESS_CONTENT, "true");
str = e.display(true);
LOG.info(str);
assertNotNull(msg.getBody());
assertTrue(msg.getBody() instanceof StringSource);
assertNotNull(msg.getAttachment("id"));
assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);