KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > engine > EchoRawXMLChunckedTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis2.engine;
18
19 //todo
20

21 import junit.framework.TestCase;
22 import org.apache.axis2.Constants;
23 import org.apache.axis2.addressing.AddressingConstants;
24 import org.apache.axis2.addressing.EndpointReference;
25 import org.apache.axis2.context.MessageContext;
26 import org.apache.axis2.context.ServiceContext;
27 import org.apache.axis2.description.ServiceDescription;
28 import org.apache.axis2.integration.TestingUtils;
29 import org.apache.axis2.integration.UtilServer;
30 import org.apache.axis2.om.OMAbstractFactory;
31 import org.apache.axis2.om.OMElement;
32 import org.apache.axis2.soap.SOAPFactory;
33 import org.apache.axis2.util.Utils;
34 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37 import javax.xml.namespace.QName JavaDoc;
38
39 public class EchoRawXMLChunckedTest extends TestCase {
40     private EndpointReference targetEPR =
41             new EndpointReference(AddressingConstants.WSA_TO,
42                     "http://127.0.0.1:"
43             + (UtilServer.TESTING_PORT)
44             + "/axis/services/EchoXMLService/echoOMElement");
45     private Log log = LogFactory.getLog(getClass());
46     private QName JavaDoc serviceName = new QName JavaDoc("EchoXMLService");
47     private QName JavaDoc operationName = new QName JavaDoc("echoOMElement");
48     private QName JavaDoc transportName = new QName JavaDoc("http://localhost/my", "NullTransport");
49
50     private AxisConfiguration engineRegistry;
51     private MessageContext mc;
52     //private Thread thisThread;
53
// private SimpleHTTPServer sas;
54
private ServiceContext serviceContext;
55     private ServiceDescription service;
56
57     private boolean finish = false;
58
59     public EchoRawXMLChunckedTest() {
60         super(EchoRawXMLChunckedTest.class.getName());
61     }
62
63     public EchoRawXMLChunckedTest(String JavaDoc testName) {
64         super(testName);
65     }
66
67     protected void setUp() throws Exception JavaDoc {
68         UtilServer.start(Constants.TESTING_PATH + "chuncked-enabledRepository");
69         service =
70                 Utils.createSimpleService(serviceName,
71         Echo.class.getName(),
72                         operationName);
73         UtilServer.deployService(service);
74         serviceContext =
75                 UtilServer.getConfigurationContext().createServiceContext(service.getName());
76                 
77
78     }
79
80     protected void tearDown() throws Exception JavaDoc {
81         UtilServer.unDeployService(serviceName);
82         UtilServer.stop();
83     }
84
85
86 // public void testEchoXMLASync() throws Exception {
87
// OMElement payload = createEnvelope();
88
//
89
// org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(Constants.TESTING_PATH + "chuncked-enabledRepository");
90
//
91
// call.setTo(targetEPR);
92
// call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
93
//
94
// Callback callback = new Callback() {
95
// public void onComplete(AsyncResult result) {
96
// try {
97
// result.getResponseEnvelope().serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
98
// } catch (XMLStreamException e) {
99
// reportError(e);
100
// } finally {
101
// finish = true;
102
// }
103
// }
104
//
105
// public void reportError(Exception e) {
106
// e.printStackTrace();
107
// finish = true;
108
// }
109
// };
110
//
111
// call.invokeNonBlocking(operationName.getLocalPart(), payload, callback);
112
// int index = 0;
113
// while (!finish) {
114
// Thread.sleep(1000);
115
// index++;
116
// if(index > 10 ){
117
// throw new AxisFault("Server is shutdown as the Async response take too longs time");
118
// }
119
// }
120
// call.close();
121
//
122
//
123
// log.info("send the reqest");
124
// }
125

126     public void testEchoXMLSync() throws Exception JavaDoc {
127         SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
128
129         OMElement payload = TestingUtils.createDummyOMElement();
130
131         org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(Constants.TESTING_PATH + "chuncked-enabledRepository");
132
133         call.setTo(targetEPR);
134         call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
135
136         OMElement result =
137                 (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
138         TestingUtils.campareWithCreatedOMElement(result);
139         call.close();
140     }
141 }
142
Popular Tags