本文整理汇总了C++中ice::CommunicatorPtr::getDefaultLocator方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorPtr::getDefaultLocator方法的具体用法?C++ CommunicatorPtr::getDefaultLocator怎么用?C++ CommunicatorPtr::getDefaultLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorPtr
的用法示例。
在下文中一共展示了CommunicatorPtr::getDefaultLocator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void
allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
{
ServerManagerPrx manager = ServerManagerPrx::checkedCast(communicator->stringToProxy(ref));
TestLocatorPrx locator = TestLocatorPrx::uncheckedCast(communicator->getDefaultLocator());
test(manager);
TestLocatorRegistryPrx registry = TestLocatorRegistryPrx::checkedCast(locator->getRegistry());
test(registry);
cout << "testing stringToProxy... " << flush;
Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrx base2 = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrx base3 = communicator->stringToProxy("test");
Ice::ObjectPrx base4 = communicator->stringToProxy("ServerManager");
Ice::ObjectPrx base5 = communicator->stringToProxy("test2");
Ice::ObjectPrx base6 = communicator->stringToProxy("test @ ReplicatedAdapter");
cout << "ok" << endl;
cout << "testing ice_locator and ice_getLocator... " << flush;
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
Ice::LocatorPrx anotherLocator = Ice::LocatorPrx::uncheckedCast(communicator->stringToProxy("anotherLocator"));
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(0);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getLocator());
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(locator);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
//
// We also test ice_router/ice_getRouter (perhaps we should add a
// test/Ice/router test?)
//
test(!base->ice_getRouter());
Ice::RouterPrx anotherRouter = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("anotherRouter"));
base = base->ice_router(anotherRouter);
test(Ice::proxyIdentityEqual(base->ice_getRouter(), anotherRouter));
Ice::RouterPrx router = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("dummyrouter"));
communicator->setDefaultRouter(router);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getRouter(), communicator->getDefaultRouter()));
communicator->setDefaultRouter(0);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getRouter());
cout << "ok" << endl;
cout << "starting server... " << flush;
manager->startServer();
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
TestIntfPrx obj = TestIntfPrx::checkedCast(base);
test(obj);
TestIntfPrx obj2 = TestIntfPrx::checkedCast(base2);
test(obj2);
TestIntfPrx obj3 = TestIntfPrx::checkedCast(base3);
test(obj3);
ServerManagerPrx obj4 = ServerManagerPrx::checkedCast(base4);
test(obj4);
TestIntfPrx obj5 = TestIntfPrx::checkedCast(base5);
test(obj5);
TestIntfPrx obj6 = TestIntfPrx::checkedCast(base6);
test(obj6);
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj6->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing identity indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
//.........这里部分代码省略.........
示例2: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
Ice::PropertiesPtr properties = communicator->getProperties();
{
ApplicationDescriptor testApp;
testApp.name = "TestApp";
admin->addApplication(testApp);
ApplicationUpdateDescriptor empty;
empty.name = "TestApp";
NodeUpdateDescriptor node;
node.name = "localnode";
empty.nodes.push_back(node);
ApplicationUpdateDescriptor update = empty;
cout << "testing server add... " << flush;
ServerDescriptorPtr server = new ServerDescriptor();
server->id = "Server";
server->exe = properties->getProperty("TestDir") + "/server";
server->pwd = ".";
server->applicationDistrib = false;
server->allocatable = false;
addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
AdapterDescriptor adapter;
adapter.name = "Server";
adapter.id = "ServerAdapter";
adapter.registerProcess = false;
adapter.serverLifetime = false;
addProperty(server, "Server.Endpoints", "default");
ObjectDescriptor object;
object.id = communicator->stringToIdentity("test");
object.type = "::Test::TestIntf";
adapter.objects.push_back(object);
server->adapters.push_back(adapter);
update.nodes[0].servers.push_back(server);
admin->updateApplication(update);
update.nodes[0].servers[0]->id = "Server2";
try
{
admin->updateApplication(update);
test(false);
}
catch(const DeploymentException&)
{
// Adapter already exists
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
test(false);
}
update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2";
try
{
admin->updateApplication(update);
test(false);
}
catch(const DeploymentException&)
{
// Object already exists
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
test(false);
}
update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2");
try
{
admin->updateApplication(update);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
test(false);
}
TemplateDescriptor templ;
templ.parameters.push_back("name");
templ.descriptor = new ServerDescriptor();
server = ServerDescriptorPtr::dynamicCast(templ.descriptor);
server->id = "${name}";
server->exe = "${test.dir}/server";
//.........这里部分代码省略.........
示例3: test
void
allTests(const Ice::CommunicatorPtr& comm)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
map<string, string> params;
params.clear();
params["id"] = "Master";
params["replicaName"] = "";
params["port"] = "12050";
instantiateServer(admin, "IceGridRegistry", params);
params.clear();
params["id"] = "Slave1";
params["replicaName"] = "Slave1";
params["port"] = "12051";
instantiateServer(admin, "IceGridRegistry", params);
params.clear();
params["id"] = "Slave2";
params["replicaName"] = "Slave2";
params["port"] = "12052";
instantiateServer(admin, "IceGridRegistry", params);
Ice::LocatorPrx masterLocator =
Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Master:default -p 12050"));
Ice::LocatorPrx slave1Locator =
Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Slave1:default -p 12051"));
Ice::LocatorPrx slave2Locator =
Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Slave2:default -p 12052"));
Ice::LocatorPrx replicatedLocator =
Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator:default -p 12050:default -p 12051"));
AdminPrx masterAdmin, slave1Admin, slave2Admin;
admin->startServer("Master");
masterAdmin = createAdminSession(masterLocator, "");
admin->startServer("Slave1");
slave1Admin = createAdminSession(slave1Locator, "Slave1");
//
// Test replication and well-known objects:
//
// - Locator interface
// - Query interface
//
// - Registry object
// - RegistryUserAccountMapper
// - SessionManager/SSLSessionManager
// - AdminSessionManager/AdminSSLSessionManager
//
cout << "testing replicated locator and query interface... " << flush;
{
Ice::EndpointSeq endpoints;
ObjectInfo info;
info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator"));
ObjectInfo info1 = slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator"));
test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info);
test(info.type == Ice::Locator::ice_staticId());
endpoints = info.proxy->ice_getEndpoints();
test(endpoints.size() == 2);
test(endpoints[0]->toString().find("-p 12050") != string::npos);
test(endpoints[1]->toString().find("-p 12051") != string::npos);
info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query"));
test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) == info);
test(info.type == IceGrid::Query::ice_staticId());
endpoints = info.proxy->ice_getEndpoints();
test(endpoints.size() == 2);
test(endpoints[0]->toString().find("-p 12050") != string::npos);
test(endpoints[1]->toString().find("-p 12051") != string::npos);
admin->startServer("Slave2");
slave2Admin = createAdminSession(slave2Locator, "Slave2");
info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator"));
// We eventually need to wait here for the update of the replicated objects to propagate to the replica.
int nRetry = 0;
while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) != info && nRetry < maxRetry)
{
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime));
++nRetry;
}
test(slave2Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info);
test(info.type == Ice::Locator::ice_staticId());
endpoints = info.proxy->ice_getEndpoints();
test(endpoints.size() == 3);
test(endpoints[0]->toString().find("-p 12050") != string::npos);
//.........这里部分代码省略.........
示例4: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
Ice::PropertiesPtr properties = communicator->getProperties();
{
ApplicationDescriptor testApp;
testApp.name = "TestApp";
admin->addApplication(testApp);
ApplicationUpdateDescriptor empty;
empty.name = "TestApp";
NodeUpdateDescriptor node;
node.name = "localnode";
empty.nodes.push_back(node);
ApplicationUpdateDescriptor update = empty;
cout << "testing server add... " << flush;
ServerDescriptorPtr server = new ServerDescriptor();
server->id = "Server";
server->exe = properties->getProperty("ServerDir") + "/server";
server->pwd = ".";
server->applicationDistrib = false;
server->allocatable = false;
server->activation = "on-demand";
addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
AdapterDescriptor adapter;
adapter.name = "Server";
adapter.id = "ServerAdapter";
adapter.registerProcess = false;
adapter.serverLifetime = true;
addProperty(server, "Server.Endpoints", "default");
ObjectDescriptor object;
object.id = communicator->stringToIdentity("${server}");
object.type = "::Test::TestIntf";
adapter.objects.push_back(object);
server->adapters.push_back(adapter);
update.nodes[0].servers.push_back(server);
admin->updateApplicationWithoutRestart(update);
admin->startServer("Server");
int serverPid = admin->getServerPid("Server");
update.nodes[0].servers[0]->id = "Server2";
update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2";
update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2");
try
{
admin->updateApplicationWithoutRestart(update);
}
catch(const DeploymentException& ex)
{
cerr << ex.reason << endl;
test(false);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
test(false);
}
admin->startServer("Server2");
int server2Pid = admin->getServerPid("Server2");
TemplateDescriptor templ;
templ.parameters.push_back("name");
templ.descriptor = new ServerDescriptor();
server = ServerDescriptorPtr::dynamicCast(templ.descriptor);
server->id = "${name}";
server->exe = "${server.dir}/server";
server->pwd = ".";
server->applicationDistrib = false;
server->allocatable = false;
server->activation = "on-demand";
addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
adapter = AdapterDescriptor();
adapter.name = "Server";
adapter.id = "${server}";
adapter.registerProcess = false;
adapter.serverLifetime = true;
addProperty(server, "Server.Endpoints", "default");
object = ObjectDescriptor();
object.id = communicator->stringToIdentity("${server}");
object.type = "::Test::TestIntf";
adapter.objects.push_back(object);
server->adapters.push_back(adapter);
update = empty;
update.serverTemplates["ServerTemplate"] = templ;
try
{
//.........这里部分代码省略.........
示例5: test
void
allTestsWithDeploy(const Ice::CommunicatorPtr& communicator)
{
cout << "testing stringToProxy... " << flush;
Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter");
test(base);
Ice::ObjectPrx base2 = communicator->stringToProxy("test");
test(base2);
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
TestIntfPrx obj = TestIntfPrx::checkedCast(base);
test(obj);
test(obj == base);
TestIntfPrx obj2 = TestIntfPrx::checkedCast(base2);
test(obj2);
test(obj2 == base2);
cout << "ok" << endl;
cout << "pinging server... " << flush;
obj->ice_ping();
obj2->ice_ping();
cout << "ok" << endl;
cout << "testing encoding versioning... " << flush;
Ice::ObjectPrx base10 = communicator->stringToProxy("test10 @ TestAdapter10");
test(base10);
Ice::ObjectPrx base102 = communicator->stringToProxy("test10");
test(base102);
try
{
base10->ice_ping();
test(false);
}
catch(const Ice::NoEndpointException&)
{
}
try
{
base102->ice_ping();
test(false);
}
catch(const Ice::NoEndpointException&)
{
}
base10 = base10->ice_encodingVersion(Ice::Encoding_1_0);
base102 = base102->ice_encodingVersion(Ice::Encoding_1_0);
base10->ice_ping();
base102->ice_ping();
cout << "ok" << endl;
cout << "testing reference with unknown identity... " << flush;
try
{
communicator->stringToProxy("unknown/unknown")->ice_ping();
test(false);
}
catch (const Ice::NotRegisteredException& ex)
{
test(ex.kindOfObject == "object");
test(ex.id == "unknown/unknown");
}
cout << "ok" << endl;
cout << "testing reference with unknown adapter... " << flush;
try
{
communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping();
test(false);
}
catch (const Ice::NotRegisteredException& ex)
{
test(ex.kindOfObject == "object adapter");
test(ex.id == "TestAdapterUnknown");
}
cout << "ok" << endl;
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
IceGrid::AdminPrx admin = session->getAdmin();
test(admin);
admin->enableServer("server", false);
admin->stopServer("server");
cout << "testing whether server is still reachable... " << flush;
try
{
obj = TestIntfPrx::checkedCast(base);
test(false);
}
catch(const Ice::NoEndpointException&)
{
}
//.........这里部分代码省略.........
示例6: test
void
allTests(const Ice::CommunicatorPtr& comm)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Query"));
test(query);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
set<string> serverReplicaIds;
serverReplicaIds.insert("Server1.ReplicatedAdapter");
serverReplicaIds.insert("Server2.ReplicatedAdapter");
serverReplicaIds.insert("Server3.ReplicatedAdapter");
set<string> svcReplicaIds;
svcReplicaIds.insert("IceBox1.Service1.Service1");
svcReplicaIds.insert("IceBox1.Service2.Service2");
svcReplicaIds.insert("IceBox1.Service3.Service3");
cout << "testing Query::findAllReplicas... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
Ice::ObjectProxySeq objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
removeServer(admin, "Server1");
removeServer(admin, "Server2");
removeServer(admin, "Server3");
}
cout << "ok" << endl;
cout << "testing replication with round-robin load balancing... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0));
obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false));
try
{
test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter");
admin->enableServer("Server1", false);
admin->enableServer("Server2", false);
admin->enableServer("Server3", false);
try
{
obj->getReplicaId();
test(false);
}
//.........这里部分代码省略.........
示例7: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways));
AdminPrx admin = session->getAdmin();
test(admin);
cout << "testing distributions... " << flush;
{
admin->startServer("Test.IcePatch2");
admin->startServer("IcePatch2-Direct");
TestIntfPrx test;
test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all"));
test(test->getServerFile("rootfile") == "");
try
{
admin->patchServer("server-all", true);
}
catch(const PatchException& ex)
{
copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n"));
test(false);
}
test(test->getServerFile("rootfile") == "rootfile");
test(test->getServerFile("dir1/file1") == "dummy-file1");
test(test->getServerFile("dir1/file2") == "dummy-file2");
test(test->getServerFile("dir2/file3") == "dummy-file3");
test(test->getApplicationFile("rootfile") == "");
test(test->getApplicationFile("dir1/file1") == "");
test(test->getApplicationFile("dir1/file2") == "");
test(test->getApplicationFile("dir2/file3") == "dummy-file3");
test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct"));
test(test->getServerFile("rootfile") == "");
test(test->getServerFile("dir1/file1") == "");
test(test->getServerFile("dir1/file2") == "");
test(test->getServerFile("dir2/file3") == "");
test(test->getApplicationFile("rootfile") == "");
test(test->getApplicationFile("dir1/file1") == "");
test(test->getApplicationFile("dir1/file2") == "");
test(test->getApplicationFile("dir2/file3") == "dummy-file3");
try
{
admin->patchServer("server-all-direct", true);
}
catch(const PatchException& ex)
{
copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n"));
test(false);
}
test(test->getServerFile("rootfile") == "rootfile");
test(test->getServerFile("dir1/file1") == "dummy-file1");
test(test->getServerFile("dir1/file2") == "dummy-file2");
test(test->getServerFile("dir2/file3") == "dummy-file3");
test(test->getApplicationFile("rootfile") == "");
test(test->getApplicationFile("dir1/file1") == "");
test(test->getApplicationFile("dir1/file2") == "");
test(test->getApplicationFile("dir2/file3") == "dummy-file3");
try
{
admin->patchApplication("Test", true);
}
catch(const PatchException& ex)
{
copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n"));
test(false);
}
test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1"));
test(test->getServerFile("rootfile") == "");
test(test->getServerFile("dir1/file1") == "dummy-file1");
test(test->getServerFile("dir1/file2") == "dummy-file2");
test(test->getServerFile("dir2/file3") == "");
test(test->getApplicationFile("rootfile") == "");
test(test->getApplicationFile("dir1/file1") == "");
test(test->getApplicationFile("dir1/file2") == "");
test(test->getApplicationFile("dir2/file3") == "dummy-file3");
admin->stopServer("Test.IcePatch2");
admin->stopServer("IcePatch2-Direct");
}
cout << "ok" << endl;
//.........这里部分代码省略.........
示例8: test
void
allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
{
ServerManagerPrx manager = ServerManagerPrx::checkedCast(communicator->stringToProxy(ref));
TestLocatorPrx locator = TestLocatorPrx::uncheckedCast(communicator->getDefaultLocator());
test(manager);
cout << "testing stringToProxy... " << flush;
Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrx base2 = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrx base3 = communicator->stringToProxy("test");
Ice::ObjectPrx base4 = communicator->stringToProxy("ServerManager");
Ice::ObjectPrx base5 = communicator->stringToProxy("test2");
Ice::ObjectPrx base6 = communicator->stringToProxy("test @ ReplicatedAdapter");
cout << "ok" << endl;
cout << "testing ice_locator and ice_getLocator... " << flush;
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
Ice::LocatorPrx anotherLocator = Ice::LocatorPrx::uncheckedCast(communicator->stringToProxy("anotherLocator"));
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(0);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getLocator());
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(locator);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
//
// We also test ice_router/ice_getRouter (perhaps we should add a
// test/Ice/router test?)
//
test(!base->ice_getRouter());
Ice::RouterPrx anotherRouter = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("anotherRouter"));
base = base->ice_router(anotherRouter);
test(Ice::proxyIdentityEqual(base->ice_getRouter(), anotherRouter));
Ice::RouterPrx router = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("dummyrouter"));
communicator->setDefaultRouter(router);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getRouter(), communicator->getDefaultRouter()));
communicator->setDefaultRouter(0);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getRouter());
cout << "ok" << endl;
cout << "starting server... " << flush;
manager->startServer();
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
TestIntfPrx obj = TestIntfPrx::checkedCast(base);
obj = TestIntfPrx::checkedCast(communicator->stringToProxy("[email protected]"));
obj = TestIntfPrx::checkedCast(communicator->stringToProxy("test @TestAdapter"));
obj = TestIntfPrx::checkedCast(communicator->stringToProxy("[email protected] TestAdapter"));
test(obj);
TestIntfPrx obj2 = TestIntfPrx::checkedCast(base2);
test(obj2);
TestIntfPrx obj3 = TestIntfPrx::checkedCast(base3);
test(obj3);
ServerManagerPrx obj4 = ServerManagerPrx::checkedCast(base4);
test(obj4);
TestIntfPrx obj5 = TestIntfPrx::checkedCast(base5);
test(obj5);
TestIntfPrx obj6 = TestIntfPrx::checkedCast(base6);
test(obj6);
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj6 = TestIntfPrx::checkedCast(base6);
obj6->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing identity indirect proxy... " << flush;
//.........这里部分代码省略.........