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.AxisOperation;
30: import org.apache.axis2.description.AxisService;
31: import org.apache.axis2.description.InOnlyAxisOperation;
32: import org.apache.axis2.engine.AxisConfiguration;
33:
34: import javax.xml.namespace.QName;
35:
36: public class SOAPMessageBodyBasedOperationDispatcherTest extends
37: TestCase {
38:
39: public void testFindOperation() throws AxisFault {
40: MessageContext messageContext;
41: AxisService as1 = new AxisService("Service1");
42:
43: AxisOperation operation1 = new InOnlyAxisOperation(new QName(
44: "operation1"));
45: AxisOperation operation2 = new InOnlyAxisOperation(new QName(
46: "operation2"));
47: as1.addOperation(operation1);
48: as1.addOperation(operation2);
49:
50: ConfigurationContext cc = ConfigurationContextFactory
51: .createEmptyConfigurationContext();
52: AxisConfiguration ac = cc.getAxisConfiguration();
53: ac.addService(as1);
54: messageContext = cc.createMessageContext();
55:
56: messageContext.setAxisService(as1);
57:
58: SOAPEnvelope se = OMAbstractFactory.getSOAP11Factory()
59: .createSOAPEnvelope();
60: SOAPBody sb = OMAbstractFactory.getSOAP11Factory()
61: .createSOAPBody(se);
62: sb.addChild(OMAbstractFactory.getSOAP11Factory()
63: .createOMElement("operation2", "http://test", "pfx"));
64: messageContext.setEnvelope(se);
65:
66: SOAPMessageBodyBasedOperationDispatcher ruisd = new SOAPMessageBodyBasedOperationDispatcher();
67: ruisd.invoke(messageContext);
68:
69: assertEquals(operation2, messageContext.getAxisOperation());
70: }
71:
72: }
|