KickJava   Java API By Example, From Geeks To Geeks.

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


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.clientapi.MessageSender;
26 import org.apache.axis2.context.MessageContext;
27 import org.apache.axis2.description.OperationDescription;
28 import org.apache.axis2.description.ServiceDescription;
29 import org.apache.axis2.integration.TestingUtils;
30 import org.apache.axis2.integration.UtilServer;
31 import org.apache.axis2.om.OMAbstractFactory;
32 import org.apache.axis2.om.OMElement;
33 import org.apache.axis2.soap.SOAPEnvelope;
34 import org.apache.axis2.soap.SOAPFactory;
35 import org.apache.commons.logging.Log;
36 import org.apache.commons.logging.LogFactory;
37
38 import javax.xml.namespace.QName JavaDoc;
39
40 public class OneWayRawXMLTest extends TestCase {
41     private EndpointReference targetEPR =
42              new EndpointReference(AddressingConstants.WSA_TO,
43                      "http://127.0.0.1:"
44              + (UtilServer.TESTING_PORT)
45              + "/axis/services/EchoXMLService/echoOMElement");
46     private Log log = LogFactory.getLog(getClass());
47     private QName JavaDoc serviceName = new QName JavaDoc("EchoXMLService");
48     private QName JavaDoc operationName = new QName JavaDoc("echoOMElement");
49     private QName JavaDoc transportName = new QName JavaDoc("http://localhost/my", "NullTransport");
50
51     private AxisConfiguration engineRegistry;
52     private MessageContext mc;
53
54     private SOAPEnvelope envelope;
55
56     private boolean finish = false;
57
58     public OneWayRawXMLTest() {
59         super(OneWayRawXMLTest.class.getName());
60     }
61
62     public OneWayRawXMLTest(String JavaDoc testName) {
63         super(testName);
64     }
65
66     protected void setUp() throws Exception JavaDoc {
67         UtilServer.start();
68
69         ServiceDescription service = new ServiceDescription(serviceName);
70         OperationDescription operation = new OperationDescription(operationName);
71         operation.setMessageReciever(new MessageReceiver() {
72             public void recieve(MessageContext messgeCtx) throws AxisFault {
73                 envelope = messgeCtx.getEnvelope();
74                 TestingUtils.campareWithCreatedOMElement(envelope.getBody().getFirstElement());
75             }
76         });
77         service.addOperation(operation);
78         UtilServer.deployService(service);
79       }
80
81    
82     protected void tearDown() throws Exception JavaDoc {
83         UtilServer.unDeployService(serviceName);
84         UtilServer.stop();
85     }
86
87   
88
89     public void testEchoXMLSync() throws Exception JavaDoc {
90         SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
91
92         OMElement payload = TestingUtils.createDummyOMElement();
93
94         MessageSender sender = new MessageSender();
95
96         sender.setTo(targetEPR);
97         sender.setSenderTransport(Constants.TRANSPORT_HTTP);
98
99         sender.send(operationName.getLocalPart(), payload);
100         int index = 0;
101         while(envelope == null){
102             Thread.sleep(4000);
103             index ++;
104             if(index == 5){
105                 throw new AxisFault("error Occured");
106             }
107         }
108     }
109
110 }
111
Popular Tags