summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/location/TestI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/location/TestI.cpp')
-rw-r--r--cpp/test/Ice/location/TestI.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/cpp/test/Ice/location/TestI.cpp b/cpp/test/Ice/location/TestI.cpp
index 42215bd7ff6..5c3bff8f9a5 100644
--- a/cpp/test/Ice/location/TestI.cpp
+++ b/cpp/test/Ice/location/TestI.cpp
@@ -10,15 +10,18 @@
#include <Ice/Ice.h>
#include <Ice/Locator.h>
#include <TestI.h>
+#include <TestCommon.h>
using namespace Test;
ServerManagerI::ServerManagerI(const ServerLocatorRegistryPtr& registry,
const Ice::InitializationData& initData) :
- _registry(registry), _initData(initData), _nextPort(12011)
+ _registry(registry),
+ _initData(initData),
+ _nextPort(1)
{
_initData.properties->setProperty("TestAdapter.AdapterId", "TestAdapter");
- _initData.properties->setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter");
+ _initData.properties->setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter");
_initData.properties->setProperty("TestAdapter2.AdapterId", "TestAdapter2");
_initData.properties->setProperty("Ice.PrintAdapterReady", "0");
}
@@ -48,28 +51,21 @@ ServerManagerI::startServer(const Ice::Current&)
// Use fixed port to ensure that OA re-activation doesn't re-use previous port from
// another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
//
- {
- std::ostringstream os;
- os << "default -p " << _nextPort++;
- serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", os.str());
- }
- {
- std::ostringstream os;
- os << "default -p " << _nextPort++;
- serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints", os.str());
- }
+ Ice::PropertiesPtr props = _initData.properties;
+ serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(props, _nextPort++));
+ serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints", getTestEndpoint(props, _nextPort++));
Ice::ObjectAdapterPtr adapter = serverCommunicator->createObjectAdapter("TestAdapter");
Ice::ObjectAdapterPtr adapter2 = serverCommunicator->createObjectAdapter("TestAdapter2");
- Ice::ObjectPrx locator = serverCommunicator->stringToProxy("locator:default -p 12010");
- adapter->setLocator(Ice::LocatorPrx::uncheckedCast(locator));
- adapter2->setLocator(Ice::LocatorPrx::uncheckedCast(locator));
+ Ice::ObjectPrxPtr locator = serverCommunicator->stringToProxy("locator:" + getTestEndpoint(props, 0));
+ adapter->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
+ adapter2->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
- Ice::ObjectPtr object = new TestI(adapter, adapter2, _registry);
- _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test")));
- _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test2")));
- adapter->add(object, serverCommunicator->stringToIdentity("test3"));
+ Ice::ObjectPtr object = ICE_MAKE_SHARED(TestI, adapter, adapter2, _registry);
+ _registry->addObject(adapter->add(object, Ice::stringToIdentity("test")));
+ _registry->addObject(adapter->add(object, Ice::stringToIdentity("test2")));
+ adapter->add(object, Ice::stringToIdentity("test3"));
adapter->activate();
adapter2->activate();
@@ -86,12 +82,12 @@ ServerManagerI::shutdown(const Ice::Current& current)
}
-TestI::TestI(const Ice::ObjectAdapterPtr& adapter,
- const Ice::ObjectAdapterPtr& adapter2,
+TestI::TestI(const Ice::ObjectAdapterPtr& adapter,
+ const Ice::ObjectAdapterPtr& adapter2,
const ServerLocatorRegistryPtr& registry) :
_adapter1(adapter), _adapter2(adapter2), _registry(registry)
{
- _registry->addObject(_adapter1->add(new HelloI(), _adapter1->getCommunicator()->stringToIdentity("hello")));
+ _registry->addObject(_adapter1->add(ICE_MAKE_SHARED(HelloI), Ice::stringToIdentity("hello")));
}
void
@@ -100,23 +96,23 @@ TestI::shutdown(const Ice::Current&)
_adapter1->getCommunicator()->shutdown();
}
-HelloPrx
+HelloPrxPtr
TestI::getHello(const Ice::Current&)
{
- return HelloPrx::uncheckedCast(_adapter1->createIndirectProxy(
- _adapter1->getCommunicator()->stringToIdentity("hello")));
+ return ICE_UNCHECKED_CAST(HelloPrx, _adapter1->createIndirectProxy(
+ Ice::stringToIdentity("hello")));
}
-HelloPrx
+HelloPrxPtr
TestI::getReplicatedHello(const Ice::Current&)
{
- return HelloPrx::uncheckedCast(_adapter1->createProxy(_adapter1->getCommunicator()->stringToIdentity("hello")));
+ return ICE_UNCHECKED_CAST(HelloPrx, _adapter1->createProxy(Ice::stringToIdentity("hello")));
}
void
TestI::migrateHello(const Ice::Current&)
{
- const Ice::Identity id = _adapter1->getCommunicator()->stringToIdentity("hello");
+ const Ice::Identity id = Ice::stringToIdentity("hello");
try
{
_registry->addObject(_adapter2->add(_adapter1->remove(id), id));