]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1975] Merge branch 'trac1975' from upstream with fixing conflicts.
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 13 Jun 2012 18:32:28 +0000 (11:32 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 13 Jun 2012 18:32:28 +0000 (11:32 -0700)
1  2 
src/lib/datasrc/list.h
src/lib/datasrc/tests/list_unittest.cc

index 7d6f2a18feabeb6dffa38a573b54cde5802200ef,6c060f028c3f5cb5f5f619e7f0bee0d3f730b84f..5fe7ed5a03531e23cc03af48c5b181935661a55d
@@@ -126,25 -133,25 +133,27 @@@ public
      /// this case, the zone finder is needed and the best matching superzone
      /// of the searched name is needed. Therefore, the call would look like:
      ///
-     /// \code SearchResult result(container->search(queried_name));
-     /// if (result.datasrc_ != NULL) {
-     ///     createTheAnswer(result.finder_);
-     /// } else {
-     ///     createNotAuthAnswer();
++    /// \code FindResult result(list->find(queried_name));
+     ///   FindResult result(list->find(queried_name));
+     ///   if (result.datasrc_) {
+     ///       createTheAnswer(result.finder_);
+     ///   } else {
+     ///       createNotAuthAnswer();
 -    ///   }
 +    /// } \endcode
      ///
      /// The other scenario is manipulating zone data (XfrOut, XfrIn, DDNS,
      /// ...). In this case, the finder itself is not so important. However,
      /// we need an exact match (if we want to manipulate zone data, we must
      /// know exactly, which zone we are about to manipulate). Then the call
      ///
-     /// \code SearchResult result(container->search(zone_name, true, false));
-     /// if (result.datasrc_ != NULL) {
-     ///     ZoneUpdaterPtr updater(result.datasrc_->getUpdater(zone_name);
-     ///     ...
++    /// \code FindResult result(list->find(zone_name, true, false));
+     ///   FindResult result(list->find(zone_name, true, false));
+     ///   if (result.datasrc_) {
+     ///       ZoneUpdaterPtr updater(result.datasrc_->getUpdater(zone_name);
+     ///       ...
 -    ///   }
 +    /// } \endcode
      ///
-     /// \param zone The name of the zone to search.
+     /// \param zone The name of the zone to look for.
      /// \param want_exact_match If it is true, it returns only exact matches.
      ///     If the best possible match is partial, a negative result is
      ///     returned instead. It is possible the caller could check it and
index 3059b90f5072953e9a0f6bda108753ed7d5fc1ec,6192ec912946c6946c0c4d4f10db8528f004a181..c29074296a6e092da86b81e50f90278655703a86
@@@ -64,8 -64,8 +64,8 @@@ public
          Name origin_;
      };
      // Constructor from a list of zones.
-     TestDS(const char* zone_names[]) {
-         for (const char** zone(zone_names); *zone != NULL; ++zone) {
+     MockDataSourceClient(const char* zone_names[]) {
 -        for (const char** zone(zone_names); *zone; ++ zone) {
++        for (const char** zone(zone_names); *zone; ++zone) {
              zones.insert(Name(*zone));
          }
      }
              return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
          }
          set<Name>::const_iterator it(zones.upper_bound(name));
 -        -- it;
+         if (it == zones.begin()) {
+             return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
+         }
-         const NameComparisonResult compar(it->compare(name));
 +        --it;
+         NameComparisonResult compar(it->compare(name));
          const ZoneFinderPtr finder(new Finder(*it));
          switch (compar.getRelation()) {
              case NameComparisonResult::EQUAL:
@@@ -217,13 -224,12 +224,14 @@@ public
                  FAIL() << "Unknown configuration index " << index;
          }
      }
 -    void checkDS(size_t index, const string& type, const string& params) {
 +    void checkDS(size_t index, const string& type, const string& params) const
 +    {
-         ASSERT_GT(container_->dataSources().size(), index);
-         const TestDS* ds(dynamic_cast<TestDS*>(
-             container_->dataSources()[index].data_src_));
+         ASSERT_GT(list_->getDataSources().size(), index);
+         MockDataSourceClient* ds(dynamic_cast<MockDataSourceClient*>(
+             list_->getDataSources()[index].data_src_client_));
++
          // Comparing with NULL does not work
-         ASSERT_TRUE(ds);
+         ASSERT_NE(ds, static_cast<const MockDataSourceClient*>(NULL));
          EXPECT_EQ(type, ds->type_);
          EXPECT_TRUE(Element::fromJSON(params)->equals(*ds->configuration_));
      }
@@@ -282,29 -290,29 +292,29 @@@ TEST_F(ListTest, singleDSExactMatch) 
  }
  
  // When asking for a partial match, we get all that the exact one, but more.
- TEST_F(ContainerTest, singleDSBestMatch) {
-     container_->dataSources().push_back(ds_info_[0]);
+ TEST_F(ListTest, singleDSBestMatch) {
+     list_->getDataSources().push_back(ds_info_[0]);
      // This zone is not there
-     EXPECT_TRUE(negativeResult_ == container_->search(Name("org.")));
+     EXPECT_TRUE(negativeResult_ == list_->find(Name("org.")));
      // But this one is, so check it.
-     positiveResult(container_->search(Name("example.org")),
-                    ds_[0], Name("example.org"), true, "Exact match");
-     // When asking for a sub zone of a zone there, we get nothing
-     // (we want exact match, this would be partial one)
-     positiveResult(container_->search(Name("sub.example.org.")),
-                    ds_[0], Name("example.org"), false, "Subdomain match");
+     positiveResult(list_->find(Name("example.org")), ds_[0],
+                    Name("example.org"), true, "Exact match");
+     // When asking for a sub zone of a zone there, we get the parent
+     // one.
+     positiveResult(list_->find(Name("sub.example.org.")), ds_[0],
+                    Name("example.org"), false, "Subdomain match");
  }
  
 -const char* test_names[] = {
 +const char* const test_names[] = {
      "Sub second",
      "Sub first",
      "With empty",
      "With a duplicity"
  };
  
- TEST_F(ContainerTest, multiExactMatch) {
+ TEST_F(ListTest, multiExactMatch) {
      // Run through all the multi-configurations
-     for (size_t i(0); i < 4; ++i) {
 -    for (size_t i(0); i < sizeof(test_names) / sizeof(*test_names); ++ i) {
++    for (size_t i(0); i < sizeof(test_names) / sizeof(*test_names); ++i) {
          SCOPED_TRACE(test_names[i]);
          multiConfiguration(i);
          // Something that is nowhere there