test_client.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (C) 2012 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. #ifndef TEST_DATA_SOURCE_CLIENT_H
  15. #define TEST_DATA_SOURCE_CLIENT_H 1
  16. #include <dns/name.h>
  17. #include <dns/rrclass.h>
  18. #include <boost/shared_ptr.hpp>
  19. #include <istream>
  20. namespace isc {
  21. namespace datasrc {
  22. namespace unittest {
  23. // Here we define utility modules for the convenience of tests that create
  24. // a data source client according to the specified conditions.
  25. /// \brief Create an SQLite3 data source client from a zone file.
  26. ///
  27. /// This function creates an SQLite3 client for the specified zone containing
  28. /// RRs in the specified zone file. The zone will be created in the given
  29. /// SQLite3 database file. The database file does not have to exist; this
  30. /// function will automatically create a new file for the test; if the given
  31. /// file already exists this function overrides the content (so basically the
  32. /// file must be an ephemeral one only for that test case).
  33. ///
  34. /// The zone file must be formatted so it's accepted by the dns::masterLoad()
  35. /// function.
  36. ///
  37. /// \param zclass The RR class of the zone
  38. /// \param zname The origin name of the zone
  39. /// \param db_file The SQLite3 data base file in which the zone data should be
  40. /// installed.
  41. /// \param zone_file The filename of the zone data in the textual format.
  42. /// \return Newly created \c DataSourceClient using the SQLite3 data source
  43. boost::shared_ptr<DataSourceClient>
  44. createSQLite3Client(dns::RRClass zclass, const dns::Name& zname,
  45. const char* const db_file, const char* const zone_file);
  46. /// \brief Create an SQLite3 data source client from a stream.
  47. ///
  48. /// This is similar to the other version of the function, but takes an input
  49. /// stream for the zone data. The stream produces strings as the corresponding
  50. /// dns::masterLoad() function expects.
  51. boost::shared_ptr<DataSourceClient>
  52. createSQLite3Client(dns::RRClass zclass, const dns::Name& zname,
  53. const char* const db_file, std::istream& rr_stream);
  54. } // end of unittest
  55. } // end of datasrc
  56. } // end of isc
  57. #endif // TEST_DATA_SOURCE_CLIENT_H
  58. // Local Variables:
  59. // mode: c++
  60. // End: