File: FaultServiceTestCase.java

package info (click to toggle)
axis 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,100 kB
  • sloc: java: 129,124; xml: 10,602; jsp: 983; sh: 84; cs: 36; makefile: 18
file content (134 lines) | stat: -rw-r--r-- 5,077 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
 * FaultServiceTestCase.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis Wsdl2java emitter.
 */

package test.wsdl.faults;




public class FaultServiceTestCase extends junit.framework.TestCase {
    public FaultServiceTestCase(String name) {
        super(name);
    }

    /* FIXME: RUNTIME WSDL broken.
    public void testFaultServiceWSDL() throws Exception {
        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.faults.FaultServiceLocator().getFaultServiceAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.faults.FaultServiceLocator().getServiceName());
        assertTrue(service != null);
    }
    */

    public void testFaultServiceGetQuote() {
        test.wsdl.faults.FaultServicePortType binding;
        try {
            binding = new FaultServiceLocator().getFaultService();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            throw new junit.framework.
                    AssertionFailedError("JAX-RPC ServiceException caught: " + jre);            
        }
        assertTrue("binding is null", binding != null);
        String symbol = new String("MACR");
        try {
            float value = 0;
            value = binding.getQuote(symbol);
            fail("Should raise an InvalidTickerFault"); 
        } 
        catch (InvalidTickerFaultMessage tickerFault) {
            assertEquals("Ticker Symbol in Fault doesn't match original argument", 
                    symbol, tickerFault.getTickerSymbol());
        }
        catch (org.apache.axis.AxisFault e) {
            throw new junit.framework.
                    AssertionFailedError("AxisFault caught: " + e);            
        }
        catch (java.rmi.RemoteException re) {
            throw new junit.framework.
                    AssertionFailedError("Remote Exception caught: " + re );
        }
    }

    public void testFaultServiceThrowFault() throws Exception {
        test.wsdl.faults.FaultServicePortType binding;
        try {
            binding = new FaultServiceLocator().getFaultService();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            throw new junit.framework.
                    AssertionFailedError("JAX-RPC ServiceException caught: " + jre);            
        }
        assertTrue("binding is null", binding != null);
        int a = 7;
        String b = "test";
        float c = 3.14F;
            
        try {
            float value = 0;
            value = binding.throwFault(a,b,c);
            fail("Should raise a DerivedFault"); 
        } 
        // We are expecting DerivedFault2 (the operation indicates
        // that it throws a DerivedFault, but we know the impl actually
        // throws DerivedFault2 which extends DerivedFault)
        catch (DerivedFault2 e) {
            assertEquals("Param A in DerivedFault2 doesn't match original",
                    a, e.getA());
            assertEquals("Param B in DerivedFault2 doesn't match original",
                    b, e.getB());
            assertEquals("Param C in DerivedFault2 doesn't match original",
                    c, e.getC(), 0.01F);
        }
        catch (DerivedFault e) {
            throw new junit.framework.
                    AssertionFailedError("DerivedFault caught: " + e);            
        }
        catch (BaseFault e) {
            throw new junit.framework.
                    AssertionFailedError("BaseFault caught: " + e);            
        }
    }

    public void testFaultServiceThrowExtensionFault() {
        test.wsdl.faults.FaultServicePortType binding;
        try {
            binding = new FaultServiceLocator().getFaultService();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            throw new junit.framework.
                    AssertionFailedError("JAX-RPC ServiceException caught: " + jre);            
        }
        assertTrue("binding is null", binding != null);
        String description = "test";
            
        try {
            int value = 0;
            value = binding.throwExtensionFault(description);
            fail("Should raise an ExtensionFault"); 
        } 
        catch (ExtensionFault e) {
            try {
                assertEquals("ExtensionFault extension element does not match original",
                        description, e.getExtension().get_any()[0].getAsDOM().getTagName());
            } catch (Exception domError) {
                throw new junit.framework.
                    AssertionFailedError("DOM Exception caught: " + domError);
            }
        }
        catch (org.apache.axis.AxisFault e) {
            throw new junit.framework.
                    AssertionFailedError("AxisFault caught: " + e);            
        }
        catch (java.rmi.RemoteException re) {
            throw new junit.framework.
                    AssertionFailedError("Remote Exception caught: " + re );
        }
    }

}