现在的位置: 首页 > 综合 > 正文

ICE 编程 client.cpp

2013年08月13日 ⁄ 综合 ⁄ 共 1860字 ⁄ 字号 评论关闭
  1. // **********************************************************************
  2. //
  3. // Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
  4. //
  5. // This copy of Ice is licensed to you under the terms described in the
  6. // ICE_LICENSE file included in this distribution.
  7. //
  8. // **********************************************************************
  9. #include <Ice/Ice.h>
  10. #include <TestCommon.h>
  11. #include <Test.h>
  12. using namespace std;
  13. int
  14. run(int argc, char* argv[],
  15.     const Ice::CommunicatorPtr& communicator,
  16.     const Ice::InitializationData& initData)
  17. {
  18.     Test::MyClassPrx allTests(const Ice::CommunicatorPtr&,
  19.       const Ice::InitializationData&, bool);
  20.     Test::MyClassPrx myClass = allTests(communicator, initData, false);
  21.     cout << "testing server shutdown... " << flush;
  22.     myClass->shutdown();
  23.     try
  24.     {
  25. myClass->opVoid();
  26. test(false);
  27.     }
  28.     catch(const Ice::LocalException&)
  29.     {
  30. cout << "ok" << endl;
  31.     }
  32.     return EXIT_SUCCESS;
  33. }
  34. int
  35. main(int argc, char* argv[])
  36. {
  37.     int status;
  38.     Ice::CommunicatorPtr communicator;
  39.     try
  40.     {
  41. //
  42. // In this test, we need at least two threads in the
  43. // client side thread pool for nested AMI.
  44. //
  45. Ice::InitializationData initData;
  46. initData.properties = Ice::createProperties(argc, argv);
  47. initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2");
  48. initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0");
  49. //
  50. // We must set MessageSizeMax to an explicit values, because
  51. // we run tests to check whether Ice.MemoryLimitException is
  52. // raised as expected.
  53. //
  54. initData.properties->setProperty("Ice.MessageSizeMax", "100");
  55. //
  56. // We don't want connection warnings because of the timeout test.
  57. //
  58. initData.properties->setProperty("Ice.Warn.Connections", "0");
  59. communicator = Ice::initialize(argc, argv, initData);
  60. status = run(argc, argv, communicator, initData);
  61.     }
  62.     catch(const Ice::Exception& ex)
  63.     {
  64. cerr << ex << endl;
  65. status = EXIT_FAILURE;
  66.     }
  67.     if(communicator)
  68.     {
  69. try
  70. {
  71.     communicator->destroy();
  72. }
  73. catch(const Ice::Exception& ex)
  74. {
  75.     cerr << ex << endl;
  76.     status = EXIT_FAILURE;
  77. }
  78.     }
  79.     return status;
  80. }

抱歉!评论已关闭.