This is an automated email from the ASF dual-hosted git repository.

fgerlits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 828fc38  MINIFICPP-1510 Register and fix InvokeHTTPTests
828fc38 is described below

commit 828fc38faf9f71e8bc590873f121deab1062cb71
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Wed Apr 21 16:04:20 2021 +0200

    MINIFICPP-1510 Register and fix InvokeHTTPTests
    
    Enable all tests in http-curl cmake file
    Remove leading spaces with tabs in cmake file
    Rename generic processor variable to listenhttp
    Remove unnecessary getCurrentFlowFile calls
    
    Signed-off-by: Ferenc Gerlits <[email protected]>
    
    This closes #1059
---
 extensions/http-curl/tests/CMakeLists.txt          | 31 +++++++--------
 .../http-curl/tests/unit/InvokeHTTPTests.cpp       | 45 +++++++++++++---------
 2 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/extensions/http-curl/tests/CMakeLists.txt 
b/extensions/http-curl/tests/CMakeLists.txt
index c182bf2..3ca8438 100644
--- a/extensions/http-curl/tests/CMakeLists.txt
+++ b/extensions/http-curl/tests/CMakeLists.txt
@@ -23,8 +23,8 @@ file(GLOB CURL_INTEGRATION_TESTS "*.cpp")
 SET(CURL_INT_TEST_COUNT 0)
 
 FOREACH(testfile ${CURL_UNIT_TESTS})
-       get_filename_component(testfilename "${testfile}" NAME_WE)
-       add_executable("${testfilename}" "${testfile}")
+       get_filename_component(testfilename "${testfile}" NAME_WE)
+       add_executable("${testfilename}" "${testfile}")
        target_include_directories(${testfilename} BEFORE PRIVATE 
"${CMAKE_SOURCE_DIR}/libminifi/test/")
        target_include_directories(${testfilename} BEFORE PRIVATE 
"${CMAKE_SOURCE_DIR}/extensions/standard-processors/")
        target_include_directories(${testfilename} BEFORE PRIVATE "../")
@@ -34,19 +34,19 @@ FOREACH(testfile ${CURL_UNIT_TESTS})
        target_include_directories(${testfilename} BEFORE PRIVATE 
"../sitetosite/")
        target_include_directories(${testfilename} BEFORE PRIVATE 
"${CMAKE_SOURCE_DIR}/extensions/civetweb/")
        target_include_directories(${testfilename} BEFORE PRIVATE ./include)
-    createTests("${testfilename}")
-    target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
+       createTests("${testfilename}")
+       target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
        target_wholearchive_library(${testfilename} minifi-http-curl)
        target_wholearchive_library(${testfilename} minifi-civet-extensions)
        target_wholearchive_library(${testfilename} minifi-standard-processors)
 
-       MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1")
-#       add_test(NAME "${testfilename}" COMMAND "${testfilename}" 
WORKING_DIRECTORY ${TEST_DIR})
+       MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1")
+       add_test(NAME "${testfilename}" COMMAND "${testfilename}" 
WORKING_DIRECTORY ${TEST_DIR})
 ENDFOREACH()
 
 FOREACH(testfile ${CURL_INTEGRATION_TESTS})
-       get_filename_component(testfilename "${testfile}" NAME_WE)
-       add_executable("${testfilename}" "${testfile}")
+       get_filename_component(testfilename "${testfile}" NAME_WE)
+       add_executable("${testfilename}" "${testfile}")
        target_include_directories(${testfilename} BEFORE PRIVATE 
"${CMAKE_SOURCE_DIR}/libminifi/test/")
        target_include_directories(${testfilename} BEFORE PRIVATE 
"${CMAKE_SOURCE_DIR}/extensions/standard-processors/")
        target_include_directories(${testfilename} BEFORE PRIVATE "../")
@@ -61,14 +61,11 @@ FOREACH(testfile ${CURL_INTEGRATION_TESTS})
        target_wholearchive_library(${testfilename} minifi-civet-extensions)
        target_wholearchive_library(${testfilename} minifi-standard-processors)
 
-    MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1")
+       MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1")
 ENDFOREACH()
 
 message("-- Finished building ${CURL_INT_TEST_COUNT} libcURL integration test 
file(s)...")
 
-add_test(NAME HTTPClientTests COMMAND "HTTPClientTests" WORKING_DIRECTORY 
${TEST_DIR})
-add_test(NAME HTTPStreamingCallbackTests COMMAND "HTTPStreamingCallbackTests" 
WORKING_DIRECTORY ${TEST_DIR})
-
 add_test(NAME HttpGetIntegrationTest COMMAND HttpGetIntegrationTest 
"${TEST_RESOURCES}/TestHTTPGet.yml"  "${TEST_RESOURCES}/")
 add_test(NAME C2UpdateTest COMMAND C2UpdateTest 
"${TEST_RESOURCES}/TestHTTPGet.yml"  "${TEST_RESOURCES}/")
 add_test(NAME C2FetchFlowIfMissingTest COMMAND C2FetchFlowIfMissingTest 
"${TEST_RESOURCES}/TestEmpty.yml"  "${TEST_RESOURCES}/")
@@ -80,14 +77,14 @@ add_test(NAME C2UpdateAgentTest COMMAND C2UpdateAgentTest 
"${TEST_RESOURCES}/Tes
 add_test(NAME C2FailedUpdateTest COMMAND C2FailedUpdateTest 
"${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/" 
"${TEST_RESOURCES}/TestBad.yml")
 add_test(NAME C2NullConfiguration COMMAND C2NullConfiguration 
"${TEST_RESOURCES}/TestNull.yml"  "${TEST_RESOURCES}/")
 add_test(NAME C2RequestClassTest COMMAND C2RequestClassTest)
-if(NOT OPENSSL_OFF)
-add_test(NAME HttpGetIntegrationTestSecure COMMAND HttpGetIntegrationTest 
"${TEST_RESOURCES}/TestHTTPGetSecure.yml"  "${TEST_RESOURCES}/")
-add_test(NAME C2VerifyHeartbeatAndStopSecure COMMAND C2VerifyHeartbeatAndStop 
"${TEST_RESOURCES}/C2VerifyHeartbeatAndStopSecure.yml" "${TEST_RESOURCES}/")
-add_test(NAME VerifyInvokeHTTPTestSecure COMMAND VerifyInvokeHTTPTest 
"${TEST_RESOURCES}/TestInvokeHTTPPostSecure.yml" "${TEST_RESOURCES}/")
+if (NOT OPENSSL_OFF)
+       add_test(NAME HttpGetIntegrationTestSecure COMMAND 
HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGetSecure.yml"  
"${TEST_RESOURCES}/")
+       add_test(NAME C2VerifyHeartbeatAndStopSecure COMMAND 
C2VerifyHeartbeatAndStop "${TEST_RESOURCES}/C2VerifyHeartbeatAndStopSecure.yml" 
"${TEST_RESOURCES}/")
+       add_test(NAME VerifyInvokeHTTPTestSecure COMMAND VerifyInvokeHTTPTest 
"${TEST_RESOURCES}/TestInvokeHTTPPostSecure.yml" "${TEST_RESOURCES}/")
 endif()
 add_test(NAME HttpPostIntegrationTest COMMAND HttpPostIntegrationTest 
"${TEST_RESOURCES}/TestHTTPPost.yml" "${TEST_RESOURCES}/")
 if (NOT APPLE)
-add_test(NAME HttpPostIntegrationTestChunked COMMAND HttpPostIntegrationTest 
"${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" "${TEST_RESOURCES}/")
+       add_test(NAME HttpPostIntegrationTestChunked COMMAND 
HttpPostIntegrationTest "${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" 
"${TEST_RESOURCES}/")
 endif()
 add_test(NAME C2VerifyServeResults COMMAND C2VerifyServeResults 
"${TEST_RESOURCES}/C2VerifyServeResults.yml" "${TEST_RESOURCES}/")
 add_test(NAME C2VerifyHeartbeatAndStop COMMAND C2VerifyHeartbeatAndStop 
"${TEST_RESOURCES}/C2VerifyHeartbeatAndStop.yml" )
diff --git a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp 
b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
index 06a7bf0..4fe4ab8 100644
--- a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
+++ b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
@@ -43,8 +43,9 @@
 
 TEST_CASE("HTTPTestsWithNoResourceClaimPOST", "[httptest1]") {
   TestController testController;
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::ListenHTTP>();
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::InvokeHTTP>();
   std::shared_ptr<core::ContentRepository> content_repo = 
std::make_shared<core::repository::VolatileContentRepository>();
-  
LogTestController::getInstance().setInfo<org::apache::nifi::minifi::processors::InvokeHTTP>();
 
   std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
 
@@ -56,8 +57,11 @@ TEST_CASE("HTTPTestsWithNoResourceClaimPOST", "[httptest1]") 
{
   auto dir = testController.createTempDirectory(format);
 
   std::shared_ptr<core::Processor> listenhttp = 
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
+  listenhttp->initialize();
 
   std::shared_ptr<core::Processor> invokehttp = 
std::make_shared<org::apache::nifi::minifi::processors::InvokeHTTP>("invokehttp");
+  invokehttp->initialize();
+
   utils::Identifier processoruuid = listenhttp->getUUID();
   REQUIRE(processoruuid);
 
@@ -140,8 +144,8 @@ TEST_CASE("HTTPTestsWithNoResourceClaimPOST", 
"[httptest1]") {
   for (auto provEventRecord : records) {
     REQUIRE(provEventRecord->getComponentType() == listenhttp->getName());
   }
-  std::shared_ptr<core::FlowFile> ffr = session2->get();
-  REQUIRE(true == LogTestController::getInstance().contains("exiting because 
method is POST"));
+
+  REQUIRE(true == LogTestController::getInstance().contains("Exiting because 
method is POST"));
   LogTestController::getInstance().reset();
 }
 
@@ -160,7 +164,8 @@ class CallBack : public minifi::OutputStreamCallback {
 
 TEST_CASE("HTTPTestsWithResourceClaimPOST", "[httptest1]") {
   TestController testController;
-  
LogTestController::getInstance().setInfo<org::apache::nifi::minifi::processors::InvokeHTTP>();
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::ListenHTTP>();
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::InvokeHTTP>();
 
   std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
 
@@ -172,15 +177,20 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", 
"[httptest1]") {
   auto dir = testController.createTempDirectory(format);
 
   std::shared_ptr<core::Processor> listenhttp = 
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
+  listenhttp->initialize();
 
   std::shared_ptr<core::Processor> invokehttp = 
std::make_shared<org::apache::nifi::minifi::processors::InvokeHTTP>("invokehttp");
+  invokehttp->initialize();
+
   utils::Identifier processoruuid = listenhttp->getUUID();
   REQUIRE(processoruuid);
 
   utils::Identifier invokehttp_uuid = invokehttp->getUUID();
   REQUIRE(invokehttp_uuid);
 
+  auto configuration = std::make_shared<minifi::Configure>();
   std::shared_ptr<core::ContentRepository> content_repo = 
std::make_shared<core::repository::VolatileContentRepository>();
+  content_repo->initialize(configuration);
 
   std::shared_ptr<minifi::Connection> gcConnection = 
std::make_shared<minifi::Connection>(repo, content_repo, 
"getfileCreate2Connection");
   gcConnection->addRelationship(core::Relationship("success", "description"));
@@ -197,18 +207,14 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", 
"[httptest1]") {
 
   // link the connections so that we can test results at the end for this
   connection->setSource(listenhttp);
-
   connection->setSourceUUID(invokehttp_uuid);
   connection->setDestinationUUID(processoruuid);
-
-  connection2->setSourceUUID(processoruuid);
   connection2->setSourceUUID(processoruuid);
 
   listenhttp->addConnection(connection);
   invokehttp->addConnection(connection);
   invokehttp->addConnection(connection2);
 
-
   std::shared_ptr<core::ProcessorNode> node = 
std::make_shared<core::ProcessorNode>(listenhttp);
   std::shared_ptr<core::ProcessorNode> node2 = 
std::make_shared<core::ProcessorNode>(invokehttp);
   std::shared_ptr<core::ProcessContext> context = 
std::make_shared<core::ProcessContext>(node, nullptr, repo, repo, content_repo);
@@ -269,23 +275,25 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", 
"[httptest1]") {
   for (auto provEventRecord : records) {
     REQUIRE(provEventRecord->getComponentType() == listenhttp->getName());
   }
-  std::shared_ptr<core::FlowFile> ffr = session2->get();
-  REQUIRE(true == LogTestController::getInstance().contains("exiting because 
method is POST"));
+
+  REQUIRE(true == LogTestController::getInstance().contains("Exiting because 
method is POST"));
   LogTestController::getInstance().reset();
 }
 
 TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
   TestController testController;
-  
LogTestController::getInstance().setInfo<org::apache::nifi::minifi::processors::InvokeHTTP>();
-  
LogTestController::getInstance().setInfo<org::apache::nifi::minifi::processors::ListenHTTP>();
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::ListenHTTP>();
+  
LogTestController::getInstance().setDebug<org::apache::nifi::minifi::processors::InvokeHTTP>();
   LogTestController::getInstance().setInfo<core::Processor>();
 
   std::shared_ptr<TestPlan> plan = testController.createPlan();
-  std::shared_ptr<core::Processor> processor = 
plan->addProcessor("ListenHTTP", "listenhttp", core::Relationship("No Retry", 
"description"), false);
+  std::shared_ptr<core::Processor> listenhttp = 
plan->addProcessor("ListenHTTP", "listenhttp", core::Relationship("No Retry", 
"description"), false);
+  listenhttp->initialize();
   std::shared_ptr<core::Processor> invokehttp = 
plan->addProcessor("InvokeHTTP", "invokehttp", core::Relationship("success", 
"description"), true);
+  invokehttp->initialize();
 
-  REQUIRE(true == plan->setProperty(processor, 
org::apache::nifi::minifi::processors::ListenHTTP::Port.getName(), "8685"));
-  REQUIRE(true == plan->setProperty(processor, 
org::apache::nifi::minifi::processors::ListenHTTP::BasePath.getName(), 
"/testytesttest"));
+  REQUIRE(true == plan->setProperty(listenhttp, 
org::apache::nifi::minifi::processors::ListenHTTP::Port.getName(), "8685"));
+  REQUIRE(true == plan->setProperty(listenhttp, 
org::apache::nifi::minifi::processors::ListenHTTP::BasePath.getName(), 
"/testytesttest"));
 
   REQUIRE(true == plan->setProperty(invokehttp, 
org::apache::nifi::minifi::processors::InvokeHTTP::Method.getName(), "POST"));
   REQUIRE(true == plan->setProperty(invokehttp, 
org::apache::nifi::minifi::processors::InvokeHTTP::URL.getName(), 
"http://localhost:8685/testytesttest";));
@@ -301,12 +309,11 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
   testController.runSession(plan, true);
 
   records = plan->getProvenanceRecords();
-  record = plan->getCurrentFlowFile();
 
   for (auto provEventRecord : records) {
-    REQUIRE(provEventRecord->getComponentType() == processor->getName());
+    REQUIRE(provEventRecord->getComponentType() == listenhttp->getName());
   }
-  std::shared_ptr<core::FlowFile> ffr = plan->getCurrentFlowFile();
-  REQUIRE(true == LogTestController::getInstance().contains("exiting because 
method is POST"));
+
+  REQUIRE(true == LogTestController::getInstance().contains("Exiting because 
method is POST"));
   LogTestController::getInstance().reset();
 }

Reply via email to