01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.dispatchers;
20:
21: import junit.framework.TestCase;
22: import org.apache.axiom.om.OMAbstractFactory;
23: import org.apache.axiom.soap.SOAPBody;
24: import org.apache.axiom.soap.SOAPEnvelope;
25: import org.apache.axis2.AxisFault;
26: import org.apache.axis2.context.ConfigurationContext;
27: import org.apache.axis2.context.ConfigurationContextFactory;
28: import org.apache.axis2.context.MessageContext;
29: import org.apache.axis2.description.AxisService;
30: import org.apache.axis2.engine.AxisConfiguration;
31:
32: public class SOAPMessageBodyBasedServiceDispatcherTest extends TestCase {
33:
34: public void testFindService() throws AxisFault {
35: MessageContext messageContext;
36: AxisService as1 = new AxisService("Service1");
37: AxisService as2 = new AxisService("Service2");
38: ConfigurationContext cc = ConfigurationContextFactory
39: .createEmptyConfigurationContext();
40: AxisConfiguration ac = cc.getAxisConfiguration();
41: ac.addService(as1);
42: ac.addService(as2);
43: messageContext = cc.createMessageContext();
44:
45: SOAPEnvelope se = OMAbstractFactory.getSOAP11Factory()
46: .createSOAPEnvelope();
47: SOAPBody sb = OMAbstractFactory.getSOAP11Factory()
48: .createSOAPBody(se);
49: sb
50: .addChild(OMAbstractFactory
51: .getSOAP11Factory()
52: .createOMElement(
53: "operation2",
54: "http://127.0.0.1:8080/axis2/services/Service2",
55: "pfx"));
56: messageContext.setEnvelope(se);
57:
58: SOAPMessageBodyBasedServiceDispatcher ruisd = new SOAPMessageBodyBasedServiceDispatcher();
59: ruisd.invoke(messageContext);
60:
61: assertEquals(as2, messageContext.getAxisService());
62: }
63:
64: }
|