KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > impl > streamwrapper > OmStAXBuilderTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 package org.apache.axis2.om.impl.streamwrapper;
17
18 import org.apache.axis2.om.AbstractTestCase;
19 import org.apache.axis2.om.OMAbstractFactory;
20 import org.apache.axis2.om.OMOutput;
21 import org.apache.axis2.om.OMXMLParserWrapper;
22 import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
23 import org.apache.axis2.soap.SOAPEnvelope;
24 import org.apache.axis2.soap.SOAPFactory;
25
26 import javax.xml.stream.XMLInputFactory;
27 import javax.xml.stream.XMLStreamReader;
28 import java.io.File JavaDoc;
29 import java.io.FileOutputStream JavaDoc;
30 import java.io.FileReader JavaDoc;
31
32 public class OmStAXBuilderTest extends AbstractTestCase {
33     private SOAPFactory factory = null;
34     private OMXMLParserWrapper builder;
35     private File JavaDoc tempFile;
36
37     public OmStAXBuilderTest(String JavaDoc testName) {
38         super(testName);
39     }
40
41     protected void setUp() throws Exception JavaDoc {
42         factory = OMAbstractFactory.getSOAP11Factory();
43         XMLStreamReader reader = XMLInputFactory.newInstance().
44                         createXMLStreamReader(new FileReader JavaDoc(getTestResourceFile("soap/soapmessage.xml")));
45         builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(factory, reader);
46         tempFile = File.createTempFile("temp", "xml");
47     }
48
49     public void testStaxBuilder() throws Exception JavaDoc {
50         SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
51         assertNotNull(envelope);
52         OMOutput omOutput = new OMOutput(new FileOutputStream JavaDoc(tempFile),false);
53         // XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
54
envelope.serializeWithCache(omOutput);
55
56
57     }
58
59     protected void tearDown() throws Exception JavaDoc {
60         tempFile.delete();
61     }
62
63
64 }
65
Popular Tags