KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > SOAPTestCase


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
17 package org.apache.axis2.soap;
18
19 import org.apache.axis2.om.AbstractTestCase;
20 import org.apache.axis2.om.OMAbstractFactory;
21 import org.apache.axis2.om.OMFactory;
22 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
23
24 import javax.xml.stream.XMLInputFactory;
25 import javax.xml.stream.XMLStreamException;
26 import javax.xml.stream.XMLStreamReader;
27 import java.io.FileNotFoundException JavaDoc;
28 import java.io.FileReader JavaDoc;
29
30 public class SOAPTestCase extends AbstractTestCase {
31     protected SOAPFactory soap11Factory;
32     protected SOAPFactory soap12Factory;
33     protected OMFactory omFactory;
34
35     protected SOAPEnvelope soap11Envelope;
36     protected SOAPEnvelope soap12Envelope;
37
38     protected SOAPEnvelope soap11EnvelopeWithParser;
39     protected SOAPEnvelope soap12EnvelopeWithParser;
40
41     protected static final String JavaDoc SOAP11_FILE_NAME = "soap/soap11/soap11message.xml";
42     protected static final String JavaDoc SOAP12_FILE_NAME = "soap/soap12message.xml";
43
44     /**
45      * @param testName
46      */

47     public SOAPTestCase(String JavaDoc testName) {
48         super(testName);
49         soap11Factory = OMAbstractFactory.getSOAP11Factory();
50         soap12Factory = OMAbstractFactory.getSOAP12Factory();
51         omFactory = OMAbstractFactory.getOMFactory();
52     }
53
54     protected void setUp() throws Exception JavaDoc {
55         super.setUp();
56
57         soap11Envelope = soap11Factory.createSOAPEnvelope();
58         soap12Envelope = soap12Factory.createSOAPEnvelope();
59
60         soap11EnvelopeWithParser = (SOAPEnvelope)this.getSOAPBuilder(SOAP11_FILE_NAME).getDocumentElement();
61         soap12EnvelopeWithParser = (SOAPEnvelope)this.getSOAPBuilder(SOAP12_FILE_NAME).getDocumentElement();
62     }
63
64     protected StAXSOAPModelBuilder getSOAPBuilder(String JavaDoc fileName) {
65         XMLStreamReader parser = null;
66         try {
67             parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader JavaDoc(getTestResourceFile(fileName)));
68         } catch (XMLStreamException e) {
69             e.printStackTrace();
70         } catch (FileNotFoundException JavaDoc e) {
71             e.printStackTrace();
72         }
73         return new StAXSOAPModelBuilder(parser);
74     }
75
76 }
77
Popular Tags