use of java.io.StringReader in project camel by apache.
the class CxfRsConsumerSimpleBindingTest method testListVipCustomers.
@Test
public void testListVipCustomers() throws Exception {
HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold");
get.addHeader("Content-Type", "text/xml");
get.addHeader("Accept", "text/xml");
HttpResponse response = httpclient.execute(get);
assertEquals(200, response.getStatusLine().getStatusCode());
CustomerList cl = (CustomerList) jaxb.createUnmarshaller().unmarshal(new StringReader(EntityUtils.toString(response.getEntity())));
List<Customer> vips = cl.getCustomers();
assertEquals(2, vips.size());
assertEquals(123, vips.get(0).getId());
assertEquals(456, vips.get(1).getId());
}
use of java.io.StringReader in project camel by apache.
the class CxfMtomDisabledProducerPayloadModeTest method testProducer.
@Override
public void testProducer() throws Exception {
if (MtomTestHelper.isAwtHeadless(logger, null)) {
return;
}
Exchange exchange = context.createProducerTemplate().send("direct:testEndpoint", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
List<Source> elements = new ArrayList<Source>();
elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.MTOM_DISABLED_REQ_MESSAGE)).getDocumentElement()));
CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(), elements, null);
exchange.getIn().setBody(body);
exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID, new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
exchange.getIn().addAttachment(MtomTestHelper.REQ_IMAGE_CID, new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
}
});
// process response - verify response attachments
CxfPayload<?> out = exchange.getOut().getBody(CxfPayload.class);
Assert.assertEquals(1, out.getBody().size());
DataHandler dr = exchange.getOut().getAttachment(MtomTestHelper.RESP_PHOTO_CID);
Assert.assertEquals("application/octet-stream", dr.getContentType());
MtomTestHelper.assertEquals(MtomTestHelper.RESP_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
dr = exchange.getOut().getAttachment(MtomTestHelper.RESP_IMAGE_CID);
Assert.assertEquals("image/jpeg", dr.getContentType());
BufferedImage image = ImageIO.read(dr.getInputStream());
Assert.assertEquals(560, image.getWidth());
Assert.assertEquals(300, image.getHeight());
}
use of java.io.StringReader in project camel by apache.
the class CacheInputStreamInDeadLetterIssue520Test method testSendingSource.
public void testSendingSource() throws Exception {
StreamSource message = new StreamSource(new StringReader("<hello>Willem</hello>"));
sendingMessage(message);
}
use of java.io.StringReader in project camel by apache.
the class CacheInputStreamInDeadLetterIssue520Test method testSendingReader.
public void testSendingReader() throws Exception {
StringReader message = new StringReader("<hello>Willem</hello>");
sendingMessage(message);
}
use of java.io.StringReader in project camel by apache.
the class StreamCachingInterceptorTest method testConvertStreamSourceWithRouteOnlyStreamCaching.
public void testConvertStreamSourceWithRouteOnlyStreamCaching() throws Exception {
b.expectedMessageCount(1);
StreamSource message = new StreamSource(new StringReader(MESSAGE));
template.sendBody("direct:b", message);
assertMockEndpointsSatisfied();
assertTrue(b.assertExchangeReceived(0).getIn().getBody() instanceof StreamCache);
assertEquals(b.assertExchangeReceived(0).getIn().getBody(String.class), MESSAGE);
}
Aggregations