use of org.apache.camel.impl.DefaultAttachment in project camel by apache.
the class MimeMultipartDataFormatTest method addAttachment.
private void addAttachment(String attContentType, String attText, String attFileName, Map<String, String> headers) throws IOException {
DataSource ds = new ByteArrayDataSource(attText, attContentType);
DefaultAttachment attachment = new DefaultAttachment(ds);
if (headers != null) {
for (String headerName : headers.keySet()) {
attachment.addHeader(headerName, headers.get(headerName));
}
}
in.addAttachmentObject(attFileName, attachment);
}
use of org.apache.camel.impl.DefaultAttachment in project camel by apache.
the class DefaultCxfBinding method createCamelAttachment.
private DefaultAttachment createCamelAttachment(Attachment attachment) {
DefaultAttachment camelAttachment = new DefaultAttachment(attachment.getDataHandler());
Iterator<String> headers = attachment.getHeaderNames();
while (headers.hasNext()) {
String name = headers.next();
camelAttachment.addHeader(name, attachment.getHeader(name));
}
return camelAttachment;
}
use of org.apache.camel.impl.DefaultAttachment in project camel by apache.
the class BeanWithAttachmentAnnotationTest method testBeanWithAnnotationAndExchangeTest.
public void testBeanWithAnnotationAndExchangeTest() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("attachment");
template.send("direct:in", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message m = exchange.getIn();
m.addAttachmentObject("attachment", new DefaultAttachment(new FileDataSource("src/test/org/apache/camel/component/bean/BeanWithAttachmentAnnotationTest.java")));
}
});
mock.assertIsSatisfied();
}
Aggregations