KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > OMTestCase


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;
17
18 import org.apache.axis2.soap.SOAPEnvelope;
19 import org.apache.axis2.soap.SOAPFactory;
20 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
21
22 import javax.xml.stream.*;
23 import java.io.FileReader JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import java.io.OutputStream JavaDoc;
26
27 public abstract class OMTestCase extends AbstractTestCase {
28     protected static final String JavaDoc IN_FILE_NAME = "soap/soapmessage.xml";
29     protected StAXSOAPModelBuilder builder;
30     protected OMFactory ombuilderFactory;
31     protected SOAPFactory soapFactory;
32
33     protected SOAPEnvelope soapEnvelope;
34
35     public OMTestCase(String JavaDoc testName) {
36         super(testName);
37         ombuilderFactory = OMAbstractFactory.getOMFactory();
38         soapFactory = OMAbstractFactory.getSOAP11Factory();
39     }
40
41     protected void setUp() throws Exception JavaDoc {
42         super.setUp();
43         soapEnvelope = (SOAPEnvelope) getOMBuilder("").getDocumentElement();
44     }
45
46     protected StAXSOAPModelBuilder getOMBuilder(String JavaDoc fileName) throws Exception JavaDoc {
47         if (fileName == "" || fileName == null) {
48             fileName = IN_FILE_NAME;
49         }
50         XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader JavaDoc(getTestResourceFile(fileName)));
51         builder = new StAXSOAPModelBuilder(parser);
52         return builder;
53     }
54
55     protected StAXSOAPModelBuilder getOMBuilder(InputStream JavaDoc in) throws Exception JavaDoc {
56         XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
57         builder = new StAXSOAPModelBuilder(parser);
58         return builder;
59     }
60
61     protected XMLStreamWriter getStAXStreamWriter(OutputStream JavaDoc out) throws XMLStreamException {
62         return XMLOutputFactory.newInstance().createXMLStreamWriter(out);
63     }
64
65
66 }
67
Popular Tags