Repository: nifi-minifi-cpp Updated Branches: refs/heads/master bc0d65e1f -> 63c53bcfd
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/PropertyTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/PropertyTests.cpp b/libminifi/test/unit/PropertyTests.cpp index cd686a1..a2d5858 100644 --- a/libminifi/test/unit/PropertyTests.cpp +++ b/libminifi/test/unit/PropertyTests.cpp @@ -17,88 +17,89 @@ */ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "../../include/core/Property.h" +#include <string> #include "utils/StringUtils.h" #include "../TestBase.h" - TEST_CASE("Test Boolean Conversion", "[testboolConversion]") { - - bool b; - REQUIRE(true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("true",b)); - REQUIRE(true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("True",b)); - REQUIRE(true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("TRue",b)); - REQUIRE(true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("tRUE",b)); - - REQUIRE(false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FALSE",b)); - REQUIRE(false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FALLSEY",b)); - REQUIRE(false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FaLSE",b)); - REQUIRE(false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("false",b)); - + bool b; + REQUIRE( + true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("true", b)); + REQUIRE( + true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("True", b)); + REQUIRE( + true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("TRue", b)); + REQUIRE( + true == org::apache::nifi::minifi::utils::StringUtils::StringToBool("tRUE", b)); + REQUIRE( + false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FALSE", b)); + REQUIRE( + false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FALLSEY", b)); + REQUIRE( + false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("FaLSE", b)); + REQUIRE( + false == org::apache::nifi::minifi::utils::StringUtils::StringToBool("false", b)); } TEST_CASE("Test Trimmer Right", "[testTrims]") { + std::string test = "a quick brown fox jumped over the road\t\n"; - std::string test = "a quick brown fox jumped over the road\t\n"; + REQUIRE(test.c_str()[test.length() - 1] == '\n'); + REQUIRE(test.c_str()[test.length() - 2] == '\t'); + test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); - REQUIRE(test.c_str()[test.length() - 1] == '\n'); - REQUIRE(test.c_str()[test.length() - 2] == '\t'); - test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); + REQUIRE(test.c_str()[test.length() - 1] == 'd'); + REQUIRE(test.c_str()[test.length() - 2] == 'a'); - REQUIRE(test.c_str()[test.length() - 1] == 'd'); - REQUIRE(test.c_str()[test.length() - 2] == 'a'); + test = "a quick brown fox jumped over the road\v\t"; - test = "a quick brown fox jumped over the road\v\t"; + REQUIRE(test.c_str()[test.length() - 1] == '\t'); + REQUIRE(test.c_str()[test.length() - 2] == '\v'); - REQUIRE(test.c_str()[test.length() - 1] == '\t'); - REQUIRE(test.c_str()[test.length() - 2] == '\v'); + test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); - test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); + REQUIRE(test.c_str()[test.length() - 1] == 'd'); + REQUIRE(test.c_str()[test.length() - 2] == 'a'); - REQUIRE(test.c_str()[test.length() - 1] == 'd'); - REQUIRE(test.c_str()[test.length() - 2] == 'a'); + test = "a quick brown fox jumped over the road \f"; - test = "a quick brown fox jumped over the road \f"; + REQUIRE(test.c_str()[test.length() - 1] == '\f'); + REQUIRE(test.c_str()[test.length() - 2] == ' '); - REQUIRE(test.c_str()[test.length() - 1] == '\f'); - REQUIRE(test.c_str()[test.length() - 2] == ' '); - - test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); - - REQUIRE(test.c_str()[test.length() - 1] == 'd'); + test = org::apache::nifi::minifi::utils::StringUtils::trimRight(test); + REQUIRE(test.c_str()[test.length() - 1] == 'd'); } TEST_CASE("Test Trimmer Left", "[testTrims]") { + std::string test = "\t\na quick brown fox jumped over the road\t\n"; - std::string test = "\t\na quick brown fox jumped over the road\t\n"; - - REQUIRE(test.c_str()[0] == '\t'); - REQUIRE(test.c_str()[1] == '\n'); - - test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); + REQUIRE(test.c_str()[0] == '\t'); + REQUIRE(test.c_str()[1] == '\n'); - REQUIRE(test.c_str()[0] == 'a'); - REQUIRE(test.c_str()[1] == ' '); + test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); - test = "\v\ta quick brown fox jumped over the road\v\t"; + REQUIRE(test.c_str()[0] == 'a'); + REQUIRE(test.c_str()[1] == ' '); - REQUIRE(test.c_str()[0] == '\v'); - REQUIRE(test.c_str()[1] == '\t'); + test = "\v\ta quick brown fox jumped over the road\v\t"; - test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); + REQUIRE(test.c_str()[0] == '\v'); + REQUIRE(test.c_str()[1] == '\t'); - REQUIRE(test.c_str()[0] == 'a'); - REQUIRE(test.c_str()[1] == ' '); + test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); - test = " \fa quick brown fox jumped over the road \f"; + REQUIRE(test.c_str()[0] == 'a'); + REQUIRE(test.c_str()[1] == ' '); - REQUIRE(test.c_str()[0] == ' '); - REQUIRE(test.c_str()[1] == '\f'); + test = " \fa quick brown fox jumped over the road \f"; - test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); + REQUIRE(test.c_str()[0] == ' '); + REQUIRE(test.c_str()[1] == '\f'); - REQUIRE(test.c_str()[0] == 'a'); - REQUIRE(test.c_str()[1] == ' '); + test = org::apache::nifi::minifi::utils::StringUtils::trimLeft(test); + REQUIRE(test.c_str()[0] == 'a'); + REQUIRE(test.c_str()[1] == ' '); } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/ProvenanceTestHelper.h ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/ProvenanceTestHelper.h b/libminifi/test/unit/ProvenanceTestHelper.h index 67b5c65..9dbff36 100644 --- a/libminifi/test/unit/ProvenanceTestHelper.h +++ b/libminifi/test/unit/ProvenanceTestHelper.h @@ -77,7 +77,7 @@ class TestRepository : public core::Repository { std::make_shared<provenance::ProvenanceEventRecord>(); if (eventRead->DeSerialize((uint8_t*) entry.second.data(), - entry.second.length())) { + entry.second.length())) { records.push_back(eventRead); } } @@ -141,7 +141,7 @@ class TestFlowRepository : public core::repository::FlowFileRepository { std::make_shared<provenance::ProvenanceEventRecord>(); if (eventRead->DeSerialize((uint8_t*) entry.second.data(), - entry.second.length())) { + entry.second.length())) { records.push_back(eventRead); } } @@ -154,12 +154,14 @@ class TestFlowRepository : public core::repository::FlowFileRepository { std::map<std::string, std::string> repositoryResults; }; -class TestFlowController : public minifi::FlowController{ +class TestFlowController : public minifi::FlowController { -public: + public: TestFlowController(std::shared_ptr<core::Repository> repo, std::shared_ptr<core::Repository> flow_file_repo) - : minifi::FlowController(repo, flow_file_repo, std::make_shared<minifi::Configure>(), nullptr, "",true) { + : minifi::FlowController(repo, flow_file_repo, + std::make_shared<minifi::Configure>(), nullptr, + "", true) { } ~TestFlowController() { @@ -206,10 +208,10 @@ public: } std::shared_ptr<minifi::Connection> createConnection(std::string name, - uuid_t uuid) { + uuid_t uuid) { return 0; } -protected: + protected: void initializePaths(const std::string &adjustedFilename) { } }; http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/ProvenanceTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/ProvenanceTests.cpp b/libminifi/test/unit/ProvenanceTests.cpp index 947932e..f5374b8 100644 --- a/libminifi/test/unit/ProvenanceTests.cpp +++ b/libminifi/test/unit/ProvenanceTests.cpp @@ -18,28 +18,28 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "../TestBase.h" -#include "../unit/ProvenanceTestHelper.h" - +#include <utility> +#include <memory> +#include <string> +#include <map> +#include "ProvenanceTestHelper.h" #include "provenance/Provenance.h" #include "FlowFileRecord.h" #include "core/Core.h" #include "core/repository/FlowFileRepository.h" TEST_CASE("Test Provenance record create", "[Testprovenance::ProvenanceEventRecord]") { - provenance::ProvenanceEventRecord record1( provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "blah", "blahblah"); REQUIRE(record1.getAttributes().size() == 0); REQUIRE(record1.getAlternateIdentifierUri().length() == 0); - } TEST_CASE("Test Provenance record serialization", "[Testprovenance::ProvenanceEventRecordSerializeDeser]") { - provenance::ProvenanceEventRecord record1( - provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "componentid", - "componenttype"); + provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, + "componentid", "componenttype"); std::string eventId = record1.getEventId(); @@ -47,12 +47,13 @@ TEST_CASE("Test Provenance record serialization", "[Testprovenance::ProvenanceEv record1.setDetails(smileyface); uint64_t sample = 65555; - std::shared_ptr<core::Repository> testRepository =std::make_shared<TestRepository>(); + std::shared_ptr<core::Repository> testRepository = std::make_shared< + TestRepository>(); record1.setEventDuration(sample); record1.Serialize(testRepository); provenance::ProvenanceEventRecord record2; - REQUIRE(record2.DeSerialize(testRepository,eventId) == true); + REQUIRE(record2.DeSerialize(testRepository, eventId) == true); REQUIRE(record2.getEventId() == record1.getEventId()); REQUIRE(record2.getComponentId() == record1.getComponentId()); REQUIRE(record2.getComponentType() == record1.getComponentType()); @@ -62,32 +63,33 @@ TEST_CASE("Test Provenance record serialization", "[Testprovenance::ProvenanceEv } TEST_CASE("Test Flowfile record added to provenance", "[TestFlowAndProv1]") { - provenance::ProvenanceEventRecord record1( - provenance::ProvenanceEventRecord::ProvenanceEventType::CLONE, "componentid", - "componenttype"); + provenance::ProvenanceEventRecord::ProvenanceEventType::CLONE, + "componentid", "componenttype"); std::string eventId = record1.getEventId(); std::map<std::string, std::string> attributes; attributes.insert(std::pair<std::string, std::string>("potato", "potatoe")); attributes.insert(std::pair<std::string, std::string>("tomato", "tomatoe")); - std::shared_ptr<core::repository::FlowFileRepository> frepo = std::make_shared<core::repository::FlowFileRepository>("./content_repository",0,0,0); + std::shared_ptr<core::repository::FlowFileRepository> frepo = + std::make_shared<core::repository::FlowFileRepository>( + "./content_repository", 0, 0, 0); std::shared_ptr<minifi::FlowFileRecord> ffr1 = std::make_shared< - minifi::FlowFileRecord>(frepo,attributes); + minifi::FlowFileRecord>(frepo, attributes); record1.addChildFlowFile(ffr1); - uint64_t sample = 65555; - std::shared_ptr<core::Repository> testRepository =std::make_shared<TestRepository>(); + uint64_t sample = 65555; + std::shared_ptr<core::Repository> testRepository = std::make_shared< + TestRepository>(); record1.setEventDuration(sample); record1.Serialize(testRepository); provenance::ProvenanceEventRecord record2; - REQUIRE(record2.DeSerialize(testRepository,eventId) == true); + REQUIRE(record2.DeSerialize(testRepository, eventId) == true); REQUIRE(record1.getChildrenUuids().size() == 1); REQUIRE(record2.getChildrenUuids().size() == 1); std::string childId = record2.getChildrenUuids().at(0); REQUIRE(childId == ffr1->getUUIDStr()); record2.removeChildUuid(childId); REQUIRE(record2.getChildrenUuids().size() == 0); - } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/RepoTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/RepoTests.cpp b/libminifi/test/unit/RepoTests.cpp index 83ea49d..4b6c4ad 100644 --- a/libminifi/test/unit/RepoTests.cpp +++ b/libminifi/test/unit/RepoTests.cpp @@ -17,8 +17,9 @@ */ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "../TestBase.h" -#include "../unit/ProvenanceTestHelper.h" - +#include <memory> +#include <string> +#include "ProvenanceTestHelper.h" #include "provenance/Provenance.h" #include "FlowFileRecord.h" #include "core/Core.h" @@ -26,18 +27,11 @@ #include "properties/Configure.h" TEST_CASE("Test Repo Empty Value Attribute", "[TestFFR1]") { - TestController testController; - - //testController.setDebugToConsole(); - char format[] = "/tmp/testRepo.XXXXXX"; char *dir = testController.createTempDirectory(format); std::shared_ptr<core::repository::FlowFileRepository> repository = - std::make_shared<core::repository::FlowFileRepository>( - dir, 0, - 0, - 1); + std::make_shared<core::repository::FlowFileRepository>(dir, 0, 0, 1); repository->initialize(std::make_shared<minifi::Configure>()); @@ -45,69 +39,44 @@ TEST_CASE("Test Repo Empty Value Attribute", "[TestFFR1]") { record.addAttribute("keyA", ""); - REQUIRE( true == record.Serialize() ); + REQUIRE(true == record.Serialize()); repository->stop(); - testController.setNullAppender(); - - } - - TEST_CASE("Test Repo Empty Key Attribute ", "[TestFFR2]") { - TestController testController; - - //testController.setDebugToConsole(); - char format[] = "/tmp/testRepo.XXXXXX"; char *dir = testController.createTempDirectory(format); std::shared_ptr<core::repository::FlowFileRepository> repository = - std::make_shared<core::repository::FlowFileRepository>( - dir, 0, - 0, - 1); + std::make_shared<core::repository::FlowFileRepository>(dir, 0, 0, 1); repository->initialize(std::make_shared<minifi::Configure>()); minifi::FlowFileRecord record(repository); - - record.addAttribute("keyA", "hasdgasdgjsdgasgdsgsadaskgasd"); record.addAttribute("", "hasdgasdgjsdgasgdsgsadaskgasd"); - - REQUIRE( true == record.Serialize() ); + REQUIRE(true == record.Serialize()); repository->stop(); - testController.setNullAppender(); - - } - TEST_CASE("Test Repo Key Attribute Verify ", "[TestFFR3]") { - TestController testController; - - //testController.setDebugToConsole(); - char format[] = "/tmp/testRepo.XXXXXX"; char *dir = testController.createTempDirectory(format); std::shared_ptr<core::repository::FlowFileRepository> repository = - std::make_shared<core::repository::FlowFileRepository>( - dir, 0, - 0, - 1); + std::make_shared<core::repository::FlowFileRepository>(dir, 0, 0, 1); - repository->initialize(std::make_shared<org::apache::nifi::minifi::Configure>()); + repository->initialize( + std::make_shared<org::apache::nifi::minifi::Configure>()); minifi::FlowFileRecord record(repository); @@ -115,7 +84,6 @@ TEST_CASE("Test Repo Key Attribute Verify ", "[TestFFR3]") { std::string uuid = record.getUUIDStr(); - record.addAttribute("keyA", "hasdgasdgjsdgasgdsgsadaskgasd"); record.addAttribute("keyB", ""); @@ -126,27 +94,21 @@ TEST_CASE("Test Repo Key Attribute Verify ", "[TestFFR3]") { record.addAttribute("", "sdgsdg"); - - - - REQUIRE( true == record.Serialize() ); + REQUIRE(true == record.Serialize()); repository->stop(); record2.DeSerialize(uuid); std::string value; - REQUIRE(true == record2.getAttribute("",value)); - - REQUIRE( "hasdgasdgjsdgasgdsgsadaskgasd2" == value); - - REQUIRE(false == record2.getAttribute("key",value)); - REQUIRE(true == record2.getAttribute("keyA",value)); - REQUIRE( "hasdgasdgjsdgasgdsgsadaskgasd" == value); - - REQUIRE(true == record2.getAttribute("keyB",value)); - REQUIRE( "" == value); + REQUIRE(true == record2.getAttribute("", value)); + REQUIRE("hasdgasdgjsdgasgdsgsadaskgasd2" == value); + REQUIRE(false == record2.getAttribute("key", value)); + REQUIRE(true == record2.getAttribute("keyA", value)); + REQUIRE("hasdgasdgjsdgasgdsgsadaskgasd" == value); + REQUIRE(true == record2.getAttribute("keyB", value)); + REQUIRE("" == value); } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/SerializationTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/SerializationTests.cpp b/libminifi/test/unit/SerializationTests.cpp index d9cea0f..1946a92 100644 --- a/libminifi/test/unit/SerializationTests.cpp +++ b/libminifi/test/unit/SerializationTests.cpp @@ -30,28 +30,24 @@ #include "../unit/SiteToSiteHelper.h" #define FMT_DEFAULT fmt_lower -using namespace org::apache::nifi::minifi::io; TEST_CASE("TestWriteUTF", "[MINIFI193]") { + org::apache::nifi::minifi::io::DataStream baseStream; - DataStream baseStream; + org::apache::nifi::minifi::io::Serializable ser; - Serializable ser; - - std::string stringOne = "helo world"; // yes, this has a typo. + std::string stringOne = "helo world"; // yes, this has a typo. std::string verifyString; ser.writeUTF(stringOne, &baseStream, false); ser.readUTF(verifyString, &baseStream, false); REQUIRE(verifyString == stringOne); - } TEST_CASE("TestWriteUTF2", "[MINIFI193]") { + org::apache::nifi::minifi::io::DataStream baseStream; - DataStream baseStream; - - Serializable ser; + org::apache::nifi::minifi::io::Serializable ser; std::string stringOne = "hel\xa1o world"; REQUIRE(11 == stringOne.length()); @@ -61,14 +57,12 @@ TEST_CASE("TestWriteUTF2", "[MINIFI193]") { ser.readUTF(verifyString, &baseStream, false); REQUIRE(verifyString == stringOne); - } TEST_CASE("TestWriteUTF3", "[MINIFI193]") { + org::apache::nifi::minifi::io::DataStream baseStream; - DataStream baseStream; - - Serializable ser; + org::apache::nifi::minifi::io::Serializable ser; std::string stringOne = "\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c"; REQUIRE(12 == stringOne.length()); @@ -78,6 +72,5 @@ TEST_CASE("TestWriteUTF3", "[MINIFI193]") { ser.readUTF(verifyString, &baseStream, false); REQUIRE(verifyString == stringOne); - } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/Site2SiteTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/Site2SiteTests.cpp b/libminifi/test/unit/Site2SiteTests.cpp index 43afa0e..4ccf012 100644 --- a/libminifi/test/unit/Site2SiteTests.cpp +++ b/libminifi/test/unit/Site2SiteTests.cpp @@ -17,28 +17,29 @@ */ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include <uuid/uuid.h> +#include <string> +#include <memory> +#include <utility> +#include <map> #include "io/BaseStream.h" #include "Site2SitePeer.h" #include "Site2SiteClientProtocol.h" -#include <uuid/uuid.h> #include "core/logging/LogAppenders.h" #include "core/logging/BaseLogger.h" #include <algorithm> -#include <string> -#include <memory> - #include "../TestBase.h" #include "../unit/SiteToSiteHelper.h" + #define FMT_DEFAULT fmt_lower -using namespace org::apache::nifi::minifi::io; TEST_CASE("TestSetPortId", "[S2S1]") { - - std::unique_ptr<minifi::Site2SitePeer> peer = - std::unique_ptr < minifi::Site2SitePeer - > (new minifi::Site2SitePeer( - std::unique_ptr < DataStream > (new DataStream()), "fake_host", - 65433)); + std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr< + minifi::Site2SitePeer>( + new minifi::Site2SitePeer( + std::unique_ptr<org::apache::nifi::minifi::io::DataStream>( + new org::apache::nifi::minifi::io::DataStream()), + "fake_host", 65433)); minifi::Site2SiteClientProtocol protocol(std::move(peer)); @@ -51,16 +52,15 @@ TEST_CASE("TestSetPortId", "[S2S1]") { protocol.setPortId(fakeUUID); REQUIRE(uuid_str == protocol.getPortId()); - } TEST_CASE("TestSetPortIdUppercase", "[S2S2]") { - - std::unique_ptr<minifi::Site2SitePeer> peer = - std::unique_ptr < minifi::Site2SitePeer - > (new minifi::Site2SitePeer( - std::unique_ptr < DataStream > (new DataStream()), "fake_host", - 65433)); + std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr< + minifi::Site2SitePeer>( + new minifi::Site2SitePeer( + std::unique_ptr<org::apache::nifi::minifi::io::DataStream>( + new org::apache::nifi::minifi::io::DataStream()), + "fake_host", 65433)); minifi::Site2SiteClientProtocol protocol(std::move(peer)); @@ -77,12 +77,10 @@ TEST_CASE("TestSetPortIdUppercase", "[S2S2]") { std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(), ::tolower); REQUIRE(uuid_str == protocol.getPortId()); - } void sunny_path_bootstrap(SiteToSiteResponder *collector) { - - char a = 0x14; // RESOURCE_OK + char a = 0x14; // RESOURCE_OK std::string resp_code; resp_code.insert(resp_code.begin(), a); collector->push_response(resp_code); @@ -104,22 +102,23 @@ void sunny_path_bootstrap(SiteToSiteResponder *collector) { TEST_CASE("TestSiteToSiteVerifySend", "[S2S3]") { std::ostringstream oss; - std::unique_ptr<logging::BaseLogger> outputLogger = std::unique_ptr< - logging::BaseLogger>( - new org::apache::nifi::minifi::core::logging::OutputStreamAppender( - std::cout, std::make_shared<minifi::Configure>())); - std::shared_ptr<logging::Logger> logger = logging::Logger::getLogger(); - logger->updateLogger(std::move(outputLogger)); - logger->setLogLevel("trace"); + std::unique_ptr<logging::BaseLogger> outputLogger = std::unique_ptr< + logging::BaseLogger>( + new org::apache::nifi::minifi::core::logging::OutputStreamAppender( + std::cout, std::make_shared<minifi::Configure>())); + std::shared_ptr<logging::Logger> logger = logging::Logger::getLogger(); + logger->updateLogger(std::move(outputLogger)); + logger->setLogLevel("trace"); SiteToSiteResponder *collector = new SiteToSiteResponder(); sunny_path_bootstrap(collector); - std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr - < minifi::Site2SitePeer - > (new minifi::Site2SitePeer( - std::unique_ptr < minifi::io::DataStream > (new BaseStream(collector)), "fake_host", - 65433)); + std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr< + minifi::Site2SitePeer>( + new minifi::Site2SitePeer( + std::unique_ptr<minifi::io::DataStream>( + new org::apache::nifi::minifi::io::BaseStream(collector)), + "fake_host", 65433)); minifi::Site2SiteClientProtocol protocol(std::move(peer)); @@ -160,7 +159,7 @@ TEST_CASE("TestSiteToSiteVerifySend", "[S2S3]") { REQUIRE(collector->get_next_client_response() == "NEGOTIATE_FLOWFILE_CODEC"); collector->get_next_client_response(); REQUIRE(collector->get_next_client_response() == "StandardFlowFileCodec"); - collector->get_next_client_response(); // codec version + collector->get_next_client_response(); // codec version // start to send the stuff // Create the transaction @@ -170,19 +169,16 @@ TEST_CASE("TestSiteToSiteVerifySend", "[S2S3]") { transaction = protocol.createTransaction(transactionID, minifi::SEND); collector->get_next_client_response(); REQUIRE(collector->get_next_client_response() == "SEND_FLOWFILES"); - std::map < std::string, std::string > attributes; + std::map<std::string, std::string> attributes; minifi::DataPacket packet(&protocol, transaction, attributes, payload); REQUIRE(protocol.send(transactionID, &packet, nullptr, nullptr) == true); collector->get_next_client_response(); collector->get_next_client_response(); std::string rx_payload = collector->get_next_client_response(); - ; REQUIRE(payload == rx_payload); - } TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S4]") { - SiteToSiteResponder *collector = new SiteToSiteResponder(); char a = 0xFF; @@ -191,11 +187,12 @@ TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S4]") { collector->push_response(resp_code); collector->push_response(resp_code); - std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr - < minifi::Site2SitePeer - > (new minifi::Site2SitePeer( - std::unique_ptr < minifi::io::DataStream > (new BaseStream(collector)), "fake_host", - 65433)); + std::unique_ptr<minifi::Site2SitePeer> peer = std::unique_ptr< + minifi::Site2SitePeer>( + new minifi::Site2SitePeer( + std::unique_ptr<minifi::io::DataStream>( + new org::apache::nifi::minifi::io::BaseStream(collector)), + "fake_host", 65433)); minifi::Site2SiteClientProtocol protocol(std::move(peer)); @@ -208,5 +205,4 @@ TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S4]") { protocol.setPortId(fakeUUID); REQUIRE(false == protocol.bootstrap()); - } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/SiteToSiteHelper.h ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/SiteToSiteHelper.h b/libminifi/test/unit/SiteToSiteHelper.h index 8c33396..1876bde 100755 --- a/libminifi/test/unit/SiteToSiteHelper.h +++ b/libminifi/test/unit/SiteToSiteHelper.h @@ -25,11 +25,11 @@ /** * Test repository */ -class SiteToSiteResponder: public minifi::io::BaseStream { -private: +class SiteToSiteResponder : public minifi::io::BaseStream { + private: std::queue<std::string> server_responses_; std::queue<std::string> client_responses_; -public: + public: SiteToSiteResponder() { } // initialize @@ -80,7 +80,7 @@ public: * @return resulting read size **/ virtual int read(uint16_t &base_value, bool is_little_endian = - minifi::io::EndiannessCheck::IS_LITTLE) { + minifi::io::EndiannessCheck::IS_LITTLE) { base_value = std::stoi(get_next_response()); return 2; } @@ -123,7 +123,7 @@ public: * @return resulting read size **/ virtual int read(uint32_t &value, bool is_little_endian = - minifi::io::EndiannessCheck::IS_LITTLE) { + minifi::io::EndiannessCheck::IS_LITTLE) { value = std::stoul(get_next_response()); return 4; } @@ -135,7 +135,7 @@ public: * @return resulting read size **/ virtual int read(uint64_t &value, bool is_little_endian = - minifi::io::EndiannessCheck::IS_LITTLE) { + minifi::io::EndiannessCheck::IS_LITTLE) { value = std::stoull(get_next_response()); return 8; } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/SocketTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/SocketTests.cpp b/libminifi/test/unit/SocketTests.cpp index 157e685..5a53b47 100644 --- a/libminifi/test/unit/SocketTests.cpp +++ b/libminifi/test/unit/SocketTests.cpp @@ -19,21 +19,25 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "../TestBase.h" +#include <memory> +#include <vector> #include "io/ClientSocket.h" -using namespace org::apache::nifi::minifi::io; TEST_CASE("TestSocket", "[TestSocket1]") { - - Socket socket(std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()), "localhost", 8183); + org::apache::nifi::minifi::io::Socket socket( + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()), + "localhost", 8183); REQUIRE(-1 == socket.initialize()); REQUIRE("localhost" == socket.getHostname()); socket.closeStream(); - } TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") { - - Socket socket(std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()), "localhost", 8183); + org::apache::nifi::minifi::io::Socket socket( + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()), + "localhost", 8183); REQUIRE(-1 == socket.initialize()); socket.writeData(0, 0); @@ -44,21 +48,23 @@ TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") { REQUIRE(-1 == socket.writeData(buffer, 1)); socket.closeStream(); - } TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") { - std::vector<uint8_t> buffer; buffer.push_back('a'); - - std::shared_ptr<SocketContext> socket_context = std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()); - Socket server(socket_context, "localhost", 9183, 1); + std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()); + + org::apache::nifi::minifi::io::Socket server(socket_context, "localhost", + 9183, 1); REQUIRE(-1 != server.initialize()); - Socket client(socket_context, "localhost", 9183); + org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", + 9183); REQUIRE(-1 != client.initialize()); @@ -74,27 +80,27 @@ TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") { server.closeStream(); client.closeStream(); - } TEST_CASE("TestGetHostName", "[TestSocket4]") { - - REQUIRE(Socket::getMyHostName().length() > 0); - + REQUIRE(org::apache::nifi::minifi::io::Socket::getMyHostName().length() > 0); } TEST_CASE("TestWriteEndian64", "[TestSocket4]") { - std::vector<uint8_t> buffer; buffer.push_back('a'); - - std::shared_ptr<SocketContext> socket_context = std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()); - Socket server(socket_context, "localhost", 9183, 1); + std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()); + + org::apache::nifi::minifi::io::Socket server(socket_context, "localhost", + 9183, 1); REQUIRE(-1 != server.initialize()); - Socket client(socket_context, "localhost", 9183); + org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", + 9183); REQUIRE(-1 != client.initialize()); @@ -109,24 +115,25 @@ TEST_CASE("TestWriteEndian64", "[TestSocket4]") { server.closeStream(); client.closeStream(); - } TEST_CASE("TestWriteEndian32", "[TestSocket5]") { - std::vector<uint8_t> buffer; buffer.push_back('a'); - std::shared_ptr<SocketContext> socket_context = std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()); - - Socket server(socket_context, "localhost", 9183, 1); + std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()); + + org::apache::nifi::minifi::io::Socket server(socket_context, "localhost", + 9183, 1); REQUIRE(-1 != server.initialize()); - Socket client(socket_context, "localhost", 9183); + org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", + 9183); REQUIRE(-1 != client.initialize()); - { uint32_t negative_one = -1; REQUIRE(4 == client.write(negative_one)); @@ -136,7 +143,6 @@ TEST_CASE("TestWriteEndian32", "[TestSocket5]") { REQUIRE(negative_two == negative_one); } - { uint16_t negative_one = -1; REQUIRE(2 == client.write(negative_one)); @@ -149,21 +155,23 @@ TEST_CASE("TestWriteEndian32", "[TestSocket5]") { server.closeStream(); client.closeStream(); - } TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket6]") { - std::vector<uint8_t> buffer; buffer.push_back('a'); - std::shared_ptr<SocketContext> socket_context = std::make_shared<SocketContext>(std::make_shared<minifi::Configure>()); - - Socket server(socket_context, "localhost", 9183, 1); + std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = + std::make_shared<org::apache::nifi::minifi::io::SocketContext>( + std::make_shared<minifi::Configure>()); + + org::apache::nifi::minifi::io::Socket server(socket_context, "localhost", + 9183, 1); REQUIRE(-1 != server.initialize()); - Socket client(socket_context, "localhost", 9183); + org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", + 9183); REQUIRE(-1 != client.initialize()); @@ -181,5 +189,4 @@ TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket6]") { REQUIRE(-1 == client.writeData(buffer, 1)); server.closeStream(); - } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/Tests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/Tests.cpp b/libminifi/test/unit/Tests.cpp index a826f3a..291fc2f 100644 --- a/libminifi/test/unit/Tests.cpp +++ b/libminifi/test/unit/Tests.cpp @@ -18,11 +18,9 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file - - #include "utils/TimeUtil.h" #include "../TestBase.h" -TEST_CASE("Test time conversion", "[testtimeconversion]"){ - REQUIRE ( "2017-02-16 20:14:56.196" == getTimeStr(1487276096196,true) ); +TEST_CASE("Test time conversion", "[testtimeconversion]") { + REQUIRE("2017-02-16 20:14:56.196" == getTimeStr(1487276096196, true)); } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/ThreadPoolTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/ThreadPoolTests.cpp b/libminifi/test/unit/ThreadPoolTests.cpp index cd34293..0fa75e6 100644 --- a/libminifi/test/unit/ThreadPoolTests.cpp +++ b/libminifi/test/unit/ThreadPoolTests.cpp @@ -17,6 +17,7 @@ */ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include <utility> #include <future> #include "../TestBase.h" #include "utils/ThreadPool.h" @@ -31,9 +32,6 @@ TEST_CASE("ThreadPoolTest1", "[TPT1]") { utils::Worker<bool> functor(f_ex); pool.start(); std::future<bool> fut = pool.execute(std::move(functor)); - fut.wait(); - REQUIRE(true == fut.get()); - } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/libminifi/test/unit/YamlConfigurationTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/YamlConfigurationTests.cpp b/libminifi/test/unit/YamlConfigurationTests.cpp index f958ca1..a7ed5df 100644 --- a/libminifi/test/unit/YamlConfigurationTests.cpp +++ b/libminifi/test/unit/YamlConfigurationTests.cpp @@ -17,7 +17,7 @@ */ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file - +#include <map> #include <memory> #include <string> #include <core/RepositoryFactory.h> @@ -25,169 +25,168 @@ #include "../TestBase.h" TEST_CASE("Test YAML Config Processing", "[YamlConfiguration]") { - - std::shared_ptr<core::Repository> testProvRepo = core::createRepository("provenancerepository", true); - std::shared_ptr<core::Repository> testFlowFileRepo = core::createRepository("flowfilerepository", true); - std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>(); - std::shared_ptr<minifi::io::StreamFactory> streamFactory = std::make_shared<minifi::io::StreamFactory>(configuration); - core::YamlConfiguration *yamlConfig = new core::YamlConfiguration(testProvRepo, testFlowFileRepo, streamFactory, configuration); + std::shared_ptr<core::Repository> testProvRepo = core::createRepository( + "provenancerepository", true); + std::shared_ptr<core::Repository> testFlowFileRepo = core::createRepository( + "flowfilerepository", true); + std::shared_ptr<minifi::Configure> configuration = std::make_shared< + minifi::Configure>(); + std::shared_ptr<minifi::io::StreamFactory> streamFactory = std::make_shared< + minifi::io::StreamFactory>(configuration); + core::YamlConfiguration *yamlConfig = new core::YamlConfiguration( + testProvRepo, testFlowFileRepo, streamFactory, configuration); SECTION("loading YAML without optional component IDs works") { + static const std::string CONFIG_YAML_WITHOUT_IDS = "" + "MiNiFi Config Version: 1\n" + "Flow Controller:\n" + " name: MiNiFi Flow\n" + " comment:\n" + "\n" + "Core Properties:\n" + " flow controller graceful shutdown period: 10 sec\n" + " flow service write delay interval: 500 ms\n" + " administrative yield duration: 30 sec\n" + " bored yield duration: 10 millis\n" + "\n" + "FlowFile Repository:\n" + " partitions: 256\n" + " checkpoint interval: 2 mins\n" + " always sync: false\n" + " Swap:\n" + " threshold: 20000\n" + " in period: 5 sec\n" + " in threads: 1\n" + " out period: 5 sec\n" + " out threads: 4\n" + "\n" + "Provenance Repository:\n" + " provenance rollover time: 1 min\n" + "\n" + "Content Repository:\n" + " content claim max appendable size: 10 MB\n" + " content claim max flow files: 100\n" + " always sync: false\n" + "\n" + "Component Status Repository:\n" + " buffer size: 1440\n" + " snapshot frequency: 1 min\n" + "\n" + "Security Properties:\n" + " keystore: /tmp/ssl/localhost-ks.jks\n" + " keystore type: JKS\n" + " keystore password: localtest\n" + " key password: localtest\n" + " truststore: /tmp/ssl/localhost-ts.jks\n" + " truststore type: JKS\n" + " truststore password: localtest\n" + " ssl protocol: TLS\n" + " Sensitive Props:\n" + " key:\n" + " algorithm: PBEWITHMD5AND256BITAES-CBC-OPENSSL\n" + " provider: BC\n" + "\n" + "Processors:\n" + " - name: TailFile\n" + " class: org.apache.nifi.processors.standard.TailFile\n" + " max concurrent tasks: 1\n" + " scheduling strategy: TIMER_DRIVEN\n" + " scheduling period: 1 sec\n" + " penalization period: 30 sec\n" + " yield period: 1 sec\n" + " run duration nanos: 0\n" + " auto-terminated relationships list:\n" + " Properties:\n" + " File to Tail: logs/minifi-app.log\n" + " Rolling Filename Pattern: minifi-app*\n" + " Initial Start Position: Beginning of File\n" + "\n" + "Connections:\n" + " - name: TailToS2S\n" + " source name: TailFile\n" + " source relationship name: success\n" + " destination name: 8644cbcc-a45c-40e0-964d-5e536e2ada61\n" + " max work queue size: 0\n" + " max work queue data size: 1 MB\n" + " flowfile expiration: 60 sec\n" + " queue prioritizer class: org.apache.nifi.prioritizer.NewestFlowFileFirstPrioritizer\n" + "\n" + "Remote Processing Groups:\n" + " - name: NiFi Flow\n" + " comment:\n" + " url: https://localhost:8090/nifi\n" + " timeout: 30 secs\n" + " yield period: 10 sec\n" + " Input Ports:\n" + " - id: 8644cbcc-a45c-40e0-964d-5e536e2ada61\n" + " name: tailed log\n" + " comments:\n" + " max concurrent tasks: 1\n" + " use compression: false\n" + "\n" + "Provenance Reporting:\n" + " comment:\n" + " scheduling strategy: TIMER_DRIVEN\n" + " scheduling period: 30 sec\n" + " host: localhost\n" + " port name: provenance\n" + " port: 8090\n" + " port uuid: 2f389b8d-83f2-48d3-b465-048f28a1cb56\n" + " destination url: https://localhost:8090/\n" + " originating url: http://${hostname(true)}:8081/nifi\n" + " use compression: true\n" + " timeout: 30 secs\n" + " batch size: 1000"; - static const std::string CONFIG_YAML_WITHOUT_IDS = "" - "MiNiFi Config Version: 1\n" - "Flow Controller:\n" - " name: MiNiFi Flow\n" - " comment:\n" - "\n" - "Core Properties:\n" - " flow controller graceful shutdown period: 10 sec\n" - " flow service write delay interval: 500 ms\n" - " administrative yield duration: 30 sec\n" - " bored yield duration: 10 millis\n" - "\n" - "FlowFile Repository:\n" - " partitions: 256\n" - " checkpoint interval: 2 mins\n" - " always sync: false\n" - " Swap:\n" - " threshold: 20000\n" - " in period: 5 sec\n" - " in threads: 1\n" - " out period: 5 sec\n" - " out threads: 4\n" - "\n" - "Provenance Repository:\n" - " provenance rollover time: 1 min\n" - "\n" - "Content Repository:\n" - " content claim max appendable size: 10 MB\n" - " content claim max flow files: 100\n" - " always sync: false\n" - "\n" - "Component Status Repository:\n" - " buffer size: 1440\n" - " snapshot frequency: 1 min\n" - "\n" - "Security Properties:\n" - " keystore: /tmp/ssl/localhost-ks.jks\n" - " keystore type: JKS\n" - " keystore password: localtest\n" - " key password: localtest\n" - " truststore: /tmp/ssl/localhost-ts.jks\n" - " truststore type: JKS\n" - " truststore password: localtest\n" - " ssl protocol: TLS\n" - " Sensitive Props:\n" - " key:\n" - " algorithm: PBEWITHMD5AND256BITAES-CBC-OPENSSL\n" - " provider: BC\n" - "\n" - "Processors:\n" - " - name: TailFile\n" - " class: org.apache.nifi.processors.standard.TailFile\n" - " max concurrent tasks: 1\n" - " scheduling strategy: TIMER_DRIVEN\n" - " scheduling period: 1 sec\n" - " penalization period: 30 sec\n" - " yield period: 1 sec\n" - " run duration nanos: 0\n" - " auto-terminated relationships list:\n" - " Properties:\n" - " File to Tail: logs/minifi-app.log\n" - " Rolling Filename Pattern: minifi-app*\n" - " Initial Start Position: Beginning of File\n" - "\n" - "Connections:\n" - " - name: TailToS2S\n" - " source name: TailFile\n" - " source relationship name: success\n" - " destination name: 8644cbcc-a45c-40e0-964d-5e536e2ada61\n" - " max work queue size: 0\n" - " max work queue data size: 1 MB\n" - " flowfile expiration: 60 sec\n" - " queue prioritizer class: org.apache.nifi.prioritizer.NewestFlowFileFirstPrioritizer\n" - "\n" - "Remote Processing Groups:\n" - " - name: NiFi Flow\n" - " comment:\n" - " url: https://localhost:8090/nifi\n" - " timeout: 30 secs\n" - " yield period: 10 sec\n" - " Input Ports:\n" - " - id: 8644cbcc-a45c-40e0-964d-5e536e2ada61\n" - " name: tailed log\n" - " comments:\n" - " max concurrent tasks: 1\n" - " use compression: false\n" - "\n" - "Provenance Reporting:\n" - " comment:\n" - " scheduling strategy: TIMER_DRIVEN\n" - " scheduling period: 30 sec\n" - " host: localhost\n" - " port name: provenance\n" - " port: 8090\n" - " port uuid: 2f389b8d-83f2-48d3-b465-048f28a1cb56\n" - " destination url: https://localhost:8090/\n" - " originating url: http://${hostname(true)}:8081/nifi\n" - " use compression: true\n" - " timeout: 30 secs\n" - " batch size: 1000"; + std::istringstream configYamlStream(CONFIG_YAML_WITHOUT_IDS); + std::unique_ptr<core::ProcessGroup> rootFlowConfig = yamlConfig->getRoot(configYamlStream); - std::istringstream configYamlStream(CONFIG_YAML_WITHOUT_IDS); - std::unique_ptr<core::ProcessGroup> rootFlowConfig = yamlConfig->getRoot(configYamlStream); + REQUIRE(rootFlowConfig); + REQUIRE(rootFlowConfig->findProcessor("TailFile")); + REQUIRE(NULL != rootFlowConfig->findProcessor("TailFile")->getUUID()); + REQUIRE(!rootFlowConfig->findProcessor("TailFile")->getUUIDStr().empty()); + REQUIRE(1 == rootFlowConfig->findProcessor("TailFile")->getMaxConcurrentTasks()); + REQUIRE(core::SchedulingStrategy::TIMER_DRIVEN == rootFlowConfig->findProcessor("TailFile")->getSchedulingStrategy()); + REQUIRE(1 == rootFlowConfig->findProcessor("TailFile")->getMaxConcurrentTasks()); + REQUIRE(1*1000*1000*1000 == rootFlowConfig->findProcessor("TailFile")->getSchedulingPeriodNano()); + REQUIRE(30*1000 == rootFlowConfig->findProcessor("TailFile")->getPenalizationPeriodMsec()); + REQUIRE(1*1000 == rootFlowConfig->findProcessor("TailFile")->getYieldPeriodMsec()); + REQUIRE(0 == rootFlowConfig->findProcessor("TailFile")->getRunDurationNano()); - REQUIRE(rootFlowConfig); - REQUIRE(rootFlowConfig->findProcessor("TailFile")); - REQUIRE(NULL != rootFlowConfig->findProcessor("TailFile")->getUUID()); - REQUIRE(!rootFlowConfig->findProcessor("TailFile")->getUUIDStr().empty()); - REQUIRE(1 == rootFlowConfig->findProcessor("TailFile")->getMaxConcurrentTasks()); - REQUIRE(core::SchedulingStrategy::TIMER_DRIVEN == rootFlowConfig->findProcessor("TailFile")->getSchedulingStrategy()); - REQUIRE(1 == rootFlowConfig->findProcessor("TailFile")->getMaxConcurrentTasks()); - REQUIRE(1*1000*1000*1000 == rootFlowConfig->findProcessor("TailFile")->getSchedulingPeriodNano()); - REQUIRE(30*1000 == rootFlowConfig->findProcessor("TailFile")->getPenalizationPeriodMsec()); - REQUIRE(1*1000 == rootFlowConfig->findProcessor("TailFile")->getYieldPeriodMsec()); - REQUIRE(0 == rootFlowConfig->findProcessor("TailFile")->getRunDurationNano()); - - std::map<std::string, std::shared_ptr<minifi::Connection>> connectionMap; - rootFlowConfig->getConnections(connectionMap); - REQUIRE(1 == connectionMap.size()); - // This is a map of UUID->Connection, and we don't know UUID, so just going to loop over it - for( - std::map<std::string,std::shared_ptr<minifi::Connection>>::iterator it = connectionMap.begin(); - it != connectionMap.end(); - ++it) { - REQUIRE(it->second); - REQUIRE(!it->second->getUUIDStr().empty()); - REQUIRE(it->second->getDestination()); - REQUIRE(it->second->getSource()); - } + std::map<std::string, std::shared_ptr<minifi::Connection>> connectionMap; + rootFlowConfig->getConnections(connectionMap); + REQUIRE(1 == connectionMap.size()); + // This is a map of UUID->Connection, and we don't know UUID, so just going to loop over it + for (auto it : connectionMap) { + REQUIRE(it.second); + REQUIRE(!it.second->getUUIDStr().empty()); + REQUIRE(it.second->getDestination()); + REQUIRE(it.second->getSource()); } +} SECTION("missing required field in YAML throws exception") { + static const std::string CONFIG_YAML_NO_RPG_PORT_ID = "" + "MiNiFi Config Version: 1\n" + "Flow Controller:\n" + " name: MiNiFi Flow\n" + "Processors: []\n" + "Connections: []\n" + "Remote Processing Groups:\n" + " - name: NiFi Flow\n" + " comment:\n" + " url: https://localhost:8090/nifi\n" + " timeout: 30 secs\n" + " yield period: 10 sec\n" + " Input Ports:\n" + " - name: tailed log\n" + " comments:\n" + " max concurrent tasks: 1\n" + " use compression: false\n" + "\n"; - static const std::string CONFIG_YAML_NO_RPG_PORT_ID = "" - "MiNiFi Config Version: 1\n" - "Flow Controller:\n" - " name: MiNiFi Flow\n" - "Processors: []\n" - "Connections: []\n" - "Remote Processing Groups:\n" - " - name: NiFi Flow\n" - " comment:\n" - " url: https://localhost:8090/nifi\n" - " timeout: 30 secs\n" - " yield period: 10 sec\n" - " Input Ports:\n" - " - name: tailed log\n" - " comments:\n" - " max concurrent tasks: 1\n" - " use compression: false\n" - "\n"; - - std::istringstream configYamlStream(CONFIG_YAML_NO_RPG_PORT_ID); - REQUIRE_THROWS_AS(yamlConfig->getRoot(configYamlStream), std::invalid_argument); - } + std::istringstream configYamlStream(CONFIG_YAML_NO_RPG_PORT_ID); + REQUIRE_THROWS_AS(yamlConfig->getRoot(configYamlStream), std::invalid_argument); +} } http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/63c53bcf/thirdparty/google-styleguide/run_linter.sh ---------------------------------------------------------------------- diff --git a/thirdparty/google-styleguide/run_linter.sh b/thirdparty/google-styleguide/run_linter.sh index fbf8730..102145f 100755 --- a/thirdparty/google-styleguide/run_linter.sh +++ b/thirdparty/google-styleguide/run_linter.sh @@ -26,4 +26,4 @@ HEADERS=`find ${1} -name '*.h' | tr '\n' ','` SOURCES=`find ${2} -name '*.cpp' | tr '\n' ' '` echo ${HEADERS} echo ${SOURCES} -python ${SCRIPT_DIR}/cpplint.py --linelength=128 --headers=${HEADERS} ${SOURCES} +python ${SCRIPT_DIR}/cpplint.py --linelength=200 --headers=${HEADERS} ${SOURCES}
