1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #include <Ice/Ice.h>
6 #include <Ice/Locator.h>
7 #include <Ice/Router.h>
8 #include <TestHelper.h>
9 #include <Test.h>
10 
11 #ifdef _MSC_VER
12 #   pragma warning(disable:4125) // decimal digit terminates octal escape sequence
13 #endif
14 
15 using namespace std;
16 
17 Test::MyClassPrxPtr
allTests(Test::TestHelper * helper)18 allTests(Test::TestHelper* helper)
19 {
20     Ice::CommunicatorPtr communicator = helper->communicator();
21     const string protocol = communicator->getProperties()->getProperty("Ice.Default.Protocol");
22 
23     const string endp = helper->getTestEndpoint();
24     cout << "testing stringToProxy... " << flush;
25 
26     string ref = "test:" + endp;
27     Ice::ObjectPrxPtr base = communicator->stringToProxy(ref);
28     test(base);
29 
30     Ice::ObjectPrxPtr b1 = communicator->stringToProxy("test");
31     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
32          b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty());
33     b1 = communicator->stringToProxy("test ");
34     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
35          b1->ice_getFacet().empty());
36     b1 = communicator->stringToProxy(" test ");
37     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
38          b1->ice_getFacet().empty());
39     b1 = communicator->stringToProxy(" test");
40     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
41          b1->ice_getFacet().empty());
42     b1 = communicator->stringToProxy("'test -f facet'");
43     test(b1->ice_getIdentity().name == "test -f facet" && b1->ice_getIdentity().category.empty() &&
44          b1->ice_getFacet().empty());
45     try
46     {
47         b1 = communicator->stringToProxy("\"test -f facet'");
48         test(false);
49     }
50     catch(const Ice::ProxyParseException&)
51     {
52     }
53     b1 = communicator->stringToProxy("\"test -f facet\"");
54     test(b1->ice_getIdentity().name == "test -f facet" && b1->ice_getIdentity().category.empty() &&
55          b1->ice_getFacet().empty());
56     b1 = communicator->stringToProxy("\"test -f facet@test\"");
57     test(b1->ice_getIdentity().name == "test -f facet@test" && b1->ice_getIdentity().category.empty() &&
58          b1->ice_getFacet().empty());
59     b1 = communicator->stringToProxy("\"test -f facet@test @test\"");
60     test(b1->ice_getIdentity().name == "test -f facet@test @test" && b1->ice_getIdentity().category.empty() &&
61          b1->ice_getFacet().empty());
62     try
63     {
64         b1 = communicator->stringToProxy("test test");
65         test(false);
66     }
67     catch(const Ice::ProxyParseException&)
68     {
69     }
70 
71     b1 = communicator->stringToProxy("test\\040test");
72     test(b1->ice_getIdentity().name == "test test" && b1->ice_getIdentity().category.empty());
73     try
74     {
75         b1 = communicator->stringToProxy("test\\777");
76         test(false);
77     }
78     catch(const Ice::IdentityParseException&)
79     {
80     }
81 
82     b1 = communicator->stringToProxy("test\\40test");
83     test(b1->ice_getIdentity().name == "test test");
84 
85     // Test some octal corner cases.
86     b1 = communicator->stringToProxy("test\\4test");
87     test(b1->ice_getIdentity().name == "test\4test");
88     b1 = communicator->stringToProxy("test\\04test");
89     test(b1->ice_getIdentity().name == "test\4test");
90     b1 = communicator->stringToProxy("test\\004test");
91     test(b1->ice_getIdentity().name == "test\4test");
92     b1 = communicator->stringToProxy("test\\1114test");
93     test(b1->ice_getIdentity().name == "test\1114test");
94 
95     b1 = communicator->stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test");
96     test(b1->ice_getIdentity().name == "test\b\f\n\r\t\'\"\\test" && b1->ice_getIdentity().category.empty());
97 
98     b1 = communicator->stringToProxy("category/test");
99     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" &&
100          b1->ice_getAdapterId().empty());
101 
102     b1 = communicator->stringToProxy("");
103     test(!b1);
104     b1 = communicator->stringToProxy("\"\"");
105     test(!b1);
106 
107     try
108     {
109         b1 = communicator->stringToProxy("\"\" test"); // Invalid trailing characters.
110         test(false);
111     }
112     catch(const Ice::ProxyParseException&)
113     {
114     }
115 
116     try
117     {
118         b1 = communicator->stringToProxy("test:"); // Missing endpoint.
119         test(false);
120     }
121     catch(const Ice::EndpointParseException&)
122     {
123     }
124 
125     b1 = communicator->stringToProxy("test@adapter");
126     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
127          b1->ice_getAdapterId() == "adapter");
128     try
129     {
130         b1 = communicator->stringToProxy("id@adapter test");
131         test(false);
132     }
133     catch(const Ice::ProxyParseException&)
134     {
135     }
136     b1 = communicator->stringToProxy("category/test@adapter");
137     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" &&
138          b1->ice_getAdapterId() == "adapter");
139     b1 = communicator->stringToProxy("category/test@adapter:tcp");
140     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" &&
141          b1->ice_getAdapterId() == "adapter:tcp");
142     b1 = communicator->stringToProxy("'category 1/test'@adapter");
143     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category 1" &&
144          b1->ice_getAdapterId() == "adapter");
145     b1 = communicator->stringToProxy("'category/test 1'@adapter");
146     test(b1->ice_getIdentity().name == "test 1" && b1->ice_getIdentity().category == "category" &&
147          b1->ice_getAdapterId() == "adapter");
148     b1 = communicator->stringToProxy("'category/test'@'adapter 1'");
149     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" &&
150          b1->ice_getAdapterId() == "adapter 1");
151     b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@adapter");
152 
153     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo"
154          && b1->ice_getAdapterId() == "adapter");
155 
156     b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\"");
157     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" &&
158          b1->ice_getAdapterId() == "adapter:tcp");
159 
160     b1 = communicator->stringToProxy("id -f facet");
161     test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() &&
162          b1->ice_getFacet() == "facet");
163     b1 = communicator->stringToProxy("id -f 'facet x'");
164     test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() &&
165          b1->ice_getFacet() == "facet x");
166     b1 = communicator->stringToProxy("id -f \"facet x\"");
167     test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() &&
168          b1->ice_getFacet() == "facet x");
169     try
170     {
171         b1 = communicator->stringToProxy("id -f \"facet x");
172         test(false);
173     }
174     catch(const Ice::ProxyParseException&)
175     {
176     }
177     try
178     {
179         b1 = communicator->stringToProxy("id -f \'facet x");
180         test(false);
181     }
182     catch(const Ice::ProxyParseException&)
183     {
184     }
185     b1 = communicator->stringToProxy("test -f facet:tcp");
186     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
187          b1->ice_getFacet() == "facet" && b1->ice_getAdapterId().empty());
188     b1 = communicator->stringToProxy("test -f \"facet:tcp\"");
189     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
190          b1->ice_getFacet() == "facet:tcp" && b1->ice_getAdapterId().empty());
191     b1 = communicator->stringToProxy("test -f facet@test");
192     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
193          b1->ice_getFacet() == "facet" && b1->ice_getAdapterId() == "test");
194     b1 = communicator->stringToProxy("test -f 'facet@test'");
195     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
196          b1->ice_getFacet() == "facet@test" && b1->ice_getAdapterId().empty());
197     b1 = communicator->stringToProxy("test -f 'facet@test'@test");
198     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
199          b1->ice_getFacet() == "facet@test" && b1->ice_getAdapterId() == "test");
200     try
201     {
202         b1 = communicator->stringToProxy("test -f facet@test @test");
203         test(false);
204     }
205     catch(const Ice::ProxyParseException&)
206     {
207     }
208     b1 = communicator->stringToProxy("test");
209     test(b1->ice_isTwoway());
210     b1 = communicator->stringToProxy("test -t");
211     test(b1->ice_isTwoway());
212     b1 = communicator->stringToProxy("test -o");
213     test(b1->ice_isOneway());
214     b1 = communicator->stringToProxy("test -O");
215     test(b1->ice_isBatchOneway());
216     b1 = communicator->stringToProxy("test -d");
217     test(b1->ice_isDatagram());
218     b1 = communicator->stringToProxy("test -D");
219     test(b1->ice_isBatchDatagram());
220     b1 = communicator->stringToProxy("test");
221     test(!b1->ice_isSecure());
222     b1 = communicator->stringToProxy("test -s");
223     test(b1->ice_isSecure());
224 
225     test(b1->ice_getEncodingVersion() == Ice::currentEncoding);
226 
227     b1 = communicator->stringToProxy("test -e 1.0");
228     test(b1->ice_getEncodingVersion().major == 1 && b1->ice_getEncodingVersion().minor == 0);
229 
230     b1 = communicator->stringToProxy("test -e 6.5");
231     test(b1->ice_getEncodingVersion().major == 6 && b1->ice_getEncodingVersion().minor == 5);
232 
233     b1 = communicator->stringToProxy("test -p 1.0 -e 1.0");
234     test(b1->ice_toString() == "test -t -e 1.0");
235 
236     b1 = communicator->stringToProxy("test -p 6.5 -e 1.0");
237     test(b1->ice_toString() == "test -t -p 6.5 -e 1.0");
238 
239     try
240     {
241         communicator->stringToProxy("test:tcp@adapterId");
242         test(false);
243     }
244     catch(const Ice::EndpointParseException&)
245     {
246     }
247     // This is an unknown endpoint warning, not a parse exception.
248     //
249     //try
250     //{
251     //   b1 = communicator->stringToProxy("test -f the:facet:tcp");
252     //   test(false);
253     //}
254     //catch(const Ice::EndpointParseException&)
255     //{
256     //}
257     try
258     {
259         communicator->stringToProxy("test: :tcp");
260         test(false);
261     }
262     catch(const Ice::EndpointParseException&)
263     {
264     }
265 
266     //
267     // Test invalid endpoint syntax
268     //
269     try
270     {
271         communicator->createObjectAdapterWithEndpoints("BadAdapter", " : ");
272         test(false);
273     }
274     catch(const Ice::EndpointParseException&)
275     {
276     }
277 
278     try
279     {
280         communicator->createObjectAdapterWithEndpoints("BadAdapter", "tcp: ");
281         test(false);
282     }
283     catch(const Ice::EndpointParseException&)
284     {
285     }
286 
287     try
288     {
289         communicator->createObjectAdapterWithEndpoints("BadAdapter", ":tcp");
290         test(false);
291     }
292     catch(const Ice::EndpointParseException&)
293     {
294     }
295 
296     //
297     // Test for bug ICE-5543: escaped escapes in stringToIdentity
298     //
299     Ice::Identity id = { "test", ",X2QNUAzSBcJ_e$AV;E\\" };
300     Ice::Identity id2 = Ice::stringToIdentity(communicator->identityToString(id));
301     test(id == id2);
302 
303     id.name = "test";
304     id.category = ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\";
305     id2 = Ice::stringToIdentity(communicator->identityToString(id));
306     test(id == id2);
307 
308     id.name = "/test";
309     id.category = "cat/";
310     string idStr = communicator->identityToString(id);
311     test(idStr == "cat\\//\\/test");
312     id2 = Ice::stringToIdentity(idStr);
313     test(id == id2);
314 
315     // Input string with various pitfalls
316     id = Ice::stringToIdentity("\\342\\x82\\254\\60\\x9\\60\\");
317     test(id.name == "\xE2\x82\xAC\60\t0\\" && id.category.empty());
318 
319     try
320     {
321         // Illegal character < 32
322         id = Ice::stringToIdentity("xx\01FooBar");
323         test(false);
324     }
325     catch(const Ice::IdentityParseException&)
326     {
327     }
328 
329     try
330     {
331         // Illegal surrogate
332         id = Ice::stringToIdentity("xx\\ud911");
333         test(false);
334     }
335     catch(const Ice::IdentityParseException&)
336     {
337     }
338 
339     // Testing bytes 127 (\x7F) and €
340     id.name = "test";
341     id.category = "\x7F\xE2\x82\xAC";
342 
343     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Unicode));
344     test(idStr == "\\u007f\xE2\x82\xAC/test");
345     id2 = Ice::stringToIdentity(idStr);
346     test(id == id2);
347     test(Ice::identityToString(id) == idStr);
348 
349     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, ASCII));
350     test(idStr == "\\u007f\\u20ac/test");
351     id2 = Ice::stringToIdentity(idStr);
352     test(id == id2);
353 
354     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Compat));
355     test(idStr == "\\177\\342\\202\\254/test");
356     id2 = Ice::stringToIdentity(idStr);
357     test(id == id2);
358 
359     id2 = Ice::stringToIdentity(communicator->identityToString(id));
360     test(id == id2);
361 
362     // More unicode characters
363 #ifdef ICE_CPP11_MAPPING
364     id.name = u8"banana \016-\U0001F34C\U000020AC\u00a2\u0024";
365     id.category = u8"greek \U0001016A";
366 
367     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Unicode));
368     test(idStr == u8"greek \U0001016A/banana \\u000e-\U0001F34C\U000020AC\u00a2$");
369     id2 = Ice::stringToIdentity(idStr);
370     test(id == id2);
371 
372     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, ASCII));
373     test(idStr == "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$");
374     id2 = Ice::stringToIdentity(idStr);
375     test(id == id2);
376 
377     idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Compat));
378     test(idStr == "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$");
379     id2 = Ice::stringToIdentity(idStr);
380     test(id == id2);
381 #endif
382 
383     cout << "ok" << endl;
384 
385     cout << "testing proxyToString... " << flush;
386     b1 = communicator->stringToProxy(ref);
387     Ice::ObjectPrxPtr b2 = communicator->stringToProxy(communicator->proxyToString(b1));
388     test(Ice::targetEqualTo(b1, b2));
389 
390     if(b1->ice_getConnection()) // not colloc-optimized target
391     {
392         b2 = b1->ice_getConnection()->createProxy(Ice::stringToIdentity("fixed"));
393         string str = communicator->proxyToString(b2);
394         test(b2->ice_toString() == str);
395         string str2 = b1->ice_identity(b2->ice_getIdentity())->ice_secure(b2->ice_isSecure())->ice_toString();
396 
397         // Verify that the stringified fixed proxy is the same as a regular stringified proxy
398         // but without endpoints
399         test(str2.substr(0, str.size()) == str);
400         test(str2[str.size()] == ':');
401     }
402     cout << "ok" << endl;
403 
404     cout << "testing propertyToProxy... " << flush;
405     Ice::PropertiesPtr prop = communicator->getProperties();
406     string propertyPrefix = "Foo.Proxy";
407     prop->setProperty(propertyPrefix, "test:" + endp);
408     b1 = communicator->propertyToProxy(propertyPrefix);
409     test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
410          b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty());
411 
412     string property;
413 
414     property = propertyPrefix + ".Locator";
415     test(!b1->ice_getLocator());
416     prop->setProperty(property, "locator:" + endp);
417     b1 = communicator->propertyToProxy(propertyPrefix);
418     test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
419     prop->setProperty(property, "");
420 
421     property = propertyPrefix + ".LocatorCacheTimeout";
422     test(b1->ice_getLocatorCacheTimeout() == -1);
423     prop->setProperty(property, "1");
424     b1 = communicator->propertyToProxy(propertyPrefix);
425     test(b1->ice_getLocatorCacheTimeout() == 1);
426     prop->setProperty(property, "");
427 
428     // Now retest with an indirect proxy.
429     prop->setProperty(propertyPrefix, "test");
430     property = propertyPrefix + ".Locator";
431     prop->setProperty(property, "locator:" + endp);
432     b1 = communicator->propertyToProxy(propertyPrefix);
433     test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
434     prop->setProperty(property, "");
435 
436     property = propertyPrefix + ".LocatorCacheTimeout";
437     test(b1->ice_getLocatorCacheTimeout() == -1);
438     prop->setProperty(property, "1");
439     b1 = communicator->propertyToProxy(propertyPrefix);
440     test(b1->ice_getLocatorCacheTimeout() == 1);
441     prop->setProperty(property, "");
442 
443     // This cannot be tested so easily because the property is cached
444     // on communicator initialization.
445     //
446     //prop->setProperty("Ice.Default.LocatorCacheTimeout", "60");
447     //b1 = communicator->propertyToProxy(propertyPrefix);
448     //test(b1->ice_getLocatorCacheTimeout() == 60);
449     //prop->setProperty("Ice.Default.LocatorCacheTimeout", "");
450 
451     prop->setProperty(propertyPrefix, "test:" + endp);
452 
453     property = propertyPrefix + ".Router";
454     test(!b1->ice_getRouter());
455     prop->setProperty(property, "router:" + endp);
456     b1 = communicator->propertyToProxy(propertyPrefix);
457     test(b1->ice_getRouter() && b1->ice_getRouter()->ice_getIdentity().name == "router");
458     prop->setProperty(property, "");
459 
460     property = propertyPrefix + ".PreferSecure";
461     test(!b1->ice_isPreferSecure());
462     prop->setProperty(property, "1");
463     b1 = communicator->propertyToProxy(propertyPrefix);
464     test(b1->ice_isPreferSecure());
465     prop->setProperty(property, "");
466 
467     property = propertyPrefix + ".ConnectionCached";
468     test(b1->ice_isConnectionCached());
469     prop->setProperty(property, "0");
470     b1 = communicator->propertyToProxy(propertyPrefix);
471     test(!b1->ice_isConnectionCached());
472     prop->setProperty(property, "");
473 
474     property = propertyPrefix + ".InvocationTimeout";
475     test(b1->ice_getInvocationTimeout() == -1);
476     prop->setProperty(property, "1000");
477     b1 = communicator->propertyToProxy(propertyPrefix);
478     test(b1->ice_getInvocationTimeout() == 1000);
479     prop->setProperty(property, "");
480 
481     property = propertyPrefix + ".EndpointSelection";
482     test(b1->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Random));
483     prop->setProperty(property, "Random");
484     b1 = communicator->propertyToProxy(propertyPrefix);
485     test(b1->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Random));
486     prop->setProperty(property, "Ordered");
487     b1 = communicator->propertyToProxy(propertyPrefix);
488     test(b1->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Ordered));
489     prop->setProperty(property, "");
490 
491     property = propertyPrefix + ".CollocationOptimized";
492     test(b1->ice_isCollocationOptimized());
493     prop->setProperty(property, "0");
494     b1 = communicator->propertyToProxy(propertyPrefix);
495     test(!b1->ice_isCollocationOptimized());
496     prop->setProperty(property, "");
497 
498     property = propertyPrefix + ".Context.c1";
499     test(b1->ice_getContext()["c1"].empty());
500     prop->setProperty(property, "TEST");
501     b1 = communicator->propertyToProxy(propertyPrefix);
502     test(b1->ice_getContext()["c1"] == "TEST");
503 
504     property = propertyPrefix + ".Context.c2";
505     test(b1->ice_getContext()["c2"].empty());
506     prop->setProperty(property, "TEST");
507     b1 = communicator->propertyToProxy(propertyPrefix);
508     test(b1->ice_getContext()["c2"] == "TEST");
509 
510     prop->setProperty(propertyPrefix + ".Context.c1", "");
511     prop->setProperty(propertyPrefix + ".Context.c2", "");
512 
513     cout << "ok" << endl;
514 
515     cout << "testing proxyToProperty... " << flush;
516 
517     b1 = communicator->stringToProxy("test");
518     b1 = b1->ice_collocationOptimized(true);
519     b1 = b1->ice_connectionCached(true);
520     b1 = b1->ice_preferSecure(false);
521     b1 = b1->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered));
522     b1 = b1->ice_locatorCacheTimeout(100);
523     b1 = b1->ice_invocationTimeout(1234);
524     Ice::EncodingVersion v = { 1, 0 };
525     b1 = b1->ice_encodingVersion(v);
526     Ice::ObjectPrxPtr router = communicator->stringToProxy("router");
527     router = router->ice_collocationOptimized(false);
528     router = router->ice_connectionCached(true);
529     router = router->ice_preferSecure(true);
530     router = router->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random));
531     router = router->ice_locatorCacheTimeout(200);
532     router = router->ice_invocationTimeout(1500);
533 
534     Ice::ObjectPrxPtr locator = communicator->stringToProxy("locator");
535     locator = locator->ice_collocationOptimized(true);
536     locator = locator->ice_connectionCached(false);
537     locator = locator->ice_preferSecure(true);
538     locator = locator->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random));
539     locator = locator->ice_locatorCacheTimeout(300);
540     locator = locator->ice_invocationTimeout(1500);
541 
542     locator = locator->ice_router(ICE_UNCHECKED_CAST(Ice::RouterPrx, router));
543     b1 = b1->ice_locator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
544 
545     Ice::PropertyDict proxyProps = communicator->proxyToProperty(b1, "Test");
546     test(proxyProps.size() == 21);
547 
548     test(proxyProps["Test"] == "test -t -e 1.0");
549     test(proxyProps["Test.CollocationOptimized"] == "1");
550     test(proxyProps["Test.ConnectionCached"] == "1");
551     test(proxyProps["Test.PreferSecure"] == "0");
552     test(proxyProps["Test.EndpointSelection"] == "Ordered");
553     test(proxyProps["Test.LocatorCacheTimeout"] == "100");
554     test(proxyProps["Test.InvocationTimeout"] == "1234");
555 
556     test(proxyProps["Test.Locator"] == "locator -t -e " + Ice::encodingVersionToString(Ice::currentEncoding));
557     // Locator collocation optimization is always disabled.
558     //test(proxyProps["Test.Locator.CollocationOptimized"] == "1");
559     test(proxyProps["Test.Locator.ConnectionCached"] == "0");
560     test(proxyProps["Test.Locator.PreferSecure"] == "1");
561     test(proxyProps["Test.Locator.EndpointSelection"] == "Random");
562     test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300");
563     test(proxyProps["Test.Locator.InvocationTimeout"] == "1500");
564 
565     test(proxyProps["Test.Locator.Router"] == "router -t -e " + Ice::encodingVersionToString(Ice::currentEncoding));
566     test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0");
567     test(proxyProps["Test.Locator.Router.ConnectionCached"] == "1");
568     test(proxyProps["Test.Locator.Router.PreferSecure"] == "1");
569     test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random");
570     test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200");
571     test(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500");
572 
573     cout << "ok" << endl;
574 
575     cout << "testing ice_getCommunicator... " << flush;
576     test(base->ice_getCommunicator() == communicator);
577     cout << "ok" << endl;
578 
579     cout << "testing proxy methods... " << flush;
580 
581     test(communicator->identityToString(base->ice_identity(Ice::stringToIdentity("other"))->ice_getIdentity())
582          == "other");
583     test(base->ice_facet("facet")->ice_getFacet() == "facet");
584     test(base->ice_adapterId("id")->ice_getAdapterId() == "id");
585     test(base->ice_twoway()->ice_isTwoway());
586     test(base->ice_oneway()->ice_isOneway());
587     test(base->ice_batchOneway()->ice_isBatchOneway());
588     test(base->ice_datagram()->ice_isDatagram());
589     test(base->ice_batchDatagram()->ice_isBatchDatagram());
590     test(base->ice_secure(true)->ice_isSecure());
591     test(!base->ice_secure(false)->ice_isSecure());
592     test(base->ice_collocationOptimized(true)->ice_isCollocationOptimized());
593     test(!base->ice_collocationOptimized(false)->ice_isCollocationOptimized());
594     test(base->ice_preferSecure(true)->ice_isPreferSecure());
595     test(!base->ice_preferSecure(false)->ice_isPreferSecure());
596     test(base->ice_encodingVersion(Ice::Encoding_1_0)->ice_getEncodingVersion() == Ice::Encoding_1_0);
597     test(base->ice_encodingVersion(Ice::Encoding_1_1)->ice_getEncodingVersion() == Ice::Encoding_1_1);
598     test(base->ice_encodingVersion(Ice::Encoding_1_0)->ice_getEncodingVersion() != Ice::Encoding_1_1);
599 
600     try
601     {
602         base->ice_timeout(0);
603         test(false);
604     }
605 #ifdef ICE_CPP11_MAPPING
606     catch(const invalid_argument&)
607 #else
608     catch(const IceUtil::IllegalArgumentException&)
609 #endif
610     {
611     }
612 
613     try
614     {
615         base->ice_timeout(-1);
616     }
617 #ifdef ICE_CPP11_MAPPING
618     catch(const invalid_argument&)
619 #else
620     catch(const IceUtil::IllegalArgumentException&)
621 #endif
622     {
623         test(false);
624     }
625 
626     try
627     {
628         base->ice_timeout(-2);
629         test(false);
630     }
631 #ifdef ICE_CPP11_MAPPING
632     catch(const invalid_argument&)
633 #else
634     catch(const IceUtil::IllegalArgumentException&)
635 #endif
636     {
637     }
638 
639     try
640     {
641         base->ice_invocationTimeout(0);
642         test(false);
643     }
644 #ifdef ICE_CPP11_MAPPING
645     catch(const invalid_argument&)
646 #else
647     catch(const IceUtil::IllegalArgumentException&)
648 #endif
649     {
650     }
651 
652     try
653     {
654         base->ice_invocationTimeout(-1);
655         base->ice_invocationTimeout(-2);
656     }
657 #ifdef ICE_CPP11_MAPPING
658     catch(const invalid_argument&)
659 #else
660     catch(const IceUtil::IllegalArgumentException&)
661 #endif
662     {
663         test(false);
664     }
665 
666     try
667     {
668         base->ice_invocationTimeout(-3);
669         test(false);
670     }
671 #ifdef ICE_CPP11_MAPPING
672     catch(const invalid_argument&)
673 #else
674     catch(const IceUtil::IllegalArgumentException&)
675 #endif
676     {
677     }
678 
679     try
680     {
681         base->ice_locatorCacheTimeout(0);
682     }
683 #ifdef ICE_CPP11_MAPPING
684     catch(const invalid_argument&)
685 #else
686     catch(const IceUtil::IllegalArgumentException&)
687 #endif
688     {
689         test(false);
690     }
691 
692     try
693     {
694         base->ice_locatorCacheTimeout(-1);
695     }
696 #ifdef ICE_CPP11_MAPPING
697     catch(const invalid_argument&)
698 #else
699     catch(const IceUtil::IllegalArgumentException&)
700 #endif
701     {
702         test(false);
703     }
704 
705     try
706     {
707         base->ice_locatorCacheTimeout(-2);
708         test(false);
709     }
710 #ifdef ICE_CPP11_MAPPING
711     catch(const invalid_argument&)
712 #else
713     catch(const IceUtil::IllegalArgumentException&)
714 #endif
715     {
716     }
717 
718     cout << "ok" << endl;
719 
720     cout << "testing proxy comparison... " << flush;
721 
722 #ifdef ICE_CPP11_MAPPING
723     test(Ice::targetEqualTo(communicator->stringToProxy("foo"), communicator->stringToProxy("foo")));
724     test(Ice::targetNotEqualTo(communicator->stringToProxy("foo"), communicator->stringToProxy("foo2")));
725     test(Ice::targetLess(communicator->stringToProxy("foo"), communicator->stringToProxy("foo2")));
726     test(Ice::targetGreaterEqual(communicator->stringToProxy("foo2"), communicator->stringToProxy("foo")));
727 
728     Ice::ObjectPrxPtr compObj = communicator->stringToProxy("foo");
729 
730     test(Ice::targetEqualTo(compObj->ice_facet("facet"), compObj->ice_facet("facet")));
731     test(Ice::targetNotEqualTo(compObj->ice_facet("facet"), compObj->ice_facet("facet1")));
732     test(Ice::targetLess(compObj->ice_facet("facet"), compObj->ice_facet("facet1")));
733     test(Ice::targetGreaterEqual(compObj->ice_facet("facet"), compObj->ice_facet("facet")));
734 
735     test(Ice::targetEqualTo(compObj->ice_oneway(), compObj->ice_oneway()));
736     test(Ice::targetNotEqualTo(compObj->ice_oneway(), compObj->ice_twoway()));
737     test(Ice::targetLess(compObj->ice_twoway(), compObj->ice_oneway()));
738     test(Ice::targetGreaterEqual(compObj->ice_oneway(), compObj->ice_twoway()));
739 
740     test(Ice::targetEqualTo(compObj->ice_secure(true), compObj->ice_secure(true)));
741     test(Ice::targetNotEqualTo(compObj->ice_secure(false), compObj->ice_secure(true)));
742     test(Ice::targetLess(compObj->ice_secure(false), compObj->ice_secure(true)));
743     test(Ice::targetGreaterEqual(compObj->ice_secure(true), compObj->ice_secure(false)));
744 
745     test(Ice::targetEqualTo(compObj->ice_collocationOptimized(true), compObj->ice_collocationOptimized(true)));
746     test(Ice::targetNotEqualTo(compObj->ice_collocationOptimized(false), compObj->ice_collocationOptimized(true)));
747     test(Ice::targetLess(compObj->ice_collocationOptimized(false), compObj->ice_collocationOptimized(true)));
748     test(Ice::targetGreaterEqual(compObj->ice_collocationOptimized(true), compObj->ice_collocationOptimized(false)));
749 
750     test(Ice::targetEqualTo(compObj->ice_connectionCached(true), compObj->ice_connectionCached(true)));
751     test(Ice::targetNotEqualTo(compObj->ice_connectionCached(false), compObj->ice_connectionCached(true)));
752     test(Ice::targetLess(compObj->ice_connectionCached(false), compObj->ice_connectionCached(true)));
753     test(Ice::targetGreaterEqual(compObj->ice_connectionCached(true), compObj->ice_connectionCached(false)));
754 
755     test(Ice::targetEqualTo(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)), compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random))));
756     test(Ice::targetNotEqualTo(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)), compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered))));
757     test(Ice::targetLess(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)), compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered))));
758     test(Ice::targetGreaterEqual(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)), compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random))));
759 
760     test(Ice::targetEqualTo(compObj->ice_connectionId("id2"), compObj->ice_connectionId("id2")));
761     test(Ice::targetNotEqualTo(compObj->ice_connectionId("id1"), compObj->ice_connectionId("id2")));
762     test(Ice::targetLess(compObj->ice_connectionId("id1"), compObj->ice_connectionId("id2")));
763     test(Ice::targetGreaterEqual(compObj->ice_connectionId("id2"), compObj->ice_connectionId("id1")));
764 
765     test(compObj->ice_connectionId("id1")->ice_getConnectionId() == "id1");
766     test(compObj->ice_connectionId("id2")->ice_getConnectionId() == "id2");
767 
768     test(Ice::targetEqualTo(compObj->ice_compress(true), compObj->ice_compress(true)));
769     test(Ice::targetNotEqualTo(compObj->ice_compress(false), compObj->ice_compress(true)));
770     test(Ice::targetLess(compObj->ice_compress(false), compObj->ice_compress(true)));
771     test(Ice::targetGreaterEqual(compObj->ice_compress(true), compObj->ice_compress(false)));
772 
773     test(compObj->ice_getCompress() == Ice::nullopt);
774     test(compObj->ice_compress(true)->ice_getCompress() == Ice::optional<bool>(true));
775     test(compObj->ice_compress(false)->ice_getCompress() == Ice::optional<bool>(false));
776 
777     test(Ice::targetEqualTo(compObj->ice_timeout(20), compObj->ice_timeout(20)));
778     test(Ice::targetNotEqualTo(compObj->ice_timeout(10), compObj->ice_timeout(20)));
779     test(Ice::targetLess(compObj->ice_timeout(10), compObj->ice_timeout(20)));
780     test(Ice::targetGreaterEqual(compObj->ice_timeout(20), compObj->ice_timeout(10)));
781 
782     test(compObj->ice_getTimeout() == Ice::nullopt);
783     test(compObj->ice_timeout(10)->ice_getTimeout() == Ice::optional<int>(10));
784     test(compObj->ice_timeout(20)->ice_getTimeout() == Ice::optional<int>(20));
785 
786     auto loc1 = Ice::uncheckedCast<Ice::LocatorPrx>(communicator->stringToProxy("loc1:default -p 10000"));
787     auto loc2 = Ice::uncheckedCast<Ice::LocatorPrx>(communicator->stringToProxy("loc2:default -p 10000"));
788 
789     test(Ice::targetEqualTo(compObj->ice_locator(0), compObj->ice_locator(0)));
790     test(Ice::targetEqualTo(compObj->ice_locator(loc1), compObj->ice_locator(loc1)));
791     test(Ice::targetNotEqualTo(compObj->ice_locator(loc1), compObj->ice_locator(0)));
792     test(Ice::targetNotEqualTo(compObj->ice_locator(0), compObj->ice_locator(loc2)));
793     test(Ice::targetNotEqualTo(compObj->ice_locator(loc1), compObj->ice_locator(loc2)));
794     test(Ice::targetLess(compObj->ice_locator(0), compObj->ice_locator(loc1)));
795     test(Ice::targetGreaterEqual(compObj->ice_locator(loc1), compObj->ice_locator(0)));
796     test(Ice::targetLess(compObj->ice_locator(loc1), compObj->ice_locator(loc2)));
797     test(Ice::targetGreaterEqual(compObj->ice_locator(loc2), compObj->ice_locator(loc1)));
798 
799     auto rtr1 = Ice::uncheckedCast<Ice::RouterPrx>(communicator->stringToProxy("rtr1:default -p 10000"));
800     auto rtr2 = Ice::uncheckedCast<Ice::RouterPrx>(communicator->stringToProxy("rtr2:default -p 10000"));
801 
802     test(Ice::targetEqualTo(compObj->ice_router(0), compObj->ice_router(0)));
803     test(Ice::targetEqualTo(compObj->ice_router(rtr1), compObj->ice_router(rtr1)));
804     test(Ice::targetNotEqualTo(compObj->ice_router(rtr1), compObj->ice_router(0)));
805     test(Ice::targetNotEqualTo(compObj->ice_router(0), compObj->ice_router(rtr2)));
806     test(Ice::targetNotEqualTo(compObj->ice_router(rtr1), compObj->ice_router(rtr2)));
807     test(Ice::targetLess(compObj->ice_router(0), compObj->ice_router(rtr1)));
808     test(Ice::targetGreaterEqual(compObj->ice_router(rtr1), compObj->ice_router(0)));
809     test(Ice::targetLess(compObj->ice_router(rtr1), compObj->ice_router(rtr2)));
810     test(Ice::targetGreaterEqual(compObj->ice_router(rtr2), compObj->ice_router(rtr1)));
811 
812     Ice::Context ctx1;
813     ctx1["ctx1"] = "v1";
814     Ice::Context ctx2;
815     ctx2["ctx2"] = "v2";
816     test(Ice::targetEqualTo(compObj->ice_context(Ice::Context()), compObj->ice_context(Ice::Context())));
817     test(Ice::targetEqualTo(compObj->ice_context(ctx1), compObj->ice_context(ctx1)));
818     test(Ice::targetNotEqualTo(compObj->ice_context(ctx1), compObj->ice_context(Ice::Context())));
819     test(Ice::targetNotEqualTo(compObj->ice_context(Ice::Context()), compObj->ice_context(ctx2)));
820     test(Ice::targetNotEqualTo(compObj->ice_context(ctx1), compObj->ice_context(ctx2)));
821     test(Ice::targetLess(compObj->ice_context(ctx1), compObj->ice_context(ctx2)));
822     test(Ice::targetGreaterEqual(compObj->ice_context(ctx2), compObj->ice_context(ctx1)));
823 
824     test(Ice::targetEqualTo(compObj->ice_preferSecure(true), compObj->ice_preferSecure(true)));
825     test(Ice::targetNotEqualTo(compObj->ice_preferSecure(true), compObj->ice_preferSecure(false)));
826     test(Ice::targetLess(compObj->ice_preferSecure(false), compObj->ice_preferSecure(true)));
827     test(Ice::targetGreaterEqual(compObj->ice_preferSecure(true), compObj->ice_preferSecure(false)));
828 
829     auto compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000");
830     auto compObj2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001");
831     test(Ice::targetNotEqualTo(compObj1, compObj2));
832     test(Ice::targetLess(compObj1, compObj2));
833     test(Ice::targetGreaterEqual(compObj2, compObj1));
834 
835     compObj1 = communicator->stringToProxy("foo@MyAdapter1");
836     compObj2 = communicator->stringToProxy("foo@MyAdapter2");
837     test(Ice::targetNotEqualTo(compObj1, compObj2));
838     test(Ice::targetLess(compObj1, compObj2));
839     test(Ice::targetGreaterEqual(compObj2, compObj1));
840 
841     test(Ice::targetEqualTo(compObj1->ice_locatorCacheTimeout(20), compObj1->ice_locatorCacheTimeout(20)));
842     test(Ice::targetNotEqualTo(compObj1->ice_locatorCacheTimeout(10), compObj1->ice_locatorCacheTimeout(20)));
843     test(Ice::targetLess(compObj1->ice_locatorCacheTimeout(10), compObj1->ice_locatorCacheTimeout(20)));
844     test(Ice::targetGreaterEqual(compObj1->ice_locatorCacheTimeout(20), compObj1->ice_locatorCacheTimeout(10)));
845 
846     test(Ice::targetEqualTo(compObj1->ice_invocationTimeout(20), compObj1->ice_invocationTimeout(20)));
847     test(Ice::targetNotEqualTo(compObj1->ice_invocationTimeout(10), compObj1->ice_invocationTimeout(20)));
848     test(Ice::targetLess(compObj1->ice_invocationTimeout(10), compObj1->ice_invocationTimeout(20)));
849     test(Ice::targetGreaterEqual(compObj1->ice_invocationTimeout(20), compObj1->ice_invocationTimeout(10)));
850 
851     compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 1000");
852     compObj2 = communicator->stringToProxy("foo@MyAdapter1");
853     test(Ice::targetNotEqualTo(compObj1, compObj2));
854     test(Ice::targetLess(compObj1, compObj2));
855     test(Ice::targetGreaterEqual(compObj2, compObj1));
856 
857     Ice::EndpointSeq endpts1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")->ice_getEndpoints();
858     Ice::EndpointSeq endpts2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001")->ice_getEndpoints();
859 
860     test(endpts1.size() != endpts2.size() || !equal(endpts1.begin(), endpts1.end(), endpts2.begin(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::equal_to>()));
861     test(lexicographical_compare(endpts1.begin(), endpts1.end(), endpts2.begin(), endpts2.end(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::less>()));
862     test(!lexicographical_compare(endpts2.begin(), endpts2.end(), endpts1.begin(), endpts1.end(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::less>()));
863 
864     Ice::EndpointSeq endpts3 =  communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")->ice_getEndpoints();
865     test(endpts1.size() == endpts3.size() && equal(endpts1.begin(), endpts1.end(), endpts3.begin(), Ice::TargetCompare<shared_ptr<Ice::Endpoint>, std::equal_to>()));
866 
867     test(Ice::targetEqualTo(compObj1->ice_encodingVersion(Ice::Encoding_1_0), compObj1->ice_encodingVersion(Ice::Encoding_1_0)));
868     test(Ice::targetNotEqualTo(compObj1->ice_encodingVersion(Ice::Encoding_1_0), compObj1->ice_encodingVersion(Ice::Encoding_1_1)));
869     test(Ice::targetLess(compObj->ice_encodingVersion(Ice::Encoding_1_0), compObj->ice_encodingVersion(Ice::Encoding_1_1)));
870     test(Ice::targetGreaterEqual(compObj->ice_encodingVersion(Ice::Encoding_1_1), compObj->ice_encodingVersion(Ice::Encoding_1_0)));
871 
872     Ice::ConnectionPtr baseConnection = base->ice_getConnection();
873     if(baseConnection && protocol != "bt")
874     {
875         Ice::ConnectionPtr baseConnection2 = base->ice_connectionId("base2")->ice_getConnection();
876         compObj1 = compObj1->ice_fixed(baseConnection);
877         compObj2 = compObj2->ice_fixed(baseConnection2);
878         test(Ice::targetNotEqualTo(compObj1, compObj2));
879         if(Ice::targetLess(compObj1, compObj2))
880         {
881             test(Ice::targetGreaterEqual(compObj2, compObj1));
882         }
883         else
884         {
885             test(Ice::targetGreaterEqual(compObj1, compObj2));
886         }
887     }
888 
889     cout << "ok" << endl;
890 
891     cout << "testing checked cast... " << flush;
892     auto cl = Ice::checkedCast<Test::MyClassPrx>(base);
893     test(cl);
894 
895     auto derived = Ice::checkedCast<Test::MyDerivedClassPrx>(cl);
896     test(derived);
897     test(Ice::targetEqualTo(cl, base));
898     test(Ice::targetEqualTo(derived, base));
899     test(Ice::targetEqualTo(cl, derived));
900 
901     auto loc = Ice::checkedCast<Ice::LocatorPrx>(base);
902     test(loc == nullptr);
903 
904     //
905     // Upcasting
906     //
907     auto cl2 = Ice::checkedCast<Test::MyClassPrx>(derived);
908     auto obj = Ice::checkedCast<Ice::ObjectPrx>(derived);
909     test(cl2);
910     test(obj);
911     test(Ice::targetEqualTo(cl2, obj));
912     test(Ice::targetEqualTo(cl2, derived));
913 #else
914     test(communicator->stringToProxy("foo") == communicator->stringToProxy("foo"));
915     test(communicator->stringToProxy("foo") != communicator->stringToProxy("foo2"));
916     test(communicator->stringToProxy("foo") < communicator->stringToProxy("foo2"));
917     test(!(communicator->stringToProxy("foo2") < communicator->stringToProxy("foo")));
918 
919     Ice::ObjectPrxPtr compObj = communicator->stringToProxy("foo");
920 
921     test(compObj->ice_facet("facet") == compObj->ice_facet("facet"));
922     test(compObj->ice_facet("facet") != compObj->ice_facet("facet1"));
923     test(compObj->ice_facet("facet") < compObj->ice_facet("facet1"));
924     test(!(compObj->ice_facet("facet") < compObj->ice_facet("facet")));
925 
926     test(compObj->ice_oneway() == compObj->ice_oneway());
927     test(compObj->ice_oneway() != compObj->ice_twoway());
928     test(compObj->ice_twoway() < compObj->ice_oneway());
929     test(!(compObj->ice_oneway() < compObj->ice_twoway()));
930 
931     test(compObj->ice_secure(true) == compObj->ice_secure(true));
932     test(compObj->ice_secure(false) != compObj->ice_secure(true));
933     test(compObj->ice_secure(false) < compObj->ice_secure(true));
934     test(!(compObj->ice_secure(true) < compObj->ice_secure(false)));
935 
936     test(compObj->ice_collocationOptimized(true) == compObj->ice_collocationOptimized(true));
937     test(compObj->ice_collocationOptimized(false) != compObj->ice_collocationOptimized(true));
938     test(compObj->ice_collocationOptimized(false) < compObj->ice_collocationOptimized(true));
939     test(!(compObj->ice_collocationOptimized(true) < compObj->ice_collocationOptimized(false)));
940 
941     test(compObj->ice_connectionCached(true) == compObj->ice_connectionCached(true));
942     test(compObj->ice_connectionCached(false) != compObj->ice_connectionCached(true));
943     test(compObj->ice_connectionCached(false) < compObj->ice_connectionCached(true));
944     test(!(compObj->ice_connectionCached(true) < compObj->ice_connectionCached(false)));
945 
946     test(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)) == compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)));
947     test(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)) != compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)));
948     test(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)) < compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)));
949     test(!(compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)) < compObj->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random))));
950 
951     test(compObj->ice_connectionId("id2") == compObj->ice_connectionId("id2"));
952     test(compObj->ice_connectionId("id1") != compObj->ice_connectionId("id2"));
953     test(compObj->ice_connectionId("id1") < compObj->ice_connectionId("id2"));
954     test(!(compObj->ice_connectionId("id2") < compObj->ice_connectionId("id1")));
955 
956     test(compObj->ice_connectionId("id1")->ice_getConnectionId() == "id1");
957     test(compObj->ice_connectionId("id2")->ice_getConnectionId() == "id2");
958 
959     test(compObj->ice_compress(true) == compObj->ice_compress(true));
960     test(compObj->ice_compress(false) != compObj->ice_compress(true));
961     test(compObj->ice_compress(false) < compObj->ice_compress(true));
962     test(!(compObj->ice_compress(true) < compObj->ice_compress(false)));
963 
964     test(!compObj->ice_getCompress());
965     test(compObj->ice_compress(true)->ice_getCompress() == IceUtil::Optional<bool>(true));
966     test(compObj->ice_compress(false)->ice_getCompress() == IceUtil::Optional<bool>(false));
967 
968     test(compObj->ice_timeout(20) == compObj->ice_timeout(20));
969     test(compObj->ice_timeout(10) != compObj->ice_timeout(20));
970     test(compObj->ice_timeout(10) < compObj->ice_timeout(20));
971     test(!(compObj->ice_timeout(20) < compObj->ice_timeout(10)));
972 
973     test(!compObj->ice_getTimeout());
974     test(compObj->ice_timeout(10)->ice_getTimeout() == IceUtil::Optional<int>(10));
975     test(compObj->ice_timeout(20)->ice_getTimeout() == IceUtil::Optional<int>(20));
976 
977     Ice::LocatorPrxPtr loc1 = ICE_UNCHECKED_CAST(Ice::LocatorPrx, communicator->stringToProxy("loc1:" + endp));
978     Ice::LocatorPrxPtr loc2 = ICE_UNCHECKED_CAST(Ice::LocatorPrx, communicator->stringToProxy("loc2:" + endp));
979     test(compObj->ice_locator(0) == compObj->ice_locator(0));
980     test(compObj->ice_locator(loc1) == compObj->ice_locator(loc1));
981     test(compObj->ice_locator(loc1) != compObj->ice_locator(0));
982     test(compObj->ice_locator(0) != compObj->ice_locator(loc2));
983     test(compObj->ice_locator(loc1) != compObj->ice_locator(loc2));
984     test(compObj->ice_locator(0) < compObj->ice_locator(loc1));
985     test(!(compObj->ice_locator(loc1) < compObj->ice_locator(0)));
986     test(compObj->ice_locator(loc1) < compObj->ice_locator(loc2));
987     test(!(compObj->ice_locator(loc2) < compObj->ice_locator(loc1)));
988 
989     Ice::RouterPrxPtr rtr1 = ICE_UNCHECKED_CAST(Ice::RouterPrx, communicator->stringToProxy("rtr1:" + endp));
990     Ice::RouterPrxPtr rtr2 = ICE_UNCHECKED_CAST(Ice::RouterPrx, communicator->stringToProxy("rtr2:" + endp));
991     test(compObj->ice_router(0) == compObj->ice_router(0));
992     test(compObj->ice_router(rtr1) == compObj->ice_router(rtr1));
993     test(compObj->ice_router(rtr1) != compObj->ice_router(0));
994     test(compObj->ice_router(0) != compObj->ice_router(rtr2));
995     test(compObj->ice_router(rtr1) != compObj->ice_router(rtr2));
996     test(compObj->ice_router(0) < compObj->ice_router(rtr1));
997     test(!(compObj->ice_router(rtr1) < compObj->ice_router(0)));
998     test(compObj->ice_router(rtr1) < compObj->ice_router(rtr2));
999     test(!(compObj->ice_router(rtr2) < compObj->ice_router(rtr1)));
1000 
1001     Ice::Context ctx1;
1002     ctx1["ctx1"] = "v1";
1003     Ice::Context ctx2;
1004     ctx2["ctx2"] = "v2";
1005     test(compObj->ice_context(Ice::Context()) == compObj->ice_context(Ice::Context()));
1006     test(compObj->ice_context(ctx1) == compObj->ice_context(ctx1));
1007     test(compObj->ice_context(ctx1) != compObj->ice_context(Ice::Context()));
1008     test(compObj->ice_context(Ice::Context()) != compObj->ice_context(ctx2));
1009     test(compObj->ice_context(ctx1) != compObj->ice_context(ctx2));
1010     test(compObj->ice_context(ctx1) < compObj->ice_context(ctx2));
1011     test(!(compObj->ice_context(ctx2) < compObj->ice_context(ctx1)));
1012 
1013     test(compObj->ice_preferSecure(true) == compObj->ice_preferSecure(true));
1014     test(compObj->ice_preferSecure(true) != compObj->ice_preferSecure(false));
1015     test(compObj->ice_preferSecure(false) < compObj->ice_preferSecure(true));
1016     test(!(compObj->ice_preferSecure(true) < compObj->ice_preferSecure(false)));
1017 
1018     Ice::ObjectPrxPtr compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000");
1019     Ice::ObjectPrxPtr compObj2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001");
1020     test(compObj1 != compObj2);
1021     test(compObj1 < compObj2);
1022     test(!(compObj2 < compObj1));
1023 
1024     compObj1 = communicator->stringToProxy("foo@MyAdapter1");
1025     compObj2 = communicator->stringToProxy("foo@MyAdapter2");
1026     test(compObj1 != compObj2);
1027     test(compObj1 < compObj2);
1028     test(!(compObj2 < compObj1));
1029 
1030     test(compObj1->ice_locatorCacheTimeout(20) == compObj1->ice_locatorCacheTimeout(20));
1031     test(compObj1->ice_locatorCacheTimeout(10) != compObj1->ice_locatorCacheTimeout(20));
1032     test(compObj1->ice_locatorCacheTimeout(10) < compObj1->ice_locatorCacheTimeout(20));
1033     test(!(compObj1->ice_locatorCacheTimeout(20) < compObj1->ice_locatorCacheTimeout(10)));
1034 
1035     test(compObj1->ice_invocationTimeout(20) == compObj1->ice_invocationTimeout(20));
1036     test(compObj1->ice_invocationTimeout(10) != compObj1->ice_invocationTimeout(20));
1037     test(compObj1->ice_invocationTimeout(10) < compObj1->ice_invocationTimeout(20));
1038     test(!(compObj1->ice_invocationTimeout(20) < compObj1->ice_invocationTimeout(10)));
1039 
1040     compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 1000");
1041     compObj2 = communicator->stringToProxy("foo@MyAdapter1");
1042     test(compObj1 != compObj2);
1043     test(compObj1 < compObj2);
1044     test(!(compObj2 < compObj1));
1045 
1046     Ice::EndpointSeq endpts1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")->ice_getEndpoints();
1047     Ice::EndpointSeq endpts2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001")->ice_getEndpoints();
1048     test(endpts1 != endpts2);
1049     test(endpts1 < endpts2);
1050     test(!(endpts2 < endpts1));
1051     test(endpts1 == communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")->ice_getEndpoints());
1052 
1053     test(compObj1->ice_encodingVersion(Ice::Encoding_1_0) == compObj1->ice_encodingVersion(Ice::Encoding_1_0));
1054     test(compObj1->ice_encodingVersion(Ice::Encoding_1_0) != compObj1->ice_encodingVersion(Ice::Encoding_1_1));
1055     test(compObj->ice_encodingVersion(Ice::Encoding_1_0) < compObj->ice_encodingVersion(Ice::Encoding_1_1));
1056     test(!(compObj->ice_encodingVersion(Ice::Encoding_1_1) < compObj->ice_encodingVersion(Ice::Encoding_1_0)));
1057 
1058     Ice::ConnectionPtr baseConnection = base->ice_getConnection();
1059     if(baseConnection && protocol != "bt")
1060     {
1061         Ice::ConnectionPtr baseConnection2 = base->ice_connectionId("base2")->ice_getConnection();
1062         compObj1 = compObj1->ice_fixed(baseConnection);
1063         compObj2 = compObj2->ice_fixed(baseConnection2);
1064         test(compObj1 != compObj2);
1065         if(compObj1 < compObj2)
1066         {
1067             test(compObj2 >= compObj1);
1068         }
1069         else
1070         {
1071             test(compObj1 >= compObj2);
1072         }
1073     }
1074 
1075     cout << "ok" << endl;
1076 
1077     cout << "testing checked cast... " << flush;
1078     Test::MyClassPrxPtr cl = ICE_CHECKED_CAST(Test::MyClassPrx, base);
1079     test(cl);
1080 
1081     Test::MyDerivedClassPrxPtr derived = ICE_CHECKED_CAST(Test::MyDerivedClassPrx, cl);
1082     test(derived);
1083     test(cl == base);
1084     test(derived == base);
1085     test(cl == derived);
1086 
1087     Ice::LocatorPrxPtr loc = ICE_CHECKED_CAST(Ice::LocatorPrx, base);
1088     test(loc == 0);
1089 
1090     //
1091     // Upcasting
1092     //
1093     Test::MyClassPrxPtr cl2 = ICE_CHECKED_CAST(Test::MyClassPrx, derived);
1094     Ice::ObjectPrxPtr obj = ICE_CHECKED_CAST(Ice::ObjectPrx, derived);
1095     test(cl2);
1096     test(obj);
1097     test(cl2 == obj);
1098     test(cl2 == derived);
1099 
1100     //
1101     // Now with alternate API
1102     //
1103     cl = Ice::checkedCast<Test::MyClassPrx>(base);
1104     test(cl);
1105     derived = Ice::checkedCast<Test::MyDerivedClassPrx>(cl);
1106     test(derived);
1107     test(cl == base);
1108     test(derived == base);
1109     test(cl == derived);
1110 
1111     loc = Ice::checkedCast<Ice::LocatorPrx>(base);
1112     test(loc == 0);
1113 
1114     cl2 = Ice::checkedCast<Test::MyClassPrx>(derived);
1115     obj = Ice::checkedCast<Ice::ObjectPrx>(derived);
1116     test(cl2);
1117     test(obj);
1118     test(cl2 == obj);
1119     test(cl2 == derived);
1120 #endif
1121     cout << "ok" << endl;
1122 
1123     cout << "testing checked cast with context... " << flush;
1124     Ice::Context ctx = cl->getContext();
1125     test(ctx.size() == 0);
1126 
1127     ctx["one"] = "hello";
1128     ctx["two"] = "world";
1129 #ifdef ICE_CPP11_MAPPING
1130     cl = Ice::checkedCast<Test::MyClassPrx>(base, ctx);
1131 #else
1132     cl = Test::MyClassPrx::checkedCast(base, ctx);
1133 #endif
1134     Ice::Context c2 = cl->getContext();
1135     test(ctx == c2);
1136 
1137     //
1138     // Now with alternate API
1139     //
1140 #ifndef ICE_CPP11_MAPPING
1141     cl = Ice::checkedCast<Test::MyClassPrx>(base);
1142     ctx = cl->getContext();
1143     test(ctx.size() == 0);
1144 
1145     cl = Ice::checkedCast<Test::MyClassPrx>(base, ctx);
1146     c2 = cl->getContext();
1147     test(ctx == c2);
1148 #endif
1149     cout << "ok" << endl;
1150 
1151     if(protocol != "bt")
1152     {
1153         cout << "testing ice_fixed... " << flush;
1154         {
1155             Ice::ConnectionPtr connection = cl->ice_getConnection();
1156             if(connection)
1157             {
1158                 Test::MyClassPrxPtr prx = cl->ice_fixed(connection); // Test factory method return type
1159                 prx->ice_ping();
1160                 test(cl->ice_secure(true)->ice_fixed(connection)->ice_isSecure());
1161                 test(cl->ice_facet("facet")->ice_fixed(connection)->ice_getFacet() == "facet");
1162                 test(cl->ice_oneway()->ice_fixed(connection)->ice_isOneway());
1163                 ctx.clear();
1164                 ctx["one"] = "hello";
1165                 ctx["two"] = "world";
1166                 test(cl->ice_fixed(connection)->ice_getContext().empty());
1167                 test(cl->ice_context(ctx)->ice_fixed(connection)->ice_getContext().size() == 2);
1168                 test(cl->ice_fixed(connection)->ice_getInvocationTimeout() == -1);
1169                 test(cl->ice_invocationTimeout(10)->ice_fixed(connection)->ice_getInvocationTimeout() == 10);
1170                 test(cl->ice_fixed(connection)->ice_getConnection() == connection);
1171                 test(cl->ice_fixed(connection)->ice_fixed(connection)->ice_getConnection() == connection);
1172                 test(*cl->ice_compress(true)->ice_fixed(connection)->ice_getCompress());
1173                 test(!cl->ice_fixed(connection)->ice_getTimeout());
1174                 Ice::ConnectionPtr fixedConnection = cl->ice_connectionId("ice_fixed")->ice_getConnection();
1175                 test(cl->ice_fixed(connection)->ice_fixed(fixedConnection)->ice_getConnection() == fixedConnection);
1176                 try
1177                 {
1178                     cl->ice_secure(!connection->getEndpoint()->getInfo()->secure())->ice_fixed(connection)->ice_ping();
1179                 }
1180                 catch(const Ice::NoEndpointException&)
1181                 {
1182                 }
1183                 try
1184                 {
1185                     cl->ice_datagram()->ice_fixed(connection)->ice_ping();
1186                 }
1187                 catch(const Ice::NoEndpointException&)
1188                 {
1189                 }
1190             }
1191             else
1192             {
1193                 try
1194                 {
1195                     cl->ice_fixed(connection);
1196                     test(false);
1197                 }
1198 #ifdef ICE_CPP11_MAPPING
1199                 catch(const invalid_argument&)
1200 #else
1201                 catch(const IceUtil::IllegalArgumentException&)
1202 #endif
1203                 {
1204                     // Expected with null connection.
1205                 }
1206 
1207             }
1208         }
1209         cout << "ok" << endl;
1210     }
1211 
1212     cout << "testing encoding versioning... " << flush;
1213     string ref20 = "test -e 2.0:" + endp;
1214     Test::MyClassPrxPtr cl20 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref20));
1215     try
1216     {
1217         cl20->ice_ping();
1218         test(false);
1219     }
1220     catch(const Ice::UnsupportedEncodingException&)
1221     {
1222         // Server 2.0 endpoint doesn't support 1.1 version.
1223     }
1224 
1225     string ref10 = "test -e 1.0:" + endp;
1226     Test::MyClassPrxPtr cl10 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref10));
1227     cl10->ice_ping();
1228     cl10->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping();
1229     cl->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping();
1230 
1231     // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
1232     // call will use the 1.1 encoding
1233     string ref13 = "test -e 1.3:" + endp;
1234     Test::MyClassPrxPtr cl13 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref13));
1235     cl13->ice_ping();
1236 #ifdef ICE_CPP11_MAPPING
1237     cl13->ice_pingAsync().get();
1238 #else
1239     cl13->end_ice_ping(cl13->begin_ice_ping());
1240 #endif
1241 
1242     try
1243     {
1244         // Send request with bogus 1.2 encoding.
1245         Ice::EncodingVersion version = { 1, 2 };
1246         Ice::OutputStream out(communicator);
1247         out.startEncapsulation();
1248         out.endEncapsulation();
1249         vector<Ice::Byte> inEncaps;
1250         out.finished(inEncaps);
1251         inEncaps[4] = version.major;
1252         inEncaps[5] = version.minor;
1253         vector<Ice::Byte> outEncaps;
1254         cl->ice_invoke("ice_ping", Ice::ICE_ENUM(OperationMode, Normal), inEncaps, outEncaps);
1255         test(false);
1256     }
1257     catch(const Ice::UnknownLocalException& ex)
1258     {
1259         // The server thrown an UnsupportedEncodingException
1260         test(ex.unknown.find("UnsupportedEncodingException") != string::npos);
1261     }
1262 
1263     try
1264     {
1265         // Send request with bogus 2.0 encoding.
1266         Ice::EncodingVersion version = { 2, 0 };
1267         Ice::OutputStream out(communicator);
1268         out.startEncapsulation();
1269         out.endEncapsulation();
1270         vector<Ice::Byte> inEncaps;
1271         out.finished(inEncaps);
1272         inEncaps[4] = version.major;
1273         inEncaps[5] = version.minor;
1274         vector<Ice::Byte> outEncaps;
1275         cl->ice_invoke("ice_ping", Ice::ICE_ENUM(OperationMode, Normal), inEncaps, outEncaps);
1276         test(false);
1277     }
1278     catch(const Ice::UnknownLocalException& ex)
1279     {
1280         // The server thrown an UnsupportedEncodingException
1281         test(ex.unknown.find("UnsupportedEncodingException") != string::npos);
1282     }
1283 
1284     cout << "ok" << endl;
1285 
1286     cout << "testing protocol versioning... " << flush;
1287 
1288     ref20 = "test -p 2.0:" + endp;
1289     cl20 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref20));
1290     try
1291     {
1292         cl20->ice_ping();
1293         test(false);
1294     }
1295     catch(const Ice::UnsupportedProtocolException&)
1296     {
1297         // Server 2.0 proxy doesn't support 1.0 version.
1298     }
1299 
1300     ref10 = "test -p 1.0:" + endp;
1301     cl10 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref10));
1302     cl10->ice_ping();
1303 
1304     // 1.3 isn't supported but since a 1.3 proxy supports 1.0, the
1305     // call will use the 1.0 encoding
1306     ref13 = "test -p 1.3:" + endp;
1307     cl13 = ICE_UNCHECKED_CAST(Test::MyClassPrx, communicator->stringToProxy(ref13));
1308     cl13->ice_ping();
1309 #ifdef ICE_CPP11_MAPPING
1310     cl13->ice_pingAsync().get();
1311 #else
1312     cl13->end_ice_ping(cl13->begin_ice_ping());
1313 #endif
1314     cout << "ok" <<endl;
1315 
1316     cout << "testing opaque endpoints... " << flush;
1317 
1318     try
1319     {
1320         // Invalid -x option
1321         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 99 -v abc -x abc");
1322         test(false);
1323     }
1324     catch(const Ice::EndpointParseException&)
1325     {
1326     }
1327 
1328     try
1329     {
1330         // Missing -t and -v
1331         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque");
1332         test(false);
1333     }
1334     catch(const Ice::EndpointParseException&)
1335     {
1336     }
1337 
1338     try
1339     {
1340         // Repeated -t
1341         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 1 -t 1 -v abc");
1342         test(false);
1343     }
1344     catch(const Ice::EndpointParseException&)
1345     {
1346     }
1347 
1348     try
1349     {
1350         // Repeated -v
1351         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 1 -v abc -v abc");
1352         test(false);
1353     }
1354     catch(const Ice::EndpointParseException&)
1355     {
1356     }
1357 
1358     try
1359     {
1360         // Missing -t
1361         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -v abc");
1362         test(false);
1363     }
1364     catch(const Ice::EndpointParseException&)
1365     {
1366     }
1367 
1368     try
1369     {
1370         // Missing -v
1371         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 1");
1372         test(false);
1373     }
1374     catch(const Ice::EndpointParseException&)
1375     {
1376     }
1377 
1378     try
1379     {
1380         // Missing arg for -t
1381         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t -v abc");
1382         test(false);
1383     }
1384     catch(const Ice::EndpointParseException&)
1385     {
1386     }
1387 
1388     try
1389     {
1390         // Missing arg for -v
1391         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 1 -v");
1392         test(false);
1393     }
1394     catch(const Ice::EndpointParseException&)
1395     {
1396     }
1397 
1398     try
1399     {
1400         // Not a number for -t
1401         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t x -v abc");
1402         test(false);
1403     }
1404     catch(const Ice::EndpointParseException&)
1405     {
1406     }
1407 
1408     try
1409     {
1410         // < 0 for -t
1411         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t -1 -v abc");
1412         test(false);
1413     }
1414     catch(const Ice::EndpointParseException&)
1415     {
1416     }
1417 
1418     try
1419     {
1420         // Invalid char for -v
1421         Ice::ObjectPrxPtr p = communicator->stringToProxy("id:opaque -t 99 -v x?c");
1422         test(false);
1423     }
1424     catch(const Ice::EndpointParseException&)
1425     {
1426     }
1427 
1428     // Legal TCP endpoint expressed as opaque endpoint
1429     Ice::ObjectPrxPtr p1 = communicator->stringToProxy("test -e 1.1:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==");
1430     string pstr = communicator->proxyToString(p1);
1431     test(pstr == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000");
1432 
1433     // Opaque endpoint encoded with 1.1 encoding.
1434     {
1435         Ice::ObjectPrxPtr p2 = communicator->stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==");
1436         test(communicator->proxyToString(p2) == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000");
1437     }
1438 
1439     if(communicator->getProperties()->getPropertyAsInt("Ice.IPv6") == 0 &&
1440        communicator->getProperties()->getProperty("Ice.Default.Host") == "127.0.0.1")
1441     {
1442         // SSL enabled?
1443         bool ssl;
1444         try
1445         {
1446             communicator->stringToProxy("dummy:ssl");
1447             ssl = true;
1448         }
1449         catch(const Ice::EndpointParseException&)
1450         {
1451             ssl = false;
1452         }
1453 
1454         const bool tcp = communicator->getProperties()->getProperty("Ice.Default.Protocol") == "tcp";
1455 
1456         // Two legal TCP endpoints expressed as opaque endpoints
1457         p1 = communicator->stringToProxy("test -e 1.0:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA==");
1458         pstr = communicator->proxyToString(p1);
1459         test(pstr == "test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000");
1460 
1461         //
1462         // Test that an SSL endpoint and a nonsense endpoint get written
1463         // back out as an opaque endpoint.
1464         //
1465         p1 = communicator->stringToProxy(
1466                 "test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch");
1467         pstr = communicator->proxyToString(p1);
1468         if(ssl)
1469         {
1470             test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch");
1471         }
1472         else if(tcp)
1473         {
1474             test(pstr ==
1475                  "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch");
1476         }
1477 
1478         //
1479         // Test that the proxy with an SSL endpoint and a nonsense
1480         // endpoint (which the server doesn't understand either) can be
1481         // sent over the wire and returned by the server without losing
1482         // the opaque endpoints.
1483         //
1484         Ice::ObjectPrxPtr p2 = derived->echo(p1);
1485         pstr = communicator->proxyToString(p2);
1486         if(ssl)
1487         {
1488             test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch");
1489         }
1490         else if(tcp)
1491         {
1492             if(pstr != "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")
1493             {
1494                 cerr << pstr << endl;
1495             }
1496             test(pstr ==
1497                  "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch");
1498         }
1499     }
1500 
1501     cout << "ok" << endl;
1502 
1503     cout << "testing communicator shutdown/destroy... " << flush;
1504     {
1505         Ice::CommunicatorPtr c = Ice::initialize();
1506         c->shutdown();
1507         test(c->isShutdown());
1508         c->waitForShutdown();
1509         c->destroy();
1510         c->shutdown();
1511         test(c->isShutdown());
1512         c->waitForShutdown();
1513         c->destroy();
1514     }
1515     cout << "ok" << endl;
1516 
1517     return cl;
1518 }
1519