1 16 package org.apache.axis2.context; 17 18 import junit.framework.TestCase; 19 import org.apache.axis2.description.OperationDescription; 20 import org.apache.axis2.description.ParameterImpl; 21 import org.apache.axis2.description.ServiceDescription; 22 import org.apache.axis2.engine.AxisConfiguration; 23 import org.apache.axis2.engine.AxisConfigurationImpl; 24 import org.apache.axis2.engine.AxisFault; 25 26 import javax.xml.namespace.QName ; 27 28 34 public class ContextHierarchyTest extends TestCase { 35 private OperationDescription operationDescription; 36 private ServiceDescription serviceDescription; 37 private AxisConfiguration axisConfiguration; 38 39 public ContextHierarchyTest(String arg0) { 40 super(arg0); 41 } 42 43 protected void setUp() throws Exception { 44 operationDescription = new OperationDescription(new QName ("Temp")); 45 serviceDescription = new ServiceDescription(new QName ("Temp")); 46 axisConfiguration = new AxisConfigurationImpl(); 47 serviceDescription.addOperation(operationDescription); 48 axisConfiguration.addService(serviceDescription); 49 } 50 51 public void testCompleteHiracy() throws AxisFault { 52 ConfigurationContext configurationContext = 53 new ConfigurationContext(axisConfiguration); 54 ServiceContext serviceCOntext = 55 configurationContext.createServiceContext( 56 serviceDescription.getName()); 57 MessageContext msgctx = 58 new MessageContext(configurationContext); 59 OperationContext opContext = 60 operationDescription.findOperationContext( 61 msgctx, 62 serviceCOntext); 63 msgctx.setServiceContext(serviceCOntext); 64 65 assertEquals(msgctx.getParent(), opContext); 67 assertEquals(opContext.getParent(), serviceCOntext); 68 assertEquals(serviceCOntext.getParent(), configurationContext); 69 70 String key1 = "key1"; 71 String value1 = "Val1"; 72 String value2 = "value2"; 73 String key2 = "key2"; 74 String value3 = "value"; 75 76 configurationContext.setProperty(key1, value1); 77 assertEquals(value1, msgctx.getProperty(key1)); 78 79 axisConfiguration.addParameter(new ParameterImpl(key2, value2)); 80 assertEquals(value2, msgctx.getProperty(key2)); 81 82 opContext.setProperty(key1, value3); 83 assertEquals(value3, msgctx.getProperty(key1)); 84 85 } 86 87 public void testDisconntectedHiracy() throws AxisFault { 88 ConfigurationContext configurationContext = 89 new ConfigurationContext(axisConfiguration); 90 91 MessageContext msgctx = 92 new MessageContext(configurationContext); 93 94 assertEquals(msgctx.getParent(), null); 96 97 String key1 = "key1"; 98 String value1 = "Val1"; 99 String value2 = "value2"; 100 String key2 = "key2"; 101 String value3 = "value"; 102 103 configurationContext.setProperty(key1, value1); 104 assertEquals(value1, msgctx.getProperty(key1)); 105 106 axisConfiguration.addParameter(new ParameterImpl(key2, value2)); 107 assertEquals(value2, msgctx.getProperty(key2)); 108 } 109 110 protected void tearDown() throws Exception { 111 } 112 113 } 114 | Popular Tags |