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
|
# **********************************************************************
#
# Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
def test(b)
if !b
raise RuntimeError, 'test assertion failed'
end
end
def allTests(helper, communicator)
print "testing Ice.Admin.Facets property... "
STDOUT.flush
test(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets").length == 0)
communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar");
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
test(facetFilter.length == 1 && facetFilter[0] == "foobar");
communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar");
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
test(facetFilter.length == 1 && facetFilter[0] == "foo'bar");
communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'");
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
test(facetFilter.length == 3 && facetFilter[0] == "foo bar" && facetFilter[1] == "toto" && facetFilter[2] == "titi");
communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'");
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
test(facetFilter.length == 2 && facetFilter[0] == "foo bar' toto" && facetFilter[1] == "titi");
# communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi");
# facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
# test(facetFilter.length == 0);
communicator.getProperties().setProperty("Ice.Admin.Facets", "");
puts "ok"
print "testing stringToProxy... "
STDOUT.flush
ref = "d:#{helper.getTestEndpoint()}"
db = communicator.stringToProxy(ref)
test(db)
puts "ok"
print "testing unchecked cast... "
STDOUT.flush
obj = Ice::ObjectPrx::uncheckedCast(db)
test(obj.ice_getFacet() == "")
obj = Ice::ObjectPrx::uncheckedCast(db, "facetABCD")
test(obj.ice_getFacet() == "facetABCD")
obj2 = Ice::ObjectPrx::uncheckedCast(obj)
test(obj2.ice_getFacet() == "facetABCD")
obj3 = Ice::ObjectPrx::uncheckedCast(obj, "")
test(obj3.ice_getFacet() == "")
d = Test::DPrx::uncheckedCast(db)
test(d.ice_getFacet() == "")
df = Test::DPrx::uncheckedCast(db, "facetABCD")
test(df.ice_getFacet() == "facetABCD")
df2 = Test::DPrx::uncheckedCast(df)
test(df2.ice_getFacet() == "facetABCD")
df3 = Test::DPrx::uncheckedCast(df, "")
test(df3.ice_getFacet() == "")
puts "ok"
print "testing checked cast... "
STDOUT.flush
obj = Ice::ObjectPrx::checkedCast(db)
test(obj.ice_getFacet() == "")
obj = Ice::ObjectPrx::checkedCast(db, "facetABCD")
test(obj.ice_getFacet() == "facetABCD")
obj2 = Ice::ObjectPrx::checkedCast(obj)
test(obj2.ice_getFacet() == "facetABCD")
obj3 = Ice::ObjectPrx::checkedCast(obj, "")
test(obj3.ice_getFacet() == "")
d = Test::DPrx::checkedCast(db)
test(d.ice_getFacet() == "")
df = Test::DPrx::checkedCast(db, "facetABCD")
test(df.ice_getFacet() == "facetABCD")
df2 = Test::DPrx::checkedCast(df)
test(df2.ice_getFacet() == "facetABCD")
df3 = Test::DPrx::checkedCast(df, "")
test(df3.ice_getFacet() == "")
puts "ok"
print "testing non-facets A, B, C, and D... "
STDOUT.flush
test(d.callA() == "A")
test(d.callB() == "B")
test(d.callC() == "C")
test(d.callD() == "D")
puts "ok"
print "testing facets A, B, C, and D... "
STDOUT.flush
df = Test::DPrx::checkedCast(d, "facetABCD")
test(df)
test(df.callA() == "A")
test(df.callB() == "B")
test(df.callC() == "C")
test(df.callD() == "D")
puts "ok"
print "testing facets E and F... "
STDOUT.flush
ff = Test::FPrx::checkedCast(d, "facetEF")
test(ff)
test(ff.callE() == "E")
test(ff.callF() == "F")
puts "ok"
print "testing facet G... "
STDOUT.flush
gf = Test::GPrx::checkedCast(ff, "facetGH")
test(gf)
test(gf.callG() == "G")
puts "ok"
print "testing whether casting preserves the facet... "
STDOUT.flush
hf = Test::HPrx::checkedCast(gf)
test(hf)
test(hf.callG() == "G")
test(hf.callH() == "H")
puts "ok"
return gf
end
|