KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > transport > http > HTTPTransportUtilTest


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 JavaDoc;
11
12 /*
13  * Copyright 2004,2005 The Apache Software Foundation.
14  *
15  * Licensed under the Apache License, Version 2.0 (the "License");
16  * you may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at
18  *
19  * http://www.apache.org/licenses/LICENSE-2.0
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  *
27  * author : Eran Chinthaka (chinthaka@apache.org)
28  */

29
30 public class HTTPTransportUtilTest extends TestCase{
31     private HTTPTransportUtils httpTransportUtils;
32     private SOAPFactory factory;
33
34     protected void setUp() throws Exception JavaDoc {
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 JavaDoc("MyFirstBodyElement"), soapEnvelope.getBody());
44         OMElement element11 = factory.createOMElement(new QName JavaDoc("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 JavaDoc("MyFirstBodyElement"), soapEnvelope.getBody());
54         OMElement element11 = factory.createOMElement(new QName JavaDoc("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