client_unittest.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <utility>
  15. #include <datasrc/client.h>
  16. #include <dns/name.h>
  17. #include <gtest/gtest.h>
  18. using namespace isc::datasrc;
  19. using isc::dns::Name;
  20. namespace {
  21. /*
  22. * The DataSourceClient can't be created as it has pure virtual methods.
  23. * So we implement them as NOPs and test the other methods.
  24. */
  25. class NopClient : public DataSourceClient {
  26. public:
  27. virtual FindResult findZone(const isc::dns::Name&) const {
  28. return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
  29. }
  30. virtual ZoneUpdaterPtr getUpdater(const isc::dns::Name&, bool, bool)
  31. const
  32. {
  33. return (ZoneUpdaterPtr());
  34. }
  35. virtual std::pair<ZoneJournalReader::Result, ZoneJournalReaderPtr>
  36. getJournalReader(const isc::dns::Name&, uint32_t, uint32_t) const {
  37. isc_throw(isc::NotImplemented, "Journaling isn't supported "
  38. "in Nop data source");
  39. }
  40. };
  41. class ClientTest : public ::testing::Test {
  42. public:
  43. NopClient client_;
  44. };
  45. // The default implementation is NotImplemented
  46. TEST_F(ClientTest, defaultIterator) {
  47. EXPECT_THROW(client_.getIterator(Name(".")), isc::NotImplemented);
  48. }
  49. TEST_F(ClientTest, defaultGetZoneCount) {
  50. EXPECT_THROW(client_.getZoneCount(), isc::NotImplemented);
  51. }
  52. }