1 package org.apache.axis2.transport.http; 2 3 import junit.framework.TestCase; 4 import org.apache.axis2.om.OMAbstractFactory; 5 import org.apache.axis2.om.OMElement; 6 import org.apache.axis2.om.OMText; 7 import org.apache.axis2.soap.SOAPEnvelope; 8 import org.apache.axis2.soap.SOAPFactory; 9 10 import javax.xml.namespace.QName ; 11 12 29 30 public class HTTPTransportUtilTest extends TestCase{ 31 private HTTPTransportUtils httpTransportUtils; 32 private SOAPFactory factory; 33 34 protected void setUp() throws Exception { 35 super.setUp(); 36 httpTransportUtils = new HTTPTransportUtils(); 37 factory = OMAbstractFactory.getSOAP11Factory(); 38 } 39 40 public void testOptimizedEnvelope(){ 41 SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope(); 42 43 OMElement element = factory.createOMElement(new QName ("MyFirstBodyElement"), soapEnvelope.getBody()); 44 OMElement element11 = factory.createOMElement(new QName ("MyFirstBodyElement"), element); 45 OMText optimizedText = factory.createText("Hi", "text/plain", true); 46 element11.addChild(optimizedText); 47 assertTrue("optmization check has not performed correctly in SOAPEnvelope", httpTransportUtils.checkEnvelopeForOptimise(soapEnvelope)); 48 } 49 50 public void testNonOptimizedEnvelope(){ 51 SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope(); 52 53 OMElement element = factory.createOMElement(new QName ("MyFirstBodyElement"), soapEnvelope.getBody()); 54 OMElement element11 = factory.createOMElement(new QName ("MyFirstBodyElement"), element); 55 OMText optimizedText = factory.createText("Hi", "text/plain", false); 56 element11.addChild(optimizedText); 57 assertFalse("optmization check has not performed correctly in SOAPEnvelope", httpTransportUtils.checkEnvelopeForOptimise(soapEnvelope)); 58 } 59 60 61 62 } 63 | Popular Tags |