use of java.io.StringReader 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 java.io.StringReader 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 java.io.StringReader 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 java.io.StringReader 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);
}
use of java.io.StringReader in project camel by apache.
the class XAdESSignatureProperties method createChildFromXmlFragmentOrText.
protected Element createChildFromXmlFragmentOrText(Document doc, Input input, String localElementName, String errorMessage, String elementOrText) throws IOException, ParserConfigurationException, XmlSignatureException {
String ending = localElementName + ">";
Element child;
if (elementOrText.startsWith("<") && elementOrText.endsWith(ending)) {
try {
// assume xml
InputSource source = new InputSource(new StringReader(elementOrText));
source.setEncoding("UTF-8");
Document parsedDoc = XmlSignatureHelper.newDocumentBuilder(Boolean.TRUE).parse(source);
replacePrefixes(parsedDoc, input);
child = (Element) doc.adoptNode(parsedDoc.getDocumentElement());
// check for correct namespace
String ns = findNamespace(input.getMessage());
if (!ns.equals(child.getNamespaceURI())) {
throw new XmlSignatureException(String.format("The XAdES confguration is invalid. The root element '%s' of the provided XML fragment '%s' has the invalid namespace '%s'. The correct namespace is '%s'.", child.getLocalName(), elementOrText, child.getNamespaceURI(), ns));
}
} catch (SAXException e) {
throw new XmlSignatureException(String.format(errorMessage, elementOrText, localElementName, namespace), e);
}
} else {
child = createElement(localElementName, doc, input);
child.setTextContent(elementOrText);
}
return child;
}
Aggregations