KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
20
21 public class SOAPHeaderBlockTest extends SOAPHeaderTestCase {
22     protected SOAPHeaderBlock soap11HeaderBlock;
23     protected SOAPHeaderBlock soap12HeaderBlock;
24     protected SOAPHeaderBlock soap11HeaderBlock1WithParser;
25     protected SOAPHeaderBlock soap12HeaderBlock1WithParser;
26     protected SOAPHeaderBlock soap11HeaderBlock2WithParser;
27     protected SOAPHeaderBlock soap12HeaderBlock2WithParser;
28     protected SOAPHeaderBlock soap11HeaderBlock3WithParser;
29     protected SOAPHeaderBlock soap12HeaderBlock3WithParser;
30
31     public SOAPHeaderBlockTest(String JavaDoc testName) {
32         super(testName);
33     }
34
35     protected void setUp() throws Exception JavaDoc {
36         super.setUp();
37         soap11HeaderBlock = soap11Factory.createSOAPHeaderBlock("testHeaderBlock", namespace, soap11Header);
38         soap12HeaderBlock = soap12Factory.createSOAPHeaderBlock("testHeaderBlock", namespace, soap12Header);
39         Iterator JavaDoc iterator = soap11HeaderWithParser.examineAllHeaderBlocks();
40         iterator.next();
41         soap11HeaderBlock1WithParser = (SOAPHeaderBlock) iterator.next();
42         iterator.next();
43         soap11HeaderBlock2WithParser = (SOAPHeaderBlock) iterator.next();
44         iterator.next();
45         soap11HeaderBlock3WithParser = (SOAPHeaderBlock) iterator.next();
46
47         iterator = soap12HeaderWithParser.examineAllHeaderBlocks();
48         iterator.next();
49         soap12HeaderBlock1WithParser = (SOAPHeaderBlock) iterator.next();
50         iterator.next();
51         soap12HeaderBlock2WithParser = (SOAPHeaderBlock) iterator.next();
52         iterator.next();
53         soap12HeaderBlock3WithParser = (SOAPHeaderBlock) iterator.next();
54     }
55
56     //SOAP 1.1 SOAPHeaderBlock Test (Programaticaly Created)
57
public void testSOAP11SetRole() {
58         soap11HeaderBlock.setRole("http://schemas.xmlsoap.org/soap/envelope/actor/next");
59         assertTrue("SOAP 1.1 HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value", soap11HeaderBlock.getRole().equals("http://schemas.xmlsoap.org/soap/envelope/actor/next"));
60         try {
61             soap11HeaderBlock.setRole("Any Value");
62         } catch (Exception JavaDoc e) {
63             fail("SOAP 1.1 HeaderBlock Test : - role value can not be set to any value");
64         }
65     }
66
67     public void testSOAP11GetRole() {
68         assertTrue("SOAP 1.1 HeaderBlock Test : - After creating SOAPHeaderBlock, it has a role", soap11HeaderBlock.getRole() == null);
69         soap11HeaderBlock.setRole("http://schemas.xmlsoap.org/soap/envelope/actor/next");
70         assertTrue("SOAP 1.1 HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value", soap11HeaderBlock.getRole().equals("http://schemas.xmlsoap.org/soap/envelope/actor/next"));
71     }
72
73     public void testSOAP11SetMustUnderstand() {
74         soap11HeaderBlock.setMustUnderstand(true);
75         assertTrue("SOAP 1.1 HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false", soap11HeaderBlock.getMustUnderstand());
76         soap11HeaderBlock.setMustUnderstand(false);
77         assertFalse("SOAP 1.1 HeaderBlock Test : - After setting MustUnderstand false calling setMustUnderstand method , getMustUnderstand method returns true", soap11HeaderBlock.getMustUnderstand());
78         soap11HeaderBlock.setMustUnderstand("1");
79         assertTrue("SOAP 1.1 HeaderBlock Test : - After setting MustUnderstand \"1\" calling setMustUnderstand method , getMustUnderstand method returns false", soap11HeaderBlock.getMustUnderstand());
80         soap11HeaderBlock.setMustUnderstand("0");
81         assertFalse("SOAP 1.1 HeaderBlock Test : - After setting MustUnderstand \"0\" calling setMustUnderstand method , getMustUnderstand method returns true", soap11HeaderBlock.getMustUnderstand());
82         try {
83             soap11HeaderBlock.setMustUnderstand("true");
84         } catch (Exception JavaDoc e) {
85             fail("SOAP 1.1 HeaderBlock Test : - MustUnderstatnd value can not be set to any value rather than 1 or 0");
86         }
87     }
88
89     public void testSOAP11GetMustUnderstand() {
90         assertFalse("SOAP 1.1 HeaderBlock Test : - After creating SOAPHeaderBlock, default MustUnderstand value true", soap11HeaderBlock.getMustUnderstand());
91         soap11HeaderBlock.setMustUnderstand(true);
92         assertTrue("SOAP 1.1 HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false", soap11HeaderBlock.getMustUnderstand());
93     }
94
95     //SOAP 1.2 SOAPHeaderBlock Test (Programaticaly Created)
96
public void testSOAP12SetRole() {
97         soap12HeaderBlock.setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
98         assertTrue("SOAP 1.2 HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value", soap12HeaderBlock.getRole().equals("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
99         try {
100             soap12HeaderBlock.setRole("Any Value");
101         } catch (Exception JavaDoc e) {
102             fail("SOAP 1.2 HeaderBlock Test : - role value can not be set to any value");
103         }
104     }
105
106     public void testSOAP12GetRole() {
107         assertTrue("SOAP 1.2 HeaderBlock Test : - After creating SOAPHeaderBlock, it has a role", soap12HeaderBlock.getRole() == null);
108         soap12HeaderBlock.setRole("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
109         assertTrue("SOAP 1.2 HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value", soap12HeaderBlock.getRole().equals("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
110     }
111
112     public void testSOAP12SetMustUnderstand() {
113         soap12HeaderBlock.setMustUnderstand(true);
114         assertTrue("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false", soap12HeaderBlock.getMustUnderstand());
115         soap12HeaderBlock.setMustUnderstand(false);
116         assertFalse("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand false calling setMustUnderstand method , getMustUnderstand method returns true", soap12HeaderBlock.getMustUnderstand());
117         soap12HeaderBlock.setMustUnderstand("true");
118         assertTrue("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand \"true\" calling setMustUnderstand method , getMustUnderstand method returns false", soap12HeaderBlock.getMustUnderstand());
119         soap12HeaderBlock.setMustUnderstand("false");
120         assertFalse("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand \"false\" calling setMustUnderstand method , getMustUnderstand method returns true", soap12HeaderBlock.getMustUnderstand());
121         soap12HeaderBlock.setMustUnderstand("1");
122         assertTrue("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand \"1\" calling setMustUnderstand method , getMustUnderstand method returns false", soap12HeaderBlock.getMustUnderstand());
123         soap12HeaderBlock.setMustUnderstand("0");
124         assertFalse("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand \"0\" calling setMustUnderstand method , getMustUnderstand method returns true", soap12HeaderBlock.getMustUnderstand());
125         try {
126             soap12HeaderBlock.setMustUnderstand("otherValue");
127             fail("SOAP 1.2 HeaderBlock Test : - MustUnderstatnd value can not be set to any value rather than 1 , 0 , true , false");
128
129         } catch (Exception JavaDoc e) {
130             assertTrue(true);
131         }
132     }
133
134     public void testSOAP12GetMustUnderstand() {
135         assertFalse("SOAP 1.2 HeaderBlock Test : - After creating SOAPHeaderBlock, default MustUnderstand value true", soap12HeaderBlock.getMustUnderstand());
136         soap12HeaderBlock.setMustUnderstand(true);
137         assertTrue("SOAP 1.2 HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false", soap12HeaderBlock.getMustUnderstand());
138     }
139
140     //SOAP 1.1 SOAPHeaderBlock Test (With Parser)
141
public void testSOAP11GetRoleWithParser() {
142         assertTrue("SOAP 1.1 HeaderBlock Test Wiht Parser : - getRole method returns incorrect role value", soap11HeaderBlock1WithParser.getRole().equals("http://schemas.xmlsoap.org/soap/actor/next"));
143     }
144
145     public void testSOAP11GetMustUnderstandWithParser() {
146         assertTrue("SOAP 1.1 HeaderBlock Test Wiht Parser : - getMustUnderstatnd method returns incorrect value", soap11HeaderBlock2WithParser.getMustUnderstand());
147         assertFalse("SOAP 1.1 HeaderBlock Test Wiht Parser : - getMustUnderstatnd method returns incorrect value", soap11HeaderBlock3WithParser.getMustUnderstand());
148
149     }
150
151     //SOAP 1.2 SOAPHeaderBlock Test (With Parser)
152
public void testSOAP12GetRoleWithParser() {
153         assertTrue("SOAP 1.2 HeaderBlock Test Wiht Parser : - getRole method returns incorrect role value", soap12HeaderBlock1WithParser.getRole().equals("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
154     }
155
156     public void testSOAP12GetMustUnderstandWithParser() {
157         assertTrue("SOAP 1.2 HeaderBlock Test Wiht Parser : - getMustUnderstatnd method returns incorrect value", soap12HeaderBlock1WithParser.getMustUnderstand());
158         assertFalse("SOAP 1.2 HeaderBlock Test Wiht Parser : - getMustUnderstatnd method returns incorrect value", soap12HeaderBlock2WithParser.getMustUnderstand());
159         try {
160             soap12HeaderBlock3WithParser.getMustUnderstand();
161         } catch (Exception JavaDoc e) {
162             fail("SOAP 1.2 HeaderBlock Test Wiht Parser : - getMustUnderstatnd method should returns exception when mustunderstand value is incorrect");
163         }
164     }
165 }
166
Popular Tags