[svn] commit: r2303 - in /branches/trac221/src/bin/auth/tests: auth_srv_unittest.cc testdata/notifyin_fromwire

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jun 28 08:13:19 UTC 2010


Author: jinmei
Date: Mon Jun 28 08:13:19 2010
New Revision: 2303

Log:
built normal requests within the test code and avoid having a separate data file.

Removed:
    branches/trac221/src/bin/auth/tests/testdata/notifyin_fromwire
Modified:
    branches/trac221/src/bin/auth/tests/auth_srv_unittest.cc

Modified: branches/trac221/src/bin/auth/tests/auth_srv_unittest.cc
==============================================================================
--- branches/trac221/src/bin/auth/tests/auth_srv_unittest.cc (original)
+++ branches/trac221/src/bin/auth/tests/auth_srv_unittest.cc Mon Jun 28 08:13:19 2010
@@ -75,6 +75,8 @@
     vector<uint8_t> data;
 
     void createDataFromFile(const char* const datafile);
+    void createRequest(const Opcode& opcode, const Name& request_name,
+                       const RRClass& rrclass, const RRType& rrtype);
 };
 
 // These are flags to indicate whether the corresponding flag bit of the
@@ -97,6 +99,21 @@
     endpoint = IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5300);
     UnitTestUtil::readWireData(datafile, data);
     io_message = new IOMessage(&data[0], data.size(),
+                               IOSocket::getDummyUDPSocket(), *endpoint);
+}
+
+void
+AuthSrvTest::createRequest(const Opcode& opcode, const Name& request_name,
+                           const RRClass& rrclass, const RRType& rrtype) 
+{
+    request_message.setOpcode(opcode);
+    request_message.addQuestion(Question(request_name, rrclass, rrtype));
+    request_message.toWire(request_renderer);
+
+    delete io_message;
+    endpoint = IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5300);
+    io_message = new IOMessage(request_renderer.getData(),
+                               request_renderer.getLength(),
                                IOSocket::getDummyUDPSocket(), *endpoint);
 }
 
@@ -246,14 +263,12 @@
 
 // notify-in teset.
 TEST_F(AuthSrvTest, notifyInTest) {
-    createDataFromFile("notifyin_fromwire");
+    createRequest(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
+                  RRType::SOA());
     parse_message.clear(Message::PARSE);
     EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
-                                              response_renderer));
-    //headerCheck(parse_message, default_qid, Rcode::SERVFAIL(), Opcode::NOTIFY().getCode(), QR_FLAG,
-    //                1, 0, 0, 0);
-}
-
+                                           response_renderer));
+}
 
 void
 updateConfig(AuthSrv* server, const char* const dbfile,




More information about the bind10-changes mailing list