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.Call; 26 import org.apache.axis2.context.MessageContext; 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.OMNamespace; 31 import org.apache.axis2.soap.SOAPBody; 32 import org.apache.axis2.soap.SOAPEnvelope; 33 import org.apache.axis2.soap.SOAPFactory; 34 import org.apache.axis2.transport.http.SimpleHTTPServer; 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 CallUnregisteredServiceTest extends TestCase { 41 private Log log = LogFactory.getLog(getClass()); 42 private QName serviceName = new QName ("", "EchoXMLService"); 43 private QName operationName = new QName ("http://localhost/my", "echoOMElement"); 44 45 private AxisConfiguration engineRegistry; 46 private MessageContext mc; 47 private Thread thisThread; 48 private SimpleHTTPServer sas; 49 50 public CallUnregisteredServiceTest() { 51 super(CallUnregisteredServiceTest.class.getName()); 52 } 53 54 public CallUnregisteredServiceTest(String testName) { 55 super(testName); 56 } 57 58 protected void setUp() throws Exception { 59 UtilServer.start(); 60 } 61 62 protected void tearDown() throws Exception { 63 UtilServer.stop(); 64 } 65 66 public void testEchoXMLSync() throws Exception { 67 try { 68 SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); 69 70 SOAPEnvelope reqEnv = fac.getDefaultEnvelope(); 71 OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my"); 72 OMElement method = fac.createOMElement("echoOMElement", omNs); 73 OMElement value = fac.createOMElement("myValue", omNs); 74 value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega")); 75 method.addChild(value); 76 reqEnv.getBody().addChild(method); 77 78 Call call = new Call(); 79 EndpointReference targetEPR = 80 new EndpointReference( 81 AddressingConstants.WSA_TO, 82 "http://127.0.0.1:" 83 + (UtilServer.TESTING_PORT) 84 + "/axis/services/EchoXMLService1"); 85 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false); 86 call.setTo(targetEPR); 87 SOAPEnvelope resEnv = 88 (SOAPEnvelope) call.invokeBlocking(operationName.getLocalPart(), reqEnv); 89 90 SOAPBody sb = resEnv.getBody(); 91 if (sb.hasFault()) { 92 throw new AxisFault(sb.getFault().getReason().getSOAPText().getText()); 93 } 94 fail("The test must fail due to wrong service Name"); 95 96 } catch (AxisFault e) { 97 assertTrue(e.getMessage().indexOf("Service Not found") > 0); 98 tearDown(); 99 return; 100 } 101 102 } 103 } 104 | Popular Tags |