use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class DefaultBulkApiClient method unmarshalResponse.
private <T> T unmarshalResponse(InputStream response, Request request, Class<T> resultClass) throws SalesforceException {
try {
Unmarshaller unmarshaller = context.createUnmarshaller();
JAXBElement<T> result = unmarshaller.unmarshal(new StreamSource(response), resultClass);
return result.getValue();
} catch (JAXBException e) {
throw new SalesforceException(String.format("Error unmarshaling response {%s:%s} : %s", request.getMethod(), request.getURI(), e.getMessage()), e);
} catch (IllegalArgumentException e) {
throw new SalesforceException(String.format("Error unmarshaling response for {%s:%s} : %s", request.getMethod(), request.getURI(), e.getMessage()), e);
}
}
use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class ConsumerEndpointMappingByBeanNameRouteTest method testBeanName.
@Test
public void testBeanName() throws Exception {
StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuote));
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
webServiceTemplate.sendSourceAndReceiveToResult(source, result);
assertNotNull(result);
TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString());
}
use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class ConsumerEndpointMappingResponseHandlingRouteTest method testRootQName.
@Test
public void testRootQName() throws Exception {
StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuote));
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
webServiceTemplate.sendSourceAndReceiveToResult(source, result);
assertNotNull(result);
TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString());
}
use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class MixedStreamCachingInterceptorTest method testNoStreamCaching.
public void testNoStreamCaching() throws Exception {
MockEndpoint b = getMockEndpoint("mock:b");
b.expectedMessageCount(1);
StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
template.sendBody("direct:b", message);
assertMockEndpointsSatisfied();
Exchange exchange = b.getExchanges().get(0);
StreamSource stream = assertIsInstanceOf(StreamSource.class, exchange.getIn().getBody());
assertNotNull(stream);
}
use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class NoStreamCachingInterceptorTest method testNoStreamCachingInterceptorEnabled.
public void testNoStreamCachingInterceptorEnabled() throws Exception {
MockEndpoint a = getMockEndpoint("mock:a");
a.expectedMessageCount(1);
StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
template.sendBody("direct:a", message);
assertMockEndpointsSatisfied();
Exchange exchange = a.getExchanges().get(0);
StreamSource stream = assertIsInstanceOf(StreamSource.class, exchange.getIn().getBody());
assertNotNull(stream);
}
Aggregations