| 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 |
/** |
| 12 |
* Ensure that SOAP 1.2's FAULT_SUBCODE_PROC_NOT_PRESENT is thrown if the method is not found |
| 13 |
*/ |
| 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 |
/** |
| 24 |
* base test ensure that SOAP1.2 works :) |
| 25 |
* @throws Exception |
| 26 |
*/ |
| 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 |
/** |
| 36 |
* call a method that does not exist and check if the correct exception |
| 37 |
* is thrown from the server. |
| 38 |
* @throws Exception |
| 39 |
*/ |
| 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 |
/** |
| 58 |
* Service method. Returns a string |
| 59 |
* |
| 60 |
* @return a string |
| 61 |
*/ |
| 62 |
public String echo() { |
| 63 |
return "hello world"; |
| 64 |
} |
| 65 |
} |