1 package test.soap12; 2 3 import org.apache.axis.AxisFault; 4 import org.apache.axis.Constants; 5 import org.apache.axis.soap.SOAPConstants; 6 import org.apache.axis.client.Call; 7 import test.GenericLocalTest; 8 9 import javax.xml.namespace.QName ; 10 11 14 public class TestExceptions extends GenericLocalTest { 15 public TestExceptions() { 16 super("foo"); 17 } 18 19 public TestExceptions(String s) { 20 super(s); 21 } 22 23 27 public void testEcho() throws Exception { 28 Object result = null; 29 Call call = getCall(); 30 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 31 result = call.invoke("echo", null); 32 assertEquals(result.toString(), "hello world"); 33 } 34 35 40 public void testNoSuchProcedure() throws Exception { 41 Object result = null; 42 try { 43 Call call = getCall(); 44 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 45 result = call.invoke("unknownFreakyMethod", null); 46 } catch (AxisFault fault){ 47 assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode()); 48 QName [] subCodes = fault.getFaultSubCodes(); 49 assertNotNull(subCodes); 50 assertEquals(1, subCodes.length); 51 assertEquals(Constants.FAULT_SUBCODE_PROC_NOT_PRESENT, subCodes[0]); 52 return; 53 } 54 fail("Didn't catch expected fault"); 55 } 56 57 62 public String echo() { 63 return "hello world"; 64 } 65 } 66 | Popular Tags |