1 16 17 package org.apache.axis2.engine; 18 19 import junit.framework.TestCase; 20 import org.apache.axis2.Constants; 21 import org.apache.axis2.addressing.AddressingConstants; 22 import org.apache.axis2.addressing.EndpointReference; 23 import org.apache.axis2.context.MessageContext; 24 import org.apache.axis2.context.ServiceContext; 25 import org.apache.axis2.description.ServiceDescription; 26 import org.apache.axis2.integration.TestingUtils; 27 import org.apache.axis2.integration.UtilServer; 28 import org.apache.axis2.om.OMAbstractFactory; 29 import org.apache.axis2.om.OMElement; 30 import org.apache.axis2.om.OMFactory; 31 import org.apache.axis2.om.OMNamespace; 32 import org.apache.axis2.transport.http.SimpleHTTPServer; 33 import org.apache.axis2.util.Utils; 34 import org.apache.commons.logging.Log; 35 import org.apache.commons.logging.LogFactory; 36 37 import javax.xml.namespace.QName ; 38 39 public class EchoRawXMLOnTwoChannelsSyncTest extends TestCase { 40 private EndpointReference targetEPR = 41 new EndpointReference( 42 AddressingConstants.WSA_TO, 43 "http://127.0.0.1:" 44 + (UtilServer.TESTING_PORT) 45 + "/axis/services/EchoXMLService/echoOMElement"); 46 private Log log = LogFactory.getLog(getClass()); 47 private QName serviceName = new QName ("EchoXMLService"); 48 private QName operationName = new QName ("echoOMElement"); 49 private QName transportName = new QName ("http://localhost/my", "NullTransport"); 50 51 private AxisConfiguration engineRegistry; 52 private MessageContext mc; 53 private Thread thisThread; 54 private SimpleHTTPServer sas; 55 private ServiceContext serviceContext; 56 57 private boolean finish = false; 58 59 public EchoRawXMLOnTwoChannelsSyncTest() { 60 super(EchoRawXMLOnTwoChannelsSyncTest.class.getName()); 61 } 62 63 public EchoRawXMLOnTwoChannelsSyncTest(String testName) { 64 super(testName); 65 } 66 67 protected void setUp() throws Exception { 68 UtilServer.start(); 69 UtilServer.getConfigurationContext().getAxisConfiguration().engageModule( 70 new QName ("addressing")); 71 72 ServiceDescription service = 73 Utils.createSimpleService(serviceName, Echo.class.getName(), operationName); 74 UtilServer.deployService(service); 75 serviceContext = 76 UtilServer.getConfigurationContext().createServiceContext(service.getName()); 77 78 } 79 80 protected void tearDown() throws Exception { 81 UtilServer.unDeployService(serviceName); 82 UtilServer.stop(); 83 } 84 85 86 87 public void testEchoXMLCompleteSync() throws Exception { 88 ServiceDescription service = 89 Utils.createSimpleService( 90 serviceName, 91 Echo.class.getName(), 92 operationName); 93 94 ServiceContext serviceContext = UtilServer.createAdressedEnabledClientSide(service); 95 96 OMFactory fac = OMAbstractFactory.getOMFactory(); 97 98 OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my"); 99 OMElement method = fac.createOMElement("echoOMElement", omNs); 100 OMElement value = fac.createOMElement("myValue", omNs); 101 value.setText("Isaac Assimov, the foundation Sega"); 102 method.addChild(value); 103 104 org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(serviceContext); 105 call.setTo(targetEPR); 106 call.engageModule(new QName (Constants.MODULE_ADDRESSING)); 107 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true); 108 109 OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), method); 110 TestingUtils.campareWithCreatedOMElement(result); 111 call.close(); 112 113 } 114 115 } 116 | Popular Tags |