1 16 17 package org.apache.axis2.soap; 18 19 import org.apache.axis2.om.OMAttribute; 20 import org.apache.axis2.soap.impl.llom.soap12.SOAP12Constants; 21 22 public class SOAPFaultTextTest extends SOAPFaultReasonTestCase { 23 protected SOAPFaultText soap11FaultText; 24 protected SOAPFaultText soap12FaultText; 25 protected SOAPFaultText soap11FaultTextWithParser; 26 protected SOAPFaultText soap12FaultTextWithParser; 27 28 public SOAPFaultTextTest(String testName) { 29 super(testName); 30 } 31 32 protected void setUp() throws Exception { 33 super.setUp(); 34 soap11FaultText = soap11Factory.createSOAPFaultText(soap11FaultReason); 35 soap12FaultText = soap12Factory.createSOAPFaultText(soap12FaultReason); 36 soap11FaultTextWithParser = soap11FaultReasonWithParser.getSOAPText(); 37 soap12FaultTextWithParser = soap12FaultReasonWithParser.getSOAPText(); 38 } 39 40 public void testSOAP11SetLang() { 42 soap11FaultText.setLang("en"); 43 assertTrue("SOAP 1.1 Fault Text Test : - After calling setLang method, Lang attribute value mismatch", soap11FaultText.getLang().equals("en")); 44 OMAttribute langAttribute = (OMAttribute) soap11FaultText.getAttributes().next(); 45 assertTrue("SOAP 1.1 Fault Text Test : - After calling setLang method, Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME)); 46 assertTrue("SOAP 1.1 Fault Text Test : - After calling setLang method, Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX)); 47 assertTrue("SOAP 1.1 Fault Text Test : - After calling setLang method, Lang attribute namespace uri mismatch", langAttribute.getNamespace().getName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI)); 48 } 49 50 public void testSOAP11GetLang() { 51 52 53 assertNull("SOAP 1.1 Fault Text Test : - After creating SOAPFaultText, it has a Lnag attribute", soap11FaultText.getLang()); 54 55 soap11FaultText.setLang("en"); 56 assertTrue("SOAP 1.1 Fault Text Test : - After calling setLang method, Lang attribute value mismatch", soap11FaultText.getLang().equals("en")); 57 } 58 59 public void testSOAP11SetText() { 60 soap11FaultText.setText("This is only a test"); 61 assertTrue("SOAP 1.1 Fault Text Test : - After calling setText method, getText method return incorrect string", soap11FaultText.getText().equals("This is only a test")); 62 } 63 64 public void testSOAP11GetText() { 65 assertTrue("SOAP 1.1 Fault Text Test : - After creating SOAPFaultText, it has a text", soap11FaultText.getText().equals("")); 66 soap11FaultText.setText("This is only a test"); 67 assertTrue("SOAP 1.1 Fault Text Test : - After calling setText method, getText method return incorrect string", soap11FaultText.getText().equals("This is only a test")); 68 } 69 70 public void testSOAP12SetLang() { 72 soap12FaultText.setLang("en"); 73 assertTrue("SOAP 1.2 Fault Text Test : - After calling setLang method, Lang attribute value mismatch", soap12FaultText.getLang().equals("en")); 74 OMAttribute langAttribute = (OMAttribute) soap12FaultText.getAttributes().next(); 75 assertTrue("SOAP 1.2 Fault Text Test : - After calling setLang method, Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME)); 76 assertTrue("SOAP 1.2 Fault Text Test : - After calling setLang method, Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX)); 77 assertTrue("SOAP 1.2 Fault Text Test : - After calling setLang method, Lang attribute namespace uri mismatch", langAttribute.getNamespace().getName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI)); 78 } 79 80 public void testSOAP12GetLang() { 81 82 assertNull("SOAP 1.2 Fault Text Test : - After creating SOAPFaultText, it has a Lnag attribute", soap12FaultText.getLang()); 83 84 soap12FaultText.setLang("en"); 85 assertTrue("SOAP 1.2 Fault Text Test : - After calling setLang method, Lang attribute value mismatch", soap12FaultText.getLang().equals("en")); 86 } 87 88 public void testSOAP12SetText() { 89 soap12FaultText.setText("This is only a test"); 90 assertTrue("SOAP 1.2 Fault Text Test : - After calling setText method, getText method return incorrect string", soap12FaultText.getText().equals("This is only a test")); 91 } 92 93 public void testSOAP12GetText() { 94 assertTrue("SOAP 1.2 Fault Text Test : - After creating SOAPFaultText, it has a text", soap12FaultText.getText().equals("")); 95 soap12FaultText.setText("This is only a test"); 96 assertTrue("SOAP 1.2 Fault Text Test : - After calling setText method, getText method return incorrect string", soap12FaultText.getText().equals("This is only a test")); 97 } 98 99 public void testSOAP11GetTextWithParser() { 101 assertTrue("SOAP 1.1 Fault Text Test With Parser : - getText method returns incorrect string", soap11FaultTextWithParser.getText().equals("Sender Timeout")); 102 } 103 104 public void testSOAP12GetLangWithParser() { 106 assertTrue("SOAP 1.2 Fault Text Test With Parser : - getLang method returns incorrect string", soap12FaultTextWithParser.getLang().equals("en")); 107 OMAttribute langAttribute = (OMAttribute) soap12FaultTextWithParser.getAttributes().next(); 108 assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME)); 109 assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX)); 110 assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace uri mismatch", langAttribute.getNamespace().getName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI)); 111 } 112 113 public void testSOAP12GetTextWithParser() { 114 assertTrue("SOAP 1.2 Fault Text Test With Parser : - getText method returns incorrect string", soap12FaultTextWithParser.getText().equals("Sender Timeout")); 115 } 116 } 117 | Popular Tags |