test_http.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. 
  2. #include "hello_test.h"
  3. //
  4. //TEST_F(HelloTest, sslSyncClient)
  5. //{
  6. // shared_ptr<Communicator> c = std::make_shared<Communicator>();
  7. // TC_Config conf = CLIENT_CONFIG();
  8. //
  9. // c->setProperty(conf);
  10. //
  11. // try
  12. // {
  13. //
  14. // HelloPrx prx = c->stringToProxy<HelloPrx>("TestApp.SSLServer.SSLObj@ssl -h 127.0.0.1 -p 9005 -t 10000");
  15. // prx->tars_ping();
  16. // LOG_CONSOLE_DEBUG << "prx succ" << endl;
  17. //
  18. // HelloPrx prx1 = c->stringToProxy<HelloPrx>("TestApp.SSLServer.SSL1Obj@ssl -h 127.0.0.1 -p 9006 -t 10000");
  19. // prx1->tars_ping();
  20. // LOG_CONSOLE_DEBUG << "prx1 succ" << endl;
  21. //
  22. // HelloPrx prx2 = c->stringToProxy<HelloPrx>("TestApp.SSLServer.SSL2Obj@ssl -h 127.0.0.1 -p 9007 -t 10000");
  23. // prx2->tars_ping();
  24. // LOG_CONSOLE_DEBUG << "prx2 succ" << endl;
  25. //
  26. // HelloPrx prx3 = c->stringToProxy<HelloPrx>("TestApp.SSLServer.SSL3Obj@ssl -h 127.0.0.1 -p 9008 -t 10000 -e 1");
  27. // prx3->tars_ping();
  28. // LOG_CONSOLE_DEBUG << "prx3 succ" << endl;
  29. // }
  30. // catch(exception &ex)
  31. // {
  32. // LOG_CONSOLE_DEBUG << ex.what() << endl;
  33. // }
  34. //
  35. //}
  36. TEST_F(HelloTest, httpSyncServerCommunicator)
  37. {
  38. transServerCommunicator([&](Communicator *comm){
  39. checkSyncHttp(comm, "HttpAdapter", true);
  40. checkSyncHttp(comm, "HttpAdapter", false);
  41. });
  42. }
  43. TEST_F(HelloTest, httpSyncServerCommunicatorInCoroutine)
  44. {
  45. transInCoroutineServerCommunicator([&](Communicator *comm){
  46. checkSyncHttp(comm, "HttpAdapter", true);
  47. checkSyncHttp(comm, "HttpAdapter", false);
  48. });
  49. }
  50. TEST_F(HelloTest, httpASyncServerCommunicator)
  51. {
  52. transServerCommunicator([&](Communicator *comm){
  53. checkASyncHttp(comm, "HttpAdapter", true);
  54. checkASyncHttp(comm, "HttpAdapter", false);
  55. });
  56. }
  57. TEST_F(HelloTest, httpASyncServerCommunicatorInCoroutine)
  58. {
  59. transInCoroutineServerCommunicator([&](Communicator *comm){
  60. checkASyncHttp(comm, "HttpAdapter", true);
  61. checkASyncHttp(comm, "HttpAdapter", false);
  62. });
  63. }
  64. #if TARS_SSL
  65. TEST_F(HelloTest, httpsSyncServerCommunicator)
  66. {
  67. transServerCommunicator([&](Communicator *comm){
  68. checkSyncHttp(comm, "HttpsAdapter", true);
  69. checkSyncHttp(comm, "HttpsAdapter", false);
  70. });
  71. }
  72. TEST_F(HelloTest, httpsSyncServerCommunicatorInCoroutine)
  73. {
  74. transInCoroutineServerCommunicator([&](Communicator *comm){
  75. checkSyncHttp(comm, "HttpsAdapter", true);
  76. checkSyncHttp(comm, "HttpsAdapter", false);
  77. });
  78. }
  79. TEST_F(HelloTest, httpsASyncServerCommunicator)
  80. {
  81. transServerCommunicator([&](Communicator *comm){
  82. checkASyncHttp(comm, "HttpsAdapter", true);
  83. checkASyncHttp(comm, "HttpsAdapter", false);
  84. });
  85. }
  86. TEST_F(HelloTest, httpsASyncServerCommunicatorInCoroutine)
  87. {
  88. transInCoroutineServerCommunicator([&](Communicator *comm){
  89. checkASyncHttp(comm, "HttpsAdapter", true);
  90. checkASyncHttp(comm, "HttpsAdapter", false);
  91. });
  92. }
  93. #endif