diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-10-20 21:03:44 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-10-20 21:03:44 -0400 |
commit | 3cb9c15995b828c52dba34d0a222f572d5bbc41b (patch) | |
tree | 87bad249c2ee04972be5f3c7635880cb0c556128 /cpp/test | |
parent | updating IceBT to BlueZ 5 (diff) | |
download | ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.tar.bz2 ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.tar.xz ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.zip |
Added support for non-ASCII characters and universal character names
to stringified identities and proxies.
This includes a new Ice.ToStringMode property.
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/Ice/interceptor/AMDInterceptorI.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/location/AllTests.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestI.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/proxy/AllTests.cpp | 94 | ||||
-rwxr-xr-x | cpp/test/Ice/proxy/run.py | 2 | ||||
-rw-r--r-- | cpp/test/Ice/stringConverter/Client.cpp | 17 | ||||
-rw-r--r-- | cpp/test/IceGrid/deployer/AllTests.cpp | 14 | ||||
-rw-r--r-- | cpp/test/IceGrid/session/AllTests.cpp | 2 |
8 files changed, 113 insertions, 22 deletions
diff --git a/cpp/test/Ice/interceptor/AMDInterceptorI.cpp b/cpp/test/Ice/interceptor/AMDInterceptorI.cpp index f790db8c6a0..7e546344602 100644 --- a/cpp/test/Ice/interceptor/AMDInterceptorI.cpp +++ b/cpp/test/Ice/interceptor/AMDInterceptorI.cpp @@ -172,4 +172,4 @@ DispatchInterceptorAsyncCallbackI::exception() test(false); return true; } -#endif
\ No newline at end of file +#endif diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 80e10c780db..39ea56f9462 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -716,7 +716,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) registry->addObject(adapter->add(ICE_MAKE_SHARED(HelloI), id)); adapter->activate(); - HelloPrxPtr helloPrx = ICE_CHECKED_CAST(HelloPrx, communicator->stringToProxy(identityToString(id))); + HelloPrxPtr helloPrx = ICE_CHECKED_CAST(HelloPrx, communicator->stringToProxy(communicator->identityToString(id))); test(!helloPrx->ice_getConnection()); adapter->deactivate(); diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index 91154cf5769..2adfceda6db 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -926,4 +926,4 @@ MyDerivedClassI::opMDict2(ICE_IN(Test::StringStringD) p1, Test::StringStringD& p return p1; } -#endif
\ No newline at end of file +#endif diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 4fe2207c759..791c6c620a7 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -20,6 +20,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { const string endp = getTestEndpoint(communicator, 0); cout << "testing stringToProxy... " << flush; + string ref = "test:" + endp; Ice::ObjectPrxPtr base = communicator->stringToProxy(ref); test(base); @@ -64,6 +65,7 @@ allTests(const Ice::CommunicatorPtr& communicator) catch(const Ice::ProxyParseException&) { } + b1 = communicator->stringToProxy("test\\040test"); test(b1->ice_getIdentity().name == "test test" && b1->ice_getIdentity().category.empty()); try @@ -74,10 +76,11 @@ allTests(const Ice::CommunicatorPtr& communicator) catch(const Ice::IdentityParseException&) { } + b1 = communicator->stringToProxy("test\\40test"); test(b1->ice_getIdentity().name == "test test"); - // Test some octal and hex corner cases. + // Test some octal corner cases. b1 = communicator->stringToProxy("test\\4test"); test(b1->ice_getIdentity().name == "test\4test"); b1 = communicator->stringToProxy("test\\04test"); @@ -98,6 +101,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(!b1); b1 = communicator->stringToProxy("\"\""); test(!b1); + try { b1 = communicator->stringToProxy("\"\" test"); // Invalid trailing characters. @@ -106,6 +110,7 @@ allTests(const Ice::CommunicatorPtr& communicator) catch(const Ice::ProxyParseException&) { } + try { b1 = communicator->stringToProxy("test:"); // Missing endpoint. @@ -142,8 +147,10 @@ allTests(const Ice::CommunicatorPtr& communicator) test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" && b1->ice_getAdapterId() == "adapter 1"); b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@adapter"); - test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" && - b1->ice_getAdapterId() == "adapter"); + + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" + && b1->ice_getAdapterId() == "adapter"); + b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" && b1->ice_getAdapterId() == "adapter:tcp"); @@ -258,14 +265,85 @@ allTests(const Ice::CommunicatorPtr& communicator) // Test for bug ICE-5543: escaped escapes in stringToIdentity // Ice::Identity id = { "test", ",X2QNUAzSBcJ_e$AV;E\\" }; - Ice::Identity id2 = Ice::stringToIdentity(Ice::identityToString(id)); + Ice::Identity id2 = Ice::stringToIdentity(communicator->identityToString(id)); test(id == id2); id.name = "test"; id.category = ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"; - id2 = Ice::stringToIdentity(Ice::identityToString(id)); + id2 = Ice::stringToIdentity(communicator->identityToString(id)); + test(id == id2); + + id.name = "/test"; + id.category = "cat/"; + string idStr = communicator->identityToString(id); + test(idStr == "cat\\//\\/test"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); + + try + { + // Illegal character < 32 + id = Ice::stringToIdentity("xx\01FooBar"); + test(false); + } + catch(const Ice::IdentityParseException&) + { + } + + try + { + // Illegal surrogate + id = Ice::stringToIdentity("xx\\ud911"); + test(false); + } + catch(const Ice::IdentityParseException&) + { + } + + // Testing bytes 127 (\x7F) and € + id.name = "test"; + id.category = "\x7F\xE2\x82\xAC"; + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Unicode)); + test(idStr == "\\u007f\xE2\x82\xAC/test"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); + test(Ice::identityToString(id) == idStr); + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, ASCII)); + test(idStr == "\\u007f\\u20ac/test"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Compat)); + test(idStr == "\\177\\342\\202\\254/test"); + id2 = Ice::stringToIdentity(idStr); test(id == id2); + id2 = Ice::stringToIdentity(communicator->identityToString(id)); + test(id == id2); + + // More unicode characters +#ifdef ICE_CPP11_MAPPING + id.name = u8"banana \016-\U0001F34C\U000020AC\u00a2\u0024"; + id.category = u8"greek \U0001016A"; + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Unicode)); + test(idStr == u8"greek \U0001016A/banana \\u000e-\U0001F34C\U000020AC\u00a2$"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, ASCII)); + test(idStr == "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); + + idStr = identityToString(id, Ice::ICE_ENUM(ToStringMode, Compat)); + test(idStr == "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$"); + id2 = Ice::stringToIdentity(idStr); + test(id == id2); +#endif + cout << "ok" << endl; cout << "testing propertyToProxy... " << flush; @@ -445,10 +523,8 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing proxy methods... " << flush; -// Deprecated -// test(communicator->identityToString(base->ice_identity(communicator->stringToIdentity("other"))->ice_getIdentity()) -// == "other"); - test(Ice::identityToString(base->ice_identity(Ice::stringToIdentity("other"))->ice_getIdentity()) == "other"); + test(communicator->identityToString(base->ice_identity(Ice::stringToIdentity("other"))->ice_getIdentity()) + == "other"); test(base->ice_facet("facet")->ice_getFacet() == "facet"); test(base->ice_adapterId("id")->ice_getAdapterId() == "id"); test(base->ice_twoway()->ice_isTwoway()); diff --git a/cpp/test/Ice/proxy/run.py b/cpp/test/Ice/proxy/run.py index 7921ce9e9ff..38e60970744 100755 --- a/cpp/test/Ice/proxy/run.py +++ b/cpp/test/Ice/proxy/run.py @@ -23,5 +23,5 @@ import TestUtil TestUtil.queueClientServerTest() TestUtil.queueClientServerTest(configName = "amd", localOnly = True, message = "Running test with AMD server.", server = TestUtil.getTestExecutable("serveramd")) -TestUtil.queueCollocatedTest() +TestUtil.queueCollocatedTest(additionalOptions = "--Ice.ToStringMode=Compat") TestUtil.runQueuedTests() diff --git a/cpp/test/Ice/stringConverter/Client.cpp b/cpp/test/Ice/stringConverter/Client.cpp index 4a8e7027aea..f0d7f4df1cd 100644 --- a/cpp/test/Ice/stringConverter/Client.cpp +++ b/cpp/test/Ice/stringConverter/Client.cpp @@ -127,6 +127,22 @@ main(int argc, char* argv[]) wstring wmsg = proxy->widen(msg); test(proxy->narrow(wmsg) == msg); test(wmsg.size() == msg.size()); + + // Test stringToIdentity and identityToString + + string identStr = "cat/" + msg; + Ice::Identity ident = Ice::stringToIdentity(identStr); + test(ident.name == msg); + test(ident.category == "cat"); + test(identityToString(ident, Ice::ICE_ENUM(ToStringMode, Unicode)) == identStr); + + identStr = identityToString(ident, Ice::ICE_ENUM(ToStringMode, ASCII)); + test(identStr == "cat/tu me fends le c\\u0153ur!"); + test(Ice::stringToIdentity(identStr) == ident); + identStr = identityToString(ident, Ice::ICE_ENUM(ToStringMode, Compat)); + test(identStr == "cat/tu me fends le c\\305\\223ur!"); + test(Ice::stringToIdentity(identStr) == ident); + communicator->destroy(); cout << "ok" << endl; } @@ -134,7 +150,6 @@ main(int argc, char* argv[]) Ice::setProcessStringConverter(ICE_NULLPTR); Ice::setProcessWstringConverter(Ice::createUnicodeWstringConverter()); - string propValue = "Ice:createStringConverter"; if(useIconv && !useLocale) { diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index 222a243ba6c..d4cfa91c6bd 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -430,16 +430,16 @@ allTests(const Ice::CommunicatorPtr& comm) test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"ReplicatedObject")) != objs.end()); { - test(identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); - test(identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); - test(identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); - test(identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); - test(identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); + test(comm->identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); + test(comm->identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); + test(comm->identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); } { Ice::ObjectPrx obj = query->findObjectByType("::Test"); - string id = identityToString(obj->ice_getIdentity()); + string id = comm->identityToString(obj->ice_getIdentity()); test(id == "Server1" || id == "Server2" || id == "SimpleServer" || id == "IceBox1-Service1" || id == "IceBox1-Service2" || id == "IceBox2-Service1" || id == "IceBox2-Service2" || @@ -448,7 +448,7 @@ allTests(const Ice::CommunicatorPtr& comm) { Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); - string id = identityToString(obj->ice_getIdentity()); + string id = comm->identityToString(obj->ice_getIdentity()); test(id == "Server1" || id == "Server2" || id == "SimpleServer" || id == "IceBox1-Service1" || id == "IceBox1-Service2" || id == "IceBox2-Service1" || id == "IceBox2-Service2" || diff --git a/cpp/test/IceGrid/session/AllTests.cpp b/cpp/test/IceGrid/session/AllTests.cpp index e7f18c31519..dcf1d8414b8 100644 --- a/cpp/test/IceGrid/session/AllTests.cpp +++ b/cpp/test/IceGrid/session/AllTests.cpp @@ -269,7 +269,7 @@ public: Lock sync(*this); this->objects.erase(id); updated(updateSerial(0, "object removed `" + - identityToString(id) + "'")); + current.adapter->getCommunicator()->identityToString(id) + "'")); } int serial; |