1 7 8 package test.wsdl.faults; 9 10 11 12 13 public class FaultServiceTestCase extends junit.framework.TestCase { 14 public FaultServiceTestCase(String name) { 15 super(name); 16 } 17 18 26 27 public void testFaultServiceGetQuote() { 28 test.wsdl.faults.FaultServicePortType binding; 29 try { 30 binding = new FaultServiceLocator().getFaultService(); 31 } 32 catch (javax.xml.rpc.ServiceException jre) { 33 throw new junit.framework. 34 AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 35 } 36 assertTrue("binding is null", binding != null); 37 String symbol = new String ("MACR"); 38 try { 39 float value = 0; 40 value = binding.getQuote(symbol); 41 fail("Should raise an InvalidTickerFault"); 42 } 43 catch (InvalidTickerFaultMessage tickerFault) { 44 assertEquals("Ticker Symbol in Fault doesn't match original argument", 45 symbol, tickerFault.getTickerSymbol()); 46 } 47 catch (org.apache.axis.AxisFault e) { 48 throw new junit.framework. 49 AssertionFailedError("AxisFault caught: " + e); 50 } 51 catch (java.rmi.RemoteException re) { 52 throw new junit.framework. 53 AssertionFailedError("Remote Exception caught: " + re ); 54 } 55 } 56 57 public void testFaultServiceThrowFault() throws Exception { 58 test.wsdl.faults.FaultServicePortType binding; 59 try { 60 binding = new FaultServiceLocator().getFaultService(); 61 } 62 catch (javax.xml.rpc.ServiceException jre) { 63 throw new junit.framework. 64 AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 65 } 66 assertTrue("binding is null", binding != null); 67 int a = 7; 68 String b = "test"; 69 float c = 3.14F; 70 71 try { 72 float value = 0; 73 value = binding.throwFault(a,b,c); 74 fail("Should raise a DerivedFault"); 75 } 76 catch (DerivedFault2 e) { 80 assertEquals("Param A in DerivedFault2 doesn't match original", 81 a, e.getA()); 82 assertEquals("Param B in DerivedFault2 doesn't match original", 83 b, e.getB()); 84 assertEquals("Param C in DerivedFault2 doesn't match original", 85 c, e.getC(), 0.01F); 86 } 87 catch (DerivedFault e) { 88 throw new junit.framework. 89 AssertionFailedError("DerivedFault caught: " + e); 90 } 91 catch (BaseFault e) { 92 throw new junit.framework. 93 AssertionFailedError("BaseFault caught: " + e); 94 } 95 } 96 97 public void testFaultServiceThrowExtensionFault() { 98 test.wsdl.faults.FaultServicePortType binding; 99 try { 100 binding = new FaultServiceLocator().getFaultService(); 101 } 102 catch (javax.xml.rpc.ServiceException jre) { 103 throw new junit.framework. 104 AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 105 } 106 assertTrue("binding is null", binding != null); 107 String description = "test"; 108 109 try { 110 int value = 0; 111 value = binding.throwExtensionFault(description); 112 fail("Should raise an ExtensionFault"); 113 } 114 catch (ExtensionFault e) { 115 try { 116 assertEquals("ExtensionFault extension element does not match original", 117 description, e.getExtension().get_any()[0].getAsDOM().getTagName()); 118 } catch (Exception domError) { 119 throw new junit.framework. 120 AssertionFailedError("DOM Exception caught: " + domError); 121 } 122 } 123 catch (org.apache.axis.AxisFault e) { 124 throw new junit.framework. 125 AssertionFailedError("AxisFault caught: " + e); 126 } 127 catch (java.rmi.RemoteException re) { 128 throw new junit.framework. 129 AssertionFailedError("Remote Exception caught: " + re ); 130 } 131 } 132 133 } 134 135 | Popular Tags |