blob: 0c1e95cc5aa47f1e8a6db62c95155c960189712e (
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
|
// **********************************************************************
//
// Copyright (c) 2002
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>
using namespace std;
void
allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports)
{
cout << "testing stringToProxy... " << flush;
ostringstream ref;
ref << "test";
for(vector<int>::const_iterator p = ports.begin(); p != ports.end(); ++p)
{
ref << ":default -t 4000 -p " << *p;
}
Ice::ObjectPrx base = communicator->stringToProxy(ref.str());
test(base);
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
TestPrx obj = TestPrx::checkedCast(base);
test(obj);
test(obj == base);
cout << "ok" << endl;
int oldPid = 0;
for(unsigned int i = 1, j = 0; i <= ports.size(); ++i, j = j >= 3 ? 0 : j + 1)
{
cout << "testing server #" << i << "... " << flush;
int pid = obj->pid();
test(pid != oldPid);
cout << "ok" << endl;
oldPid = pid;
if(j == 0)
{
cout << "shutting down server #" << i << "... " << flush;
obj->shutdown();
cout << "ok" << endl;
}
else if(j == 1 || i + 1 > ports.size())
{
cout << "aborting server #" << i << "... " << flush;
try
{
obj->abort();
test(false);
}
catch(const Ice::ConnectionLostException&)
{
cout << "ok" << endl;
}
}
else if(j == 2)
{
cout << "aborting server #" << i << " and #" << i + 1 << " with idempotent call... " << flush;
try
{
obj->idempotentAbort();
test(false);
}
catch(const Ice::ConnectionLostException&)
{
cout << "ok" << endl;
}
++i;
}
else if(j == 3)
{
cout << "aborting server #" << i << " and #" << i + 1 << " with nonmutating call... " << flush;
try
{
obj->nonmutatingAbort();
test(false);
}
catch(const Ice::ConnectionLostException&)
{
cout << "ok" << endl;
}
++i;
}
else
{
assert(false);
}
}
cout << "testing whether all servers are gone... " << flush;
try
{
obj->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
cout << "ok" << endl;
}
}
|