// setup the default context for testing
public void testGetCxfInMessage() throws Exception {
HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
org.apache.camel.Exchange exchange = new DefaultExchange(context);
// String
exchange.getIn().setBody("hello world");
org.apache.cxf.message.Message message = CxfSoapBinding.getCxfInMessage(
headerFilterStrategy, exchange, false);
// test message
InputStream is = message.getContent(InputStream.class);
assertNotNull("The input stream should not be null", is);
assertEquals("Don't get the right message", toString(is), "hello world");
// DOMSource
URL request = this.getClass().getResource("RequestBody.xml");
File requestFile = new File(request.toURI());
FileInputStream inputStream = new FileInputStream(requestFile);
XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
DOMSource source = new DOMSource(StaxUtils.read(xmlReader));
exchange.getIn().setBody(source);
message = CxfSoapBinding.getCxfInMessage(headerFilterStrategy, exchange, false);
is = message.getContent(InputStream.class);
assertNotNull("The input stream should not be null", is);
assertEquals("Don't get the right message", toString(is), REQUEST_STRING);
// File
exchange.getIn().setBody(requestFile);
message = CxfSoapBinding.getCxfInMessage(headerFilterStrategy, exchange, false);
is = message.getContent(InputStream.class);
assertNotNull("The input stream should not be null", is);
assertEquals("Don't get the right message", toString(is), REQUEST_STRING);