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.axis2.AxisFault;
23: import org.apache.axis2.addressing.RelatesTo;
24: import org.apache.axis2.context.ConfigurationContext;
25: import org.apache.axis2.context.MessageContext;
26: import org.apache.axis2.context.OperationContext;
27: import org.apache.axis2.context.ServiceGroupContext;
28: import org.apache.axis2.context.ServiceContext;
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.description.AxisServiceGroup;
33: import org.apache.axis2.engine.AxisConfiguration;
34:
35: import javax.xml.namespace.QName;
36:
37: public class RelatesToBasedOperationDispatcherTest extends TestCase {
38:
39: public void testFindOperation() throws AxisFault {
40:
41: MessageContext messageContext;
42: AxisService as1 = new AxisService("Service1");
43: AxisConfiguration ac = new AxisConfiguration();
44: ac.addService(as1);
45:
46: AxisOperation operation1 = new InOnlyAxisOperation(new QName(
47: "operation1"));
48: AxisOperation operation2 = new InOnlyAxisOperation(new QName(
49: "operation2"));
50: as1.addOperation(operation1);
51: as1.addOperation(operation2);
52:
53: ConfigurationContext cc = new ConfigurationContext(ac);
54: ServiceGroupContext sgc = cc.createServiceGroupContext(as1
55: .getAxisServiceGroup());
56: ServiceContext serviceContext = sgc.getServiceContext(as1);
57: OperationContext oc1 = serviceContext
58: .createOperationContext(operation1);
59: OperationContext oc2 = serviceContext
60: .createOperationContext(operation2);
61: cc.registerOperationContext(
62: "urn:org.apache.axis2.dispatchers.messageid:123", oc1);
63: cc.registerOperationContext(
64: "urn:org.apache.axis2.dispatchers.messageid:456", oc2);
65: messageContext = cc.createMessageContext();
66: messageContext.addRelatesTo(new RelatesTo(
67: "urn:org.apache.axis2.dispatchers.messageid:456"));
68: messageContext.setAxisService(as1);
69:
70: RelatesToBasedOperationDispatcher ruisd = new RelatesToBasedOperationDispatcher();
71: ruisd.invoke(messageContext);
72:
73: assertEquals(operation2, messageContext.getAxisOperation());
74: }
75:
76: }
|