use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class ConsumerWSAEndpointMappingRouteTest method testWSAddressingToResponseActions.
@Test
public void testWSAddressingToResponseActions() throws Exception {
StreamSource source = new StreamSource(new StringReader(xmlBody));
webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://doesn-not-matter.com"), new Addressing10(), new URI("http://urlOutputAndFault2.to")), TestUtil.NOOP_SOURCE_EXTRACTOR);
resultOutputAndFault2.expectedMinimumMessageCount(1);
resultOutputAndFault2.assertIsSatisfied();
}
use of javax.xml.transform.stream.StreamSource in project camel by apache.
the class AbstractWSATests method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
// initialize beans for catching results
webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
newReply = getMandatoryBean(OutputChannelReceiver.class, "replyReceiver");
response = getMandatoryBean(OutputChannelReceiver.class, "responseReceiver");
// sample data
source = new StreamSource(new StringReader(xmlBody));
result = new StreamResult(new StringWriter());
// reset from previous test
response.clear();
newReply.clear();
requestInputAction = null;
}
use of javax.xml.transform.stream.StreamSource in project hazelcast by hazelcast.
the class ClientDiscoverySpiTest method testSchema.
@Test
public void testSchema() throws Exception {
String xmlFileName = "hazelcast-client-discovery-spi-test.xml";
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL schemaResource = ClientDiscoverySpiTest.class.getClassLoader().getResource("hazelcast-client-config-3.9.xsd");
Schema schema = factory.newSchema(schemaResource);
InputStream xmlResource = ClientDiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
Source source = new StreamSource(xmlResource);
Validator validator = schema.newValidator();
validator.validate(source);
}
use of javax.xml.transform.stream.StreamSource in project hazelcast by hazelcast.
the class ConfigXmlGenerator method format.
private String format(final String input, int indent) {
if (!formatted) {
return input;
}
StreamResult xmlOutput = null;
try {
final Source xmlInput = new StreamSource(new StringReader(input));
xmlOutput = new StreamResult(new StringWriter());
TransformerFactory transformerFactory = TransformerFactory.newInstance();
/* Older versions of Xalan still use this method of setting indent values.
* Attempt to make this work but don't completely fail if it's a problem.
*/
try {
transformerFactory.setAttribute("indent-number", indent);
} catch (IllegalArgumentException e) {
if (LOGGER.isFinestEnabled()) {
LOGGER.finest("Failed to set indent-number attribute; cause: " + e.getMessage());
}
}
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
/* Newer versions of Xalan will look for a fully-qualified output property in order to specify amount of
* indentation to use. Attempt to make this work as well but again don't completely fail if it's a problem.
*/
try {
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(indent));
} catch (IllegalArgumentException e) {
if (LOGGER.isFinestEnabled()) {
LOGGER.finest("Failed to set indent-amount property; cause: " + e.getMessage());
}
}
transformer.transform(xmlInput, xmlOutput);
return xmlOutput.getWriter().toString();
} catch (Exception e) {
LOGGER.warning(e);
return input;
} finally {
if (xmlOutput != null) {
closeResource(xmlOutput.getWriter());
}
}
}
use of javax.xml.transform.stream.StreamSource in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldBeAValidXSD.
@Test
public void shouldBeAValidXSD() throws Exception {
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
factory.newSchema(new StreamSource(getClass().getResourceAsStream("/cruise-config.xsd")));
}
Aggregations