1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#include <Ice/Ice.h>
#include <TestI.h>
#include <TestHelper.h>
using namespace std;
class Server : public Test::TestHelper
{
public:
void run(int, char**);
};
void
Server::run(int argc, char** argv)
{
//
// In this test, we need a longer server idle time, otherwise
// our test servers may time out before they are used in the
// test.
//
Ice::PropertiesPtr properties = createTestProperties(argc, argv);
properties->setProperty("Ice.ServerIdleTime", "120"); // Two minutes.
Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
int port = 0;
for(int i = 1; i < argc; ++i)
{
if(argv[i][0] == '-')
{
ostringstream os;
os << ": unknown option `" << argv[i] << "'";
throw invalid_argument(os.str());
}
if(port > 0)
{
throw runtime_error("only one port can be specified");
}
port = atoi(argv[i]);
}
if(port <= 0)
{
throw runtime_error("no port specified");
}
ostringstream endpts;
endpts << getTestEndpoint(port);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", endpts.str());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::ObjectPtr object = ICE_MAKE_SHARED(TestI);
adapter->add(object, Ice::stringToIdentity("test"));
adapter->activate();
serverReady();
communicator->waitForShutdown();
}
DEFINE_TEST(Server)
|