~ubuntu-branches/debian/squeeze/axis/squeeze

« back to all changes in this revision

Viewing changes to test/dynamic/TestDynamicInvoker.java

  • Committer: Bazaar Package Importer
  • Author(s): Vladimír Lapáček
  • Date: 2006-09-06 22:31:39 UTC
  • Revision ID: james.westby@ubuntu.com-20060906223139-l7m5edxeositeppl
Tags: upstream-1.4
Import upstream version 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2001-2004 The Apache Software Foundation.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
package test.dynamic;
 
18
 
 
19
import junit.framework.TestCase;
 
20
import org.apache.axis.AxisFault;
 
21
import samples.client.DynamicInvoker;
 
22
 
 
23
import java.io.InterruptedIOException;
 
24
import java.net.ConnectException;
 
25
 
 
26
public class TestDynamicInvoker extends TestCase {
 
27
    public TestDynamicInvoker(String name) {
 
28
        super(name);
 
29
    } // ctor
 
30
 
 
31
    public void test1() throws Exception {
 
32
        try {
 
33
            String[] args = new String[]{"http://www.xmethods.net/sd/2001/TemperatureService.wsdl", "getTemp", "02067"};
 
34
            DynamicInvoker.main(args);
 
35
        }  catch (java.net.ConnectException ce) {
 
36
            System.err.println("getTemp connect error: " + ce);
 
37
            return;
 
38
        }  catch (java.rmi.RemoteException re) {
 
39
            if (re instanceof AxisFault) {
 
40
                AxisFault fault = (AxisFault) re;
 
41
                if (fault.detail instanceof ConnectException ||
 
42
                    fault.detail instanceof InterruptedIOException ||
 
43
                    (fault.getFaultString().indexOf("Connection timed out") != -1) ||
 
44
                    fault.getFaultCode().getLocalPart().equals("HTTP")) {
 
45
                    System.err.println("getTemp HTTP error: " + fault);
 
46
                    return;
 
47
                }
 
48
            }
 
49
            throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
 
50
        }  catch (java.io.IOException ioe) {
 
51
            System.err.println("getTemp connect error: " + ioe);
 
52
            return;
 
53
        }
 
54
    }
 
55
 
 
56
    public void test2() throws Exception {
 
57
        try {
 
58
            String[] args = new String[]{"http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl", "getQuote", "IBM"};
 
59
            DynamicInvoker.main(args);
 
60
        }  catch (java.net.ConnectException ce) {
 
61
            System.err.println("getQuote connect error: " + ce);
 
62
            return;
 
63
        }  catch (java.rmi.RemoteException re) {
 
64
            if (re instanceof AxisFault) {
 
65
                AxisFault fault = (AxisFault) re;
 
66
                if (fault.detail instanceof ConnectException ||
 
67
                    fault.detail instanceof InterruptedIOException ||
 
68
                    fault.getFaultCode().getLocalPart().equals("HTTP")) {
 
69
                    System.err.println("getQuote HTTP error: " + fault);
 
70
                    return;
 
71
                }
 
72
            }
 
73
            throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
 
74
        }  catch (java.io.IOException ioe) {
 
75
            System.err.println("getQuote connect error: " + ioe);
 
76
            return;
 
77
        }
 
78
    }
 
79
 
 
80
    public void test3() throws Exception {
 
81
        try {
 
82
            String[] args = new String[]{"http://mssoapinterop.org/asmx/xsd/round4XSD.wsdl", "echoString(Round4XSDTestSoap)", "Hello World!!!"};
 
83
            DynamicInvoker.main(args);
 
84
        }  catch (java.net.ConnectException ce) {
 
85
            System.err.println("round4XSD connect error: " + ce);
 
86
            return;
 
87
        }  catch (java.rmi.RemoteException re) {
 
88
            if (re instanceof AxisFault) {
 
89
                AxisFault fault = (AxisFault) re;
 
90
                if (fault.detail instanceof ConnectException ||
 
91
                    fault.detail instanceof InterruptedIOException ||
 
92
                    fault.getFaultCode().getLocalPart().equals("HTTP")) {
 
93
                    System.err.println("round4XSD HTTP error: " + fault);
 
94
                    return;
 
95
                }
 
96
            }
 
97
            throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
 
98
        }  catch (java.io.IOException ioe) {
 
99
            System.err.println("round4XSD connect error: " + ioe);
 
100
            return;
 
101
        }
 
102
    }
 
103
 
 
104
    public void test4() throws Exception {
 
105
        try {
 
106
            String[] args = new String[]{"http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?WSDL", 
 
107
                                        "Add", 
 
108
                                        "3", 
 
109
                                        "4"};
 
110
            DynamicInvoker.main(args);
 
111
        }  catch (java.net.ConnectException ce) {
 
112
            System.err.println("MathService connect error: " + ce);
 
113
            return;
 
114
        }  catch (java.rmi.RemoteException re) {
 
115
            if (re instanceof AxisFault) {
 
116
                AxisFault fault = (AxisFault) re;
 
117
                if (fault.detail instanceof ConnectException ||
 
118
                    fault.detail instanceof InterruptedIOException ||
 
119
                    fault.getFaultCode().getLocalPart().equals("HTTP")) {
 
120
                    System.err.println("MathService HTTP error: " + fault);
 
121
                    return;
 
122
                }
 
123
            }
 
124
            throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
 
125
        }  catch (java.io.IOException ioe) {
 
126
            System.err.println("MathService connect error: " + ioe);
 
127
            return;
 
128
        }
 
129
    }
 
130
}