01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.saaj.support;
18:
19: import javax.xml.soap.MessageFactory;
20: import javax.xml.soap.SOAPMessage;
21: import javax.xml.transform.Result;
22: import javax.xml.transform.Source;
23: import javax.xml.transform.Transformer;
24: import javax.xml.transform.TransformerFactory;
25: import javax.xml.transform.dom.DOMSource;
26: import javax.xml.transform.sax.SAXSource;
27:
28: import org.custommonkey.xmlunit.XMLTestCase;
29: import org.springframework.xml.transform.StringResult;
30: import org.xml.sax.InputSource;
31:
32: public class SaajXmlReaderTest extends XMLTestCase {
33:
34: private SaajXmlReader reader;
35:
36: private SOAPMessage message;
37:
38: private Transformer transformer;
39:
40: protected void setUp() throws Exception {
41: MessageFactory messageFactory = MessageFactory.newInstance();
42: message = messageFactory.createMessage();
43: reader = new SaajXmlReader(message.getSOAPPart().getEnvelope());
44: transformer = TransformerFactory.newInstance().newTransformer();
45: }
46:
47: public void testIt() throws Exception {
48: Result result = new StringResult();
49: Source source = new SAXSource(reader, new InputSource());
50: transformer.transform(source, result);
51: Result expected = new StringResult();
52: transformer.transform(new DOMSource(message.getSOAPPart()
53: .getEnvelope()), expected);
54: assertXMLEqual(expected.toString(), result.toString());
55: }
56: }
|