1 16 17 package org.apache.axis2.soap; 18 19 import org.apache.axis2.soap.impl.llom.SOAPProcessingException; 20 import org.apache.axis2.soap.impl.llom.soap12.SOAP12Constants; 21 22 public class SOAPFaultCodeTest extends SOAPFaultCodeTestCase { 23 24 public SOAPFaultCodeTest(String testName) { 25 super(testName); 26 } 27 28 protected void setUp() throws Exception { 29 super.setUp(); 30 } 31 32 public void testSOAP11SetValue() { 34 soap11FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode)); 35 assertFalse("SOAP 1.1 Fault Code Test :- After calling setValue method, getValue method returns null",soap11FaultCode.getValue() == null); 36 try{ 37 soap11FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode)); 38 fail("SOAP12FaultValue should not be inserted to SOAP11FaultCode"); 39 } catch (SOAPProcessingException e) { 40 assertTrue(true); 41 } 42 43 } 44 45 public void testSOAP11GetValue() { 46 assertTrue("SOAP 1.1 Fault Code Test :- After creating soapfaultcode, it has a value",soap11FaultCode.getValue() == null); 47 soap11FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode)); 48 assertFalse("SOAP 1.1 Fault Code Test :- After calling setValue method, getValue method returns null",soap11FaultCode.getValue() == null); 49 } 50 51 public void testSOAP12SetValue() { 53 soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode)); 54 assertFalse("SOAP 1.2 Fault Code Test :- After calling setValue method, getValue method returns null",soap12FaultCode.getValue() == null); 55 try{ 56 soap12FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode)); 57 fail("SOAP11FaultValue should not be inserted to SOAP12FaultCode"); 58 } catch (SOAPProcessingException e) { 59 assertTrue(true); 60 } 61 62 try { 63 soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12Factory.createSOAPFaultSubCode(soap12FaultCode))); 64 } catch (Exception e) { 65 fail("SOAP 1.2 Fault Code Test :- When calling setValue method, parent of value element mismatch"); 66 } 67 } 68 69 public void testSOAP12GetValue() { 70 assertTrue("SOAP 1.2 Fault Code Test :- After creating soapfaultcode, it has a value",soap12FaultCode.getValue() == null); 71 soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode)); 72 assertFalse("SOAP 1.2 Fault Code Test :- After calling setValue method, getValue method returns null",soap12FaultCode.getValue() == null); 73 } 74 75 public void testSOAP12SetSubCode() { 76 soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode)); 77 assertFalse("SOAP 1.2 Fault Code Test :- After calling setSubCode method, getSubCode method returns null",soap12FaultCode.getSubCode() == null); 78 try{ 79 soap12FaultCode.setSubCode(soap11Factory.createSOAPFaultSubCode(soap11FaultCode)); 80 fail("SOAP11FaultSubCode should not be inserted to SOAP12FaultCode"); 81 } catch (SOAPProcessingException e) { 82 assertTrue(true); 83 } 84 85 try { 86 soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode))); 87 } catch (Exception e) { 88 fail("SOAP 1.2 Fault Code Test :- When calling setSubCode method, parent of subcode element mismatch"); 89 } 90 } 91 92 public void testSOAP12GetSubCode() { 93 assertTrue("SOAP 1.2 Fault Code Test :- After creating soapfaultcode, it has a subcode",soap12FaultCode.getSubCode() == null); 94 soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode)); 95 assertFalse("SOAP 1.2 Fault Code Test :- After calling setSubCode method, getSubCode method returns null",soap12FaultCode.getSubCode() == null); 96 } 97 98 public void testSOAP11GetValueWithParser() { 100 assertFalse("SOAP 1.1 Fault Code Test with parser : - getValue method returns null",soap11FaultCodeWithParser.getValue() == null); 101 assertTrue("SOAP 1.1 Fault Code Test with parser : - Value local name mismatch",soap11FaultCodeWithParser.getValue().getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)); 102 } 103 104 public void testSOAP12GetValueWithParser() { 106 assertFalse("SOAP 1.2 Fault Code Test with parser : - getValue method returns null",soap12FaultCodeWithParser.getValue() == null); 107 assertTrue("SOAP 1.2 Fault Code Test with parser : - Value local name mismatch",soap12FaultCodeWithParser.getValue().getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)); 108 } 109 110 public void testSOAP12GetSubCodeWithParser() { 111 assertFalse("SOAP 1.2 Fault Code Test with parser :- getSubCode method returns null",soap12FaultCodeWithParser.getSubCode() == null); 112 assertTrue("SOAP 1.2 Fault Code Test with parser : - subcode local name mismatch",soap12FaultCodeWithParser.getSubCode().getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)); 113 } 114 } 115 | Popular Tags |