1 16 17 package org.apache.axis2.engine; 18 19 21 import junit.framework.TestCase; 22 import org.apache.axis2.Constants; 23 import org.apache.axis2.addressing.AddressingConstants; 24 import org.apache.axis2.addressing.EndpointReference; 25 import org.apache.axis2.clientapi.MessageSender; 26 import org.apache.axis2.context.MessageContext; 27 import org.apache.axis2.description.OperationDescription; 28 import org.apache.axis2.description.ServiceDescription; 29 import org.apache.axis2.integration.TestingUtils; 30 import org.apache.axis2.integration.UtilServer; 31 import org.apache.axis2.om.OMAbstractFactory; 32 import org.apache.axis2.om.OMElement; 33 import org.apache.axis2.soap.SOAPEnvelope; 34 import org.apache.axis2.soap.SOAPFactory; 35 import org.apache.commons.logging.Log; 36 import org.apache.commons.logging.LogFactory; 37 38 import javax.xml.namespace.QName ; 39 40 public class OneWayRawXMLTest extends TestCase { 41 private EndpointReference targetEPR = 42 new EndpointReference(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 54 private SOAPEnvelope envelope; 55 56 private boolean finish = false; 57 58 public OneWayRawXMLTest() { 59 super(OneWayRawXMLTest.class.getName()); 60 } 61 62 public OneWayRawXMLTest(String testName) { 63 super(testName); 64 } 65 66 protected void setUp() throws Exception { 67 UtilServer.start(); 68 69 ServiceDescription service = new ServiceDescription(serviceName); 70 OperationDescription operation = new OperationDescription(operationName); 71 operation.setMessageReciever(new MessageReceiver() { 72 public void recieve(MessageContext messgeCtx) throws AxisFault { 73 envelope = messgeCtx.getEnvelope(); 74 TestingUtils.campareWithCreatedOMElement(envelope.getBody().getFirstElement()); 75 } 76 }); 77 service.addOperation(operation); 78 UtilServer.deployService(service); 79 } 80 81 82 protected void tearDown() throws Exception { 83 UtilServer.unDeployService(serviceName); 84 UtilServer.stop(); 85 } 86 87 88 89 public void testEchoXMLSync() throws Exception { 90 SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); 91 92 OMElement payload = TestingUtils.createDummyOMElement(); 93 94 MessageSender sender = new MessageSender(); 95 96 sender.setTo(targetEPR); 97 sender.setSenderTransport(Constants.TRANSPORT_HTTP); 98 99 sender.send(operationName.getLocalPart(), payload); 100 int index = 0; 101 while(envelope == null){ 102 Thread.sleep(4000); 103 index ++; 104 if(index == 5){ 105 throw new AxisFault("error Occured"); 106 } 107 } 108 } 109 110 } 111 | Popular Tags |