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:
20: package org.apache.axis2.context;
21:
22: import org.apache.axiom.om.util.UUIDGenerator;
23: import org.apache.axis2.AbstractTestCase;
24: import org.apache.axis2.AxisFault;
25: import org.apache.axis2.addressing.RelatesTo;
26: import org.apache.axis2.description.AxisOperation;
27: import org.apache.axis2.description.AxisService;
28: import org.apache.axis2.description.AxisServiceGroup;
29: import org.apache.axis2.description.InOutAxisOperation;
30: import org.apache.axis2.description.TransportInDescription;
31: import org.apache.axis2.description.TransportOutDescription;
32: import org.apache.axis2.engine.AxisConfiguration;
33:
34: import javax.xml.namespace.QName;
35:
36: public class OperationContextTest extends AbstractTestCase {
37:
38: private ConfigurationContext configContext = new ConfigurationContext(
39: new AxisConfiguration());
40:
41: public OperationContextTest(String arg0) {
42: super (arg0);
43: }
44:
45: public void testMEPfindingOnRelatesTO() throws Exception {
46:
47: AxisService axisService = new AxisService("TempSC");
48: configContext.getAxisConfiguration().addService(axisService);
49: ServiceGroupContext sgc = configContext
50: .createServiceGroupContext(axisService
51: .getAxisServiceGroup());
52: ServiceContext sessionContext = sgc
53: .getServiceContext(axisService);
54: MessageContext messageContext1 = this .getBasicMessageContext();
55:
56: messageContext1.setMessageID(UUIDGenerator.getUUID());
57: AxisOperation axisOperation = new InOutAxisOperation(new QName(
58: "test"));
59: OperationContext operationContext1 = axisOperation
60: .findOperationContext(messageContext1, sessionContext);
61: axisOperation.registerOperationContext(messageContext1,
62: operationContext1);
63:
64: MessageContext messageContext2 = this .getBasicMessageContext();
65: messageContext2.setMessageID(UUIDGenerator.getUUID());
66: messageContext2.getOptions().addRelatesTo(
67: new RelatesTo(messageContext1.getMessageID()));
68: messageContext2.setAxisOperation(axisOperation);
69: OperationContext operationContext2 = axisOperation
70: .findOperationContext(messageContext2, sessionContext);
71: assertEquals(operationContext1, operationContext2);
72: }
73:
74: public MessageContext getBasicMessageContext() throws AxisFault {
75: MessageContext messageContext = configContext
76: .createMessageContext();
77: messageContext.setTransportIn(new TransportInDescription(
78: "axis2"));
79: messageContext.setTransportOut(new TransportOutDescription(
80: "axis2"));
81:
82: return messageContext;
83:
84: }
85:
86: }
|