chunks: refactor Producer options handling
Change-Id: I10331ad9fa33cce1133bc3270cadf65b3e31c93b
diff --git a/tests/chunks/producer.t.cpp b/tests/chunks/producer.t.cpp
index 479d03f..902c3fb 100644
--- a/tests/chunks/producer.t.cpp
+++ b/tests/chunks/producer.t.cpp
@@ -47,25 +47,26 @@
ProducerFixture()
: face(io, {true, true})
, prefix("/ndn/chunks/test")
+ , version(1449227841747)
+ , keyLocatorName(m_keyChain.createIdentity("/ProducerFixture").getDefaultKey().getName())
, testString(std::string(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget "
"dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, "
"nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, "
"sem. Nulla consequat massa Donec pede justo,"))
- ,keyLocatorName(m_keyChain.createIdentity("/ProducerFixture").getDefaultKey().getName())
{
+ options.maxSegmentSize = 40;
+ options.isQuiet = true;
}
protected:
boost::asio::io_service io;
util::DummyClientFace face;
- security::SigningInfo signingInfo;
Name prefix;
- time::milliseconds freshnessPeriod = time::seconds(10);
- size_t maxSegmentSize = 40;
- std::istringstream testString;
- uint64_t version = 1449227841747;
+ Producer::Options options;
+ uint64_t version;
Name keyLocatorName;
+ std::istringstream testString;
};
BOOST_AUTO_TEST_SUITE(Chunks)
@@ -73,7 +74,7 @@
BOOST_AUTO_TEST_CASE(InputData)
{
- std::vector<std::string> testStrings {
+ std::vector<std::string> testStrings{
"",
"a1b2c3%^&(#$&%^$$/><",
@@ -87,13 +88,12 @@
"consequat massa Donec pede justo,"
};
- for (size_t i = 0; i < testStrings.size(); ++i) {
- std::istringstream str(testStrings[i]);
- Producer prod(prefix, face, m_keyChain, signingInfo, time::seconds(4), maxSegmentSize, false,
- false, false, str);
+ for (size_t i = 0; i < testStrings.size(); ++i) {
+ std::istringstream input(testStrings[i]);
+ Producer prod(prefix, face, m_keyChain, input, options);
- size_t expectedSize = std::ceil(static_cast<double>(testStrings[i].size()) / maxSegmentSize);
- if (testStrings[i].size() == 0)
+ size_t expectedSize = std::ceil(static_cast<double>(testStrings[i].size()) / options.maxSegmentSize);
+ if (testStrings[i].empty())
expectedSize = 1;
BOOST_CHECK_EQUAL(prod.m_store.size(), expectedSize);
@@ -102,11 +102,9 @@
BOOST_AUTO_TEST_CASE(RequestSegmentUnspecifiedVersion)
{
- Producer producer(prefix, face, m_keyChain, signingInfo, freshnessPeriod, maxSegmentSize,
- false, false, false, testString);
+ Producer producer(prefix, face, m_keyChain, testString, options);
io.poll();
-
- size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
+ size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / options.maxSegmentSize);
// version request
face.receive(*makeInterest(prefix));
@@ -139,11 +137,9 @@
BOOST_AUTO_TEST_CASE(RequestSegmentSpecifiedVersion)
{
- Producer producer(prefix.appendVersion(version), face, m_keyChain, signingInfo, freshnessPeriod,
- maxSegmentSize, false, false, false, testString);
+ Producer producer(prefix.appendVersion(version), face, m_keyChain, testString, options);
io.poll();
-
- size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
+ size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / options.maxSegmentSize);
// version request
face.receive(*makeInterest(prefix));
@@ -177,11 +173,9 @@
BOOST_AUTO_TEST_CASE(RequestNotExistingSegment)
{
- Producer producer(prefix, face, m_keyChain, signingInfo, freshnessPeriod, maxSegmentSize,
- false, false, false, testString);
+ Producer producer(prefix, face, m_keyChain, testString, options);
io.poll();
-
- size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
+ size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / options.maxSegmentSize);
// version request
face.receive(*makeInterest(prefix));