ICE 编程 client.cpp

  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. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值