KickJava   Java API By Example, From Geeks To Geeks.

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


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 EchoRawXMLLoadTest 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 EchoRawXMLLoadTest() {
60         super(EchoRawXMLLoadTest.class.getName());
61     }
62
63     public EchoRawXMLLoadTest(String JavaDoc testName) {
64         super(testName);
65     }
66
67     protected void setUp() throws Exception JavaDoc {
68         UtilServer.start();
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     protected void tearDown() throws Exception JavaDoc {
80         UtilServer.unDeployService(serviceName);
81         UtilServer.stop();
82     }
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();
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(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
//
121
//
122
// log.info("send the reqest");
123
// }
124

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