PageRenderTime 150ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/tests/llregionpresenceverifier_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 108 lines | 64 code | 15 blank | 29 comment | 0 complexity | a871022c21ed8635946fae6dfaf93f3e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file
  3. * @brief
  4. *
  5. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "../test/lltut.h"
  28. #include "llregionpresenceverifier.h"
  29. #include "llcurl_stub.cpp"
  30. #include "llhost.cpp"
  31. #include "net.cpp"
  32. #include "lltesthttpclientadapter.cpp"
  33. class LLTestResponse : public LLRegionPresenceVerifier::Response
  34. {
  35. public:
  36. virtual bool checkValidity(const LLSD& content) const
  37. {
  38. return true;
  39. }
  40. virtual void onRegionVerified(const LLSD& region_details)
  41. {
  42. }
  43. virtual void onRegionVerificationFailed()
  44. {
  45. }
  46. virtual LLHTTPClientInterface& getHttpClient()
  47. {
  48. return mHttpInterface;
  49. }
  50. LLTestHTTPClientAdapter mHttpInterface;
  51. };
  52. namespace tut
  53. {
  54. struct LLRegionPresenceVerifierData
  55. {
  56. LLRegionPresenceVerifierData() :
  57. mResponse(new LLTestResponse()),
  58. mResponder("", LLRegionPresenceVerifier::ResponsePtr(mResponse),
  59. LLSD(), 3)
  60. {
  61. }
  62. LLTestResponse* mResponse;
  63. LLRegionPresenceVerifier::VerifiedDestinationResponder mResponder;
  64. };
  65. typedef test_group<LLRegionPresenceVerifierData> factory;
  66. typedef factory::object object;
  67. }
  68. namespace
  69. {
  70. tut::factory tf("LLRegionPresenceVerifier");
  71. }
  72. namespace tut
  73. {
  74. // Test that VerifiedDestinationResponder does retry
  75. // on error when shouldRetry returns true.
  76. template<> template<>
  77. void object::test<1>()
  78. {
  79. mResponder.error(500, "Internal server error");
  80. ensure_equals(mResponse->mHttpInterface.mGetUrl.size(), 1);
  81. }
  82. // Test that VerifiedDestinationResponder only retries
  83. // on error until shouldRetry returns false.
  84. template<> template<>
  85. void object::test<2>()
  86. {
  87. mResponder.error(500, "Internal server error");
  88. mResponder.error(500, "Internal server error");
  89. mResponder.error(500, "Internal server error");
  90. mResponder.error(500, "Internal server error");
  91. ensure_equals(mResponse->mHttpInterface.mGetUrl.size(), 3);
  92. }
  93. }