blob: bba9cb681d17086d6cd155e0f65636a13fcbe72f (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
public class AllTests
{
private static void
test(boolean b)
{
if(!b)
{
throw new RuntimeException();
}
}
public static void
allTests(Ice.Communicator communicator, int[] ports)
{
System.out.print("testing stringToProxy... ");
System.out.flush();
String ref = "test";
for(int i = 0; i < ports.length; i++)
{
ref += ":default -t 4000 -p " + ports[i];
}
Ice.ObjectPrx base = communicator.stringToProxy(ref);
test(base != null);
System.out.println("ok");
System.out.print("testing checked cast... ");
System.out.flush();
TestPrx obj = TestPrxHelper.checkedCast(base);
test(obj != null);
test(obj.equals(base));
System.out.println("ok");
int oldPid = 0;
for(int i = 1, j = 0; i <= ports.length; ++i, j = j >= 3 ? 0 : j + 1)
{
System.out.print("testing server #" + i + "... ");
System.out.flush();
int pid = obj.pid();
test(pid != oldPid);
System.out.println("ok");
if(j == 0)
{
System.out.print("shutting down server #" + i + "... ");
System.out.flush();
obj.shutdown();
System.out.println("ok");
}
else if(j == 1 || i + 1 > ports.length)
{
System.out.print("aborting server #" + i + "... ");
System.out.flush();
try
{
obj.abort();
test(false);
}
catch(Ice.ConnectionLostException ex)
{
System.out.println("ok");
}
}
else if(j == 2)
{
System.out.print("aborting server #" + i + " and #" + (i + 1) + " with idempotent call... ");
System.out.flush();
try
{
obj.idempotentAbort();
test(false);
}
catch(Ice.ConnectionLostException ex)
{
System.out.println("ok");
}
++i;
}
else if(j == 3)
{
System.out.print("aborting server #" + i + " and #" + (i + 1) + " with nonmutating call... ");
System.out.flush();
try
{
obj.nonmutatingAbort();
test(false);
}
catch(Ice.ConnectionLostException ex)
{
System.out.println("ok");
}
++i;
}
else
{
assert(false);
}
}
System.out.print("testing whether all servers are gone... ");
System.out.flush();
try
{
obj.ice_ping();
test(false);
}
catch(Ice.LocalException ex)
{
System.out.println("ok");
}
}
}
|