martinzink commented on code in PR #1543:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1543#discussion_r1155846613
##########
extensions/standard-processors/tests/unit/ConfigurationTests.cpp:
##########
@@ -53,4 +54,130 @@ TEST_CASE("Configuration can validate values to be assigned
to specific properti
REQUIRE(Configuration::validatePropertyValue("random.property",
"random_value"));
}
+TEST_CASE("Configuration can fix misconfigured timeperiod<->integer validated
properties") {
+ LogTestController::getInstance().setInfo<minifi::Configure>();
+ LogTestController::getInstance().setInfo<minifi::Properties>();
+
+ auto properties_path = std::filesystem::temp_directory_path() /
"test.properties";
+
+ {
+ std::ofstream properties_file(properties_path);
+ properties_file << "nifi.c2.agent.heartbeat.period=1min" << std::endl;
+ properties_file << "nifi.administrative.yield.duration=30000" << std::endl;
+ properties_file.close();
+ }
+ auto properties_file_time_after_creation =
std::filesystem::last_write_time(properties_path);
+ const std::shared_ptr<minifi::Configure> configure =
std::make_shared<minifi::Configure>();
+
+ configure->loadConfigureFile(properties_path);
+ CHECK(configure->get("nifi.c2.agent.heartbeat.period") == "60000");
+ CHECK(configure->get("nifi.administrative.yield.duration") == "30000 ms");
+
+ {
+ CHECK(properties_file_time_after_creation ==
std::filesystem::last_write_time(properties_path));
+ std::ifstream properties_file(properties_path);
+ std::string first_line;
+ std::string second_line;
+ CHECK(std::getline(properties_file, first_line));
+ CHECK(std::getline(properties_file, second_line));
+ CHECK(first_line == "nifi.c2.agent.heartbeat.period=1min");
+ CHECK(second_line == "nifi.administrative.yield.duration=30000");
+ }
+
+ CHECK(configure->commitChanges());
+
+ {
+ CHECK(properties_file_time_after_creation <=
std::filesystem::last_write_time(properties_path));
+ std::ifstream properties_file(properties_path);
+ std::string first_line;
+ std::string second_line;
+ CHECK(std::getline(properties_file, first_line));
+ CHECK(std::getline(properties_file, second_line));
+ CHECK(first_line == "nifi.c2.agent.heartbeat.period=60000");
+ CHECK(second_line == "nifi.administrative.yield.duration=30000 ms");
+ }
+}
+
+TEST_CASE("Configuration can fix misconfigured datasize<->integer validated
properties") {
+ LogTestController::getInstance().setInfo<minifi::Configure>();
+ LogTestController::getInstance().setInfo<minifi::Properties>();
+
+ auto properties_path = std::filesystem::temp_directory_path() /
"test.properties";
+
+ {
+ std::ofstream properties_file(properties_path);
+ properties_file << "appender.rolling.max_file_size=6000" << std::endl;
+ properties_file.close();
+ }
+ auto properties_file_time_after_creation =
std::filesystem::last_write_time(properties_path);
+ const std::shared_ptr<minifi::Configure> configure =
std::make_shared<minifi::Configure>();
+
+ configure->loadConfigureFile(properties_path, "nifi.log.");
+ CHECK(configure->get("appender.rolling.max_file_size") == "6000 B");
+
+ {
+ CHECK(properties_file_time_after_creation <=
std::filesystem::last_write_time(properties_path));
+ std::ifstream properties_file(properties_path);
+ std::string first_line;
+ CHECK(std::getline(properties_file, first_line));
+ CHECK(first_line == "appender.rolling.max_file_size=6000");
+ }
+
+ CHECK(configure->commitChanges());
+
+ {
+ CHECK(properties_file_time_after_creation <=
std::filesystem::last_write_time(properties_path));
+ std::ifstream properties_file(properties_path);
+ std::string first_line;
+ CHECK(std::getline(properties_file, first_line));
+ CHECK(first_line == "appender.rolling.max_file_size=6000 B");
+ }
+}
+
+
+TEST_CASE("Configuration misconfigured validated properties with in
environmental variables") {
Review Comment:
fixed it in
https://github.com/apache/nifi-minifi-cpp/pull/1543/commits/64c5975e3fda0911820465778fa4d73f16d12002#diff-245bd52b73142917446d5f4b4ca2a752e2a7131635f8609b50502849d4159f28R138
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]