KickJava   Java API By Example, From Geeks To Geeks.

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


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.OMElement;
20 import org.apache.axis2.om.OMNamespace;
21 import org.apache.axis2.om.OMText;
22
23 import java.util.Iterator JavaDoc;
24
25 public class SOAPFaultDetailTest extends SOAPFaultTestCase {
26     protected SOAPFaultDetail soap11FaultDetail;
27     protected SOAPFaultDetail soap12FaultDetail;
28     protected SOAPFaultDetail soap11FaultDetailWithParser;
29     protected SOAPFaultDetail soap12FaultDetailWithParser;
30     protected OMNamespace omNamespace;
31
32     public SOAPFaultDetailTest(String JavaDoc testName) {
33         super(testName);
34         omNamespace = omFactory.createOMNamespace("http://www.test.org","test");
35     }
36
37     protected void setUp() throws Exception JavaDoc {
38         super.setUp();
39         soap11FaultDetail = soap11Factory.createSOAPFaultDetail(soap11Fault);
40         soap12FaultDetail = soap12Factory.createSOAPFaultDetail(soap12Fault);
41         soap11FaultDetailWithParser = soap11FaultWithParser.getDetail();
42         soap12FaultDetailWithParser = soap12FaultWithParser.getDetail();
43     }
44
45     //SOAP 1.1 Fault Detail Test (Programaticaly Created)
46
public void testSOAP11AddDetailEntry() {
47         soap11FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry1",omNamespace));
48         soap11FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry2",omNamespace));
49         Iterator JavaDoc iterator = soap11FaultDetail.getAllDetailEntries();
50         OMElement detailEntry1 = (OMElement)iterator.next();
51         assertFalse("SOAP 1.1 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns empty iterator",detailEntry1 == null);
52         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry1 local name mismatch",detailEntry1.getLocalName().equals("DetailEntry1"));
53         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry1 namespace uri mismatch",detailEntry1.getNamespace().getName().equals("http://www.test.org"));
54         OMElement detailEntry2 = (OMElement)iterator.next();
55         assertFalse("SOAP 1.1 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with only one object",detailEntry2 == null);
56         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry2 local name mismatch",detailEntry2.getLocalName().equals("DetailEntry2"));
57         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry2 namespace uri mismatch",detailEntry2.getNamespace().getName().equals("http://www.test.org"));
58         assertTrue("SOAP 1.1 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with three objects",iterator.next() == null);
59     }
60
61     public void testSOAP11GetAllDetailEntries() {
62         Iterator JavaDoc iterator = soap11FaultDetail.getAllDetailEntries();
63         assertTrue("SOAP 1.1 Fault Detail Test : - After creating SOAP11FaultDetail element, it has DetailEntries",iterator.next() == null);
64         soap11FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry",omNamespace));
65         iterator = soap11FaultDetail.getAllDetailEntries();
66         OMElement detailEntry = (OMElement)iterator.next();
67         assertFalse("SOAP 1.1 Fault Detail Test : - After calling addDetailEntry method, getAllDetailEntries method returns empty iterator",detailEntry == null);
68         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry local name mismatch",detailEntry.getLocalName().equals("DetailEntry"));
69         assertTrue("SOAP 1.1 Fault Detail Test : - detailEntry namespace uri mismatch",detailEntry.getNamespace().getName().equals("http://www.test.org"));
70         assertTrue("SOAP 1.1 Fault Detail Test : - After calling addDetailEntry method once, getAllDetailEntries method returns an iterator with two objects",iterator.next() == null);
71     }
72
73     //SOAP 1.2 Fault Detail Test (Programaticaly Created)
74
public void testSOAP12AddDetailEntry() {
75         soap12FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry1",omNamespace));
76         soap12FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry2",omNamespace));
77         Iterator JavaDoc iterator = soap12FaultDetail.getAllDetailEntries();
78         OMElement detailEntry1 = (OMElement)iterator.next();
79         assertFalse("SOAP 1.2 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns empty iterator",detailEntry1 == null);
80         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry1 local name mismatch",detailEntry1.getLocalName().equals("DetailEntry1"));
81         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry1 namespace uri mismatch",detailEntry1.getNamespace().getName().equals("http://www.test.org"));
82         OMElement detailEntry2 = (OMElement)iterator.next();
83         assertFalse("SOAP 1.2 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with only one object",detailEntry2 == null);
84         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry2 local name mismatch",detailEntry2.getLocalName().equals("DetailEntry2"));
85         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry2 namespace uri mismatch",detailEntry2.getNamespace().getName().equals("http://www.test.org"));
86         assertTrue("SOAP 1.2 Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with three objects",iterator.next() == null);
87     }
88
89     public void testSOAP12GetAllDetailEntries() {
90         Iterator JavaDoc iterator = soap12FaultDetail.getAllDetailEntries();
91         assertTrue("SOAP 1.2 Fault Detail Test : - After creating SOAP11FaultDetail element, it has DetailEntries",iterator.next() == null);
92         soap12FaultDetail.addDetailEntry(omFactory.createOMElement("DetailEntry",omNamespace));
93         iterator = soap12FaultDetail.getAllDetailEntries();
94         OMElement detailEntry = (OMElement)iterator.next();
95         assertFalse("SOAP 1.2 Fault Detail Test : - After calling addDetailEntry method, getAllDetailEntries method returns empty iterator",detailEntry == null);
96         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry local name mismatch",detailEntry.getLocalName().equals("DetailEntry"));
97         assertTrue("SOAP 1.2 Fault Detail Test : - detailEntry namespace uri mismatch",detailEntry.getNamespace().getName().equals("http://www.test.org"));
98         assertTrue("SOAP 1.2 Fault Detail Test : - After calling addDetailEntry method once, getAllDetailEntries method returns an iterator with two objects",iterator.next() == null);
99     }
100
101     //SOAP 1.1 Fault Detail Test (With Parser)
102
public void testSOAP11GetAllDetailEntriesWithParser() {
103         Iterator JavaDoc iterator = soap11FaultDetailWithParser.getAllDetailEntries();
104         OMText textEntry = (OMText)iterator.next();
105         assertFalse("SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns empty iterator",textEntry == null);
106         assertTrue("SOAP 1.1 Fault Detail Test With Parser : - text value mismatch",textEntry.getText().trim().equals("Details of error"));
107         OMElement detailEntry1 = (OMElement)iterator.next();
108         assertFalse("SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator without detail entries",detailEntry1 == null);
109         assertTrue("SOAP 1.1 Fault Detail Test With Parser : - detailEntry1 localname mismatch",detailEntry1.getLocalName().equals("MaxTime"));
110         iterator.next();
111         OMElement detailEntry2 = (OMElement)iterator.next();
112         assertFalse("SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with only one detail entries",detailEntry2 == null);
113         assertTrue("SOAP 1.1 Fault Detail Test With Parser : - detailEntry2 localname mismatch",detailEntry2.getLocalName().equals("AveTime"));
114         iterator.next();
115         assertTrue("SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with more than two detail entries",iterator.next() == null);
116     }
117
118     //SOAP 1.2 Fault Detail Test (With Parser)
119
public void testSOAP12GetAllDetailEntriesWithParser() {
120         Iterator JavaDoc iterator = soap12FaultDetailWithParser.getAllDetailEntries();
121         OMText textEntry = (OMText)iterator.next();
122         assertFalse("SOAP 1.2 Fault Detail Test With Parser : - getAllDetailEntries method returns empty iterator",textEntry == null);
123         assertTrue("SOAP 1.2 Fault Detail Test With Parser : - text value mismatch",textEntry.getText().trim().equals("Details of error"));
124         OMElement detailEntry1 = (OMElement)iterator.next();
125         assertFalse("SOAP 1.2 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator without detail entries",detailEntry1 == null);
126         assertTrue("SOAP 1.2 Fault Detail Test With Parser : - detailEntry1 localname mismatch",detailEntry1.getLocalName().equals("MaxTime"));
127         iterator.next();
128         OMElement detailEntry2 = (OMElement)iterator.next();
129         assertFalse("SOAP 1.2 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with only one detail entries",detailEntry2 == null);
130         assertTrue("SOAP 1.2 Fault Detail Test With Parser : - detailEntry2 localname mismatch",detailEntry2.getLocalName().equals("AveTime"));
131         iterator.next();
132         assertTrue("SOAP 1.2 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with more than two detail entries",iterator.next() == null);
133     }
134 }
135
Popular Tags