KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import javax.xml.stream.XMLOutputFactory;
21 import javax.xml.stream.XMLStreamException;
22
23
24 public class SOAPFaultTest extends AbstractTestCase {
25     private SOAPEnvelope soapEnvelope;
26     private OMOutput omOutput;
27
28     /**
29      * Constructor.
30      */

31     public SOAPFaultTest(String JavaDoc testName) {
32         super(testName);
33     }
34
35     protected void setUp() throws Exception JavaDoc {
36         super.setUp();
37         omOutput = new OMOutput(XMLOutputFactory.newInstance().
38                 createXMLStreamWriter(System.out));
39     }
40
41     public void testSOAPFault() throws Exception JavaDoc {
42 // soapEnvelope = (SOAPEnvelope) OMTestUtils.getOMBuilder(getTestResourceFile("soap/minimalMessage.xml")).getDocumentElement();
43
// SOAPBody soapBody = soapEnvelope.getBody();
44
// SOAPFault soapFault = OMAbstractFactory.getSOAP11Factory().createSOAPFault(soapBody, new Exception("Something has gone wrong som where !!"));
45
// soapBody.addFault(soapFault);
46
// soapFault.setCode(null);
47
// assertEquals("faultcode returned is incorrect", soapFault.getCode().getLocalName(), "Axis");
48
// assertEquals("faultcode returned is incorrect", soapFault.getCode().getNamespace().getPrefix(), "SOAP-ENV");
49

50
51
52     }
53
54     private void print() throws XMLStreamException {
55         soapEnvelope.serializeWithCache(omOutput);
56         omOutput.flush();
57     }
58 }
59
Popular Tags