KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > context > OperationContextTest


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis2.context;
18
19 import org.apache.axis2.AbstractTestCase;
20 import org.apache.axis2.addressing.miheaders.RelatesTo;
21 import org.apache.axis2.description.OperationDescription;
22 import org.apache.axis2.description.ServiceDescription;
23 import org.apache.axis2.description.TransportInDescription;
24 import org.apache.axis2.description.TransportOutDescription;
25 import org.apache.axis2.engine.AxisFault;
26
27 import javax.xml.namespace.QName JavaDoc;
28
29 /**
30  * @author chathura@opensource.lk
31  *
32  */

33 public class OperationContextTest extends AbstractTestCase {
34
35     private ConfigurationContext engineCtx = new ConfigurationContext(null);
36
37     public OperationContextTest(String JavaDoc arg0) {
38         super(arg0);
39     }
40     
41     public void testMEPfindingOnRelatesTO() throws Exception JavaDoc{
42          
43         ServiceContext sessionContext = new ServiceContext(new ServiceDescription(),new ConfigurationContext(null));
44         MessageContext messageContext1 = this.getBasicMessageContext();
45         
46         messageContext1.setMessageID(new Long JavaDoc(System.currentTimeMillis()).toString());
47         OperationDescription axisOperation = new OperationDescription(new QName JavaDoc("test"));
48         OperationContext operationContext1 = axisOperation.findOperationContext(messageContext1, sessionContext);
49         
50         MessageContext messageContext2 = this.getBasicMessageContext();
51         messageContext2.setMessageID(new Long JavaDoc(System.currentTimeMillis()).toString());
52         messageContext2.getMessageInformationHeaders().setRelatesTo(new RelatesTo(messageContext1.getMessageID()));
53         OperationContext operationContext2 = axisOperation.findOperationContext(messageContext2, sessionContext);
54         assertEquals(operationContext1, operationContext2);
55     }
56     
57     public MessageContext getBasicMessageContext() throws AxisFault{
58
59         return new MessageContext(engineCtx,new TransportInDescription(new QName JavaDoc("axis")), new TransportOutDescription(new QName JavaDoc("axis")));
60
61     }
62     
63 }
64
Popular Tags