1 16 17 package org.apache.axis2.soap; 18 19 import java.util.Iterator ; 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 testName) { 32 super(testName); 33 } 34 35 protected void setUp() throws Exception { 36 super.setUp(); 37 soap11HeaderBlock = soap11Factory.createSOAPHeaderBlock("testHeaderBlock", namespace, soap11Header); 38 soap12HeaderBlock = soap12Factory.createSOAPHeaderBlock("testHeaderBlock", namespace, soap12Header); 39 Iterator 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 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 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 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 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 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 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 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 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 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 |