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.context.MessageContext;
23: import org.apache.axis2.description.AxisOperation;
24: import org.apache.axis2.description.AxisService;
25: import org.apache.axis2.description.InOnlyAxisOperation;
26:
27: import javax.xml.namespace.QName;
28: import java.util.ArrayList;
29:
30: public class ActionBasedOperationDispatchTest extends TestCase {
31:
32: public void testFindOperation() throws Exception {
33: MessageContext messageContext = new MessageContext();
34: AxisService as = new AxisService("Service1");
35: messageContext.setAxisService(as);
36:
37: AxisOperation operation1 = new InOnlyAxisOperation(new QName(
38: "operation1"));
39: ArrayList op1actions = new ArrayList();
40: op1actions
41: .add("urn:org.apache.axis2.dispatchers.test:operation1");
42: operation1.setWsamappingList(op1actions);
43:
44: AxisOperation operation2 = new InOnlyAxisOperation(new QName(
45: "operation2"));
46: ArrayList op2actions = new ArrayList();
47: op2actions
48: .add("urn:org.apache.axis2.dispatchers.test:operation2");
49: operation2.setWsamappingList(op2actions);
50:
51: as.addOperation(operation1);
52: as.addOperation(operation2);
53:
54: as.mapActionToOperation(
55: "urn:org.apache.axis2.dispatchers.test:operation1",
56: operation1);
57: as.mapActionToOperation(
58: "urn:org.apache.axis2.dispatchers.test:operation2",
59: operation2);
60:
61: messageContext
62: .setWSAAction("urn:org.apache.axis2.dispatchers.test:operation2");
63:
64: ActionBasedOperationDispatcher abod = new ActionBasedOperationDispatcher();
65: abod.invoke(messageContext);
66: assertEquals(operation2, messageContext.getAxisOperation());
67: }
68:
69: }
|