KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.apache.axis2.addressing.AddressingConstants;
20 import org.apache.axis2.addressing.EndpointReference;
21 import org.apache.axis2.context.ConfigurationContext;
22 import org.apache.axis2.context.MessageContext;
23 import org.apache.axis2.context.OperationContextFactory;
24 import org.apache.axis2.context.ServiceContext;
25 import org.apache.axis2.description.OperationDescription;
26 import org.apache.axis2.description.ServiceDescription;
27 import org.apache.axis2.description.TransportInDescription;
28 import org.apache.axis2.description.TransportOutDescription;
29 import org.apache.axis2.om.OMAbstractFactory;
30 import org.apache.axis2.soap.SOAPFactory;
31 import org.apache.axis2.transport.http.HTTPTransportSender;
32 import org.apache.wsdl.WSDLConstants;
33 import org.apache.wsdl.WSDLService;
34
35 import javax.xml.namespace.QName JavaDoc;
36 import java.util.ArrayList JavaDoc;
37
38 public class EngineWithoutPhaseResolvingTest extends AbstractEngineTest {
39     private MessageContext mc;
40     private ArrayList JavaDoc executedHandlers = new ArrayList JavaDoc();
41     private AxisConfiguration engineRegistry;
42     private QName JavaDoc serviceName = new QName JavaDoc("axis/services/NullService");
43     private QName JavaDoc opearationName = new QName JavaDoc("NullOperation");
44     private ServiceDescription service;
45     private ConfigurationContext engineContext;
46     private OperationDescription axisOp;
47
48     public EngineWithoutPhaseResolvingTest() {
49     }
50
51     public EngineWithoutPhaseResolvingTest(String JavaDoc arg0) {
52         super(arg0);
53     }
54
55     protected void setUp() throws Exception JavaDoc {
56
57         engineRegistry = new AxisConfigurationImpl();
58         engineContext = new ConfigurationContext(engineRegistry);
59
60         TransportOutDescription transport = new TransportOutDescription(new QName JavaDoc("null"));
61         transport.setSender(new HTTPTransportSender());
62
63         TransportInDescription transportIn = new TransportInDescription(new QName JavaDoc("null"));
64         axisOp = new OperationDescription(opearationName);
65
66         service = new ServiceDescription(serviceName);
67         axisOp.setMessageReciever(new MessageReceiver() {
68             public void recieve(MessageContext messgeCtx) throws AxisFault {
69                 // TODO Auto-generated method stub
70

71             }
72         });
73         engineRegistry.addService(service);
74         service.setStyle(WSDLService.STYLE_DOC);
75         service.addOperation(axisOp);
76
77         ServiceContext serviceContext = engineContext.createServiceContext(serviceName);
78
79         mc =
80                 new MessageContext(engineContext,
81                         transportIn,
82                         transport);
83                         
84         mc.setOperationContext(OperationContextFactory.createMEPContext(WSDLConstants.MEP_CONSTANT_IN_OUT, axisOp, serviceContext));
85         mc.setTransportOut(transport);
86         mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);
87         mc.setServerSide(true);
88         SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
89         mc.setEnvelope(omFac.getDefaultEnvelope());
90
91
92         mc.setWSAAction(opearationName.getLocalPart());
93         mc.setSoapAction(opearationName.getLocalPart());
94         System.out.flush();
95     }
96
97 // public void testServerSend() throws Exception {
98
// AxisEngine engine = new AxisEngine(engineContext);
99
// mc.setServerSide(true);
100
//
101
// mc.setServiceContext(engineContext.createServiceContext(serviceName));
102
// engine.send(mc);
103
// }
104
//
105
// public void testClientSend() throws Exception {
106
// AxisEngine engine = new AxisEngine(engineContext);
107
// mc.setServerSide(false);
108
// mc.setServiceContext(engineContext.createServiceContext(serviceName));
109
// engine.send(mc);
110
// }
111

112     public void testServerReceive() throws Exception JavaDoc {
113         mc.setTo(new EndpointReference(AddressingConstants.WSA_TO, "axis/services/NullService"));
114         AxisEngine engine = new AxisEngine(engineContext);
115         mc.setServerSide(true);
116         engine.receive(mc);
117     }
118 //
119
// public void testClientReceive() throws Exception {
120
// mc.setServiceContext(engineContext.createServiceContext(serviceName));
121
// mc.setOperationContext(axisOp.findOperationContext(mc,mc.getServiceContext(),false));
122
// AxisEngine engine = new AxisEngine(engineContext);
123
// mc.setServerSide(false);
124
// engine.receive(mc);
125
// }
126
}
127
Popular Tags