You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ph...@apache.org on 2019/08/16 21:36:27 UTC
[nifi-minifi-cpp] branch master updated: MINIFICPP-883: Add windows
build script
This is an automated email from the ASF dual-hosted git repository.
phrocker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new a6876db MINIFICPP-883: Add windows build script
a6876db is described below
commit a6876db93676cc43cdfee0b61926b0141c38f91e
Author: Marc Parisi <ph...@apache.org>
AuthorDate: Sun May 26 18:48:55 2019 +0000
MINIFICPP-883: Add windows build script
MINIFICPP-883: change appveyor to use winbuild
MINIFICPP-833: remove Win64 req
MINIFICPP-883: Minor update to move to new image
MINIFICPP-796: Enable tests
MINIFICPP-796: Update path creator
MINIFICPP-796: Minor update
MINIFICPP-796: more adjustments
MINIFICPP-796: Updates to tests and cmake
MINIFICPP-769: Fix inclusion of minifi
MINIFICPP-796: remove nanofi
MINIFICPP-796: Remove test
MINIFICPP-796: Updates
Update SecureSocketGetTCPTest.cpp
Update appveyor.yml
Update appveyor.yml
Update appveyor.yml
Update CMakeLists.txt
Approved on GH by apiri.
This closes #595.
Signed-off-by: Marc Parisi <ph...@apache.org>
---
CMakeLists.txt | 139 +++---
CMakeSettings.json | 111 +----
Windows.md | 45 ++
appveyor.yml | 7 +-
bootstrap.sh | 6 +-
cmake/BuildTests.cmake | 10 +-
cmake/curl/dummy/FindCURL.cmake | 3 +-
conf/minifi.properties | 22 +-
extensions/coap/CMakeLists.txt | 1 +
extensions/coap/tests/CoapC2VerifyHeartbeat.cpp | 2 +-
extensions/expression-language/CMakeLists.txt | 37 +-
extensions/expression-language/Expression.cpp | 17 +
.../ExpressionContextBuilder.cpp | 47 ++
.../expression-language/ExpressionContextBuilder.h | 56 +++
.../expression-language/ExpressionLoader.cpp | 23 +-
extensions/expression-language/ExpressionLoader.h | 72 ++++
.../expression-language/ProcessContextExpr.cpp | 14 +-
.../expression-language/ProcessContextExpr.h | 78 ++++
.../impl/expression/Expression.h | 6 +-
.../expression-language/tests/CMakeLists.txt | 109 +++++
.../tests}/ExpressionLanguageTests.cpp | 472 ++++++++++-----------
.../tests}/RouteOnAttributeTests.cpp | 2 +-
.../integration/UpdateAttributeIntegrationTest.cpp | 9 +-
extensions/http-curl/CMakeLists.txt | 7 +-
extensions/http-curl/sitetosite/HTTPProtocol.cpp | 3 +-
extensions/http-curl/sitetosite/HTTPTransaction.h | 3 +-
extensions/http-curl/tests/C2FailedUpdateTest.cpp | 5 +-
extensions/http-curl/tests/C2JstackTest.cpp | 2 -
extensions/http-curl/tests/C2NullConfiguration.cpp | 2 +-
extensions/http-curl/tests/C2UpdateAgentTest.cpp | 2 -
extensions/http-curl/tests/C2UpdateTest.cpp | 2 -
.../http-curl/tests/C2VerifyHeartbeatAndStop.cpp | 4 +-
.../http-curl/tests/C2VerifyServeResults.cpp | 2 +-
extensions/http-curl/tests/CMakeLists.txt | 10 +-
extensions/http-curl/tests/GetFileNoData.cpp | 3 +-
extensions/http-curl/tests/HTTPHandlers.h | 8 +-
extensions/http-curl/tests/HTTPIntegrationBase.h | 30 +-
extensions/http-curl/tests/HTTPSiteToSiteTests.cpp | 12 +-
.../http-curl/tests/HttpGetIntegrationTest.cpp | 5 -
.../http-curl/tests/HttpPostIntegrationTest.cpp | 2 +-
extensions/http-curl/tests/SiteToSiteRestTest.cpp | 2 +-
extensions/http-curl/tests/TestServer.h | 47 +-
extensions/http-curl/tests/ThreadPoolAdjust.cpp | 2 +-
.../http-curl/tests/unit}/CivetwebTests.cpp | 7 +-
.../http-curl/tests/unit/InvokeHTTPTests.cpp | 4 +-
extensions/jni/CMakeLists.txt | 2 +-
extensions/jni/jvm/JniControllerServiceLookup.cpp | 8 +-
extensions/jni/jvm/JniFlowFile.cpp | 22 +-
extensions/jni/jvm/JniFlowFile.h | 1 -
extensions/jni/jvm/JniInitializationContext.cpp | 12 +-
extensions/jni/jvm/JniLogger.cpp | 20 +-
extensions/jni/jvm/JniProcessContext.cpp | 10 +-
extensions/jni/jvm/JniProcessContext.h | 10 +-
extensions/jni/jvm/JniProcessSession.cpp | 39 +-
.../nifi/processor/JniInitializationContext.java | 3 +-
.../apache/nifi/processor/JniProcessContext.java | 7 +-
.../org/apache/nifi/processor/JniStateManager.java | 30 ++
.../org/apache/nifi/processor/JniStateMap.java | 33 ++
extensions/librdkafka/CMakeLists.txt | 11 +-
extensions/sftp/tests/CMakeLists.txt | 8 +-
.../standard-processors/processors/GetFile.cpp | 36 +-
.../standard-processors/processors/GetTCP.cpp | 24 +-
.../standard-processors/processors/PutFile.cpp | 16 +-
.../standard-processors/processors/TailFile.cpp | 9 +-
.../standard-processors/tests/CMakeLists.txt | 7 +
.../tests/integration/SecureSocketGetTCPTest.cpp | 19 +-
.../tests/integration/TailFileCronTest.cpp | 10 +-
.../tests/integration/TailFileTest.cpp | 11 +-
.../tests/integration/TestExecuteProcess.cpp | 2 +
.../standard-processors/tests/minifi-tmpfile.txt | 6 +
.../tests/unit/ExtractTextTests.cpp | 249 ++++++-----
.../tests/unit/GetFileTests.cpp | 59 ++-
.../standard-processors/tests/unit/GetTCPTests.cpp | 18 +-
.../tests/unit/HashContentTest.cpp | 28 +-
.../tests/unit/ManifestTests.cpp | 6 +-
.../tests/unit/ProcessorTests.cpp | 26 +-
.../tests/unit/PutFileTests.cpp | 54 +--
.../tests/unit/TailFileTests.cpp | 283 ++++++------
.../windows-event-log/ConsumeWindowsEventLog.cpp | 121 +++++-
.../windows-event-log/ConsumeWindowsEventLog.h | 14 +-
extensions/windows-event-log/tests/CMakeLists.txt | 35 ++
libminifi/CMakeLists.txt | 8 -
libminifi/include/core/ClassLoader.h | 21 +-
libminifi/include/core/Core.h | 8 +-
libminifi/include/core/Deprecated.h | 6 +-
libminifi/include/core/ProcessContext.h | 13 +-
libminifi/include/core/ProcessContextBuilder.h | 91 ++++
libminifi/include/core/ProcessSession.h | 2 +-
libminifi/include/core/PropertyValue.h | 7 +-
libminifi/include/core/TypedValues.h | 6 +-
.../include/core/repository/VolatileRepository.h | 2 +-
.../include/{core/Deprecated.h => utils/OsUtils.h} | 38 +-
libminifi/include/utils/file/FileUtils.h | 38 +-
libminifi/opsys/win/io/ClientSocket.h | 11 +-
libminifi/src/Properties.cpp | 6 +-
libminifi/src/RemoteProcessorGroupPort.cpp | 19 +-
libminifi/src/ThreadedSchedulingAgent.cpp | 10 +-
libminifi/src/core/ProcessContextBuilder.cpp | 84 ++++
libminifi/src/core/ProcessSession.cpp | 8 +-
libminifi/src/core/logging/LoggerConfiguration.cpp | 7 +-
libminifi/src/io/DataStream.cpp | 9 -
libminifi/src/io/posix/ClientSocket.cpp | 1 +
libminifi/src/io/tls/TLSSocket.cpp | 20 +-
libminifi/src/io/win/ClientSocket.cpp | 13 +-
libminifi/src/sitetosite/SiteToSiteClient.cpp | 2 +-
libminifi/src/utils/OsUtils.cpp | 156 +++++++
libminifi/test/TestBase.cpp | 22 +-
libminifi/test/TestBase.h | 45 +-
libminifi/test/archive-tests/FocusArchiveTests.cpp | 6 +-
.../test/archive-tests/ManipulateArchiveTests.cpp | 4 +-
.../test/bustache-tests/ApplyTemplateTests.cpp | 6 +-
libminifi/test/civetweb-tests/CMakeLists.txt | 42 --
.../test/expression-language-tests/CMakeLists.txt | 67 ---
libminifi/test/gps-tests/GPSTests.cpp | 2 +-
libminifi/test/integration/IntegrationBase.h | 2 -
.../test/integration/ProvenanceReportingTest.cpp | 4 +
libminifi/test/resources/TestUpdateAttribute.yml | 3 +-
.../rocksdb-tests/DBContentRepositoryTests.cpp | 14 +-
libminifi/test/rocksdb-tests/RepoTests.cpp | 19 +-
.../test/script-tests/LuaExecuteScriptTests.cpp | 8 +-
.../test/script-tests/PythonExecuteScriptTests.cpp | 12 +-
libminifi/test/sqlite-tests/SQLiteTests.cpp | 14 +-
libminifi/test/unit/C2MetricsTests.cpp | 5 +-
libminifi/test/unit/ControllerTests.cpp | 11 +-
libminifi/test/unit/FileStreamTests.cpp | 12 +-
libminifi/test/unit/FileTriggerTests.cpp | 4 +-
libminifi/test/unit/FileUtilsTests.cpp | 5 +-
libminifi/test/unit/LoggerConfigurationTests.cpp | 5 +-
libminifi/test/unit/SocketTests.cpp | 31 +-
libminifi/test/unit/StreamTests.cpp | 4 +-
libminifi/test/unit/StringUtilsTests.cpp | 7 +
main/MiNiFiMain.cpp | 16 +-
msi/WixWin.wsi | 332 +++++++++++++++
msi/WixWin64.wsi | 47 --
msi/bgr.png | Bin 0 -> 10526 bytes
msi/minifi-logo-ico.ico | Bin 0 -> 48264 bytes
msi/minifi-logo-png-banner.png | Bin 0 -> 13616 bytes
nanofi/include/api/nanofi.h | 4 +-
nanofi/include/core/cstructs.h | 9 +-
nanofi/tests/CAPITests.cpp | 50 +--
thirdparty/rocksdb/CMakeLists.txt | 10 +-
win_build_vs.bat | 72 ++++
142 files changed, 2802 insertions(+), 1379 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f87f074..cee2f23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,31 +30,21 @@ include(FeatureSummary)
include(ExternalProject)
option(SKIP_TESTS "Skips building all tests." OFF)
-
option(PORTABLE "Instructs the compiler to remove architecture specific optimizations" ON)
-
option(USE_SHARED_LIBS "Builds using shared libraries" ON)
-
option(ENABLE_PYTHON "Instructs the build system to enable building shared objects for the python lib" OFF)
-
-cmake_dependent_option(STATIC_BUILD "Attempts to statically link as many dependencies as possible." ON "NOT ENABLE_PYTHON; NOT USE_SHARED_LIBS" OFF)
-
+cmake_dependent_option(STATIC_BUILD "Attempts to statically link as many dependencies as possible." ON "NOT ENABLE_PYTHON; NOT USE_SHARED_LIBS" OFF)
cmake_dependent_option(USE_SYSTEM_OPENSSL "Instructs the build system to search for and use an SSL library available in the host system" ON "NOT STATIC_BUILD" OFF)
option(LIBC_STATIC "Instructs the build system to statically link libstdc++ and glibc into minifiexe. Experiemental" OFF)
-
option(OPENSSL_OFF "Disables OpenSSL" OFF)
option(ENABLE_OPS "Enable Operations/zlib Tools" ON)
option(USE_SYSTEM_UUID "Instructs the build system to search for and use a UUID library available in the host system" OFF)
-
option(ENABLE_JNI "Instructs the build system to enable the JNI extension" OFF)
option(ENABLE_OPENCV "Instructs the build system to enable the OpenCV extension" OFF)
cmake_dependent_option(USE_SYSTEM_CURL "Instructs the build system to search for and use a cURL library available in the host system" ON "NOT STATIC_BUILD" OFF)
option(BUILD_SHARED_LIBS "Build yaml cpp shared lib" OFF)
-
cmake_dependent_option(USE_SYSTEM_ZLIB "Instructs the build system to search for and use a zlib library available in the host system" ON "NOT STATIC_BUILD" OFF)
-
cmake_dependent_option(USE_SYSTEM_LIBSSH2 "Instructs the build system to search for and use a libssh2 library available in the host system" OFF "NOT STATIC_BUILD" OFF)
-
option(USE_SYSTEM_BZIP2 "Instructs the build system to search for and use a bzip2 library available in the host system" ON)
option(BUILD_ROCKSDB "Instructs the build system to use RocksDB from the third party directory" ON)
option(FORCE_WINDOWS "Instructs the build system to force Windows builds when WIN32 is specified" OFF)
@@ -62,6 +52,29 @@ option(DISABLE_CURL "Disables libCurl Properties." OFF)
option(USE_GOLD_LINKER "Use Gold Linker" OFF)
+if (OPENSSL_ROOT_DIR )
+ set(OPENSSL_PASSTHROUGH "-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}")
+endif()
+
+set(PASSTHROUGH_CMAKE_ARGS -DANDROID_ABI=${ANDROID_ABI}
+ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
+ -DANDROID_STL=${ANDROID_STL}
+ -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DANDROID_NDK=${ANDROID_NDK}
+ -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=${CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY}
+ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=${CMAKE_FIND_ROOT_PATH_MODE_INCLUDE}
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+ ${OPENSSL_PASSTHROUGH}
+ -G${CMAKE_GENERATOR})
+
if(NOT WIN32)
if (ENABLE_JNI)
if (NOT DISABLE_JEMALLOC)
@@ -130,6 +143,8 @@ endif()
include(CheckCXXCompilerFlag)
if (WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_compile_options("/W1")
if ((MSVC_VERSION GREATER "1900") OR (MSVC_VERSION EQUAL "1900"))
CHECK_CXX_COMPILER_FLAG("/std:c++14" _cpp_latest_flag_supported)
if (_cpp_latest_flag_supported)
@@ -150,7 +165,7 @@ endif()
endif()
if (WIN32)
- add_definitions(-DSERVICE_NAME="MiNiFi")
+ add_definitions(-DSERVICE_NAME="Apache NiFi MINiFi")
endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
@@ -178,6 +193,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if (NOT OPENSSL_OFF)
if(USE_SYSTEM_OPENSSL)
+
# Set the right openssl root path
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl/")
@@ -188,8 +204,8 @@ if (NOT OPENSSL_OFF)
endif()
else()
include(LibreSSL)
- use_libre_ssl(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/ssl")
+ use_libre_ssl("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ssl")
endif()
find_package (OpenSSL REQUIRED)
@@ -267,8 +283,8 @@ endif(DISABLE_CURL)
if(NOT DISABLE_CURL AND (NOT USE_SYSTEM_CURL))
message("Using bundled cURL")
- set(CURL_C_FLAGS "-I${OPENSSL_INCLUDE_DIR}")
- set(CURL_CXX_FLAGS "${CURL_C_FLAGS}")
+ set(CURL_C_FLAGS "${CMAKE_C_FLAGS}")
+ set(CURL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
@@ -280,13 +296,9 @@ else()
endif()
if (WIN32)
- if (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo OR CMAKE_BUILD_TYPE MATCHES Release)
- set(BYPRODUCT "lib/libcurl.lib")
- else()
- set(BYPRODUCT "lib/libcurl-d.lib")
- endif()
+ set(BYPRODUCT "lib/libcurl.lib")
else()
- set(BYPRODUCT "lib${LIBSUFFIX}/libcurl.a")
+ set(BYPRODUCT "lib${LIBSUFFIX}/libcurl.a")
endif()
if (WIN32)
@@ -305,10 +317,11 @@ endif()
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=OFF
-DHTTP_ONLY=ON
- -DLIBRESSL_BIN_DIR=${LIBRESSL_BIN_DIR}
- -DLIBRESSL_SRC_DIR=${LIBRESSL_SRC_DIR}
+ "-DLIBRESSL_BIN_DIR=${LIBRESSL_BIN_DIR}"
+ "-DLIBRESSL_SRC_DIR=${LIBRESSL_SRC_DIR}"
-DCURL_DISABLE_CRYPTO_AUTH=ON
-DCMAKE_USE_LIBSSH2=OFF
+ "-DCMAKE_DEBUG_POSTFIX="
-DHAVE_GLIBC_STRERROR_R=1
-DHAVE_GLIBC_STRERROR_R__TRYRUN_OUTPUT=""
-DHAVE_POSIX_STRERROR_R=0
@@ -318,6 +331,7 @@ endif()
-DHAVE_FSETXATTR_5__TRYRUN_OUTPUT=""
"-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake/ssl"
"-DCMAKE_C_FLAGS=${CURL_C_FLAGS}"
+ "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_CXX_FLAGS=${CURL_CXX_FLAGS}"
${PC}
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}"
@@ -330,13 +344,10 @@ endif()
set(CURL_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/" CACHE STRING "" FORCE)
set(CURL_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/curl-install/" CACHE STRING "" FORCE)
set(CURL_BYPRODUCT_DIR "${BYPRODUCT}" CACHE STRING "" FORCE)
-
-
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/curl/dummy")
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/curl/dummy")
add_library(curl STATIC IMPORTED)
set_target_properties(curl PROPERTIES IMPORTED_LOCATION "${CURL_BIN_DIR}${BYPRODUCT}")
-
-
+
if (OPENSSL_FOUND)
if (NOT WIN32)
set_target_properties(curl PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBRARIES})
@@ -346,7 +357,7 @@ endif()
set(CURL_FOUND "YES")
set(CURL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/include")
set(CURL_LIBRARY "${CURL_BIN_DIR}${BYPRODUCT}" CACHE STRING "" FORCE)
- set(CURL_LIBRARIES ${CURL_LIBRARY} CACHE STRING "" FORCE)
+ set(CURL_LIBRARIES "${CURL_LIBRARY}" CACHE STRING "" FORCE)
else()
message("Using System cURL")
endif()
@@ -385,33 +396,21 @@ include_directories(thirdparty/yaml-cpp-yaml-cpp-20171024/include)
include_directories(thirdparty/rapidjson-1.1.0/include)
## Expression language extensions
-option(DISABLE_EXPRESSION_LANGUAGE "Disables the scripting extensions." OFF)
-include_directories("extensions/expression-language/common")
-if (DISABLE_EXPRESSION_LANGUAGE)
- # Build expression language NoOp implementation, if necessary
- include_directories("extensions/expression-language/noop")
- add_subdirectory(extensions/expression-language/noop)
-else()
- include_directories("extensions/expression-language/impl")
- createExtension(EXPRESSION-LANGUAGE-EXTENSIONS "EXPRESSION LANGUAGE EXTENSIONS" "This enables NiFi expression language" "extensions/expression-language" "${TEST_DIR}/expression-language-tests")
- if(NOT USE_SYSTEM_CURL)
- message("minifi-expression-language-extensions will depend on curl-external")
- add_dependencies(minifi-expression-language-extensions curl-external)
- endif()
-endif()
-
if(BOOTSTRAP)
# display an error message for those using the bootstrap
message(FATAL_ERROR "Bootstrapping is no longer needed within the agent")
endif()
-
add_subdirectory(libminifi)
if(NOT USE_SYSTEM_OPENSSL OR USE_SYSTEM_OPENSSL STREQUAL "OFF")
add_dependencies(minifi libressl-portable)
endif()
+if(NOT USE_SYSTEM_CURL)
+ add_dependencies(minifi curl-external)
+endif()
+
if (WIN32 OR NOT USE_SYSTEM_ZLIB)
add_dependencies(minifi zlib-external)
endif(WIN32 OR NOT USE_SYSTEM_ZLIB)
@@ -428,9 +427,23 @@ if ((DISABLE_CURL STREQUAL "OFF" OR NOT DISABLE_CURL) AND NOT DISABLE_CIVET)
endif()
endif()
+option(DISABLE_EXPRESSION_LANGUAGE "Disables the scripting extensions." OFF)
+if (NOT DISABLE_EXPRESSION_LANGUAGE)
+ createExtension(EXPRESSION-LANGUAGE-EXTENSIONS "EXPRESSION LANGUAGE EXTENSIONS" "This enables NiFi expression language" "extensions/expression-language" "extensions/expression-language/tests")
+ if(NOT USE_SYSTEM_OPENSSL OR USE_SYSTEM_OPENSSL STREQUAL "OFF")
+ add_dependencies(minifi-expression-language-extensions libressl-portable)
+ endif()
+ if(NOT USE_SYSTEM_CURL)
+ message("minifi-expression-language-extensions will depend on curl-external")
+ add_dependencies(minifi-expression-language-extensions curl-external)
+ endif()
+endif()
+
+
+
option(DISABLE_CIVET "Disables CivetWeb components." OFF)
if (NOT DISABLE_CIVET)
- createExtension(CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb" "${TEST_DIR}/civetweb-tests")
+ createExtension(CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb")
endif()
## Add the rocks DB extension
@@ -468,7 +481,7 @@ endif()
if (WIN32)
option(ENABLE_WEL "Enables the suite of Windows Event Log extensions." OFF)
if (ENABLE_ALL OR ENABLE_WEL)
- createExtension(WEL-EXTENSION "WEL EXTENSIONS" "Enables the suite of Windows Event Log extensions." "extensions/windows-event-log" "${TEST_DIR}/windows-event-log-tests")
+ createExtension(WEL-EXTENSION "WEL EXTENSIONS" "Enables the suite of Windows Event Log extensions." "extensions/windows-event-log" "extensions/windows-event-log/tests")
endif()
endif(WIN32)
@@ -537,6 +550,7 @@ if (ENABLE_OPENCV)
createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")
endif()
+
## Bustache/template extensions
option(ENABLE_BUSTACHE "Enables Bustache (ApplyTemplate) support." OFF)
if (ENABLE_BUSTACHE)
@@ -571,6 +585,7 @@ if ((ENABLE_ALL OR ENABLE_SFTP) AND NOT DISABLE_CURL)
endif()
endif()
+
## NOW WE CAN ADD LIBRARIES AND EXTENSIONS TO MAIN
add_subdirectory(main)
@@ -643,7 +658,14 @@ set(CPACK_ALL_INSTALL_TYPES Full Developer)
set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
-set(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/msi/WixWin64.wsi")
+set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/msi/minifi-logo-png-banner.png")
+set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/msi/bgr.png")
+
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conf/")
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/README.md" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/NOTICE" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
+set(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/msi/WixWin.wsi")
else()
set(CPACK_SOURCE_GENERATOR "TGZ")
endif(WIN32)
@@ -659,9 +681,11 @@ install(DIRECTORY extensions/pythonprocessors/
DESTINATION minifi-python
COMPONENT bin)
+if (NOT WIN32)
install(PROGRAMS bin/minifi.sh
DESTINATION bin
COMPONENT bin)
+endif()
install(FILES LICENSE README.md NOTICE
DESTINATION .
@@ -672,19 +696,22 @@ if(WIN32)
#but that leaves the onus up to the developer, so until we can automate some of that build let's enforce
#the exe here temporarily
#TODO: Remove this and automate this step.
-install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi.exe
- DESTINATION bin
- COMPONENT bin)
+#install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi.exe
+ #DESTINATION bin
+ #COMPONENT bin)
else()
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi
DESTINATION bin
COMPONENT bin)
-endif()
-
+endif()
+
if (WIN32)
set(CPACK_GENERATOR "WIX")
+
+set(CPACK_WIX_UPGRADE_GUID, "FE29F801-3486-4E9E-AFF9-838C1A5C8D59")
+set(CPACK_WIX_PRODUCT_ICON,"${CMAKE_CURRENT_SOURCE_DIR}/msi/minifi-logo-ico.ico")
else()
set(CPACK_GENERATOR "TGZ")
endif()
@@ -697,11 +724,13 @@ set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/msi/LICENSE.txt")
-set(CPACK_PACKAGE_FILE_NAME "${ASSEMBLY_BASE_NAME}")
if(NOT WIN32)
+set(CPACK_PACKAGE_FILE_NAME "${ASSEMBLY_BASE_NAME}")
set(CPACK_GENERATOR "TGZ")
set(CPACK_BINARY_TGZ, "ON")
endif()
+set(CPACK_PACKAGE_FILE_NAME "minifi-agent-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "ApacheNiFiMiNiFi/${CMAKE_PROJECT_NAME}")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_RDKAFKA_COMPONENT_INSTALL ON)
set(CPACK_MQTT_COMPONENT_INSTALL ON)
diff --git a/CMakeSettings.json b/CMakeSettings.json
index 7582dc5..f430bb4 100644
--- a/CMakeSettings.json
+++ b/CMakeSettings.json
@@ -2,107 +2,14 @@
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
- "name": "x64-RelWithDebInfo",
- "generator": "Ninja",
- "configurationType": "RelWithDebInfo",
- "inheritEnvironments": [ "msvc_x64_x64" ],
- "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
- "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
- "cmakeCommandArgs": "",
- "buildCommandArgs": "-v -j8",
- "variables": [
- {
- "name": "OPENSSL_OFF",
- "value": "OFF"
- },
- {
- "name": "USE_SYSTEM_OPENSSL",
- "value": "ON"
- },
- {
- "name": "PORTABLE",
- "value": "ON"
- },
- {
- "name": "OPENSSL_ROOT_DIR",
- "value": "C:\\OpenSSL-Win64"
- },
- {
- "name": "USE_SYSTEM_ZLIB",
- "value": "OFF"
- },
- {
- "name": "DISABLE_CONTROLLER",
- "value": "TRUE"
- },
- {
- "name": "USE_SYSTEM_CURL",
- "value": "OFF"
- },
- {
- "name": "ENABLE_JNI",
- "value": "ON"
- },
- {
- "name": "USE_SYSTEM_UUID",
- "value": "OFF"
- },
- {
- "name": "FORCE_WINDOWS",
- "value": "ON"
- },
- {
- "name": "DISABLE_ROCKSDB",
- "value": "FALSE"
- },
- {
- "name": "ENABLE_WEL",
- "value": "TRUE"
- },
- {
- "name": "ENABLE_LIBRDKAFKA",
- "value": "OFF"
- },
- {
- "name": "DISABLE_CURL",
- "value": "OFF"
- },
- {
- "name": "FORCE_WINDOWS",
- "value": "ON"
- },
- {
- "name": "ENABLE_COAP",
- "value": "OFF"
- },
- {
- "name": "DISABLE_LIBARCHIVE",
- "value": "TRUE"
- },
- {
- "name": "DISABLE_SCRIPTING",
- "value": "TRUE"
- },
- {
- "name": "EXCLUDE_BOOST",
- "value": "TRUE"
- },
- {
- "name": "SKIP_TESTS",
- "value": "TRUE"
- }
- ],
- "ctestCommandArgs": ""
- },
- {
"name": "x64-Release",
- "generator": "Ninja",
+ "generator": "Visual Studio 15 2017",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
- "buildCommandArgs": "-v -j8",
+ "buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "OPENSSL_OFF",
@@ -129,11 +36,11 @@
"value": "OFF"
},
{
- "name": "ENABLE_JNI",
- "value": "ON"
+ "name": "USE_SYSTEM_UUID",
+ "value": "OFF"
},
{
- "name": "USE_SYSTEM_UUID",
+ "name": "USE_SHARED_LIBS",
"value": "OFF"
},
{
@@ -145,6 +52,10 @@
"value": "FALSE"
},
{
+ "name": "FAIL_ON_WARNINGS",
+ "value": "OFF"
+ },
+ {
"name": "ENABLE_WEL",
"value": "TRUE"
},
@@ -175,10 +86,6 @@
{
"name": "EXCLUDE_BOOST",
"value": "TRUE"
- },
- {
- "name": "SKIP_TESTS",
- "value": "TRUE"
}
],
"ctestCommandArgs": ""
diff --git a/Windows.md b/Windows.md
new file mode 100644
index 0000000..e09d199
--- /dev/null
+++ b/Windows.md
@@ -0,0 +1,45 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Apache NiFi - MiNiFi - C++ Windows Build Guide
+
+## Requirements
+
+Apache NiFi MiNiFi C++ has been built on Window Server 2016, 2019, and Windows 10 operating systems. Since the project is CMAKE focused we suggest building via
+Visual Studio 2017 or our ms_build.bat script. In order to build the MSI, please install the [WiX Toolset](https://wixtoolset.org/)
+
+The project previously required OpenSSL to be installed. If you follow our build procedures, below, you will not need to install that dependency. Further, any MSI
+distributable requires that systems install the [Visual Studio 2010 redistributables](https://www.microsoft.com/en-us/download/details.aspx?id=26999&irgwc=1&OCID=AID681541_aff_7593_312327&tduid=(ir__2dz2dkkuookfr3a22jsv1zgwwn2xmb9vrhvzwmdq00)
+
+## Building with Visual Studio
+
+In order to support Visual Studio you must install [plugins capable of building CMAKE](https://devblogs.microsoft.com/cppblog/cmake-support-in-visual-studio/). We also advise
+installing WiX and Visual Studio Command Prompt via the marketplace. To do this please go to the Tools Menu, followed by Extensions and Updates. Once the popup displays you
+may install additional features from Online sources in the Online menui.
+
+Once you have CMAKE support available please select the appropriate target. A file named CMakeSettings.json provides a few base configurations, x64-RelWithDebInfo, x64-Release,
+x64-RelWithDebInfo-WithJNI, and x64-Release-WithJNI. Though the project is written in C++, JNI functionality supports running Java processors stored in NiFi Archives. These can be run
+in a much smaller memory footprint and consumer fewer resources. If your systems do not support Java or you do not want a JDK installed, please select the non JNI targets.
+
+CMAKE must generate its cache, under Cache in the CMake Menu. After that is complete go to 'Build Only' under the CMAKE menu. Due to limitations in Visual Studio's CMAKE support, it is advised
+that you build minifi.lib then minifiexe targets. Once you have built these targets, you may use the cpack command to build your MSI. If you are building with JNI functionality the MSI will be
+significantly larger ( about 160 MB ) since it contains the base NARs to run the standard set of Apache NiFi processors.
+
+## Building via the build script
+
+The preferred way of building the project is via the win_build_vs.bat script found in our root source folder. You must supply a single command, the build directory. Typically you create a directory
+with CMAKE and build in that referencing your CMAKE tree. Simply supply win_build_vs.bat an argument like 'build' as the name of your build directory and it will create this directory building the
+project within it. If WiX is installed cpack will create your MSI in the chosen build directory.
+
diff --git a/appveyor.yml b/appveyor.yml
index 4d7a65f..fe0d9b4 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,7 +3,6 @@ image: Visual Studio 2017
environment:
MSVC_DEFAULT_OPTIONS: ON
APPVEYOR_SAVE_CACHE_ON_ERROR: true
-
cache:
- build\curl-install\ -> appveyor.yml
- build\libressl-install\ -> appveyor.yml
@@ -18,8 +17,4 @@ clone_folder: C:\projects\nifi-minifi-cpp
build_script:
- cd C:\projects\nifi-minifi-cpp
- - mkdir build & exit 0
- - cd build
- - cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE_INIT=Release -DCMAKE_BUILD_TYPE=Release -DWIN32=WIN32 -DOPENSSL_OFF=OFF -DUSE_SHARED_LIBS=OFF -DDISABLE_CONTROLLER=ON -DBUILD_ROCKSDB=ON -DFORCE_WINDOWS=ON -DUSE_SYSTEM_UUID=OFF -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DEXCLUDE_BOOST=ON -DENABLE_WEL=TRUE -DSKIP_TESTS=ON -DFAIL_ON_WARNINGS=OFF ..
- - set msbuild_platform=x64
- - msbuild /m nifi-minifi-cpp.sln /property:Configuration=Release
+ - win_build_vs.bat build
diff --git a/bootstrap.sh b/bootstrap.sh
index 9bc864d..f69d5ed 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -472,7 +472,11 @@ build_cmake_command(){
if [ $? == 0 ]; then
echo "Using libcurl-openssl..."
else
- CMAKE_BUILD_COMMAND="${CMAKE_BUILD_COMMAND} -DUSE_CURL_NSS=true .."
+ if [ "${USE_SHARED_LIBS}" = "${TRUE}" ]; then
+ CMAKE_BUILD_COMMAND="${CMAKE_BUILD_COMMAND} -DUSE_CURL_NSS=true .."
+ else
+ echo "Using LibreSSL..."
+ fi
fi
CMAKE_BUILD_COMMAND="${CMAKE_BUILD_COMMAND} .."
diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake
index 668564e..fb63ae1 100644
--- a/cmake/BuildTests.cmake
+++ b/cmake/BuildTests.cmake
@@ -76,10 +76,12 @@ function(createTests testName)
endif()
target_link_libraries(${testName} ${CMAKE_DL_LIBS} ${SPD_LIB} ${TEST_BASE_LIB})
target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT} core-minifi yaml-cpp)
- #${OPENSSL_LIBRARIES}
if (NOT excludeBase)
if (APPLE)
target_link_libraries (${testName} -Wl,-all_load minifi)
+ elseif(WIN32)
+ target_link_libraries (${testName} minifi)
+ set_target_properties(${testName} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi")
else ()
target_link_libraries (${testName} -Wl,--whole-archive minifi -Wl,--no-whole-archive)
endif ()
@@ -130,6 +132,7 @@ FOREACH(testfile ${UNIT_TESTS})
ENDFOREACH()
message("-- Finished building ${UNIT_TEST_COUNT} unit test file(s)...")
+if(NOT WIN32)
SET(UNIT_TEST_COUNT 0)
FOREACH(testfile ${NANOFI_UNIT_TESTS})
get_filename_component(testfilename "${testfile}" NAME_WE)
@@ -148,17 +151,18 @@ FOREACH(testfile ${NANOFI_UNIT_TESTS})
target_link_libraries (${testfilename} -Wl,--whole-archive minifi-standard-processors -Wl,--no-whole-archive)
else()
set(WIN32_ARCHIVES "${WIN32_ARCHIVES} /WHOLEARCHIVE:minifi-standard-processors")
+ target_link_libraries (${testfilename} minifi-standard-processors)
endif ()
if(WIN32)
- set_target_properties($Ptestfilename{ PROPERTIES LINK_FLAGS "${WIN32_ARCHIVES}")
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${WIN32_ARCHIVES}")
endif()
MATH(EXPR UNIT_TEST_COUNT "${UNIT_TEST_COUNT}+1")
add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR})
ENDFOREACH()
message("-- Finished building ${UNIT_TEST_COUNT} NanoFi unit test file(s)...")
-
+endif(NOT WIN32)
SET(INT_TEST_COUNT 0)
FOREACH(testfile ${INTEGRATION_TESTS})
get_filename_component(testfilename "${testfile}" NAME_WE)
diff --git a/cmake/curl/dummy/FindCURL.cmake b/cmake/curl/dummy/FindCURL.cmake
index 4af4f5e..d179cb2 100644
--- a/cmake/curl/dummy/FindCURL.cmake
+++ b/cmake/curl/dummy/FindCURL.cmake
@@ -14,8 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
set(CURL_FOUND "YES" CACHE STRING "" FORCE)
set(CURL_INCLUDE_DIR "${CURL_SRC_DIR}/include" CACHE STRING "" FORCE)
set(CURL_LIBRARY "${CURL_BIN_DIR}${CURL_BYPRODUCT_DIR}" CACHE STRING "" FORCE)
-set(CURL_LIBRARIES "${CURL_BIN_DIR}${CURL_BYPRODUCT_DIR}" CACHE STRING "" FORCE)
\ No newline at end of file
+set(CURL_LIBRARIES "${CURL_BIN_DIR}${CURL_BYPRODUCT_DIR}" CACHE STRING "" FORCE)
diff --git a/conf/minifi.properties b/conf/minifi.properties
index 46af4f4..50144c8 100644
--- a/conf/minifi.properties
+++ b/conf/minifi.properties
@@ -51,22 +51,22 @@ nifi.database.content.repository.directory.default=${MINIFI_HOME}/content_reposi
#nifi.c2.flow.base.url=
#nifi.c2.rest.url=
#nifi.c2.rest.url.ack=
-#nifi.c2.root.classes=DeviceInfoNode,AgentInformation,FlowInformation
+nifi.c2.root.classes=DeviceInfoNode,AgentInformation,FlowInformation
## heartbeat 4 times a second
-#nifi.c2.agent.heartbeat.period=250
+nifi.c2.agent.heartbeat.period=250
## define parameters about your agent
#nifi.c2.agent.class=
#nifi.c2.agent.identifier=
## define metrics reported
-#nifi.c2.root.class.definitions=metrics
-#nifi.c2.root.class.definitions.metrics.name=metrics
-#nifi.c2.root.class.definitions.metrics.metrics=typedmetrics
-#nifi.c2.root.class.definitions.metrics.metrics.typedmetrics.name=RuntimeMetrics
-#nifi.c2.root.class.definitions.metrics.metrics.queuemetrics.name=QueueMetrics
-#nifi.c2.root.class.definitions.metrics.metrics.queuemetrics.classes=QueueMetrics
-#nifi.c2.root.class.definitions.metrics.metrics.typedmetrics.classes=ProcessMetrics,SystemInformation
-#nifi.c2.root.class.definitions.metrics.metrics.processorMetrics.name=ProcessorMetric
-#nifi.c2.root.class.definitions.metrics.metrics.processorMetrics.classes=GetFileMetrics
+nifi.c2.root.class.definitions=metrics
+nifi.c2.root.class.definitions.metrics.name=metrics
+nifi.c2.root.class.definitions.metrics.metrics=typedmetrics
+nifi.c2.root.class.definitions.metrics.metrics.typedmetrics.name=RuntimeMetrics
+nifi.c2.root.class.definitions.metrics.metrics.queuemetrics.name=QueueMetrics
+nifi.c2.root.class.definitions.metrics.metrics.queuemetrics.classes=QueueMetrics
+nifi.c2.root.class.definitions.metrics.metrics.typedmetrics.classes=ProcessMetrics,SystemInformation
+nifi.c2.root.class.definitions.metrics.metrics.processorMetrics.name=ProcessorMetric
+nifi.c2.root.class.definitions.metrics.metrics.processorMetrics.classes=GetFileMetrics
## enable the controller socket provider on port 9998
## off by default. C2 must be enabled to support these
diff --git a/extensions/coap/CMakeLists.txt b/extensions/coap/CMakeLists.txt
index 5a5c642..9bfa977 100644
--- a/extensions/coap/CMakeLists.txt
+++ b/extensions/coap/CMakeLists.txt
@@ -86,3 +86,4 @@ endif ()
SET (COAP-EXTENSION minifi-coap PARENT_SCOPE)
register_extension(minifi-coap)
+
diff --git a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
index af73de9..81a2587 100644
--- a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
+++ b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp
@@ -192,7 +192,7 @@ class VerifyCoAPServer : public CoapIntegrationBase {
moodycamel::ConcurrentQueue<minifi::coap::CoapResponse> responses;
std::unique_ptr<minifi::coap::CoapServer> server;
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/expression-language/CMakeLists.txt b/extensions/expression-language/CMakeLists.txt
index 6b946a3..1876c7e 100644
--- a/extensions/expression-language/CMakeLists.txt
+++ b/extensions/expression-language/CMakeLists.txt
@@ -96,27 +96,29 @@ flex_target(
add_flex_bison_dependency(el-scanner el-parser)
endif()
-include_directories(../../libminifi/include ../../libminifi/include/core ../../thirdparty/spdlog-20170710/include ../../thirdparty/concurrentqueue ../../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ${CIVET_THIRDPARTY_ROOT}/include ../../thirdparty/)
+include_directories(./ ../../libminifi/include ../../libminifi/include/core ../../thirdparty/cron ../../thirdparty/spdlog-20170710/include ../../thirdparty/concurrentqueue ../../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ${CIVET_THIRDPARTY_ROOT}/include ../../thirdparty/)
include_directories(common)
include_directories(impl)
include_directories(../../thirdparty/date/include)
+if(WIN32)
+include_directories(../../libminifi/opsys/win)
+set(SOCKET_SOURCES "src/io/win/*.cpp")
+else()
+include_directories(../../libminifi/opsys/posix)
+set(SOCKET_SOURCES "src/io/posix/*.cpp")
+endif()
+
+
add_subdirectory(../../thirdparty/date ${CMAKE_CURRENT_BINARY_DIR}/date)
file(GLOB SOURCES "*.cpp")
add_library(minifi-expression-language-extensions STATIC ${SOURCES} ${BISON_el-parser_OUTPUTS} ${FLEX_el-scanner_OUTPUTS})
set_property(TARGET minifi-expression-language-extensions PROPERTY POSITION_INDEPENDENT_CODE ON)
-if(THREADS_HAVE_PTHREAD_ARG)
- target_compile_options(PUBLIC minifi-expression-language-extensions "-pthread")
-endif()
-if(CMAKE_THREAD_LIBS_INIT)
- target_link_libraries(minifi-expression-language-extensions "${CMAKE_THREAD_LIBS_INIT}")
-endif()
-target_link_libraries(minifi-expression-language-extensions ${LIBMINIFI} tz)
+target_link_libraries(minifi-expression-language-extensions minifi tz)
-target_link_libraries(minifi-expression-language-extensions ${LIBMINIFI} ${UUID_LIBRARIES})
if (NOT DISABLE_CURL)
if (NOT CURL_FOUND)
find_package(CURL REQUIRED)
@@ -131,21 +133,12 @@ find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries (minifi-expression-language-extensions ${ZLIB_LIBRARIES})
-if (WIN32)
+if (WIN32 AND NOT DISABLE_CURL)
set_target_properties(minifi-expression-language-extensions PROPERTIES
- LINK_FLAGS "/WHOLEARCHIVE"
+ LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:${CURL_LIBRARIES}"
)
-elseif (APPLE)
- set_target_properties(minifi-expression-language-extensions PROPERTIES
- LINK_FLAGS "-Wl,-all_load"
- )
-else ()
- set_target_properties(minifi-expression-language-extensions PROPERTIES
- LINK_FLAGS "-Wl,--whole-archive"
- )
-endif ()
+endif()
SET (EXPRESSION-LANGUAGE-EXTENSIONS minifi-expression-language-extensions PARENT_SCOPE)
-register_extension(minifi-expression-language-extensions)
-
+register_extension(minifi-expression-language-extensions)
\ No newline at end of file
diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp
index 225c90c..873e522 100644
--- a/extensions/expression-language/Expression.cpp
+++ b/extensions/expression-language/Expression.cpp
@@ -26,6 +26,7 @@
#include "rapidjson/document.h"
#include <utils/StringUtils.h>
+#include <utils/OsUtils.h>
#include <expression/Expression.h>
#include <regex>
#ifndef DISABLE_CURL
@@ -39,10 +40,12 @@
#endif
#include <Windows.h>
#include <WS2tcpip.h>
+#include <sddl.h>
#pragma comment(lib, "Ws2_32.lib")
#else
#include <netdb.h>
#include <arpa/inet.h>
+#include <sys/types.h>
#endif
#include "utils/base64.h"
@@ -91,6 +94,18 @@ Expression make_dynamic_attr(const std::string &attribute_id) {
});
}
+Value resolve_user_id(const std::vector<Value> &args) {
+ std::string name;
+ if (args.size() == 1) {
+ name = args[0].asString();
+ if (!name.empty()) {
+ name = minifi::utils::OsUtils::userIdToUsername(name);
+ }
+ }
+
+ return Value(name);
+}
+
Value expr_hostname(const std::vector<Value> &args) {
char hostname[1024];
hostname[1023] = '\0';
@@ -1345,6 +1360,8 @@ Expression make_join(const std::string &function_name, const std::vector<Express
Expression make_dynamic_function(const std::string &function_name, const std::vector<Expression> &args) {
if (function_name == "hostname") {
return make_dynamic_function_incomplete<expr_hostname>(function_name, args, 0);
+ } else if (function_name == "resolve_user_id") {
+ return make_dynamic_function_incomplete<resolve_user_id>(function_name, args, 0);
} else if (function_name == "ip") {
return make_dynamic_function_incomplete<expr_ip>(function_name, args, 0);
} else if (function_name == "UUID") {
diff --git a/extensions/expression-language/ExpressionContextBuilder.cpp b/extensions/expression-language/ExpressionContextBuilder.cpp
new file mode 100644
index 0000000..5714947
--- /dev/null
+++ b/extensions/expression-language/ExpressionContextBuilder.cpp
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ExpressionContextBuilder.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+namespace expressions {
+
+ExpressionContextBuilder::ExpressionContextBuilder(const std::string &name, minifi::utils::Identifier &uuid)
+ : core::ProcessContextBuilder(name, uuid) {
+}
+
+ExpressionContextBuilder::ExpressionContextBuilder(const std::string &name)
+ : core::ProcessContextBuilder(name) {
+}
+
+ExpressionContextBuilder::~ExpressionContextBuilder() {
+}
+
+std::shared_ptr<core::ProcessContext> ExpressionContextBuilder::build(const std::shared_ptr<ProcessorNode> &processor) {
+ return std::make_shared<core::ProcessContextExpr>(processor, controller_service_provider_, prov_repo_, flow_repo_, configuration_, content_repo_);
+}
+
+} /* namespace expressions */
+} /* namespace core */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
diff --git a/extensions/expression-language/ExpressionContextBuilder.h b/extensions/expression-language/ExpressionContextBuilder.h
new file mode 100644
index 0000000..d9f078e
--- /dev/null
+++ b/extensions/expression-language/ExpressionContextBuilder.h
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTENSIONS_EXPRESSION_LANGUAGE_EXPRESSIONCONTEXTBUILDER_H_
+#define EXTENSIONS_EXPRESSION_LANGUAGE_EXPRESSIONCONTEXTBUILDER_H_
+
+#include "core/ProcessContextBuilder.h"
+#include "ProcessContextExpr.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+namespace expressions {
+
+/**
+ * Purpose: Creates a context builder that can be used by the class loader to inject EL functionality
+ *
+ * Justification: Linking became problematic across platforms since EL was used as a carrier of what was
+ * effectively core functionality. To eliminate this awkward linking and help with disabling EL entirely
+ * on some platforms, this builder was placed into the class loader.
+ */
+class ExpressionContextBuilder : public core::ProcessContextBuilder {
+ public:
+ ExpressionContextBuilder(const std::string &name, minifi::utils::Identifier &uuid);
+
+ ExpressionContextBuilder(const std::string &name);
+
+ virtual ~ExpressionContextBuilder();
+
+ virtual std::shared_ptr<core::ProcessContext> build(const std::shared_ptr<ProcessorNode> &processor) override;
+};
+
+} /* namespace expressions */
+} /* namespace core */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
+
+#endif /* EXTENSIONS_EXPRESSION_LANGUAGE_EXPRESSIONCONTEXTBUILDER_H_ */
diff --git a/libminifi/include/core/Deprecated.h b/extensions/expression-language/ExpressionLoader.cpp
similarity index 71%
copy from libminifi/include/core/Deprecated.h
copy to extensions/expression-language/ExpressionLoader.cpp
index faed844..b051d47 100644
--- a/libminifi/include/core/Deprecated.h
+++ b/extensions/expression-language/ExpressionLoader.cpp
@@ -1,5 +1,5 @@
/**
-
+ *
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -15,15 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_
-#define LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_
+#include "core/FlowConfiguration.h"
+#include "ExpressionLoader.h"
+
+bool ExpressionObjectFactory::added = core::FlowConfiguration::add_static_func("createExpressionFactory");
+extern "C" {
+
+
-#ifdef _MSC_VER
-#define DEPRECATED __declspec(deprecated)
-#elif defined(__GNUC__) | defined(__clang__)
-#define DEPRECATED __attribute__((__deprecated__))
-#else
-#define DEPRECATED
-#endif
+void *createExpressionFactory(void) {
+ return new ExpressionObjectFactory();
+}
-#endif /* LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_ */
+}
diff --git a/extensions/expression-language/ExpressionLoader.h b/extensions/expression-language/ExpressionLoader.h
new file mode 100644
index 0000000..ba174e4
--- /dev/null
+++ b/extensions/expression-language/ExpressionLoader.h
@@ -0,0 +1,72 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef EXTENSIONS_EXPRESSIONLOADER_H_
+#define EXTENSIONS_EXPRESSIONLOADER_H_
+#include "core/ClassLoader.h"
+#include "utils/StringUtils.h"
+#include "ExpressionContextBuilder.h"
+#include "core/controller/ControllerServiceProvider.h"
+
+/**
+ * Object factory class loader for this extension.
+ * Can add extensions to the default class loader through REGISTER_RESOURCE,
+ * but we want to ensure this factory is used specifically for CoAP and not the default loader.
+ */
+class ExpressionObjectFactory : public core::ObjectFactory {
+ public:
+ ExpressionObjectFactory() {
+
+ }
+
+ /**
+ * Gets the name of the object.
+ * @return class name of processor
+ */
+ virtual std::string getName() override {
+ return "ExpressionObjectFactory";
+ }
+
+ virtual std::string getClassName() override {
+ return "ExpressionObjectFactory";
+ }
+ /**
+ * Gets the class name for the object
+ * @return class name for the processor.
+ */
+ virtual std::vector<std::string> getClassNames() override {
+ std::vector<std::string> class_names;
+ class_names.push_back("ProcessContextBuilder");
+ return class_names;
+ }
+
+ virtual std::unique_ptr<ObjectFactory> assign(const std::string &class_name) override {
+ if (utils::StringUtils::equalsIgnoreCase(class_name, "ProcessContextBuilder")) {
+ return std::unique_ptr<ObjectFactory>(new core::DefautObjectFactory<core::expressions::ExpressionContextBuilder>());
+ } else {
+ return nullptr;
+ }
+ }
+
+ static bool added;
+
+};
+
+extern "C" {
+DLL_EXPORT void *createExpressionFactory(void);
+}
+#endif /* EXTENSIONS_EXPRESSIONLOADER_H_ */
diff --git a/extensions/expression-language/ProcessContextExpr.cpp b/extensions/expression-language/ProcessContextExpr.cpp
index 928029f..2882302 100644
--- a/extensions/expression-language/ProcessContextExpr.cpp
+++ b/extensions/expression-language/ProcessContextExpr.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include <core/ProcessContext.h>
+#include "ProcessContextExpr.h"
#include <memory>
namespace org {
namespace apache {
@@ -23,14 +23,14 @@ namespace nifi {
namespace minifi {
namespace core {
-bool ProcessContext::getProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
+bool ProcessContextExpr::getProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
if (!property.supportsExpressionLangauge()) {
- return getProperty(property.getName(), value);
+ return ProcessContext::getProperty(property.getName(), value);
}
auto name = property.getName();
if (expressions_.find(name) == expressions_.end()) {
std::string expression_str;
- getProperty(name, expression_str);
+ ProcessContext::getProperty(name, expression_str);
logger_->log_debug("Compiling expression for %s/%s: %s", getProcessorNode()->getName(), name, expression_str);
expressions_.emplace(name, expression::compile(expression_str));
}
@@ -40,15 +40,15 @@ bool ProcessContext::getProperty(const Property &property, std::string &value, c
return true;
}
-bool ProcessContext::getDynamicProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
+bool ProcessContextExpr::getDynamicProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
if (!property.supportsExpressionLangauge()) {
- return getDynamicProperty(property.getName(), value);
+ return ProcessContext::getDynamicProperty(property.getName(), value);
}
auto name = property.getName();
if (dynamic_property_expressions_.find(name) == dynamic_property_expressions_.end()) {
std::string expression_str;
- getDynamicProperty(name, expression_str);
+ ProcessContext::getDynamicProperty(name, expression_str);
logger_->log_debug("Compiling expression for %s/%s: %s", getProcessorNode()->getName(), name, expression_str);
dynamic_property_expressions_.emplace(name, expression::compile(expression_str));
}
diff --git a/extensions/expression-language/ProcessContextExpr.h b/extensions/expression-language/ProcessContextExpr.h
new file mode 100644
index 0000000..0464228
--- /dev/null
+++ b/extensions/expression-language/ProcessContextExpr.h
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ProcessContext.h>
+#include <memory>
+#include <impl/expression/Expression.h>
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+/**
+ * Purpose and Justification: Used to inject EL functionality into the classloader and remove EL as
+ * a core functionality. This created linking issues as it was always required even in a disabled
+ * state. With this case, we can rely on instantiation of a builder to create the necessary
+ * ProcessContext. *
+ */
+class ProcessContextExpr : public core::ProcessContext {
+ public:
+
+ /**
+ std::forward of argument list did not work on all platform.
+ **/
+ ProcessContextExpr(const std::shared_ptr<ProcessorNode> &processor, std::shared_ptr<controller::ControllerServiceProvider> &controller_service_provider,
+ const std::shared_ptr<core::Repository> &repo, const std::shared_ptr<core::Repository> &flow_repo,
+ const std::shared_ptr<core::ContentRepository> &content_repo = std::make_shared<core::repository::FileSystemRepository>())
+ : core::ProcessContext(processor, controller_service_provider, repo, flow_repo, content_repo),
+ logger_(logging::LoggerFactory<ProcessContextExpr>::getLogger()) {
+ }
+
+ ProcessContextExpr(const std::shared_ptr<ProcessorNode> &processor, std::shared_ptr<controller::ControllerServiceProvider> &controller_service_provider,
+ const std::shared_ptr<core::Repository> &repo, const std::shared_ptr<core::Repository> &flow_repo, const std::shared_ptr<minifi::Configure> &configuration,
+ const std::shared_ptr<core::ContentRepository> &content_repo = std::make_shared<core::repository::FileSystemRepository>())
+ : core::ProcessContext(processor, controller_service_provider, repo, flow_repo, configuration, content_repo),
+ logger_(logging::LoggerFactory<ProcessContextExpr>::getLogger()) {
+ }
+ // Destructor
+ virtual ~ProcessContextExpr() {
+ }
+ /**
+ * Retrieves property using EL
+ * @param property property
+ * @param value that will be filled
+ * @param flow_file flow file.
+ */
+ virtual bool getProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) override;
+
+ virtual bool getDynamicProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) override;
+ protected:
+
+ std::map<std::string, org::apache::nifi::minifi::expression::Expression> expressions_;
+ std::map<std::string, org::apache::nifi::minifi::expression::Expression> dynamic_property_expressions_;
+
+ private:
+ std::shared_ptr<logging::Logger> logger_;
+};
+
+} /* namespace core */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
diff --git a/extensions/expression-language/impl/expression/Expression.h b/extensions/expression-language/impl/expression/Expression.h
index ac987f7..47b71d3 100644
--- a/extensions/expression-language/impl/expression/Expression.h
+++ b/extensions/expression-language/impl/expression/Expression.h
@@ -32,9 +32,9 @@
#undef EXPRESSION_LANGUAGE_USE_DATE
#endif
-#include <Value.h>
-#include <core/FlowFile.h>
-#include <core/VariableRegistry.h>
+#include "common/Value.h"
+#include <FlowFile.h>
+#include <VariableRegistry.h>
#include <string>
#include <memory>
diff --git a/extensions/expression-language/tests/CMakeLists.txt b/extensions/expression-language/tests/CMakeLists.txt
new file mode 100644
index 0000000..52f01d0
--- /dev/null
+++ b/extensions/expression-language/tests/CMakeLists.txt
@@ -0,0 +1,109 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+file(GLOB EXPRESSION_LANGUAGE_TESTS "*.cpp")
+
+SET(EXTENSIONS_TEST_COUNT 0)
+if (NOT WIN32)
+ FOREACH(testfile ${EXPRESSION_LANGUAGE_TESTS})
+ get_filename_component(testfilename "${testfile}" NAME_WE)
+ add_executable(${testfilename} "${testfile}")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language")
+ createTests(${testfilename})
+ target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
+
+
+ if (NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} ${CURL_LIBRARIES})
+ endif()
+ if (WIN32)
+ foreach(OPENSSL_LIB ${OPENSSL_LIBRARIES})
+ if (OPENSSL_LIB MATCHES "\\.lib$" OR OPENSSL_LIB MATCHES "\\.dll$" )
+ message( "Including ${OPENSSL_LIB}")
+ target_link_libraries (${testfilename} ${OPENSSL_LIB})
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:${OPENSSL_LIB}")
+ endif()
+ endforeach()
+ target_link_libraries (${testfilename} minifi-expression-language-extensions minifi-standard-processors)
+ elseif (APPLE)
+ target_link_libraries (${testfilename} -Wl,-all_load minifi-expression-language-extensions minifi-standard-processors)
+ else ()
+ target_link_libraries (${testfilename} -Wl,--whole-archive ${OPENSSL_LIBRARIES} minifi-expression-language-extensions minifi-standard-processors -Wl,--no-whole-archive)
+ endif()
+ MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1")
+ add_test(NAME ${testfilename} COMMAND ${testfilename} WORKING_DIRECTORY ${TEST_DIR})
+ ENDFOREACH()
+endif()
+
+
+### integration tests
+
+if(NOT WIN32)
+file(GLOB INT_EXPRESSION_LANGUAGE_TESTS "integration/*.cpp")
+
+SET(INT_EXTENSIONS_TEST_COUNT 0)
+
+FOREACH(testfile ${INT_EXPRESSION_LANGUAGE_TESTS})
+ get_filename_component(testfilename "${testfile}" NAME_WE)
+ add_executable(${testfilename} "${testfile}")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch")
+ 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 "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors")
+ target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language")
+ createTests(${testfilename})
+
+ if (WIN32)
+ foreach(OPENSSL_LIB ${OPENSSL_LIBRARIES})
+ if (OPENSSL_LIB MATCHES "\\.lib$" OR OPENSSL_LIB MATCHES "\\.dll$" )
+ message( "Including ${OPENSSL_LIB}")
+ target_link_libraries (${testfilename} ${OPENSSL_LIB})
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:${OPENSSL_LIB}")
+ endif()
+ endforeach()
+ if (NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} ${CURL_LIBRARIES})
+ endif()
+ target_link_libraries (${testfilename} minifi-expression-language-extensions minifi-standard-processors)
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi-expression-language-extensions /WHOLEARCHIVE:minifi-standard-processors")
+ elseif (APPLE)
+ if (NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} ${CURL_LIBRARIES})
+ endif(NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} -Wl,-all_load minifi-expression-language-extensions minifi-standard-processors)
+ else ()
+ if (NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} ${CURL_LIBRARIES})
+ endif(NOT DISABLE_CURL)
+ target_link_libraries (${testfilename} -Wl,--whole-archive ${OPENSSL_LIBRARIES} minifi-expression-language-extensions minifi-standard-processors -Wl,--no-whole-archive)
+ endif()
+ MATH(EXPR EXTENSIONS_TEST_COUNT "${INT_EXTENSIONS_TEST_COUNT}+1")
+ENDFOREACH()
+
+
+add_test(NAME UpdateAttributeIntegrationTest COMMAND UpdateAttributeIntegrationTest "${TEST_RESOURCES}/TestUpdateAttribute.yml" "${TEST_RESOURCES}/")
+
+message("-- Finished building ${EXTENSIONS_TEST_COUNT} expression language related test file(s)...")
+endif()
\ No newline at end of file
diff --git a/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp b/extensions/expression-language/tests/ExpressionLanguageTests.cpp
similarity index 79%
rename from libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
rename to extensions/expression-language/tests/ExpressionLanguageTests.cpp
index c96cd12..68f7849 100644
--- a/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
+++ b/extensions/expression-language/tests/ExpressionLanguageTests.cpp
@@ -20,45 +20,54 @@
#include <memory>
#include <string>
-
-#include "../TestBase.h"
+#ifndef DISABLE_CURL
+#pragma comment(lib, "libcurl.lib")
+#pragma comment(lib, "Ws2_32.lib")
+#pragma comment(lib, "legacy_stdio_definitions.lib")
+#pragma comment(lib, "crypt32.lib")
+#include <curl/curl.h>
+#endif
+#include "impl/expression/Expression.h"
#include <ExtractText.h>
#include <GetFile.h>
#include <PutFile.h>
#include <UpdateAttribute.h>
+#include "core/FlowFile.h"
#include <LogAttribute.h>
+#include "TestBase.h"
namespace expression = org::apache::nifi::minifi::expression;
class MockFlowFile : public core::FlowFile {
- void releaseClaim(const std::shared_ptr<minifi::ResourceClaim> claim) override {}
+ void releaseClaim(const std::shared_ptr<minifi::ResourceClaim> claim) override {
+ }
};
TEST_CASE("Trivial static expression", "[expressionLanguageTestTrivialStaticExpr]") { // NOLINT
- REQUIRE("a" == expression::make_static("a")({}).asString());
+ REQUIRE("a" == expression::make_static("a")( { }).asString());
}
TEST_CASE("Text expression", "[expressionLanguageTestTextExpression]") { // NOLINT
auto expr = expression::compile("text");
- REQUIRE("text" == expr({}).asString());
+ REQUIRE("text" == expr( { }).asString());
}
TEST_CASE("Text expression with escaped dollar", "[expressionLanguageTestEscapedDollar]") { // NOLINT
auto expr = expression::compile("te$$xt");
- REQUIRE("te$xt" == expr({}).asString());
+ REQUIRE("te$xt" == expr( { }).asString());
}
TEST_CASE("Attribute expression", "[expressionLanguageTestAttributeExpression]") { // NOLINT
auto flow_file = std::make_shared<MockFlowFile>();
flow_file->addAttribute("attr_a", "__attr_value_a__");
auto expr = expression::compile("text_before${attr_a}text_after");
- REQUIRE("text_before__attr_value_a__text_after" == expr({flow_file}).asString());
+ REQUIRE("text_before__attr_value_a__text_after" == expr( { flow_file }).asString());
}
TEST_CASE("Attribute expression (Null)", "[expressionLanguageTestAttributeExpressionNull]") { // NOLINT
auto expr = expression::compile("text_before${attr_a}text_after");
std::shared_ptr<MockFlowFile> flow_file = nullptr;
- REQUIRE("text_beforetext_after" == expr({flow_file}).asString());
+ REQUIRE("text_beforetext_after" == expr( { flow_file }).asString());
}
TEST_CASE("Multi-attribute expression", "[expressionLanguageTestMultiAttributeExpression]") { // NOLINT
@@ -66,27 +75,27 @@ TEST_CASE("Multi-attribute expression", "[expressionLanguageTestMultiAttributeEx
flow_file->addAttribute("attr_a", "__attr_value_a__");
flow_file->addAttribute("attr_b", "__attr_value_b__");
auto expr = expression::compile("text_before${attr_a}text_between${attr_b}text_after");
- REQUIRE("text_before__attr_value_a__text_between__attr_value_b__text_after" == expr({flow_file}).asString());
+ REQUIRE("text_before__attr_value_a__text_between__attr_value_b__text_after" == expr( { flow_file }).asString());
}
TEST_CASE("Multi-flowfile attribute expression",
- "[expressionLanguageTestMultiFlowfileAttributeExpression]") { // NOLINT
+ "[expressionLanguageTestMultiFlowfileAttributeExpression]") { // NOLINT
auto expr = expression::compile("text_before${attr_a}text_after");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__flow_a_attr_value_a__");
- REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
auto flow_file_b = std::make_shared<MockFlowFile>();
flow_file_b->addAttribute("attr_a", "__flow_b_attr_value_a__");
- REQUIRE("text_before__flow_b_attr_value_a__text_after" == expr({flow_file_b}).asString());
+ REQUIRE("text_before__flow_b_attr_value_a__text_after" == expr( { flow_file_b }).asString());
}
TEST_CASE("Attribute expression with whitespace", "[expressionLanguageTestAttributeExpressionWhitespace]") { // NOLINT
auto flow_file = std::make_shared<MockFlowFile>();
flow_file->addAttribute("attr_a", "__attr_value_a__");
auto expr = expression::compile("text_before${\n\tattr_a \r}text_after");
- REQUIRE("text_before__attr_value_a__text_after" == expr({flow_file}).asString());
+ REQUIRE("text_before__attr_value_a__text_after" == expr( { flow_file }).asString());
}
TEST_CASE("Special characters expression", "[expressionLanguageTestSpecialCharactersExpression]") { // NOLINT
@@ -94,7 +103,7 @@ TEST_CASE("Special characters expression", "[expressionLanguageTestSpecialCharac
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__flow_a_attr_value_a__");
- REQUIRE("text_before|{}()[],:;\\/*#'\" \t\r\n__flow_a_attr_value_a__}()text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before|{}()[],:;\\/*#'\" \t\r\n__flow_a_attr_value_a__}()text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("UTF-8 characters expression", "[expressionLanguageTestUTF8Expression]") { // NOLINT
@@ -102,7 +111,7 @@ TEST_CASE("UTF-8 characters expression", "[expressionLanguageTestUTF8Expression]
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__flow_a_attr_value_a__");
- REQUIRE("text_before¥£€¢₡₢₣₤₥₦₧₨₩₪₫â‚₮₯₹__flow_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before¥£€¢₡₢₣₤₥₦₧₨₩₪₫â‚₮₯₹__flow_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("UTF-8 characters attribute", "[expressionLanguageTestUTF8Attribute]") { // NOLINT
@@ -110,7 +119,7 @@ TEST_CASE("UTF-8 characters attribute", "[expressionLanguageTestUTF8Attribute]")
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__¥£€¢₡₢₣₤₥₦₧₨₩₪₫â‚₮₯₹__");
- REQUIRE("text_before__¥£€¢₡₢₣₤₥₦₧₨₩₪₫â‚₮₯₹__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__¥£€¢₡₢₣₤₥₦₧₨₩₪₫â‚₮₯₹__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("Single quoted attribute expression", "[expressionLanguageTestSingleQuotedAttributeExpression]") { // NOLINT
@@ -118,7 +127,7 @@ TEST_CASE("Single quoted attribute expression", "[expressionLanguageTestSingleQu
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("|{}()[],:;\\/*# \t\r\n$", "__flow_a_attr_value_a__");
- REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("Double quoted attribute expression", "[expressionLanguageTestDoubleQuotedAttributeExpression]") { // NOLINT
@@ -126,7 +135,7 @@ TEST_CASE("Double quoted attribute expression", "[expressionLanguageTestDoubleQu
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("|{}()[],:;\\/*# \t\r\n$", "__flow_a_attr_value_a__");
- REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("Hostname function", "[expressionLanguageTestHostnameFunction]") { // NOLINT
@@ -140,7 +149,7 @@ TEST_CASE("Hostname function", "[expressionLanguageTestHostnameFunction]") { //
expected.append("text_after");
auto flow_file_a = std::make_shared<MockFlowFile>();
- REQUIRE(expected == expr({flow_file_a}).asString());
+ REQUIRE(expected == expr( { flow_file_a }).asString());
}
TEST_CASE("ToUpper function", "[expressionLanguageTestToUpperFunction]") { // NOLINT
@@ -149,14 +158,14 @@ TEST_CASE("ToUpper function", "[expressionLanguageTestToUpperFunction]") { // N
}text_after)");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__flow_a_attr_value_a__");
- REQUIRE("text_before__FLOW_A_ATTR_VALUE_A__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__FLOW_A_ATTR_VALUE_A__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("ToUpper function w/o whitespace", "[expressionLanguageTestToUpperFunctionWithoutWhitespace]") { // NOLINT
auto expr = expression::compile(R"(text_before${attr_a:toUpper()}text_after)");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__flow_a_attr_value_a__");
- REQUIRE("text_before__FLOW_A_ATTR_VALUE_A__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__FLOW_A_ATTR_VALUE_A__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("ToLower function", "[expressionLanguageTestToLowerFunction]") { // NOLINT
@@ -165,7 +174,7 @@ TEST_CASE("ToLower function", "[expressionLanguageTestToLowerFunction]") { // N
}text_after)");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr_a", "__FLOW_A_ATTR_VALUE_A__");
- REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before__flow_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("GetFile PutFile dynamic attribute", "[expressionLanguageTestGetFilePutFileDynamicAttribute]") { // NOLINT
@@ -186,70 +195,33 @@ TEST_CASE("GetFile PutFile dynamic attribute", "[expressionLanguageTestGetFilePu
auto plan = testController.createPlan(conf);
auto repo = std::make_shared<TestRepository>();
- std::string in_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&in_dir[0]) != nullptr);
+ char format[] = "/tmp/gt.XXXXXX";
+ std::string in_dir = testController.createTempDirectory(format);
+ REQUIRE(!in_dir.empty());
std::string in_file(in_dir);
in_file.append("/file");
-
- std::string out_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&out_dir[0]) != nullptr);
+ char formatX[] = "/tmp/gt.XXXXXX";
+ std::string out_dir = testController.createTempDirectory(formatX);
+ REQUIRE(!out_dir.empty());
std::string out_file(out_dir);
out_file.append("/extracted_attr/file");
// Build MiNiFi processing graph
- auto get_file = plan->addProcessor(
- "GetFile",
- "GetFile");
- plan->setProperty(
- get_file,
- processors::GetFile::Directory.getName(), in_dir);
- plan->setProperty(
- get_file,
- processors::GetFile::KeepSourceFile.getName(),
- "false");
- auto update = plan->addProcessor(
- "UpdateAttribute",
- "UpdateAttribute",
- core::Relationship("success", "description"),
- true);
+ auto get_file = plan->addProcessor("GetFile", "GetFile");
+ plan->setProperty(get_file, processors::GetFile::Directory.getName(), in_dir);
+ plan->setProperty(get_file, processors::GetFile::KeepSourceFile.getName(), "false");
+ auto update = plan->addProcessor("UpdateAttribute", "UpdateAttribute", core::Relationship("success", "description"), true);
update->setDynamicProperty("prop_attr", "${'nifi.my.own.property'}_added");
- plan->addProcessor(
- "LogAttribute",
- "LogAttribute",
- core::Relationship("success", "description"),
- true);
- auto extract_text = plan->addProcessor(
- "ExtractText",
- "ExtractText",
- core::Relationship("success", "description"),
- true);
- plan->setProperty(
- extract_text,
- processors::ExtractText::Attribute.getName(), "extracted_attr_name");
- plan->addProcessor(
- "LogAttribute",
- "LogAttribute",
- core::Relationship("success", "description"),
- true);
- auto put_file = plan->addProcessor(
- "PutFile",
- "PutFile",
- core::Relationship("success", "description"),
- true);
- plan->setProperty(
- put_file,
- processors::PutFile::Directory.getName(),
- out_dir + "/${extracted_attr_name}");
- plan->setProperty(
- put_file,
- processors::PutFile::ConflictResolution.getName(),
- processors::PutFile::CONFLICT_RESOLUTION_STRATEGY_REPLACE);
- plan->setProperty(
- put_file,
- processors::PutFile::CreateDirs.getName(),
- "true");
+ plan->addProcessor("LogAttribute", "LogAttribute", core::Relationship("success", "description"), true);
+ auto extract_text = plan->addProcessor("ExtractText", "ExtractText", core::Relationship("success", "description"), true);
+ plan->setProperty(extract_text, processors::ExtractText::Attribute.getName(), "extracted_attr_name");
+ plan->addProcessor("LogAttribute", "LogAttribute", core::Relationship("success", "description"), true);
+ auto put_file = plan->addProcessor("PutFile", "PutFile", core::Relationship("success", "description"), true);
+ plan->setProperty(put_file, processors::PutFile::Directory.getName(), out_dir + "/${extracted_attr_name}");
+ plan->setProperty(put_file, processors::PutFile::ConflictResolution.getName(), processors::PutFile::CONFLICT_RESOLUTION_STRATEGY_REPLACE);
+ plan->setProperty(put_file, processors::PutFile::CreateDirs.getName(), "true");
// Write test input
{
@@ -280,7 +252,7 @@ TEST_CASE("Substring 2 arg", "[expressionLanguageSubstring2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("text_before_a_attr_text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before_a_attr_text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring 1 arg", "[expressionLanguageSubstring1]") { // NOLINT
@@ -288,7 +260,7 @@ TEST_CASE("Substring 1 arg", "[expressionLanguageSubstring1]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("text_before_a_attr_value_a__text_after" == expr({flow_file_a}).asString());
+ REQUIRE("text_before_a_attr_value_a__text_after" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring Before", "[expressionLanguageSubstringBefore]") { // NOLINT
@@ -296,7 +268,7 @@ TEST_CASE("Substring Before", "[expressionLanguageSubstringBefore]") { // NOLIN
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("__flow_a_" == expr({flow_file_a}).asString());
+ REQUIRE("__flow_a_" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring Before Last", "[expressionLanguageSubstringBeforeLast]") { // NOLINT
@@ -304,7 +276,7 @@ TEST_CASE("Substring Before Last", "[expressionLanguageSubstringBeforeLast]") {
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("__flow_a_attr_value" == expr({flow_file_a}).asString());
+ REQUIRE("__flow_a_attr_value" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring After", "[expressionLanguageSubstringAfter]") { // NOLINT
@@ -312,7 +284,7 @@ TEST_CASE("Substring After", "[expressionLanguageSubstringAfter]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("_attr_value_a__" == expr({flow_file_a}).asString());
+ REQUIRE("_attr_value_a__" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring After Last", "[expressionLanguageSubstringAfterLast]") { // NOLINT
@@ -320,7 +292,7 @@ TEST_CASE("Substring After Last", "[expressionLanguageSubstringAfterLast]") { /
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
- REQUIRE("__" == expr({flow_file_a}).asString());
+ REQUIRE("__" == expr( { flow_file_a }).asString());
}
TEST_CASE("Get Delimited", "[expressionLanguageGetDelimited]") { // NOLINT
@@ -328,7 +300,7 @@ TEST_CASE("Get Delimited", "[expressionLanguageGetDelimited]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "\"Jacobson, John\", 32, Mr.");
- REQUIRE(" 32" == expr({flow_file_a}).asString());
+ REQUIRE(" 32" == expr( { flow_file_a }).asString());
}
TEST_CASE("Get Delimited 2", "[expressionLanguageGetDelimited2]") { // NOLINT
@@ -336,7 +308,7 @@ TEST_CASE("Get Delimited 2", "[expressionLanguageGetDelimited2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "\"Jacobson, John\", 32, Mr.");
- REQUIRE("\"Jacobson, John\"" == expr({flow_file_a}).asString());
+ REQUIRE("\"Jacobson, John\"" == expr( { flow_file_a }).asString());
}
TEST_CASE("Get Delimited 3", "[expressionLanguageGetDelimited3]") { // NOLINT
@@ -344,7 +316,7 @@ TEST_CASE("Get Delimited 3", "[expressionLanguageGetDelimited3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "\"Jacobson, John\", 32, Mr.");
- REQUIRE("Jacobson, John" == expr({flow_file_a}).asString());
+ REQUIRE("Jacobson, John" == expr( { flow_file_a }).asString());
}
TEST_CASE("Starts With", "[expressionLanguageStartsWith]") { // NOLINT
@@ -352,7 +324,7 @@ TEST_CASE("Starts With", "[expressionLanguageStartsWith]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "A BRAND TEST");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Starts With 2", "[expressionLanguageStartsWith2]") { // NOLINT
@@ -360,7 +332,7 @@ TEST_CASE("Starts With 2", "[expressionLanguageStartsWith2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand TEST");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Ends With", "[expressionLanguageEndsWith]") { // NOLINT
@@ -368,7 +340,7 @@ TEST_CASE("Ends With", "[expressionLanguageEndsWith]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.TXT");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Ends With 2", "[expressionLanguageEndsWith2]") { // NOLINT
@@ -376,7 +348,7 @@ TEST_CASE("Ends With 2", "[expressionLanguageEndsWith2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.TXT");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Contains", "[expressionLanguageContains]") { // NOLINT
@@ -384,7 +356,7 @@ TEST_CASE("Contains", "[expressionLanguageContains]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Contains 2", "[expressionLanguageContains2]") { // NOLINT
@@ -392,7 +364,7 @@ TEST_CASE("Contains 2", "[expressionLanguageContains2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("In", "[expressionLanguageIn]") { // NOLINT
@@ -400,7 +372,7 @@ TEST_CASE("In", "[expressionLanguageIn]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "JOHN");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("In 2", "[expressionLanguageIn2]") { // NOLINT
@@ -408,16 +380,17 @@ TEST_CASE("In 2", "[expressionLanguageIn2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "JOHN");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Substring Before No Args", "[expressionLanguageSubstringBeforeNoArgs]") { // NOLINT
- REQUIRE_THROWS_WITH(expression::compile("${attr:substringBefore()}"),
- "Expression language function substringBefore called with 1 argument(s), but 2 are required");
+ REQUIRE_THROWS_WITH(expression::compile("${attr:substringBefore()}"), "Expression language function substringBefore called with 1 argument(s), but 2 are required");
}
TEST_CASE("Substring After No Args", "[expressionLanguageSubstringAfterNoArgs]") { // NOLINT
- REQUIRE_THROWS_WITH(expression::compile("${attr:substringAfter()}"); ,
+ REQUIRE_THROWS_WITH(expression::compile("${attr:substringAfter()}")
+ ;
+ ,
"Expression language function substringAfter called with 1 argument(s), but 2 are required");
}
@@ -428,7 +401,7 @@ TEST_CASE("Replace", "[expressionLanguageReplace]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a brand new filename_txt" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename_txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace 2", "[expressionLanguageReplace2]") { // NOLINT
@@ -436,7 +409,7 @@ TEST_CASE("Replace 2", "[expressionLanguageReplace2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a.brand.new.filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a.brand.new.filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace First", "[expressionLanguageReplaceFirst]") { // NOLINT
@@ -444,7 +417,7 @@ TEST_CASE("Replace First", "[expressionLanguageReplaceFirst]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("the brand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("the brand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace First Regex", "[expressionLanguageReplaceFirstRegex]") { // NOLINT
@@ -452,7 +425,7 @@ TEST_CASE("Replace First Regex", "[expressionLanguageReplaceFirstRegex]") { //
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a grand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a grand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace All", "[expressionLanguageReplaceAll]") { // NOLINT
@@ -460,7 +433,7 @@ TEST_CASE("Replace All", "[expressionLanguageReplaceAll]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a brand new filename" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace All 2", "[expressionLanguageReplaceAll2]") { // NOLINT
@@ -468,7 +441,7 @@ TEST_CASE("Replace All 2", "[expressionLanguageReplaceAll2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace All 3", "[expressionLanguageReplaceAll3]") { // NOLINT
@@ -476,7 +449,7 @@ TEST_CASE("Replace All 3", "[expressionLanguageReplaceAll3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a brand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace Null", "[expressionLanguageReplaceNull]") { // NOLINT
@@ -484,7 +457,7 @@ TEST_CASE("Replace Null", "[expressionLanguageReplaceNull]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a brand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace Null 2", "[expressionLanguageReplaceNull2]") { // NOLINT
@@ -492,7 +465,7 @@ TEST_CASE("Replace Null 2", "[expressionLanguageReplaceNull2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr2", "a brand new filename.txt");
- REQUIRE("abc" == expr({flow_file_a}).asString());
+ REQUIRE("abc" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace Empty", "[expressionLanguageReplaceEmpty]") { // NOLINT
@@ -500,7 +473,7 @@ TEST_CASE("Replace Empty", "[expressionLanguageReplaceEmpty]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("a brand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace Empty 2", "[expressionLanguageReplaceEmpty2]") { // NOLINT
@@ -508,7 +481,7 @@ TEST_CASE("Replace Empty 2", "[expressionLanguageReplaceEmpty2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", " \t \r \n ");
- REQUIRE("abc" == expr({flow_file_a}).asString());
+ REQUIRE("abc" == expr( { flow_file_a }).asString());
}
TEST_CASE("Replace Empty 3", "[expressionLanguageReplaceEmpty2]") { // NOLINT
@@ -516,7 +489,7 @@ TEST_CASE("Replace Empty 3", "[expressionLanguageReplaceEmpty2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr2", "test");
- REQUIRE("abc" == expr({flow_file_a}).asString());
+ REQUIRE("abc" == expr( { flow_file_a }).asString());
}
TEST_CASE("Matches", "[expressionLanguageMatches]") { // NOLINT
@@ -524,7 +497,7 @@ TEST_CASE("Matches", "[expressionLanguageMatches]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "At:est");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Matches 2", "[expressionLanguageMatches2]") { // NOLINT
@@ -532,7 +505,7 @@ TEST_CASE("Matches 2", "[expressionLanguageMatches2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "At:something");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Matches 3", "[expressionLanguageMatches3]") { // NOLINT
@@ -540,7 +513,7 @@ TEST_CASE("Matches 3", "[expressionLanguageMatches3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", " At:est");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Find", "[expressionLanguageFind]") { // NOLINT
@@ -548,7 +521,7 @@ TEST_CASE("Find", "[expressionLanguageFind]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Find 2", "[expressionLanguageFind2]") { // NOLINT
@@ -556,7 +529,7 @@ TEST_CASE("Find 2", "[expressionLanguageFind2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Find 3", "[expressionLanguageFind3]") { // NOLINT
@@ -564,7 +537,7 @@ TEST_CASE("Find 3", "[expressionLanguageFind3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("IndexOf", "[expressionLanguageIndexOf]") { // NOLINT
@@ -572,7 +545,7 @@ TEST_CASE("IndexOf", "[expressionLanguageIndexOf]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("-1" == expr({flow_file_a}).asString());
+ REQUIRE("-1" == expr( { flow_file_a }).asString());
}
TEST_CASE("IndexOf2", "[expressionLanguageIndexOf2]") { // NOLINT
@@ -580,7 +553,7 @@ TEST_CASE("IndexOf2", "[expressionLanguageIndexOf2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("20" == expr({flow_file_a}).asString());
+ REQUIRE("20" == expr( { flow_file_a }).asString());
}
TEST_CASE("IndexOf3", "[expressionLanguageIndexOf3]") { // NOLINT
@@ -588,7 +561,7 @@ TEST_CASE("IndexOf3", "[expressionLanguageIndexOf3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("0" == expr({flow_file_a}).asString());
+ REQUIRE("0" == expr( { flow_file_a }).asString());
}
TEST_CASE("IndexOf4", "[expressionLanguageIndexOf4]") { // NOLINT
@@ -596,7 +569,7 @@ TEST_CASE("IndexOf4", "[expressionLanguageIndexOf4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("1" == expr({flow_file_a}).asString());
+ REQUIRE("1" == expr( { flow_file_a }).asString());
}
TEST_CASE("LastIndexOf", "[expressionLanguageLastIndexOf]") { // NOLINT
@@ -604,7 +577,7 @@ TEST_CASE("LastIndexOf", "[expressionLanguageLastIndexOf]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("-1" == expr({flow_file_a}).asString());
+ REQUIRE("-1" == expr( { flow_file_a }).asString());
}
TEST_CASE("LastIndexOf2", "[expressionLanguageLastIndexOf2]") { // NOLINT
@@ -612,7 +585,7 @@ TEST_CASE("LastIndexOf2", "[expressionLanguageLastIndexOf2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("20" == expr({flow_file_a}).asString());
+ REQUIRE("20" == expr( { flow_file_a }).asString());
}
TEST_CASE("LastIndexOf3", "[expressionLanguageLastIndexOf3]") { // NOLINT
@@ -620,7 +593,7 @@ TEST_CASE("LastIndexOf3", "[expressionLanguageLastIndexOf3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("17" == expr({flow_file_a}).asString());
+ REQUIRE("17" == expr( { flow_file_a }).asString());
}
TEST_CASE("LastIndexOf4", "[expressionLanguageLastIndexOf4]") { // NOLINT
@@ -628,7 +601,7 @@ TEST_CASE("LastIndexOf4", "[expressionLanguageLastIndexOf4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "a brand new filename.txt");
- REQUIRE("11" == expr({flow_file_a}).asString());
+ REQUIRE("11" == expr( { flow_file_a }).asString());
}
#endif // EXPRESSION_LANGUAGE_USE_REGEX
@@ -638,7 +611,7 @@ TEST_CASE("Plus Integer", "[expressionLanguagePlusInteger]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11");
- REQUIRE("24" == expr({flow_file_a}).asString());
+ REQUIRE("24" == expr( { flow_file_a }).asString());
}
TEST_CASE("Plus Decimal", "[expressionLanguagePlusDecimal]") { // NOLINT
@@ -646,7 +619,7 @@ TEST_CASE("Plus Decimal", "[expressionLanguagePlusDecimal]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11.1");
- REQUIRE("-2.24567" == expr({flow_file_a}).asString());
+ REQUIRE("-2.24567" == expr( { flow_file_a }).asString());
}
TEST_CASE("Plus Exponent", "[expressionLanguagePlusExponent]") { // NOLINT
@@ -654,7 +627,7 @@ TEST_CASE("Plus Exponent", "[expressionLanguagePlusExponent]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11");
- REQUIRE("10000011" == expr({flow_file_a}).asString());
+ REQUIRE("10000011" == expr( { flow_file_a }).asString());
}
TEST_CASE("Plus Exponent 2", "[expressionLanguagePlusExponent2]") { // NOLINT
@@ -662,7 +635,7 @@ TEST_CASE("Plus Exponent 2", "[expressionLanguagePlusExponent2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11.345678901234");
- REQUIRE("10000011.345678901234351" == expr({flow_file_a}).asString());
+ REQUIRE("10000011.345678901234351" == expr( { flow_file_a }).asString());
}
TEST_CASE("Minus Integer", "[expressionLanguageMinusInteger]") { // NOLINT
@@ -670,7 +643,7 @@ TEST_CASE("Minus Integer", "[expressionLanguageMinusInteger]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11");
- REQUIRE("-2" == expr({flow_file_a}).asString());
+ REQUIRE("-2" == expr( { flow_file_a }).asString());
}
TEST_CASE("Minus Decimal", "[expressionLanguageMinusDecimal]") { // NOLINT
@@ -678,7 +651,7 @@ TEST_CASE("Minus Decimal", "[expressionLanguageMinusDecimal]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11.1");
- REQUIRE("24.44567" == expr({flow_file_a}).asString());
+ REQUIRE("24.44567" == expr( { flow_file_a }).asString());
}
TEST_CASE("Multiply Integer", "[expressionLanguageMultiplyInteger]") { // NOLINT
@@ -686,7 +659,7 @@ TEST_CASE("Multiply Integer", "[expressionLanguageMultiplyInteger]") { // NOLIN
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11");
- REQUIRE("143" == expr({flow_file_a}).asString());
+ REQUIRE("143" == expr( { flow_file_a }).asString());
}
TEST_CASE("Multiply Decimal", "[expressionLanguageMultiplyDecimal]") { // NOLINT
@@ -694,7 +667,7 @@ TEST_CASE("Multiply Decimal", "[expressionLanguageMultiplyDecimal]") { // NOLIN
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11.1");
- REQUIRE("-148.136937" == expr({flow_file_a}).asString());
+ REQUIRE("-148.136937" == expr( { flow_file_a }).asString());
}
TEST_CASE("Divide Integer", "[expressionLanguageDivideInteger]") { // NOLINT
@@ -702,7 +675,7 @@ TEST_CASE("Divide Integer", "[expressionLanguageDivideInteger]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11");
- REQUIRE("0.846153846153846" == expr({flow_file_a}).asString());
+ REQUIRE("0.846153846153846" == expr( { flow_file_a }).asString());
}
TEST_CASE("Divide Decimal", "[expressionLanguageDivideDecimal]") { // NOLINT
@@ -710,7 +683,7 @@ TEST_CASE("Divide Decimal", "[expressionLanguageDivideDecimal]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "11.1");
- REQUIRE("-0.831730441409086" == expr({flow_file_a}).asString());
+ REQUIRE("-0.831730441409086" == expr( { flow_file_a }).asString());
}
TEST_CASE("To Radix", "[expressionLanguageToRadix]") { // NOLINT
@@ -718,7 +691,7 @@ TEST_CASE("To Radix", "[expressionLanguageToRadix]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "10");
- REQUIRE("0000000000001010" == expr({flow_file_a}).asString());
+ REQUIRE("0000000000001010" == expr( { flow_file_a }).asString());
}
TEST_CASE("To Radix 2", "[expressionLanguageToRadix2]") { // NOLINT
@@ -726,7 +699,7 @@ TEST_CASE("To Radix 2", "[expressionLanguageToRadix2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "13");
- REQUIRE("d" == expr({flow_file_a}).asString());
+ REQUIRE("d" == expr( { flow_file_a }).asString());
}
TEST_CASE("To Radix 3", "[expressionLanguageToRadix3]") { // NOLINT
@@ -734,7 +707,7 @@ TEST_CASE("To Radix 3", "[expressionLanguageToRadix3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "-2347");
- REQUIRE("-000004a1" == expr({flow_file_a}).asString());
+ REQUIRE("-000004a1" == expr( { flow_file_a }).asString());
}
TEST_CASE("From Radix", "[expressionLanguageFromRadix]") { // NOLINT
@@ -742,7 +715,7 @@ TEST_CASE("From Radix", "[expressionLanguageFromRadix]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "0000000000001010");
- REQUIRE("10" == expr({flow_file_a}).asString());
+ REQUIRE("10" == expr( { flow_file_a }).asString());
}
TEST_CASE("From Radix 2", "[expressionLanguageFromRadix2]") { // NOLINT
@@ -750,7 +723,7 @@ TEST_CASE("From Radix 2", "[expressionLanguageFromRadix2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "d");
- REQUIRE("13" == expr({flow_file_a}).asString());
+ REQUIRE("13" == expr( { flow_file_a }).asString());
}
TEST_CASE("From Radix 3", "[expressionLanguageFromRadix3]") { // NOLINT
@@ -758,14 +731,14 @@ TEST_CASE("From Radix 3", "[expressionLanguageFromRadix3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "-000004a1");
- REQUIRE("-2347" == expr({flow_file_a}).asString());
+ REQUIRE("-2347" == expr( { flow_file_a }).asString());
}
TEST_CASE("Random", "[expressionLanguageRandom]") { // NOLINT
auto expr = expression::compile("${random()}");
auto flow_file_a = std::make_shared<MockFlowFile>();
- auto result = expr({flow_file_a}).asSignedLong();
+ auto result = expr( { flow_file_a }).asSignedLong();
REQUIRE(result > 0);
}
@@ -774,14 +747,14 @@ TEST_CASE("Chained call", "[expressionChainedCall]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("22" == expr({flow_file_a}).asString());
+ REQUIRE("22" == expr( { flow_file_a }).asString());
}
TEST_CASE("Chained call 2", "[expressionChainedCall2]") { // NOLINT
auto expr = expression::compile("${literal(10):multiply(2):plus(1):multiply(2)}");
auto flow_file_a = std::make_shared<MockFlowFile>();
- REQUIRE(42 == expr({flow_file_a}).asSignedLong());
+ REQUIRE(42 == expr( { flow_file_a }).asSignedLong());
}
TEST_CASE("Chained call 3", "[expressionChainedCall3]") { // NOLINT
@@ -789,7 +762,7 @@ TEST_CASE("Chained call 3", "[expressionChainedCall3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("238" == expr({flow_file_a}).asString());
+ REQUIRE("238" == expr( { flow_file_a }).asString());
}
TEST_CASE("LiteralBool", "[expressionLiteralBool]") { // NOLINT
@@ -797,7 +770,7 @@ TEST_CASE("LiteralBool", "[expressionLiteralBool]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE(true == expr({flow_file_a}).asBoolean());
+ REQUIRE(true == expr( { flow_file_a }).asBoolean());
}
TEST_CASE("LiteralBool 2", "[expressionLiteralBool2]") { // NOLINT
@@ -805,7 +778,7 @@ TEST_CASE("LiteralBool 2", "[expressionLiteralBool2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE(false == expr({flow_file_a}).asBoolean());
+ REQUIRE(false == expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Is Null", "[expressionIsNull]") { // NOLINT
@@ -813,7 +786,7 @@ TEST_CASE("Is Null", "[expressionIsNull]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Null 2", "[expressionIsNull2]") { // NOLINT
@@ -821,7 +794,7 @@ TEST_CASE("Is Null 2", "[expressionIsNull2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "7");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Not Null", "[expressionNotNull]") { // NOLINT
@@ -829,7 +802,7 @@ TEST_CASE("Not Null", "[expressionNotNull]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Not Null 2", "[expressionNotNull2]") { // NOLINT
@@ -837,7 +810,7 @@ TEST_CASE("Not Null 2", "[expressionNotNull2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "7");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Empty", "[expressionIsEmpty]") { // NOLINT
@@ -845,7 +818,7 @@ TEST_CASE("Is Empty", "[expressionIsEmpty]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Empty 2", "[expressionIsEmpty2]") { // NOLINT
@@ -853,7 +826,7 @@ TEST_CASE("Is Empty 2", "[expressionIsEmpty2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "7");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Empty 3", "[expressionIsEmpty3]") { // NOLINT
@@ -861,7 +834,7 @@ TEST_CASE("Is Empty 3", "[expressionIsEmpty3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", " \t\r\n ");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Empty 4", "[expressionIsEmpty4]") { // NOLINT
@@ -869,7 +842,7 @@ TEST_CASE("Is Empty 4", "[expressionIsEmpty4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Is Empty 5", "[expressionIsEmpty5]") { // NOLINT
@@ -877,7 +850,7 @@ TEST_CASE("Is Empty 5", "[expressionIsEmpty5]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", " \t\r\n a \t\r\n ");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Equals", "[expressionEquals]") { // NOLINT
@@ -885,7 +858,7 @@ TEST_CASE("Equals", "[expressionEquals]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "hello.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Equals 2", "[expressionEquals2]") { // NOLINT
@@ -893,7 +866,7 @@ TEST_CASE("Equals 2", "[expressionEquals2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "helllo.txt");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Equals 3", "[expressionEquals3]") { // NOLINT
@@ -901,7 +874,7 @@ TEST_CASE("Equals 3", "[expressionEquals3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Equals Ignore Case", "[expressionEqualsIgnoreCase]") { // NOLINT
@@ -909,7 +882,7 @@ TEST_CASE("Equals Ignore Case", "[expressionEqualsIgnoreCase]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "hello.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Equals Ignore Case 2", "[expressionEqualsIgnoreCase2]") { // NOLINT
@@ -917,7 +890,7 @@ TEST_CASE("Equals Ignore Case 2", "[expressionEqualsIgnoreCase2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("GT", "[expressionGT]") { // NOLINT
@@ -925,7 +898,7 @@ TEST_CASE("GT", "[expressionGT]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("GT2", "[expressionGT2]") { // NOLINT
@@ -933,7 +906,7 @@ TEST_CASE("GT2", "[expressionGT2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("GT3", "[expressionGT3]") { // NOLINT
@@ -941,7 +914,7 @@ TEST_CASE("GT3", "[expressionGT3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("GE", "[expressionGE]") { // NOLINT
@@ -949,7 +922,7 @@ TEST_CASE("GE", "[expressionGE]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("GE2", "[expressionGE2]") { // NOLINT
@@ -957,7 +930,7 @@ TEST_CASE("GE2", "[expressionGE2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("GE3", "[expressionGE3]") { // NOLINT
@@ -965,7 +938,7 @@ TEST_CASE("GE3", "[expressionGE3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("LT", "[expressionLT]") { // NOLINT
@@ -973,7 +946,7 @@ TEST_CASE("LT", "[expressionLT]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("LT2", "[expressionLT2]") { // NOLINT
@@ -981,7 +954,7 @@ TEST_CASE("LT2", "[expressionLT2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("LT3", "[expressionLT3]") { // NOLINT
@@ -989,7 +962,7 @@ TEST_CASE("LT3", "[expressionLT3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("LE", "[expressionLE]") { // NOLINT
@@ -997,7 +970,7 @@ TEST_CASE("LE", "[expressionLE]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("LE2", "[expressionLE2]") { // NOLINT
@@ -1005,7 +978,7 @@ TEST_CASE("LE2", "[expressionLE2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("LE3", "[expressionLE3]") { // NOLINT
@@ -1013,7 +986,7 @@ TEST_CASE("LE3", "[expressionLE3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("attr", "1");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("And", "[expressionAnd]") { // NOLINT
@@ -1021,7 +994,7 @@ TEST_CASE("And", "[expressionAnd]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("And 2", "[expressionAnd2]") { // NOLINT
@@ -1029,7 +1002,7 @@ TEST_CASE("And 2", "[expressionAnd2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Or", "[expressionOr]") { // NOLINT
@@ -1037,7 +1010,7 @@ TEST_CASE("Or", "[expressionOr]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Or 2", "[expressionOr2]") { // NOLINT
@@ -1045,7 +1018,7 @@ TEST_CASE("Or 2", "[expressionOr2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("Not", "[expressionNot]") { // NOLINT
@@ -1053,7 +1026,7 @@ TEST_CASE("Not", "[expressionNot]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("false" == expr({flow_file_a}).asString());
+ REQUIRE("false" == expr( { flow_file_a }).asString());
}
TEST_CASE("Not 2", "[expressionNot2]") { // NOLINT
@@ -1061,7 +1034,7 @@ TEST_CASE("Not 2", "[expressionNot2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("true" == expr({flow_file_a}).asString());
+ REQUIRE("true" == expr( { flow_file_a }).asString());
}
TEST_CASE("If Else", "[expressionIfElse]") { // NOLINT
@@ -1069,7 +1042,7 @@ TEST_CASE("If Else", "[expressionIfElse]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "an example file.txt");
- REQUIRE("yes" == expr({flow_file_a}).asString());
+ REQUIRE("yes" == expr( { flow_file_a }).asString());
}
TEST_CASE("If Else 2", "[expressionIfElse2]") { // NOLINT
@@ -1077,7 +1050,7 @@ TEST_CASE("If Else 2", "[expressionIfElse2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("filename", "An example file.txt");
- REQUIRE("no" == expr({flow_file_a}).asString());
+ REQUIRE("no" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode JSON", "[expressionEncodeJSON]") { // NOLINT
@@ -1085,7 +1058,7 @@ TEST_CASE("Encode JSON", "[expressionEncodeJSON]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "This is a \"test!\"");
- REQUIRE("This is a \\\"test!\\\"" == expr({flow_file_a}).asString());
+ REQUIRE("This is a \\\"test!\\\"" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode JSON", "[expressionDecodeJSON]") { // NOLINT
@@ -1093,7 +1066,7 @@ TEST_CASE("Decode JSON", "[expressionDecodeJSON]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "This is a \\\"test!\\\"");
- REQUIRE("This is a \"test!\"" == expr({flow_file_a}).asString());
+ REQUIRE("This is a \"test!\"" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode JSON", "[expressionEncodeDecodeJSON]") { // NOLINT
@@ -1101,7 +1074,7 @@ TEST_CASE("Encode Decode JSON", "[expressionEncodeDecodeJSON]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "This is a \"test!\"");
- REQUIRE("This is a \"test!\"" == expr({flow_file_a}).asString());
+ REQUIRE("This is a \"test!\"" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode XML", "[expressionEncodeXML]") { // NOLINT
@@ -1109,7 +1082,7 @@ TEST_CASE("Encode XML", "[expressionEncodeXML]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < \"two!\" & 'true'");
- REQUIRE("Zero > One < "two!" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < "two!" & 'true'" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode XML", "[expressionDecodeXML]") { // NOLINT
@@ -1117,7 +1090,7 @@ TEST_CASE("Decode XML", "[expressionDecodeXML]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < "two!" & 'true'");
- REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < \"two!\" & 'true'" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode XML", "[expressionEncodeDecodeXML]") { // NOLINT
@@ -1125,7 +1098,7 @@ TEST_CASE("Encode Decode XML", "[expressionEncodeDecodeXML]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < \"two!\" & 'true'");
- REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < \"two!\" & 'true'" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode HTML3", "[expressionEncodeHTML3]") { // NOLINT
@@ -1133,7 +1106,7 @@ TEST_CASE("Encode HTML3", "[expressionEncodeHTML3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ & < «");
- REQUIRE("¥ & < «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ & < «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode HTML3", "[expressionDecodeHTML3]") { // NOLINT
@@ -1141,7 +1114,7 @@ TEST_CASE("Decode HTML3", "[expressionDecodeHTML3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ & < «");
- REQUIRE("¥ & < «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ & < «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode HTML3", "[expressionEncodeDecodeHTML3]") { // NOLINT
@@ -1149,7 +1122,7 @@ TEST_CASE("Encode Decode HTML3", "[expressionEncodeDecodeHTML3]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ & < «");
- REQUIRE("¥ & < «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ & < «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode HTML4", "[expressionEncodeHTML4]") { // NOLINT
@@ -1157,7 +1130,7 @@ TEST_CASE("Encode HTML4", "[expressionEncodeHTML4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ & Φ < «");
- REQUIRE("¥ & Φ < «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ & Φ < «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode HTML4", "[expressionDecodeHTML4]") { // NOLINT
@@ -1165,7 +1138,7 @@ TEST_CASE("Decode HTML4", "[expressionDecodeHTML4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ ι & < «");
- REQUIRE("¥ ι & < «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ ι & < «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode HTML4", "[expressionEncodeDecodeHTML4]") { // NOLINT
@@ -1173,7 +1146,7 @@ TEST_CASE("Encode Decode HTML4", "[expressionEncodeDecodeHTML4]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "¥ & < Π «");
- REQUIRE("¥ & < Π «" == expr({flow_file_a}).asString());
+ REQUIRE("¥ & < Π «" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode CSV", "[expressionEncodeCSV]") { // NOLINT
@@ -1181,7 +1154,7 @@ TEST_CASE("Encode CSV", "[expressionEncodeCSV]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < \"two!\" & 'true'");
- REQUIRE("\"Zero > One < \"\"two!\"\" & 'true'\"" == expr({flow_file_a}).asString());
+ REQUIRE("\"Zero > One < \"\"two!\"\" & 'true'\"" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode CSV", "[expressionDecodeCSV]") { // NOLINT
@@ -1189,7 +1162,7 @@ TEST_CASE("Decode CSV", "[expressionDecodeCSV]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", R"("Zero > One < ""two!"" & 'true'")");
- REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < \"two!\" & 'true'" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode CSV 2", "[expressionDecodeCSV2]") { // NOLINT
@@ -1197,25 +1170,25 @@ TEST_CASE("Decode CSV 2", "[expressionDecodeCSV2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", R"("quoted")");
- REQUIRE("\"quoted\"" == expr({flow_file_a}).asString());
+ REQUIRE("\"quoted\"" == expr( { flow_file_a }).asString());
}
-
TEST_CASE("Encode Decode CSV", "[expressionEncodeDecodeCSV]") { // NOLINT
auto expr = expression::compile("${message:escapeCsv():unescapeCsv()}");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < \"two!\" & 'true'");
- REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < \"two!\" & 'true'" == expr( { flow_file_a }).asString());
}
+#ifndef WIN32
#ifndef DISABLE_CURL
TEST_CASE("Encode URL", "[expressionEncodeURL]") { // NOLINT
auto expr = expression::compile("${message:urlEncode()}");
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some value with spaces");
- REQUIRE("some%20value%20with%20spaces" == expr({flow_file_a}).asString());
+ REQUIRE("some%20value%20with%20spaces" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode URL", "[expressionDecodeURL]") { // NOLINT
@@ -1223,7 +1196,7 @@ TEST_CASE("Decode URL", "[expressionDecodeURL]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some%20value%20with%20spaces");
- REQUIRE("some value with spaces" == expr({flow_file_a}).asString());
+ REQUIRE("some value with spaces" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURL]") { // NOLINT
@@ -1231,7 +1204,7 @@ TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURL]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some value with spaces");
- REQUIRE("some value with spaces" == expr({flow_file_a}).asString());
+ REQUIRE("some value with spaces" == expr( { flow_file_a }).asString());
}
#else
TEST_CASE("Encode URL", "[expressionEncodeURLExcept]") { // NOLINT
@@ -1239,7 +1212,7 @@ TEST_CASE("Encode URL", "[expressionEncodeURLExcept]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some value with spaces");
- REQUIRE_THROWS(expr({flow_file_a}).asString());
+ REQUIRE_THROWS(expr( {flow_file_a}).asString());
}
TEST_CASE("Decode URL", "[expressionDecodeURLExcept]") { // NOLINT
@@ -1247,7 +1220,7 @@ TEST_CASE("Decode URL", "[expressionDecodeURLExcept]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some%20value%20with%20spaces");
- REQUIRE_THROWS(expr({flow_file_a}).asString());
+ REQUIRE_THROWS(expr( {flow_file_a}).asString());
}
TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURLExcept]") { // NOLINT
@@ -1255,9 +1228,10 @@ TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURLExcept]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "some value with spaces");
- REQUIRE_THROWS(expr({flow_file_a}).asString());
+ REQUIRE_THROWS(expr( {flow_file_a}).asString());
}
#endif
+#endif
#ifdef EXPRESSION_LANGUAGE_USE_DATE
@@ -1266,7 +1240,7 @@ TEST_CASE("Parse Date", "[expressionParseDate]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "2014/04/30");
- REQUIRE("1398841200000" == expr({flow_file_a}).asString());
+ REQUIRE("1398841200000" == expr( { flow_file_a }).asString());
}
TEST_CASE("Format Date", "[expressionFormatDate]") { // NOLINT
@@ -1274,7 +1248,7 @@ TEST_CASE("Format Date", "[expressionFormatDate]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "1394755200000");
- REQUIRE("03-14-2014" == expr({flow_file_a}).asString());
+ REQUIRE("03-14-2014" == expr( { flow_file_a }).asString());
}
TEST_CASE("Reformat Date", "[expressionReformatDate]") { // NOLINT
@@ -1282,7 +1256,7 @@ TEST_CASE("Reformat Date", "[expressionReformatDate]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "2014/03/14");
- REQUIRE("03-13-2014" == expr({flow_file_a}).asString());
+ REQUIRE("03-13-2014" == expr( { flow_file_a }).asString());
}
TEST_CASE("Now Date", "[expressionNowDate]") { // NOLINT
@@ -1294,7 +1268,7 @@ TEST_CASE("Now Date", "[expressionNowDate]") { // NOLINT
struct tm lt;
localtime_r(&t, <);
- REQUIRE((lt.tm_year + 1900) == expr({flow_file_a}).asUnsignedLong());
+ REQUIRE((lt.tm_year + 1900) == expr( { flow_file_a }).asUnsignedLong());
}
#endif // EXPRESSION_LANGUAGE_USE_DATE
@@ -1303,21 +1277,21 @@ TEST_CASE("IP", "[expressionIP]") { // NOLINT
auto expr = expression::compile("${ip()}");
auto flow_file_a = std::make_shared<MockFlowFile>();
- REQUIRE("" != expr({flow_file_a}).asString());
+ REQUIRE("" != expr( { flow_file_a }).asString());
}
TEST_CASE("Full Hostname", "[expressionFullHostname]") { // NOLINT
auto expr = expression::compile("${hostname('true')}");
auto flow_file_a = std::make_shared<MockFlowFile>();
- REQUIRE("" != expr({flow_file_a}).asString());
+ REQUIRE("" != expr( { flow_file_a }).asString());
}
TEST_CASE("UUID", "[expressionUuid]") { // NOLINT
auto expr = expression::compile("${UUID()}");
auto flow_file_a = std::make_shared<MockFlowFile>();
- REQUIRE(36 == expr({flow_file_a}).asString().length());
+ REQUIRE(36 == expr( { flow_file_a }).asString().length());
}
TEST_CASE("Trim", "[expressionTrim]") { // NOLINT
@@ -1325,7 +1299,7 @@ TEST_CASE("Trim", "[expressionTrim]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", " 1 2 3 ");
- REQUIRE("1 2 3" == expr({flow_file_a}).asString());
+ REQUIRE("1 2 3" == expr( { flow_file_a }).asString());
}
TEST_CASE("Append", "[expressionAppend]") { // NOLINT
@@ -1333,7 +1307,7 @@ TEST_CASE("Append", "[expressionAppend]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "a brand new filename.txt");
- REQUIRE("a brand new filename.txt.gz" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename.txt.gz" == expr( { flow_file_a }).asString());
}
TEST_CASE("Prepend", "[expressionPrepend]") { // NOLINT
@@ -1341,7 +1315,7 @@ TEST_CASE("Prepend", "[expressionPrepend]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "filename.txt");
- REQUIRE("a brand new filename.txt" == expr({flow_file_a}).asString());
+ REQUIRE("a brand new filename.txt" == expr( { flow_file_a }).asString());
}
TEST_CASE("Length", "[expressionLength]") { // NOLINT
@@ -1349,7 +1323,7 @@ TEST_CASE("Length", "[expressionLength]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "a brand new filename.txt");
- REQUIRE(24 == expr({flow_file_a}).asUnsignedLong());
+ REQUIRE(24 == expr( { flow_file_a }).asUnsignedLong());
}
TEST_CASE("Encode B64", "[expressionEncodeB64]") { // NOLINT
@@ -1357,7 +1331,7 @@ TEST_CASE("Encode B64", "[expressionEncodeB64]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "admin:admin");
- REQUIRE("YWRtaW46YWRtaW4=" == expr({flow_file_a}).asString());
+ REQUIRE("YWRtaW46YWRtaW4=" == expr( { flow_file_a }).asString());
}
TEST_CASE("Decode B64", "[expressionDecodeB64]") { // NOLINT
@@ -1365,7 +1339,7 @@ TEST_CASE("Decode B64", "[expressionDecodeB64]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "YWRtaW46YWRtaW4=");
- REQUIRE("admin:admin" == expr({flow_file_a}).asString());
+ REQUIRE("admin:admin" == expr( { flow_file_a }).asString());
}
TEST_CASE("Encode Decode B64", "[expressionEncodeDecodeB64]") { // NOLINT
@@ -1373,7 +1347,7 @@ TEST_CASE("Encode Decode B64", "[expressionEncodeDecodeB64]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("message", "Zero > One < \"two!\" & 'true'");
- REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
+ REQUIRE("Zero > One < \"two!\" & 'true'" == expr( { flow_file_a }).asString());
}
TEST_CASE("All Contains", "[expressionAllContains]") { // NOLINT
@@ -1382,7 +1356,7 @@ TEST_CASE("All Contains", "[expressionAllContains]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello 1");
flow_file_a->addAttribute("b", "hello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Contains 2", "[expressionAllContains2]") { // NOLINT
@@ -1391,7 +1365,7 @@ TEST_CASE("All Contains 2", "[expressionAllContains2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello 1");
flow_file_a->addAttribute("b", "mello 2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Contains", "[expressionAnyContains]") { // NOLINT
@@ -1400,7 +1374,7 @@ TEST_CASE("Any Contains", "[expressionAnyContains]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello 1");
flow_file_a->addAttribute("b", "mello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Contains 2", "[expressionAnyContains2]") { // NOLINT
@@ -1409,7 +1383,7 @@ TEST_CASE("Any Contains 2", "[expressionAnyContains2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "mello 1");
flow_file_a->addAttribute("b", "mello 2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
#ifdef EXPRESSION_LANGUAGE_USE_REGEX
@@ -1420,7 +1394,7 @@ TEST_CASE("All Matching Contains", "[expressionAllMatchingContains]") { // NOLI
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "hello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Matching Contains 2", "[expressionAllMatchingContains2]") { // NOLINT
@@ -1429,7 +1403,7 @@ TEST_CASE("All Matching Contains 2", "[expressionAllMatchingContains2]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "hello 2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Matching Contains 3", "[expressionAllMatchingContains3]") { // NOLINT
@@ -1438,7 +1412,7 @@ TEST_CASE("All Matching Contains 3", "[expressionAllMatchingContains3]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("abc_2", "hello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Matching Contains 4", "[expressionAllMatchingContains4]") { // NOLINT
@@ -1447,7 +1421,7 @@ TEST_CASE("All Matching Contains 4", "[expressionAllMatchingContains4]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Matching Contains", "[expressionAnyMatchingContains]") { // NOLINT
@@ -1456,7 +1430,7 @@ TEST_CASE("Any Matching Contains", "[expressionAnyMatchingContains]") { // NOLI
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "mello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Matching Contains 2", "[expressionAnyMatchingContains2]") { // NOLINT
@@ -1465,7 +1439,7 @@ TEST_CASE("Any Matching Contains 2", "[expressionAnyMatchingContains2]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "mello 2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Matching Contains 3", "[expressionAnyMatchingContains3]") { // NOLINT
@@ -1474,7 +1448,7 @@ TEST_CASE("Any Matching Contains 3", "[expressionAnyMatchingContains3]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("abc_1", "hello 1");
flow_file_a->addAttribute("xyz_2", "mello 2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Matching Contains 4", "[expressionAnyMatchingContains4]") { // NOLINT
@@ -1483,7 +1457,7 @@ TEST_CASE("Any Matching Contains 4", "[expressionAnyMatchingContains4]") { // N
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("xyz_1", "mello 1");
flow_file_a->addAttribute("xyz_2", "mello 2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
#endif // EXPRESSION_LANGUAGE_USE_REGEX
@@ -1493,7 +1467,7 @@ TEST_CASE("All Delineated Contains", "[expressionAllDelineatedContains]") { //
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("word_list", "hello_1,hello_2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Delineated Contains 2", "[expressionAllDelineatedContains2]") { // NOLINT
@@ -1501,7 +1475,7 @@ TEST_CASE("All Delineated Contains 2", "[expressionAllDelineatedContains2]") {
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("word_list", "hello_1,mello_2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("All Delineated Contains 3", "[expressionAllDelineatedContains3]") { // NOLINT
@@ -1509,7 +1483,7 @@ TEST_CASE("All Delineated Contains 3", "[expressionAllDelineatedContains3]") {
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("word_list", "hello_1,hello_2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Delineated Contains", "[expressionAnyDelineatedContains]") { // NOLINT
@@ -1517,7 +1491,7 @@ TEST_CASE("Any Delineated Contains", "[expressionAnyDelineatedContains]") { //
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("word_list", "hello_1,mello_2");
- REQUIRE(expr({flow_file_a}).asBoolean());
+ REQUIRE(expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Any Delineated Contains 2", "[expressionAnyDelineatedContains2]") { // NOLINT
@@ -1525,7 +1499,7 @@ TEST_CASE("Any Delineated Contains 2", "[expressionAnyDelineatedContains2]") {
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("word_list", "mello_1,mello_2");
- REQUIRE(!expr({flow_file_a}).asBoolean());
+ REQUIRE(!expr( { flow_file_a }).asBoolean());
}
TEST_CASE("Count", "[expressionCount]") { // NOLINT
@@ -1534,7 +1508,7 @@ TEST_CASE("Count", "[expressionCount]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello 1");
flow_file_a->addAttribute("b", "mello 2");
- REQUIRE(1 == expr({flow_file_a}).asUnsignedLong());
+ REQUIRE(1 == expr( { flow_file_a }).asUnsignedLong());
}
TEST_CASE("Count 2", "[expressionCount2]") { // NOLINT
@@ -1544,7 +1518,7 @@ TEST_CASE("Count 2", "[expressionCount2]") { // NOLINT
flow_file_a->addAttribute("a", "mello 1");
flow_file_a->addAttribute("b", "mello 2");
flow_file_a->addAttribute("c", "hello 3");
- REQUIRE(2 == expr({flow_file_a}).asUnsignedLong());
+ REQUIRE(2 == expr( { flow_file_a }).asUnsignedLong());
}
TEST_CASE("Count 3", "[expressionCount3]") { // NOLINT
@@ -1554,7 +1528,7 @@ TEST_CASE("Count 3", "[expressionCount3]") { // NOLINT
flow_file_a->addAttribute("a", "mello 1");
flow_file_a->addAttribute("b", "mello 2");
flow_file_a->addAttribute("c", "hello 3");
- REQUIRE("abc2xyz" == expr({flow_file_a}).asString());
+ REQUIRE("abc2xyz" == expr( { flow_file_a }).asString());
}
TEST_CASE("Join", "[expressionJoin]") { // NOLINT
@@ -1563,7 +1537,7 @@ TEST_CASE("Join", "[expressionJoin]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello");
flow_file_a->addAttribute("b", "mello");
- REQUIRE("abc_def_hello_ghi|def_mello_ghi_xyz" == expr({flow_file_a}).asString());
+ REQUIRE("abc_def_hello_ghi|def_mello_ghi_xyz" == expr( { flow_file_a }).asString());
}
TEST_CASE("Join 2", "[expressionJoin2]") { // NOLINT
@@ -1572,5 +1546,27 @@ TEST_CASE("Join 2", "[expressionJoin2]") { // NOLINT
auto flow_file_a = std::make_shared<MockFlowFile>();
flow_file_a->addAttribute("a", "hello");
flow_file_a->addAttribute("b", "mello");
- REQUIRE("abc_def_hello|mello_ghi_xyz" == expr({flow_file_a}).asString());
+ REQUIRE("abc_def_hello|mello_ghi_xyz" == expr( { flow_file_a }).asString());
+}
+
+TEST_CASE("resolve_user_id_test", "[resolve_user_id tests]") { // NOLINT
+ auto expr = expression::compile("${attribute_sid:resolve_user_id()}");
+
+ auto flow_file_a = std::make_shared<MockFlowFile>();
+
+ SECTION("TEST 0"){
+ flow_file_a->addAttribute("attribute_sid", "0");
+ REQUIRE("0" == expr( {flow_file_a}).asString());
+}
+
+ SECTION("TEST abcd"){
+ flow_file_a->addAttribute("attribute_sid", "abcd");
+ REQUIRE("abcd" == expr( {flow_file_a}).asString());
}
+
+ SECTION("TEST empty"){
+ flow_file_a->addAttribute("attribute_sid", "");
+ REQUIRE("" == expr( {flow_file_a}).asString());
+}
+}
+
diff --git a/libminifi/test/expression-language-tests/RouteOnAttributeTests.cpp b/extensions/expression-language/tests/RouteOnAttributeTests.cpp
similarity index 99%
rename from libminifi/test/expression-language-tests/RouteOnAttributeTests.cpp
rename to extensions/expression-language/tests/RouteOnAttributeTests.cpp
index 329ffe0..8b98b30 100644
--- a/libminifi/test/expression-language-tests/RouteOnAttributeTests.cpp
+++ b/extensions/expression-language/tests/RouteOnAttributeTests.cpp
@@ -16,7 +16,7 @@
* limitations under the License.
*/
#include <memory>
-#include "../TestBase.h"
+#include "TestBase.h"
#include <RouteOnAttribute.h>
#include "processors/LogAttribute.h"
#include "processors/UpdateAttribute.h"
diff --git a/libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
similarity index 87%
rename from libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp
rename to extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
index e635a2b..a525404 100644
--- a/libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp
+++ b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp
@@ -30,8 +30,9 @@
#include <iostream>
#include <sstream>
#include "processors/LogAttribute.h"
-#include "../../integration/IntegrationBase.h"
-#include "../../TestBase.h"
+#include "integration/IntegrationBase.h"
+#include "ProcessContextExpr.h"
+#include "TestBase.h"
class TestHarness : public IntegrationBase {
public:
@@ -40,7 +41,9 @@ class TestHarness : public IntegrationBase {
}
void testSetup() {
- LogTestController::getInstance().setInfo<minifi::FlowController>();
+ LogTestController::getInstance().setTrace<minifi::FlowController>();
+ LogTestController::getInstance().setTrace<core::ProcessSession>();
+ LogTestController::getInstance().setTrace<core::ProcessContextExpr>();
LogTestController::getInstance().setInfo<processors::LogAttribute>();
}
diff --git a/extensions/http-curl/CMakeLists.txt b/extensions/http-curl/CMakeLists.txt
index ccec972..2697475 100644
--- a/extensions/http-curl/CMakeLists.txt
+++ b/extensions/http-curl/CMakeLists.txt
@@ -41,7 +41,7 @@ endif()
if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
if (WIN32)
- message("Including ${CURL_LIBRARY}")
+ message("Including ${CURL_LIBRARY} into minifi-http-curl")
target_link_libraries (minifi-http-curl ${CURL_LIBRARY})
set_target_properties(minifi-http-curl PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:${CURL_LIBRARY}")
@@ -50,10 +50,6 @@ if (CURL_FOUND)
endif()
endif ()
-# Include UUID
-find_package(UUID REQUIRED)
-#set(LINK_FLAGS ${LINK_FLAGS} "-Wl,-whole-archive")
-
# Include OpenSSL
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
@@ -86,7 +82,6 @@ elseif (APPLE)
else ()
message("${OPENSSL_LIBRARIES}")
foreach(OPENSSL_LIB ${OPENSSL_LIBRARIES})
- #target_link_libraries (minifi-http-curl ${OPENSSL_LIB} )
target_link_libraries (minifi-http-curl ${OPENSSL_LIB})
endforeach()
endif ()
diff --git a/extensions/http-curl/sitetosite/HTTPProtocol.cpp b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
index 0c1d0f9..2641e17 100644
--- a/extensions/http-curl/sitetosite/HTTPProtocol.cpp
+++ b/extensions/http-curl/sitetosite/HTTPProtocol.cpp
@@ -69,10 +69,9 @@ std::shared_ptr<Transaction> HttpSiteToSiteClient::createTransaction(std::string
if (utils::StringUtils::equalsIgnoreCase(intent_name, "transaction-url")) {
auto url = client->getHeaderValue("Location");
- if (IsNullOrEmpty(&url)) {
+ if (IsNullOrEmpty(url)) {
logger_->log_debug("Location is empty");
} else {
-
org::apache::nifi::minifi::io::CRCStream<SiteToSitePeer> crcstream(peer_.get());
auto transaction = std::make_shared<HttpTransaction>(direction, crcstream);
transaction->initialize(this, url);
diff --git a/extensions/http-curl/sitetosite/HTTPTransaction.h b/extensions/http-curl/sitetosite/HTTPTransaction.h
index a3c83bd..e625ad6 100644
--- a/extensions/http-curl/sitetosite/HTTPTransaction.h
+++ b/extensions/http-curl/sitetosite/HTTPTransaction.h
@@ -43,7 +43,8 @@ class HttpTransaction : public sitetosite::Transaction {
~HttpTransaction(){
auto stream = dynamic_cast< org::apache::nifi::minifi::io::HttpStream*>( dynamic_cast<SiteToSitePeer*>(crcStream.getstream())->getStream() );
- stream->forceClose();
+ if (stream)
+ stream->forceClose();
}
void initialize(sitetosite::SiteToSiteClient *client, const std::string &url) {
diff --git a/extensions/http-curl/tests/C2FailedUpdateTest.cpp b/extensions/http-curl/tests/C2FailedUpdateTest.cpp
index d70f337..f5f206e 100644
--- a/extensions/http-curl/tests/C2FailedUpdateTest.cpp
+++ b/extensions/http-curl/tests/C2FailedUpdateTest.cpp
@@ -45,6 +45,7 @@
#include "CivetServer.h"
#include <cstring>
#include "protocols/RESTSender.h"
+#include "utils/file/FileUtils.h"
void waitToVerifyProcessor() {
std::this_thread::sleep_for(std::chrono::seconds(10));
@@ -176,7 +177,7 @@ int main(int argc, char **argv) {
configuration->set("nifi.c2.rest.url", c2_rest_url);
configuration->set("nifi.c2.rest.url.ack", c2_rest_url);
configuration->set("nifi.c2.agent.heartbeat.period", "1000");
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ utils::file::FileUtils::create_dir("content_repository");
std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
@@ -211,7 +212,7 @@ int main(int argc, char **argv) {
assert(logs.find("Invalid configuration payload") != std::string::npos);
assert(logs.find("update failed.") != std::string::npos);
LogTestController::getInstance().reset();
- rmdir("./content_repository");
+ utils::file::FileUtils::delete_dir("content_repository",true);
assert(h_ex.calls_ <= (milliseconds / 1000) + 1);
return 0;
diff --git a/extensions/http-curl/tests/C2JstackTest.cpp b/extensions/http-curl/tests/C2JstackTest.cpp
index 5e0538c..dd2ad27 100644
--- a/extensions/http-curl/tests/C2JstackTest.cpp
+++ b/extensions/http-curl/tests/C2JstackTest.cpp
@@ -126,7 +126,6 @@ int main(int argc, char **argv) {
configuration->set("c2.rest.url", c2_rest_url);
configuration->set("c2.agent.heartbeat.period", "1000");
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
@@ -162,7 +161,6 @@ int main(int argc, char **argv) {
assert(logs.find("SchedulingAgent") != std::string::npos);
#endif
LogTestController::getInstance().reset();
- rmdir("./content_repository");
assert(h_ex.calls_ <= (milliseconds / 1000) + 1);
return 0;
diff --git a/extensions/http-curl/tests/C2NullConfiguration.cpp b/extensions/http-curl/tests/C2NullConfiguration.cpp
index 3b86c49..ea511a8 100644
--- a/extensions/http-curl/tests/C2NullConfiguration.cpp
+++ b/extensions/http-curl/tests/C2NullConfiguration.cpp
@@ -108,7 +108,7 @@ class VerifyC2Server : public CoapIntegrationBase {
protected:
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/http-curl/tests/C2UpdateAgentTest.cpp b/extensions/http-curl/tests/C2UpdateAgentTest.cpp
index 2137c41..ba47e8c 100644
--- a/extensions/http-curl/tests/C2UpdateAgentTest.cpp
+++ b/extensions/http-curl/tests/C2UpdateAgentTest.cpp
@@ -152,7 +152,6 @@ int main(int argc, char **argv) {
configuration->set("nifi.c2.agent.update.allow","true");
configuration->set("nifi.c2.rest.url", c2_rest_url);
configuration->set("nifi.c2.agent.heartbeat.period", "1000");
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
@@ -188,7 +187,6 @@ int main(int argc, char **argv) {
assert(logs.find("removing file") != std::string::npos);
assert(logs.find("May not have command processor") != std::string::npos);
LogTestController::getInstance().reset();
- rmdir("./content_repository");
assert(h_ex.calls_ <= (milliseconds / 1000) + 1);
return 0;
diff --git a/extensions/http-curl/tests/C2UpdateTest.cpp b/extensions/http-curl/tests/C2UpdateTest.cpp
index cb3a4c3..ea4b151 100644
--- a/extensions/http-curl/tests/C2UpdateTest.cpp
+++ b/extensions/http-curl/tests/C2UpdateTest.cpp
@@ -150,7 +150,6 @@ int main(int argc, char **argv) {
configuration->set("nifi.c2.agent.class", "test");
configuration->set("nifi.c2.rest.url", c2_rest_url);
configuration->set("nifi.c2.agent.heartbeat.period", "1000");
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
@@ -184,7 +183,6 @@ int main(int argc, char **argv) {
std::string logs = LogTestController::getInstance().log_output.str();
assert(logs.find("Starting to reload Flow Controller with flow control name MiNiFi Flow, version") != std::string::npos);
LogTestController::getInstance().reset();
- rmdir("./content_repository");
assert(h_ex.calls_ <= (milliseconds / 1000) + 1);
return 0;
diff --git a/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp b/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp
index 9323a16..2eaa10b 100644
--- a/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp
+++ b/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp
@@ -63,7 +63,7 @@ class Responder : public CivetHandler {
std::string response;
int blockSize = 1024 * sizeof(char), readBytes;
- char buffer[blockSize];
+ char buffer[1024];
while ((readBytes = mg_read(conn, buffer, blockSize)) > 0) {
response.append(buffer, 0, (readBytes / sizeof(char)));
}
@@ -175,7 +175,7 @@ class VerifyC2Heartbeat : public CoapIntegrationBase {
protected:
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/http-curl/tests/C2VerifyServeResults.cpp b/extensions/http-curl/tests/C2VerifyServeResults.cpp
index 5335238..9f87c18 100644
--- a/extensions/http-curl/tests/C2VerifyServeResults.cpp
+++ b/extensions/http-curl/tests/C2VerifyServeResults.cpp
@@ -126,7 +126,7 @@ class VerifyC2Server : public CoapIntegrationBase {
protected:
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/http-curl/tests/CMakeLists.txt b/extensions/http-curl/tests/CMakeLists.txt
index 2290927..417a807 100644
--- a/extensions/http-curl/tests/CMakeLists.txt
+++ b/extensions/http-curl/tests/CMakeLists.txt
@@ -40,6 +40,9 @@ FOREACH(testfile ${CURL_UNIT_TESTS})
target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
if (APPLE)
target_link_libraries ("${testfilename}" -Wl,-all_load ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors)
+ elseif(WIN32)
+ target_link_libraries ("${testfilename}" ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors)
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi-http-curl /WHOLEARCHIVE:minifi-standard-processors")
else ()
target_link_libraries ("${testfilename}" -Wl,--whole-archive ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors -Wl,--no-whole-archive)
endif()
@@ -60,12 +63,15 @@ FOREACH(testfile ${CURL_INTEGRATION_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}")
if (APPLE)
target_link_libraries ("${testfilename}" -Wl,-all_load ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors)
+ elseif(WIN32)
+ target_link_libraries ("${testfilename}" ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors)
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi-http-curl /WHOLEARCHIVE:minifi-standard-processors")
else ()
target_link_libraries ("${testfilename}" -Wl,--whole-archive ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-http-curl minifi-civet-extensions minifi-standard-processors -Wl,--no-whole-archive)
endif()
- createTests("${testfilename}")
MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1")
ENDFOREACH()
@@ -79,7 +85,9 @@ add_test(NAME C2FailedUpdateTest COMMAND C2FailedUpdateTest "${TEST_RESOURCES}/T
add_test(NAME C2NullConfiguration COMMAND C2NullConfiguration "${TEST_RESOURCES}/TestNull.yml" "${TEST_RESOURCES}/")
add_test(NAME HttpGetIntegrationTestSecure COMMAND HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGetSecure.yml" "${TEST_RESOURCES}/")
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}/")
+endif()
add_test(NAME C2VerifyServeResults COMMAND C2VerifyServeResults "${TEST_RESOURCES}/C2VerifyServeResults.yml" "${TEST_RESOURCES}/")
add_test(NAME C2VerifyHeartbeatAndStopSecure COMMAND C2VerifyHeartbeatAndStop "${TEST_RESOURCES}/C2VerifyHeartbeatAndStopSecure.yml" "${TEST_RESOURCES}/")
add_test(NAME C2VerifyHeartbeatAndStop COMMAND C2VerifyHeartbeatAndStop "${TEST_RESOURCES}/C2VerifyHeartbeatAndStop.yml" )
diff --git a/extensions/http-curl/tests/GetFileNoData.cpp b/extensions/http-curl/tests/GetFileNoData.cpp
index a0a5dfd..7481991 100644
--- a/extensions/http-curl/tests/GetFileNoData.cpp
+++ b/extensions/http-curl/tests/GetFileNoData.cpp
@@ -136,8 +136,7 @@ int main(int argc, char **argv) {
configuration->set("c2.rest.url",
"http://localhost:9090/update");
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
-
+
std::shared_ptr<core::Repository> test_repo =
std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<
diff --git a/extensions/http-curl/tests/HTTPHandlers.h b/extensions/http-curl/tests/HTTPHandlers.h
index 704a9a9..282b470 100644
--- a/extensions/http-curl/tests/HTTPHandlers.h
+++ b/extensions/http-curl/tests/HTTPHandlers.h
@@ -78,7 +78,13 @@ class PeerResponder : public CivetHandler {
}
bool handleGet(CivetServer *server, struct mg_connection *conn) {
- std::string site2site_rest_resp = "{\"peers\" : [{ \"hostname\": \"localhost\", \"port\": 8099, \"secure\": false, \"flowFileCount\" : 0 }] }";
+
+#ifdef WIN32
+ std::string hostname = org::apache::nifi::minifi::io::Socket::getMyHostName();
+#else
+ std::string hostname = "localhost";
+#endif
+ std::string site2site_rest_resp = "{\"peers\" : [{ \"hostname\": \"" + hostname + "\", \"port\": 8099, \"secure\": false, \"flowFileCount\" : 0 }] }";
std::stringstream headers;
headers << "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " << site2site_rest_resp.length() << "\r\nConnection: close\r\n\r\n";
mg_printf(conn, "%s", headers.str().c_str());
diff --git a/extensions/http-curl/tests/HTTPIntegrationBase.h b/extensions/http-curl/tests/HTTPIntegrationBase.h
index 628c822..03a2c73 100644
--- a/extensions/http-curl/tests/HTTPIntegrationBase.h
+++ b/extensions/http-curl/tests/HTTPIntegrationBase.h
@@ -67,22 +67,20 @@ void CoapIntegrationBase::setUrl(std::string url, CivetHandler *handler) {
parse_http_components(url, port, scheme, path);
struct mg_callbacks callback;
- if (url.find("localhost") != std::string::npos || url.find(minifi::io::Socket::getMyHostName()) != std::string::npos) {
- if (server != nullptr) {
- server->addHandler(path, handler);
- return;
- }
- if (scheme == "https" && !key_dir.empty()) {
- std::string cert = "";
- cert = key_dir + "nifi-cert.pem";
- memset(&callback, 0, sizeof(callback));
- callback.init_ssl = ssl_enable;
- port += "s";
- callback.log_message = log_message;
- server = start_webserver(port, path, handler, &callback, cert, cert);
- } else {
- server = start_webserver(port, path, handler);
- }
+ if (server != nullptr) {
+ server->addHandler(path, handler);
+ return;
+ }
+ if (scheme == "https" && !key_dir.empty()) {
+ std::string cert = "";
+ cert = key_dir + "nifi-cert.pem";
+ memset(&callback, 0, sizeof(callback));
+ callback.init_ssl = ssl_enable;
+ port += "s";
+ callback.log_message = log_message;
+ server = start_webserver(port, path, handler, &callback, cert, cert);
+ } else {
+ server = start_webserver(port, path, handler);
}
if (port == "0" || port == "0s") {
bool secure = (port == "0s");
diff --git a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
index de7113b..378c143 100644
--- a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
+++ b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp
@@ -68,7 +68,7 @@ class SiteToSiteTestHarness : public CoapIntegrationBase {
LogTestController::getInstance().setDebug<core::ConfigurableComponent>();
std::fstream file;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -83,7 +83,6 @@ class SiteToSiteTestHarness : public CoapIntegrationBase {
}
void cleanup() {
- unlink(ss.str().c_str());
}
void runAssertions() {
@@ -91,7 +90,7 @@ class SiteToSiteTestHarness : public CoapIntegrationBase {
protected:
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
@@ -228,6 +227,13 @@ int main(int argc, char **argv) {
isSecure = true;
}
+#ifdef WIN32
+ if (url.find("localhost") != std::string::npos) {
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ url = scheme + "://" + org::apache::nifi::minifi::io::Socket::getMyHostName() + ":" + port + path;
+ }
+#endif
{
struct test_profile profile;
run_variance(test_file_location, isSecure, url, profile);
diff --git a/extensions/http-curl/tests/HttpGetIntegrationTest.cpp b/extensions/http-curl/tests/HttpGetIntegrationTest.cpp
index 3fc207a..f117a1e 100644
--- a/extensions/http-curl/tests/HttpGetIntegrationTest.cpp
+++ b/extensions/http-curl/tests/HttpGetIntegrationTest.cpp
@@ -89,7 +89,6 @@ int main(int argc, char **argv) {
}
std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
configuration->set(minifi::Configure::nifi_default_directory, key_dir);
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
@@ -127,10 +126,8 @@ int main(int argc, char **argv) {
HttpResponder h_ex;
std::string port, scheme, path;
CivetServer *server = nullptr;
-
parse_http_components(url, port, scheme, path);
struct mg_callbacks callback;
- if (url.find("localhost") != std::string::npos) {
if (scheme == "https") {
std::string cert = "";
cert = key_dir + "nifi-cert.pem";
@@ -142,7 +139,6 @@ int main(int argc, char **argv) {
} else {
server = start_webserver(port, path, &h_ex);
}
- }
controller->load();
controller->start();
waitToVerifyProcessor();
@@ -160,7 +156,6 @@ int main(int argc, char **argv) {
assert(logs.find("key:flow.id") != std::string::npos);
LogTestController::getInstance().reset();
- rmdir("./content_repository");
stop_webserver(server);
return 0;
}
diff --git a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
index 9b149f9..4b841da 100644
--- a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
+++ b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp
@@ -92,7 +92,7 @@ class HttpTestHarness : public CoapIntegrationBase {
}
protected:
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/http-curl/tests/SiteToSiteRestTest.cpp b/extensions/http-curl/tests/SiteToSiteRestTest.cpp
index 63721e1..036b949 100644
--- a/extensions/http-curl/tests/SiteToSiteRestTest.cpp
+++ b/extensions/http-curl/tests/SiteToSiteRestTest.cpp
@@ -114,7 +114,7 @@ class SiteToSiteTestHarness : public CoapIntegrationBase {
protected:
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/http-curl/tests/TestServer.h b/extensions/http-curl/tests/TestServer.h
index 601da4e..0e9b260 100644
--- a/extensions/http-curl/tests/TestServer.h
+++ b/extensions/http-curl/tests/TestServer.h
@@ -17,7 +17,11 @@
*/
#ifndef LIBMINIFI_TEST_TESTSERVER_H_
#define LIBMINIFI_TEST_TESTSERVER_H_
+#if defined(_WIN32) || __cplusplus > 201103L
+#include <regex>
+#else
#include <regex.h>
+#endif
#include <string>
#include <iostream>
#include "civetweb.h"
@@ -76,10 +80,47 @@ CivetServer * start_webserver(std::string &port, std::string &rooturi, CivetHand
}
+/**
+This funciton, unfortunately, assumes that we're parsing http components of a local host. On windows this is problematic
+so we convert localhost to our local hostname.
+ */
bool parse_http_components(const std::string &url, std::string &port, std::string &scheme, std::string &path) {
- regex_t regex;
- const char *regexstr = "^(http|https)://(localhost:)([0-9]+)?(/.*)$";
+#if (__cplusplus > 201103L) || defined(_WIN32)
+#ifdef WIN32
+ auto hostname = (url.find(org::apache::nifi::minifi::io::Socket::getMyHostName()) != std::string::npos ? org::apache::nifi::minifi::io::Socket::getMyHostName() : "localhost");
+ std::string regexstr = "^(http|https)://(" + hostname + ":)([0-9]+)?(/.*)$";
+#else
+ std::string regexstr = "^(http|https)://(localhost:)([0-9]+)?(/.*)$";
+#endif
+ std::regex rgx;
+ std::regex_constants::syntax_option_type regex_mode = std::regex_constants::icase;
+
+ rgx = std::regex(regexstr, regex_mode);
+
+ std::smatch matches;
+ std::string scratch = url;
+ if (std::regex_search(scratch, matches, rgx)) {
+ for (int i = 1; i < matches.size(); i++) {
+ auto str = matches[i].str();
+ switch (i) {
+ case 1:
+ scheme = str;
+ break;
+ case 3:
+ port = str;
+ break;
+ case 4:
+ path = str;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+#else
+ const char *regexstr = "^(http|https)://(localhost:)([0-9]+)?(/.*)$";
+ regex_t regex;
int ret = regcomp(®ex, regexstr, REG_EXTENDED);
if (ret) {
@@ -113,7 +154,7 @@ bool parse_http_components(const std::string &url, std::string &port, std::strin
return false;
regfree(®ex);
-
+#endif
return true;
}
diff --git a/extensions/http-curl/tests/ThreadPoolAdjust.cpp b/extensions/http-curl/tests/ThreadPoolAdjust.cpp
index 18cf99d..1670e71 100644
--- a/extensions/http-curl/tests/ThreadPoolAdjust.cpp
+++ b/extensions/http-curl/tests/ThreadPoolAdjust.cpp
@@ -93,7 +93,7 @@ class HttpTestHarness : public IntegrationBase {
}
protected:
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/libminifi/test/civetweb-tests/CivetwebTests.cpp b/extensions/http-curl/tests/unit/CivetwebTests.cpp
similarity index 96%
rename from libminifi/test/civetweb-tests/CivetwebTests.cpp
rename to extensions/http-curl/tests/unit/CivetwebTests.cpp
index 516022d..7122141 100644
--- a/libminifi/test/civetweb-tests/CivetwebTests.cpp
+++ b/extensions/http-curl/tests/unit/CivetwebTests.cpp
@@ -18,6 +18,7 @@
#include <uuid/uuid.h>
#include <fstream>
+#include <chrono>
#include <map>
#include <memory>
#include <set>
@@ -27,11 +28,11 @@
#include <processors/LogAttribute.h>
#include <processors/ListenHTTP.h>
-#include "../TestBase.h"
+#include "TestBase.h"
#include "processors/GetFile.h"
#include "processors/PutFile.h"
-#include "../../../extensions/http-curl/client/HTTPClient.h"
+#include "client/HTTPClient.h"
TEST_CASE("Test Creation of ListenHTTP", "[ListenHTTPreate]") { // NOLINT
TestController testController;
@@ -55,7 +56,7 @@ TEST_CASE("Test GET Body", "[ListenHTTPGETBody]") { // NOLINT
// Define directory for test input
std::string test_in_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_in_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_in_dir[0]).empty());
// Define test input file
std::string test_input_file(test_in_dir);
diff --git a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
index 6b54bb7..9a5822a 100644
--- a/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
+++ b/extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
@@ -53,7 +53,7 @@ TEST_CASE("HTTPTestsWithNoResourceClaimPOST", "[httptest1]") {
std::shared_ptr<core::Processor> logAttribute = std::make_shared<org::apache::nifi::minifi::processors::LogAttribute>("logattribute");
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::Processor> listenhttp = std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
@@ -170,7 +170,7 @@ TEST_CASE("HTTPTestsWithResourceClaimPOST", "[httptest1]") {
std::shared_ptr<core::Processor> logAttribute = std::make_shared<org::apache::nifi::minifi::processors::LogAttribute>("logattribute");
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::Processor> listenhttp = std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
diff --git a/extensions/jni/CMakeLists.txt b/extensions/jni/CMakeLists.txt
index 721175c..ac4c3b2 100644
--- a/extensions/jni/CMakeLists.txt
+++ b/extensions/jni/CMakeLists.txt
@@ -108,7 +108,7 @@ else ()
target_link_libraries (minifi-jni ${JAVA_JVM_LIBRARY})
target_link_libraries (minifi-jni ${Java_LIBRARIES})
else()
- target_link_libraries (minifi-jni -Wl,--whole-archive ${JAVA_JVM_LIBRARY} -Wl,--no-whole-archive)
+ target_link_libraries (minifi-jni ${JAVA_JVM_LIBRARY})
endif()
endif ()
diff --git a/extensions/jni/jvm/JniControllerServiceLookup.cpp b/extensions/jni/jvm/JniControllerServiceLookup.cpp
index e7658e0..ccaa8ec 100644
--- a/extensions/jni/jvm/JniControllerServiceLookup.cpp
+++ b/extensions/jni/jvm/JniControllerServiceLookup.cpp
@@ -42,7 +42,7 @@
extern "C" {
#endif
-jobject Java_org_apache_nifi_processor_JniControllerServiceLookup_getControllerService(JNIEnv *env, jobject obj, jstring cs) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniControllerServiceLookup_getControllerService(JNIEnv *env, jobject obj, jstring cs) {
minifi::jni::JniControllerServiceLookup *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniControllerServiceLookup>(env, obj);
auto str = JniStringToUTF(env, cs);
auto controller_service = ptr->cs_lookup_reference_->getControllerService(str);
@@ -55,19 +55,19 @@ jobject Java_org_apache_nifi_processor_JniControllerServiceLookup_getControllerS
return nullptr;
}
-jboolean Java_org_apache_nifi_processor_JniControllerServiceLookup_isControllerServiceEnabled(JNIEnv *env, jobject obj, jstring cs) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniControllerServiceLookup_isControllerServiceEnabled(JNIEnv *env, jobject obj, jstring cs) {
minifi::jni::JniControllerServiceLookup *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniControllerServiceLookup>(env, obj);
auto str = JniStringToUTF(env, cs);
return ptr->cs_lookup_reference_->isControllerServiceEnabled(str);
}
-jboolean Java_org_apache_nifi_processor_JniControllerServiceLookup_isControllerServiceEnabling(JNIEnv *env, jobject obj, jstring cs) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniControllerServiceLookup_isControllerServiceEnabling(JNIEnv *env, jobject obj, jstring cs) {
minifi::jni::JniControllerServiceLookup *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniControllerServiceLookup>(env, obj);
auto str = JniStringToUTF(env, cs);
return ptr->cs_lookup_reference_->isControllerServiceEnabling(str);
}
-jstring Java_org_apache_nifi_processor_JniControllerServiceLookup_getControllerServiceName(JNIEnv *env, jobject obj, jstring cs) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniControllerServiceLookup_getControllerServiceName(JNIEnv *env, jobject obj, jstring cs) {
minifi::jni::JniControllerServiceLookup *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniControllerServiceLookup>(env, obj);
auto str = JniStringToUTF(env, cs);
return env->NewStringUTF(ptr->cs_lookup_reference_->getControllerServiceName(str).c_str());
diff --git a/extensions/jni/jvm/JniFlowFile.cpp b/extensions/jni/jvm/JniFlowFile.cpp
index ec34395..69af71a 100644
--- a/extensions/jni/jvm/JniFlowFile.cpp
+++ b/extensions/jni/jvm/JniFlowFile.cpp
@@ -38,7 +38,7 @@
extern "C" {
#endif
-jlong Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
@@ -48,7 +48,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv *env, jobject obj)
return id;
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -56,7 +56,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(JNIEnv *env, jobje
jlong entryDate = ff->getEntryDate();
return entryDate;
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getLineageStartDate(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageStartDate(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -64,7 +64,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getLineageStartDate(JNIEnv *env
jlong val = ff->getlineageStartDate();
return val;
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getLineageStartIndex(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageStartIndex(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -72,7 +72,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getLineageStartIndex(JNIEnv *en
jlong val = ff->getlineageStartDate();
return val;
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getLastQueueDatePrim(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLastQueueDatePrim(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -80,7 +80,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getLastQueueDatePrim(JNIEnv *en
jlong val = 0;
return val;
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getQueueDateIndex(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getQueueDateIndex(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -88,7 +88,7 @@ jlong Java_org_apache_nifi_processor_JniFlowFile_getQueueDateIndex(JNIEnv *env,
jlong val = 0;
return val;
}
-jboolean Java_org_apache_nifi_processor_JniFlowFile_isPenalized(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniFlowFile_isPenalized(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -96,7 +96,7 @@ jboolean Java_org_apache_nifi_processor_JniFlowFile_isPenalized(JNIEnv *env, job
jboolean val = ff->isPenalized();
return val;
}
-jstring Java_org_apache_nifi_processor_JniFlowFile_getAttribute(JNIEnv *env, jobject obj, jstring key) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttribute(JNIEnv *env, jobject obj, jstring key) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -105,14 +105,14 @@ jstring Java_org_apache_nifi_processor_JniFlowFile_getAttribute(JNIEnv *env, job
ff->getAttribute(JniStringToUTF(env, key), value);
return env->NewStringUTF(value.c_str());
}
-jlong Java_org_apache_nifi_processor_JniFlowFile_getSize(JNIEnv *env, jobject obj) {
+JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getSize(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
THROW_IF_NULL(ff, env, NO_FF_OBJECT);
jlong val = ff->getSize();
return val;
}
-jstring Java_org_apache_nifi_processor_JniFlowFile_getUUIDStr(JNIEnv *env, jobject obj) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniFlowFile_getUUIDStr(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
auto ff = ptr->get();
@@ -120,7 +120,7 @@ jstring Java_org_apache_nifi_processor_JniFlowFile_getUUIDStr(JNIEnv *env, jobje
return env->NewStringUTF(ff->getUUIDStr().c_str());
}
-jobject Java_org_apache_nifi_processor_JniFlowFile_getAttributes(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniFlowFile_getAttributes(JNIEnv *env, jobject obj) {
minifi::jni::JniFlowFile *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniFlowFile>(env, obj);
diff --git a/extensions/jni/jvm/JniFlowFile.h b/extensions/jni/jvm/JniFlowFile.h
index fa6b31c..88bb1e6 100644
--- a/extensions/jni/jvm/JniFlowFile.h
+++ b/extensions/jni/jvm/JniFlowFile.h
@@ -33,7 +33,6 @@ extern "C" {
#endif
JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniFlowFile_initialise(JNIEnv *env, jobject obj);
-
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getId(JNIEnv *env, jobject obj);
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getEntryDate(JNIEnv *env, jobject obj);
JNIEXPORT jlong JNICALL Java_org_apache_nifi_processor_JniFlowFile_getLineageStartDate(JNIEnv *env, jobject obj);
diff --git a/extensions/jni/jvm/JniInitializationContext.cpp b/extensions/jni/jvm/JniInitializationContext.cpp
index e3cffa7..c47670d 100644
--- a/extensions/jni/jvm/JniInitializationContext.cpp
+++ b/extensions/jni/jvm/JniInitializationContext.cpp
@@ -31,12 +31,12 @@
#include "properties/Configure.h"
#include "JVMLoader.h"
-jstring Java_org_apache_nifi_processor_JniInitializationContext_getIdentifier(JNIEnv *env, jobject obj) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniInitializationContext_getIdentifier(JNIEnv *env, jobject obj) {
minifi::jni::JniInitializationContext *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniInitializationContext>(env, obj);
return env->NewStringUTF(ptr->identifier_.c_str());
}
-jobject Java_org_apache_nifi_processor_JniInitializationContext_getControllerServiceLookup(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniInitializationContext_getControllerServiceLookup(JNIEnv *env, jobject obj) {
minifi::jni::JniInitializationContext *ptr = minifi::jni::JVMLoader::getInstance()->getReference<minifi::jni::JniInitializationContext>(env, obj);
if (ptr->lookup_ref_ == nullptr) {
auto csl = minifi::jni::JVMLoader::getInstance()->load_class("org/apache/nifi/processor/JniControllerServiceLookup", env);
@@ -49,7 +49,7 @@ jobject Java_org_apache_nifi_processor_JniInitializationContext_getControllerSer
-jstring Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName) {
if (obj == nullptr || propertyName == nullptr) {
return nullptr;
}
@@ -69,7 +69,7 @@ jstring Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyValue(
return env->NewStringUTF(value.c_str());
}
-jobject Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyNames(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyNames(JNIEnv *env, jobject obj) {
minifi::jni::JniConfigurationContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniConfigurationContext>(env, obj);
auto cppProcessor = context->service_reference_;
auto keys = cppProcessor->getProperties();
@@ -88,13 +88,13 @@ jobject Java_org_apache_nifi_processor_JniConfigurationContext_getPropertyNames(
return result;
}
-jobject Java_org_apache_nifi_processor_JniConfigurationContext_getComponent(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniConfigurationContext_getComponent(JNIEnv *env, jobject obj) {
minifi::jni::JniConfigurationContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniConfigurationContext>(env, obj);
minifi::jni::ThrowIf(env);
return context->service_reference_->getClassInstance();
}
-jstring Java_org_apache_nifi_processor_JniConfigurationContext_getName(JNIEnv *env, jobject obj) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniConfigurationContext_getName(JNIEnv *env, jobject obj) {
minifi::jni::JniConfigurationContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniConfigurationContext>(env, obj);
minifi::jni::ThrowIf(env);
return env->NewStringUTF(context->service_reference_->getName().c_str());
diff --git a/extensions/jni/jvm/JniLogger.cpp b/extensions/jni/jvm/JniLogger.cpp
index 1d696ff..ae497f7 100644
--- a/extensions/jni/jvm/JniLogger.cpp
+++ b/extensions/jni/jvm/JniLogger.cpp
@@ -40,53 +40,53 @@
extern "C" {
#endif
-jboolean Java_org_apache_nifi_processor_JniLogger_isWarnEnabled(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniLogger_isWarnEnabled(JNIEnv *env, jobject obj) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
return logger_ref->logger_reference_->should_log(core::logging::LOG_LEVEL::warn);
}
-jboolean Java_org_apache_nifi_processor_JniLogger_isTraceEnabled(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniLogger_isTraceEnabled(JNIEnv *env, jobject obj) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
return logger_ref->logger_reference_->should_log(core::logging::LOG_LEVEL::trace);
}
-jboolean Java_org_apache_nifi_processor_JniLogger_isInfoEnabled(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniLogger_isInfoEnabled(JNIEnv *env, jobject obj) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
return logger_ref->logger_reference_->should_log(core::logging::LOG_LEVEL::info);
}
-jboolean Java_org_apache_nifi_processor_JniLogger_isErrorEnabled(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniLogger_isErrorEnabled(JNIEnv *env, jobject obj) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
return logger_ref->logger_reference_->should_log(core::logging::LOG_LEVEL::err);
}
-jboolean Java_org_apache_nifi_processor_JniLogger_isDebugEnabled(JNIEnv *env, jobject obj) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniLogger_isDebugEnabled(JNIEnv *env, jobject obj) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
return logger_ref->logger_reference_->should_log(core::logging::LOG_LEVEL::debug);
}
-void Java_org_apache_nifi_processor_JniLogger_warn(JNIEnv *env, jobject obj, jstring msg) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniLogger_warn(JNIEnv *env, jobject obj, jstring msg) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
if (!logger_ref)
return;
logger_ref->logger_reference_->log_warn(JniStringToUTF(env, msg).c_str());
}
-void Java_org_apache_nifi_processor_JniLogger_error(JNIEnv *env, jobject obj, jstring msg) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniLogger_error(JNIEnv *env, jobject obj, jstring msg) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
if (!logger_ref)
return;
logger_ref->logger_reference_->log_error(JniStringToUTF(env, msg).c_str());
}
-void Java_org_apache_nifi_processor_JniLogger_info(JNIEnv *env, jobject obj, jstring msg) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniLogger_info(JNIEnv *env, jobject obj, jstring msg) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
if (!logger_ref)
return;
logger_ref->logger_reference_->log_info(JniStringToUTF(env, msg).c_str());
}
-void Java_org_apache_nifi_processor_JniLogger_debug(JNIEnv *env, jobject obj, jstring msg) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniLogger_debug(JNIEnv *env, jobject obj, jstring msg) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
if (!logger_ref)
return;
logger_ref->logger_reference_->log_debug(JniStringToUTF(env, msg).c_str());
}
-void Java_org_apache_nifi_processor_JniLogger_trace(JNIEnv *env, jobject obj, jstring msg) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniLogger_trace(JNIEnv *env, jobject obj, jstring msg) {
minifi::jni::JniLogger *logger_ref = minifi::jni::JVMLoader::getPtr<minifi::jni::JniLogger>(env, obj);
if (!logger_ref)
return;
diff --git a/extensions/jni/jvm/JniProcessContext.cpp b/extensions/jni/jvm/JniProcessContext.cpp
index 15c2d34..e9e0c35 100644
--- a/extensions/jni/jvm/JniProcessContext.cpp
+++ b/extensions/jni/jvm/JniProcessContext.cpp
@@ -30,7 +30,7 @@
#include "properties/Configure.h"
#include "JVMLoader.h"
-jstring Java_org_apache_nifi_processor_JniProcessContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName) {
if (obj == nullptr || propertyName == nullptr) {
return nullptr;
}
@@ -50,7 +50,7 @@ jstring Java_org_apache_nifi_processor_JniProcessContext_getPropertyValue(JNIEnv
return env->NewStringUTF(value.c_str());
}
-jobject Java_org_apache_nifi_processor_JniProcessContext_getPropertyNames(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyNames(JNIEnv *env, jobject obj) {
minifi::jni::JniProcessContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniProcessContext>(env, obj);
auto cppProcessor = context->processor_;
auto keys = cppProcessor->getProperties();
@@ -69,19 +69,19 @@ jobject Java_org_apache_nifi_processor_JniProcessContext_getPropertyNames(JNIEnv
return result;
}
-jobject Java_org_apache_nifi_processor_JniProcessContext_getComponent(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getComponent(JNIEnv *env, jobject obj) {
minifi::jni::JniProcessContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniProcessContext>(env, obj);
minifi::jni::ThrowIf(env);
return context->nifi_processor_;
}
-jstring Java_org_apache_nifi_processor_JniProcessContext_getName(JNIEnv *env, jobject obj) {
+JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getName(JNIEnv *env, jobject obj) {
minifi::jni::JniProcessContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniProcessContext>(env, obj);
minifi::jni::ThrowIf(env);
return env->NewStringUTF(context->context_->getProcessorNode()->getName().c_str());
}
-jobject Java_org_apache_nifi_processor_JniProcessContext_getControllerServiceLookup(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getControllerServiceLookup(JNIEnv *env, jobject obj) {
minifi::jni::JniProcessContext *context = minifi::jni::JVMLoader::getPtr<minifi::jni::JniProcessContext>(env, obj);
minifi::jni::ThrowIf(env);
return context->cslookup_;
diff --git a/extensions/jni/jvm/JniProcessContext.h b/extensions/jni/jvm/JniProcessContext.h
index 60f0a2b..06a79a2 100644
--- a/extensions/jni/jvm/JniProcessContext.h
+++ b/extensions/jni/jvm/JniProcessContext.h
@@ -59,15 +59,15 @@ struct JniProcessContext {
extern "C" {
#endif
-JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName);
+DLL_EXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyValue(JNIEnv *env, jobject obj, jstring propertyName);
-JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyNames(JNIEnv *env, jobject obj);
+DLL_EXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getPropertyNames(JNIEnv *env, jobject obj);
-JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getComponent(JNIEnv *env, jobject obj);
+DLL_EXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getComponent(JNIEnv *env, jobject obj);
-JNIEXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getName(JNIEnv *env, jobject obj);
+DLL_EXPORT jstring JNICALL Java_org_apache_nifi_processor_JniProcessContext_getName(JNIEnv *env, jobject obj);
-JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getControllerServiceLookup(JNIEnv *env, jobject obj);
+DLL_EXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessContext_getControllerServiceLookup(JNIEnv *env, jobject obj);
//getname
//getControllerservicelookup
diff --git a/extensions/jni/jvm/JniProcessSession.cpp b/extensions/jni/jvm/JniProcessSession.cpp
index 0baad8d..36cbb73 100644
--- a/extensions/jni/jvm/JniProcessSession.cpp
+++ b/extensions/jni/jvm/JniProcessSession.cpp
@@ -39,7 +39,7 @@
extern "C" {
#endif
-jobject Java_org_apache_nifi_processor_JniProcessSession_create(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_create(JNIEnv *env, jobject obj) {
if (obj == nullptr) {
return nullptr;
}
@@ -65,7 +65,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_create(JNIEnv *env, job
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_readFlowFile(JNIEnv *env, jobject obj, jobject ff) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_readFlowFile(JNIEnv *env, jobject obj, jobject ff) {
if (obj == nullptr) {
return nullptr;
}
@@ -97,7 +97,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_readFlowFile(JNIEnv *en
}
-jint Java_org_apache_nifi_processor_JniInputStream_read(JNIEnv *env, jobject obj) {
+JNIEXPORT jint JNICALL Java_org_apache_nifi_processor_JniInputStream_read(JNIEnv *env, jobject obj) {
minifi::jni::JniInputStream *jin = minifi::jni::JVMLoader::getPtr<minifi::jni::JniInputStream>(env, obj);
if (obj == nullptr) {
// this technically can't happen per JNI specs
@@ -110,7 +110,7 @@ jint Java_org_apache_nifi_processor_JniInputStream_read(JNIEnv *env, jobject obj
return -1;
}
-jint Java_org_apache_nifi_processor_JniInputStream_readWithOffset(JNIEnv *env, jobject obj, jbyteArray arr, jint offset, jint length) {
+JNIEXPORT jint JNICALL Java_org_apache_nifi_processor_JniInputStream_readWithOffset(JNIEnv *env, jobject obj, jbyteArray arr, jint offset, jint length) {
minifi::jni::JniInputStream *jin = minifi::jni::JVMLoader::getPtr<minifi::jni::JniInputStream>(env, obj);
if (obj == nullptr) {
// this technically can't happen per JNI specs
@@ -119,7 +119,7 @@ jint Java_org_apache_nifi_processor_JniInputStream_readWithOffset(JNIEnv *env, j
return jin->read(env, arr, (int) offset, (int) length);
}
-jboolean Java_org_apache_nifi_processor_JniProcessSession_write(JNIEnv *env, jobject obj, jobject ff, jbyteArray byteArray) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniProcessSession_write(JNIEnv *env, jobject obj, jobject ff, jbyteArray byteArray) {
if (obj == nullptr) {
return false;
}
@@ -145,7 +145,7 @@ jboolean Java_org_apache_nifi_processor_JniProcessSession_write(JNIEnv *env, job
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_clone(JNIEnv *env, jobject obj, jobject prevff) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_clone(JNIEnv *env, jobject obj, jobject prevff) {
if (obj == nullptr) {
return nullptr;
}
@@ -177,7 +177,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_clone(JNIEnv *env, jobj
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_get(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_get(JNIEnv *env, jobject obj) {
if (obj == nullptr)
return nullptr;
@@ -214,7 +214,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_get(JNIEnv *env, jobjec
return ff_instance;
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_putAttribute(JNIEnv *env, jobject obj, jobject ff, jstring key, jstring value) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_putAttribute(JNIEnv *env, jobject obj, jobject ff, jstring key, jstring value) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -240,7 +240,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_putAttribute(JNIEnv *en
}
-void Java_org_apache_nifi_processor_JniProcessSession_transfer(JNIEnv *env, jobject obj, jobject ff, jstring relationship) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniProcessSession_transfer(JNIEnv *env, jobject obj, jobject ff, jstring relationship) {
if (obj == nullptr) {
return;
}
@@ -264,7 +264,7 @@ jstring Java_org_apache_nifi_processor_JniProcessSession_getPropertyValue(JNIEnv
return env->NewStringUTF(value.c_str());
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_createWithParent(JNIEnv *env, jobject obj, jobject parent) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_createWithParent(JNIEnv *env, jobject obj, jobject parent) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -298,7 +298,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_createWithParent(JNIEnv
}
-void Java_org_apache_nifi_processor_JniProcessSession_commit(JNIEnv *env, jobject obj) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniProcessSession_commit(JNIEnv *env, jobject obj) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -316,7 +316,7 @@ void Java_org_apache_nifi_processor_JniProcessSession_commit(JNIEnv *env, jobjec
}
}
-void Java_org_apache_nifi_processor_JniProcessSession_rollback(JNIEnv *env, jobject obj) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniProcessSession_rollback(JNIEnv *env, jobject obj) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -326,7 +326,7 @@ void Java_org_apache_nifi_processor_JniProcessSession_rollback(JNIEnv *env, jobj
session->getSession()->rollback();
}
-jobject Java_org_apache_nifi_processor_JniProcessSessionFactory_createSession(JNIEnv *env, jobject obj) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSessionFactory_createSession(JNIEnv *env, jobject obj) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -336,7 +336,6 @@ jobject Java_org_apache_nifi_processor_JniProcessSessionFactory_createSession(JN
auto session_class = minifi::jni::JVMLoader::getInstance()->load_class("org/apache/nifi/processor/JniProcessSession", env);
auto session_instance = session_class.newInstance(env);
-
minifi::jni::ThrowIf(env);
// create a session
@@ -346,18 +345,16 @@ jobject Java_org_apache_nifi_processor_JniProcessSessionFactory_createSession(JN
// add a reference so the minifi C++ session factory knows to remove these eventually.
procSession->addReference(session);
-
auto rawSession = sessionFactory->addSession(session);
// set the reference in session_instance using the raw pointer.
minifi::jni::JVMLoader::getInstance()->setReference(session_instance, env, rawSession);
// catalog the session
-
return session_instance;
}
-void Java_org_apache_nifi_processor_JniProcessSession_remove(JNIEnv *env, jobject obj, jobject ff) {
+JNIEXPORT void JNICALL Java_org_apache_nifi_processor_JniProcessSession_remove(JNIEnv *env, jobject obj, jobject ff) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -373,7 +370,7 @@ void Java_org_apache_nifi_processor_JniProcessSession_remove(JNIEnv *env, jobjec
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_penalize(JNIEnv *env, jobject obj, jobject ff) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_penalize(JNIEnv *env, jobject obj, jobject ff) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -389,7 +386,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_penalize(JNIEnv *env, j
return ff;
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_removeAttribute(JNIEnv *env, jobject obj, jobject ff, jstring attr) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_removeAttribute(JNIEnv *env, jobject obj, jobject ff, jstring attr) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -404,7 +401,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_removeAttribute(JNIEnv
return ff;
}
-jobject Java_org_apache_nifi_processor_JniProcessSession_clonePortion(JNIEnv *env, jobject obj, jobject prevff, jlong offset, jlong size) {
+JNIEXPORT jobject JNICALL Java_org_apache_nifi_processor_JniProcessSession_clonePortion(JNIEnv *env, jobject obj, jobject prevff, jlong offset, jlong size) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
@@ -438,7 +435,7 @@ jobject Java_org_apache_nifi_processor_JniProcessSession_clonePortion(JNIEnv *en
}
-jboolean Java_org_apache_nifi_processor_JniProcessSession_append(JNIEnv *env, jobject obj, jobject ff, jbyteArray byteArray) {
+JNIEXPORT jboolean JNICALL Java_org_apache_nifi_processor_JniProcessSession_append(JNIEnv *env, jobject obj, jobject ff, jbyteArray byteArray) {
if (obj == nullptr) {
// does not mean an error should be thrown, rather we will let
// Java do its thing as this is a condition of GC most likely
diff --git a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniInitializationContext.java b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniInitializationContext.java
index 343e3bd..586b065 100644
--- a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniInitializationContext.java
+++ b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniInitializationContext.java
@@ -4,6 +4,7 @@ import org.apache.nifi.components.state.StateManager;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
import org.apache.nifi.controller.ControllerServiceLookup;
import org.apache.nifi.controller.NodeTypeProvider;
+import org.apache.nifi.documentation.init.NopStateManager;
import org.apache.nifi.logging.ComponentLog;
import java.io.File;
@@ -35,7 +36,7 @@ public class JniInitializationContext implements ProcessorInitializationContext,
@Override
public StateManager getStateManager() {
- return null;
+ return new JniStateManager();
}
@Override
diff --git a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniProcessContext.java b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniProcessContext.java
index b136a9b..38bda9a 100644
--- a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniProcessContext.java
+++ b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniProcessContext.java
@@ -8,6 +8,7 @@ import org.apache.nifi.components.state.StateManager;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ControllerServiceLookup;
+import org.apache.nifi.documentation.init.NopStateManager;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -74,7 +75,7 @@ public class JniProcessContext implements ProcessContext, ControllerServiceLooku
@Override
public String getAnnotationData() {
- return null;
+ return "";
}
@Override
@@ -88,7 +89,7 @@ public class JniProcessContext implements ProcessContext, ControllerServiceLooku
}
- return null;
+ return new HashMap<>();
}
private native List<String> getPropertyNames();
@@ -135,7 +136,7 @@ public class JniProcessContext implements ProcessContext, ControllerServiceLooku
@Override
public StateManager getStateManager() {
- return null;
+ return new JniStateManager();
}
@Override
diff --git a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateManager.java b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateManager.java
new file mode 100644
index 0000000..502f162
--- /dev/null
+++ b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateManager.java
@@ -0,0 +1,30 @@
+package org.apache.nifi.processor;
+
+import org.apache.nifi.components.state.Scope;
+import org.apache.nifi.components.state.StateManager;
+import org.apache.nifi.components.state.StateMap;
+
+import java.util.Map;
+
+public class JniStateManager implements StateManager {
+
+
+
+ @Override
+ public void setState(final Map<String, String> state, final Scope scope) {
+ }
+
+ @Override
+ public StateMap getState(final Scope scope) {
+ return new JniStateMap(null,1);
+ }
+
+ @Override
+ public boolean replace(final StateMap oldValue, final Map<String, String> newValue, final Scope scope) {
+ return false;
+ }
+
+ @Override
+ public void clear(final Scope scope) {
+ }
+}
\ No newline at end of file
diff --git a/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateMap.java b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateMap.java
new file mode 100644
index 0000000..709ee38
--- /dev/null
+++ b/extensions/jni/nifi-framework-jni/src/main/java/org/apache/nifi/processor/JniStateMap.java
@@ -0,0 +1,33 @@
+package org.apache.nifi.processor;
+
+
+import org.apache.nifi.components.state.StateMap;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JniStateMap implements StateMap {
+ private final Map<String, String> stateValues;
+ private final long version;
+
+ public JniStateMap(final Map<String, String> stateValues, final long version) {
+ this.stateValues = stateValues == null ? Collections.<String, String> emptyMap() : new HashMap<>(stateValues);
+ this.version = version;
+ }
+
+ @Override
+ public long getVersion() {
+ return version;
+ }
+
+ @Override
+ public String get(final String key) {
+ return stateValues.get(key);
+ }
+
+ @Override
+ public Map<String, String> toMap() {
+ return Collections.unmodifiableMap(stateValues);
+ }
+}
diff --git a/extensions/librdkafka/CMakeLists.txt b/extensions/librdkafka/CMakeLists.txt
index 8d96666..5aeb383 100644
--- a/extensions/librdkafka/CMakeLists.txt
+++ b/extensions/librdkafka/CMakeLists.txt
@@ -32,7 +32,7 @@ endif()
set(BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/kafka")
if (WIN32)
- set(BYPRODUCT "${BASE_DIR}/install/lib/librdkafka.lib")
+ set(BYPRODUCT "${BASE_DIR}/install/lib/rdkafka.lib")
else()
set(BYPRODUCT "${BASE_DIR}/install/lib/librdkafka.a")
endif()
@@ -63,10 +63,17 @@ if ( NOT USE_SYSTEM_OPENSSL )
add_dependencies(kafka-external libressl-portable)
endif()
set(KAFKA_INCLUDE "${BASE_DIR}/install/include/librdkafka/")
+set(KAFKA_LIBRARY "${BYPRODUCT}")
add_dependencies(minifi-rdkafka-extensions kafka-external)
include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(${KAFKA_INCLUDE})
-target_link_libraries (minifi-rdkafka-extensions ${BYPRODUCT})
+if (WIN32)
+ target_link_libraries (minifi-rdkafka-extensions -WHOLEARCHIVE:${KAFKA_LIBRARY} ${KAFKA_LIBRARY})
+elseif (APPLE)
+ target_link_libraries (minifi-rdkafka-extensions -Wl,-force_load ${KAFKA_LIBRARY})
+else ()
+ target_link_libraries (minifi-rdkafka-extensions -Wl,--whole-archive ${KAFKA_LIBRARY} -Wl,--no-whole-archive)
+endif ()
SET (RDKAFKA-EXTENSIONS minifi-rdkafka-extensions PARENT_SCOPE)
diff --git a/extensions/sftp/tests/CMakeLists.txt b/extensions/sftp/tests/CMakeLists.txt
index f8663f7..afff438 100644
--- a/extensions/sftp/tests/CMakeLists.txt
+++ b/extensions/sftp/tests/CMakeLists.txt
@@ -23,7 +23,7 @@ find_package(Java)
find_package(Maven)
message(STATUS "MAVEN: ${MAVEN_EXECUTABLE}")
-if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND)
+if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND AND NOT DISABLE_EXPRESSION_LANGUAGE)
file(GLOB SFTP_INTEGRATION_TESTS "*.cpp")
SET(SFTP-EXTENSIONS_TEST_COUNT 0)
FOREACH(testfile ${SFTP_INTEGRATION_TESTS})
@@ -42,10 +42,12 @@ if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND)
target_include_directories(${testfilename} BEFORE PRIVATE ./include)
target_include_directories(${testfilename} BEFORE PRIVATE ./tools)
+ # need to add reference to minifi to get EL support for these tests.
+ # these tests aren't valid without EL
if (APPLE)
- target_link_libraries (${testfilename} -Wl,-all_load ${LIBSSH2_LIBRARY} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-sftp minifi-standard-processors sftp-test-tools)
+ target_link_libraries (${testfilename} -Wl,-all_load ${LIBSSH2_LIBRARY} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-expression-language-extensions inifi-sftp minifi-standard-processors sftp-test-tools)
else ()
- target_link_libraries (${testfilename} -Wl,--whole-archive ${LIBSSH2_LIBRARY} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-sftp minifi-standard-processors sftp-test-tools -Wl,--no-whole-archive)
+ target_link_libraries (${testfilename} -Wl,--whole-archive ${LIBSSH2_LIBRARY} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-expression-language-extensions minifi-sftp minifi-standard-processors sftp-test-tools -Wl,--no-whole-archive)
endif ()
createTests("${testfilename}")
diff --git a/extensions/standard-processors/processors/GetFile.cpp b/extensions/standard-processors/processors/GetFile.cpp
index dfaa00e..082b7f7 100644
--- a/extensions/standard-processors/processors/GetFile.cpp
+++ b/extensions/standard-processors/processors/GetFile.cpp
@@ -53,16 +53,14 @@ namespace minifi {
namespace processors {
core::Property GetFile::BatchSize(
- core::PropertyBuilder::createProperty("Batch Size")->withDescription("The maximum number of files to pull in each iteration")->withDefaultValue<uint32_t>(10)
- ->build());
+ core::PropertyBuilder::createProperty("Batch Size")->withDescription("The maximum number of files to pull in each iteration")->withDefaultValue<uint32_t>(10)->build());
core::Property GetFile::Directory(
core::PropertyBuilder::createProperty("Input Directory")->withDescription("The input directory from which to pull files")->isRequired(true)->supportsExpressionLanguage(true)->withDefaultValue(".")
->build());
core::Property GetFile::IgnoreHiddenFile(
- core::PropertyBuilder::createProperty("Ignore Hidden Files")->withDescription("Indicates whether or not hidden files should be ignored")->withDefaultValue<bool>(true)
- ->build());
+ core::PropertyBuilder::createProperty("Ignore Hidden Files")->withDescription("Indicates whether or not hidden files should be ignored")->withDefaultValue<bool>(true)->build());
core::Property GetFile::KeepSourceFile(
core::PropertyBuilder::createProperty("Keep Source File")->withDescription("If true, the file is not deleted after it has been copied to the Content Repository")->withDefaultValue<bool>(false)
@@ -70,33 +68,29 @@ core::Property GetFile::KeepSourceFile(
core::Property GetFile::MaxAge(
core::PropertyBuilder::createProperty("Maximum File Age")->withDescription("The maximum age that a file must be in order to be pulled;"
- " any file older than this amount of time (according to last modification date) will be ignored")->withDefaultValue<core::TimePeriodValue>("0 sec")
- ->build());
+ " any file older than this amount of time (according to last modification date) will be ignored")
+ ->withDefaultValue<core::TimePeriodValue>("0 sec")->build());
core::Property GetFile::MinAge(
core::PropertyBuilder::createProperty("Minimum File Age")->withDescription("The minimum age that a file must be in order to be pulled;"
- " any file younger than this amount of time (according to last modification date) will be ignored")->withDefaultValue<core::TimePeriodValue>("0 sec")
- ->build());
+ " any file younger than this amount of time (according to last modification date) will be ignored")
+ ->withDefaultValue<core::TimePeriodValue>("0 sec")->build());
core::Property GetFile::MaxSize(
- core::PropertyBuilder::createProperty("Minimum File Size")->withDescription("The maximum size that a file can be in order to be pulled")->withDefaultValue<core::DataSizeValue>("0 B")
- ->build());
+ core::PropertyBuilder::createProperty("Maximum File Size")->withDescription("The maximum size that a file can be in order to be pulled")->withDefaultValue<core::DataSizeValue>("0 B")->build());
core::Property GetFile::MinSize(
- core::PropertyBuilder::createProperty("Minimum File Size")->withDescription("The minimum size that a file can be in order to be pulled")->withDefaultValue<core::DataSizeValue>("0 B")
- ->build());
+ core::PropertyBuilder::createProperty("Minimum File Size")->withDescription("The minimum size that a file can be in order to be pulled")->withDefaultValue<core::DataSizeValue>("0 B")->build());
core::Property GetFile::PollInterval(
core::PropertyBuilder::createProperty("Polling Interval")->withDescription("Indicates how long to wait before performing a directory listing")->withDefaultValue<core::TimePeriodValue>("0 sec")
->build());
core::Property GetFile::Recurse(
- core::PropertyBuilder::createProperty("Recurse Subdirectories")->withDescription("Indicates whether or not to pull files from subdirectories")->withDefaultValue<bool>(true)
- ->build());
+ core::PropertyBuilder::createProperty("Recurse Subdirectories")->withDescription("Indicates whether or not to pull files from subdirectories")->withDefaultValue<bool>(true)->build());
core::Property GetFile::FileFilter(
- core::PropertyBuilder::createProperty("File Filter")->withDescription("Only files whose names match the given regular expression will be picked up")->withDefaultValue("[^\\.].*")
- ->build());
+ core::PropertyBuilder::createProperty("File Filter")->withDescription("Only files whose names match the given regular expression will be picked up")->withDefaultValue("[^\\.].*")->build());
core::Relationship GetFile::Success("success", "All files are routed to success");
@@ -164,11 +158,13 @@ void GetFile::onTrigger(core::ProcessContext *context, core::ProcessSession *ses
if (request_.pollInterval == 0 || (getTimeMillis() - last_listing_time_) > request_.pollInterval) {
std::string directory;
const std::shared_ptr<core::FlowFile> flow_file;
- if (!context->getProperty(Directory, directory, flow_file)) {
+ if (context->getProperty(Directory, directory, flow_file)) {
logger_->log_warn("Resolved missing Input Directory property value");
+ performListing(directory, request_);
+ last_listing_time_.store(getTimeMillis());
+ } else {
+ return;
}
- performListing(directory, request_);
- last_listing_time_.store(getTimeMillis());
}
}
logger_->log_debug("Is listing empty %i", isListingEmpty());
@@ -267,7 +263,7 @@ bool GetFile::acceptFile(std::string fullName, std::string name, const GetFileRe
}
void GetFile::performListing(std::string dir, const GetFileRequest &request) {
- auto callback = [this, request](const std::string& dir, const std::string& filename) -> bool{
+ auto callback = [this, request](const std::string& dir, const std::string& filename) -> bool {
std::string fullpath = dir + utils::file::FileUtils::get_separator() + filename;
if (acceptFile(fullpath, filename, request)) {
putListing(fullpath);
diff --git a/extensions/standard-processors/processors/GetTCP.cpp b/extensions/standard-processors/processors/GetTCP.cpp
index 11c99af..22979af 100644
--- a/extensions/standard-processors/processors/GetTCP.cpp
+++ b/extensions/standard-processors/processors/GetTCP.cpp
@@ -245,24 +245,36 @@ void GetTCP::onTrigger(const std::shared_ptr<core::ProcessContext> &context, con
std::lock_guard<std::mutex> lock(mutex_);
// check if the futures are valid. If they've terminated remove it from the map.
- for (auto &endpoint : endpoints) {
+ for (auto &initEndpoint : endpoints) {
+ std::vector<std::string> hostAndPort = utils::StringUtils::split(initEndpoint, ":");
+ auto realizedHost = hostAndPort.at(0);
+#ifdef WIN32
+ if ("localhost" == realizedHost) {
+ realizedHost = org::apache::nifi::minifi::io::Socket::getMyHostName();
+ }
+#endif
+ if (hostAndPort.size() != 2) {
+ continue;
+ }
+
+ auto portStr = hostAndPort.at(1);
+ auto endpoint = realizedHost + ":" + portStr;
+
auto endPointFuture = live_clients_.find(endpoint);
// does not exist
if (endPointFuture == live_clients_.end()) {
logger_->log_info("creating endpoint for %s", endpoint);
- std::vector<std::string> hostAndPort = utils::StringUtils::split(endpoint, ":");
if (hostAndPort.size() == 2) {
- logger_->log_debug("Opening another socket to %s:%s is secure %d", hostAndPort.at(0), hostAndPort.at(1), (ssl_service_ != nullptr));
+ logger_->log_debug("Opening another socket to %s:%s is secure %d", realizedHost, portStr, (ssl_service_ != nullptr));
std::unique_ptr<io::Socket> socket =
- ssl_service_ != nullptr ?
- stream_factory_->createSecureSocket(hostAndPort.at(0), std::stoi(hostAndPort.at(1)), ssl_service_) : stream_factory_->createSocket(hostAndPort.at(0), std::stoi(hostAndPort.at(1)));
+ ssl_service_ != nullptr ? stream_factory_->createSecureSocket(realizedHost, std::stoi(portStr), ssl_service_) : stream_factory_->createSocket(realizedHost, std::stoi(portStr));
if (!socket) {
logger_->log_error("Could not create socket during initialization for %s", endpoint);
continue;
}
socket->setNonBlocking();
if (socket->initialize() != -1) {
- logger_->log_debug("Enqueueing socket into ring buffer %s:%s", hostAndPort.at(0), hostAndPort.at(1));
+ logger_->log_debug("Enqueueing socket into ring buffer %s:%s", realizedHost, portStr);
socket_ring_buffer_.enqueue(std::move(socket));
} else {
logger_->log_error("Could not create socket during initialization for %s", endpoint);
diff --git a/extensions/standard-processors/processors/PutFile.cpp b/extensions/standard-processors/processors/PutFile.cpp
index a7adaa1..880577f 100644
--- a/extensions/standard-processors/processors/PutFile.cpp
+++ b/extensions/standard-processors/processors/PutFile.cpp
@@ -124,7 +124,7 @@ void PutFile::onTrigger(core::ProcessContext *context, core::ProcessSession *ses
// Determine dest full file paths
std::stringstream destFileSs;
- destFileSs << directory << "/" << filename;
+ destFileSs << directory << utils::file::FileUtils::get_separator() << filename;
std::string destFile = destFileSs.str();
logger_->log_debug("PutFile writing file %s into directory %s", filename, directory);
@@ -175,12 +175,12 @@ std::string PutFile::tmpWritePath(const std::string &filename, const std::string
id_generator_->generate(tmpFileUuid);
std::stringstream tmpFileSs;
tmpFileSs << directory;
- auto lastSeparatorPos = filename.find_last_of("/");
+ auto lastSeparatorPos = filename.find_last_of(utils::file::FileUtils::get_separator());
if (lastSeparatorPos == std::string::npos) {
- tmpFileSs << "/." << filename;
+ tmpFileSs << utils::file::FileUtils::get_separator() << "." << filename;
} else {
- tmpFileSs << "/" << filename.substr(0, lastSeparatorPos) << "/." << filename.substr(lastSeparatorPos + 1);
+ tmpFileSs << utils::file::FileUtils::get_separator() << filename.substr(0, lastSeparatorPos) << utils::file::FileUtils::get_separator() << "." << filename.substr(lastSeparatorPos + 1);
}
tmpFileSs << "." << tmpFileUuid.to_string();
@@ -197,7 +197,7 @@ bool PutFile::putFile(core::ProcessSession *session, std::shared_ptr<FlowFileRec
logger_->log_debug("Destination directory does not exist; will attempt to create: ", destDir);
size_t i = 0;
- auto pos = destFile.find('/');
+ auto pos = destFile.find(utils::file::FileUtils::get_separator());
while (pos != std::string::npos) {
auto dir_path_component = destFile.substr(i, pos - i);
@@ -207,14 +207,14 @@ bool PutFile::putFile(core::ProcessSession *session, std::shared_ptr<FlowFileRec
if (!dir_path_component.empty()) {
logger_->log_debug("Attempting to create directory if it does not already exist: %s", dir_path);
utils::file::FileUtils::create_dir(dir_path);
- dir_path_stream << '/';
+ dir_path_stream << utils::file::FileUtils::get_separator();
} else if (pos == 0) {
// Support absolute paths
- dir_path_stream << '/';
+ dir_path_stream << utils::file::FileUtils::get_separator();
}
i = pos + 1;
- pos = destFile.find('/', pos + 1);
+ pos = destFile.find(utils::file::FileUtils::get_separator(), pos + 1);
}
}
diff --git a/extensions/standard-processors/processors/TailFile.cpp b/extensions/standard-processors/processors/TailFile.cpp
index f22ceb5..f74417f 100644
--- a/extensions/standard-processors/processors/TailFile.cpp
+++ b/extensions/standard-processors/processors/TailFile.cpp
@@ -213,7 +213,7 @@ void TailFile::parseStateFileLine(char *buf) {
if (tail_states_.size() != 1) {
throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION, "Incompatible state file types");
}
- const auto position = std::stoi(value);
+ const auto position = std::stoull(value);
logger_->log_debug("Received position %d", position);
tail_states_.begin()->second.currentTailFilePosition_ = position;
}
@@ -230,7 +230,7 @@ void TailFile::parseStateFileLine(char *buf) {
if (key.find(POSITION_STR) == 0) {
const auto file = key.substr(strlen(POSITION_STR));
- tail_states_[file].currentTailFilePosition_ = std::stoi(value);
+ tail_states_[file].currentTailFilePosition_ = std::stoull(value);
}
return;
@@ -305,8 +305,8 @@ void TailFile::checkRollOver(TailState &file, const std::string &base_file_name)
if ((fileFullName.find(pattern) != std::string::npos) && stat(fileFullName.c_str(), &sb) == 0) {
uint64_t candidateModTime = ((uint64_t) (sb.st_mtime) * 1000);
if (candidateModTime >= file.currentTailFileModificationTime_) {
- logger_->log_trace("File %s ( short name %s ), disk mod time %llu, struct mod timer %llu , size on disk %llu, position %llu",
- filename, file.current_file_name_, candidateModTime, file.currentTailFileModificationTime_, sb.st_size, file.currentTailFilePosition_);
+ logging::LOG_TRACE(logger_) << "File " << filename << " (short name " << file.current_file_name_ <<
+ ") disk mod time " << candidateModTime << ", struct mod time " << file.currentTailFileModificationTime_ << ", size on disk " << sb.st_size << ", position " << file.currentTailFilePosition_;
if (filename == file.current_file_name_ && candidateModTime == file.currentTailFileModificationTime_ &&
sb.st_size == file.currentTailFilePosition_) {
return true; // Skip the current file as a candidate in case it wasn't updated
@@ -363,6 +363,7 @@ void TailFile::onTrigger(const std::shared_ptr<core::ProcessContext> &context, c
for (auto &state : tail_states_) {
auto fileLocation = state.second.path_;
+ logger_->log_debug("Tailing file %s from %llu", fileLocation, state.second.currentTailFilePosition_);
checkRollOver(state.second, state.first);
std::string fullPath = fileLocation + utils::file::FileUtils::get_separator() + state.second.current_file_name_;
struct stat statbuf;
diff --git a/extensions/standard-processors/tests/CMakeLists.txt b/extensions/standard-processors/tests/CMakeLists.txt
index 51d95ce..93b80fb 100644
--- a/extensions/standard-processors/tests/CMakeLists.txt
+++ b/extensions/standard-processors/tests/CMakeLists.txt
@@ -23,6 +23,7 @@ file(GLOB PROCESSOR_INTEGRATION_TESTS "integration/*.cpp")
SET(PROCESSOR_INT_TEST_COUNT 0)
+find_package(OpenSSL REQUIRED)
FOREACH(testfile ${PROCESSOR_UNIT_TESTS})
get_filename_component(testfilename "${testfile}" NAME_WE)
add_executable("${testfilename}" "${testfile}")
@@ -36,6 +37,9 @@ FOREACH(testfile ${PROCESSOR_UNIT_TESTS})
target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
if (APPLE)
target_link_libraries ("${testfilename}" -Wl,-all_load ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-standard-processors minifi-civet-extensions)
+ elseif(WIN32)
+ target_link_libraries(${testfilename} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi minifi-standard-processors minifi-civet-extensions)
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi /WHOLEARCHIVE:minifi-standard-processors /WHOLEARCHIVE:minifi-civet-extensions")
else ()
target_link_libraries ("${testfilename}" -Wl,--whole-archive ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-standard-processors minifi-civet-extensions -Wl,--no-whole-archive)
endif()
@@ -59,6 +63,9 @@ FOREACH(testfile ${PROCESSOR_INTEGRATION_TESTS})
createTests("${testfilename}")
if (APPLE)
target_link_libraries ("${testfilename}" -Wl,-all_load ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-standard-processors minifi-civet-extensions)
+ elseif(WIN32)
+ target_link_libraries(${testfilename} ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi minifi-standard-processors minifi-civet-extensions)
+ set_target_properties(${testfilename} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /WHOLEARCHIVE:minifi /WHOLEARCHIVE:minifi-standard-processors /WHOLEARCHIVE:minifi-civet-extensions")
else ()
target_link_libraries ("${testfilename}" -Wl,--whole-archive ${ZLIB_LIBRARY} ${OPENSSL_LIBRARIES} minifi-standard-processors minifi-civet-extensions -Wl,--no-whole-archive)
endif()
diff --git a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
index 73b2005..7e53b55 100644
--- a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
+++ b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp
@@ -65,7 +65,7 @@ class SecureSocketTest : public IntegrationBase {
LogTestController::getInstance().setTrace<minifi::io::TLSSocket>();
LogTestController::getInstance().setTrace<processors::GetTCP>();
std::fstream file;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -73,7 +73,6 @@ class SecureSocketTest : public IntegrationBase {
void cleanup() {
LogTestController::getInstance().reset();
- unlink(ss.str().c_str());
}
void runAssertions() {
@@ -104,7 +103,11 @@ class SecureSocketTest : public IntegrationBase {
assert(1 == endpoints.size());
auto hostAndPort = utils::StringUtils::split(endpoint, ":");
std::shared_ptr<org::apache::nifi::minifi::io::TLSContext> socket_context = std::make_shared<org::apache::nifi::minifi::io::TLSContext>(configuration);
- server_socket = std::make_shared<org::apache::nifi::minifi::io::TLSServerSocket>(socket_context, hostAndPort.at(0), std::stoi(hostAndPort.at(1)), 3);
+ std::string host = hostAndPort.at(0);
+ if (host == "localhost") {
+ host = org::apache::nifi::minifi::io::Socket::getMyHostName();
+ }
+ server_socket = std::make_shared<org::apache::nifi::minifi::io::TLSServerSocket>(socket_context, host, std::stoi(hostAndPort.at(1)), 3);
server_socket->initialize();
isRunning_ = true;
@@ -112,6 +115,7 @@ class SecureSocketTest : public IntegrationBase {
return isRunning_;
};
handler = [this](std::vector<uint8_t> *b, int *size) {
+ std::cout << "oh write!" << std::endl;
b->reserve(20);
memset(b->data(), 0x00, 20);
memcpy(b->data(), "hello world", 11);
@@ -160,12 +164,16 @@ class SecureSocketTest : public IntegrationBase {
cleanup();
}
+ virtual void waitToVerifyProcessor() {
+ std::this_thread::sleep_for(std::chrono::seconds(3));
+ }
+
protected:
std::function<bool()> check;
std::function<int(std::vector<uint8_t>*b, int *size)> handler;
std::atomic<bool> isRunning_;
bool isSecure;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
std::shared_ptr<org::apache::nifi::minifi::io::TLSServerSocket> server_socket;
@@ -181,8 +189,9 @@ int main(int argc, char **argv) {
key_dir = argv[2];
}
+#ifndef WIN32
signal(SIGPIPE, sigpipe_handle);
-
+#endif
SecureSocketTest harness(true);
harness.setKeyDir(key_dir);
diff --git a/extensions/standard-processors/tests/integration/TailFileCronTest.cpp b/extensions/standard-processors/tests/integration/TailFileCronTest.cpp
index 2b5ee77..a3b2a57 100644
--- a/extensions/standard-processors/tests/integration/TailFileCronTest.cpp
+++ b/extensions/standard-processors/tests/integration/TailFileCronTest.cpp
@@ -47,11 +47,10 @@ class TailFileTestHarness : public IntegrationBase {
TailFileTestHarness() {
char format[] = "/tmp/ssth.XXXXXX";
dir = testController.createTempDirectory(format);
-
- statefile = dir;
- statefile += "/statefile";
+ statefile = dir + utils::file::FileUtils::get_separator();
+ statefile += "statefile";
std::fstream file;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "Lin\\e1\nli\\nen\nli\\ne3\nli\\ne4\nli\\ne5\n";
file.close();
@@ -61,7 +60,6 @@ class TailFileTestHarness : public IntegrationBase {
LogTestController::getInstance().setInfo<minifi::processors::LogAttribute>();
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
LogTestController::getInstance().setInfo<minifi::FlowController>();
- LogTestController::getInstance().setTrace<core::ProcessSession>();
LogTestController::getInstance().setDebug<core::ConfigurableComponent>();
}
@@ -88,7 +86,7 @@ class TailFileTestHarness : public IntegrationBase {
}
std::string statefile;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/standard-processors/tests/integration/TailFileTest.cpp b/extensions/standard-processors/tests/integration/TailFileTest.cpp
index 2b5ee77..933b489 100644
--- a/extensions/standard-processors/tests/integration/TailFileTest.cpp
+++ b/extensions/standard-processors/tests/integration/TailFileTest.cpp
@@ -48,10 +48,10 @@ class TailFileTestHarness : public IntegrationBase {
char format[] = "/tmp/ssth.XXXXXX";
dir = testController.createTempDirectory(format);
- statefile = dir;
- statefile += "/statefile";
+ statefile = dir + utils::file::FileUtils::get_separator();
+ statefile += "statefile";
std::fstream file;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "Lin\\e1\nli\\nen\nli\\ne3\nli\\ne4\nli\\ne5\n";
file.close();
@@ -60,8 +60,7 @@ class TailFileTestHarness : public IntegrationBase {
void testSetup() {
LogTestController::getInstance().setInfo<minifi::processors::LogAttribute>();
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
- LogTestController::getInstance().setInfo<minifi::FlowController>();
- LogTestController::getInstance().setTrace<core::ProcessSession>();
+ LogTestController::getInstance().setTrace<minifi::FlowController>();
LogTestController::getInstance().setDebug<core::ConfigurableComponent>();
}
@@ -88,7 +87,7 @@ class TailFileTestHarness : public IntegrationBase {
}
std::string statefile;
- char *dir;
+ std::string dir;
std::stringstream ss;
TestController testController;
};
diff --git a/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp b/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
index 2c8cdf8..0f01433 100644
--- a/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
+++ b/extensions/standard-processors/tests/integration/TestExecuteProcess.cpp
@@ -45,6 +45,7 @@
#include "TestBase.h"
int main(int argc, char **argv) {
+#ifndef WIN32
TestController testController;
std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ExecuteProcess>("executeProcess");
processor->setMaxConcurrentTasks(1);
@@ -107,4 +108,5 @@ int main(int argc, char **argv) {
});
std::shared_ptr<org::apache::nifi::minifi::processors::ExecuteProcess> execp = std::static_pointer_cast<org::apache::nifi::minifi::processors::ExecuteProcess>(processor);
+#endif
}
diff --git a/extensions/standard-processors/tests/minifi-tmpfile.txt b/extensions/standard-processors/tests/minifi-tmpfile.txt
new file mode 100644
index 0000000..3b19f0e
--- /dev/null
+++ b/extensions/standard-processors/tests/minifi-tmpfile.txt
@@ -0,0 +1,6 @@
+9);.Resk"EyWh#iU.tuZ+.d__lh[_"B3|;#,/Dm*X*h6M)[H2O0f/i>?}zVyF,pgGqtdywW [OI[9]"NrN!#mV7l`5^oF2#~qTD1&86L;,Ur7nm1V<&Bgf(k8Utd@7@?egZN&hy4-1h*4S'%TR'Mw.Kb;A(;[!(V&[{fY>nAh(9S@~R-2[5%x~~-jkWu@t'`f^z)k4?m*Et"5"eLL4vy#Tl#8Qkr0@kaX*!z6uc8,>3;>jh(I#I,_pRNZR'J6{3Y(M0tFNs:gDG;'x-v?7Z+MEkd:,Bh1YI`zb&)Amgetm+cA'jO:u6W1/3}?&Q.+}Iw]Oo@[T_(cd+L8_RmQfPNL}t|`s)AkO]f>We/mcEC=Hfl!7B03;4X*1HeYgpin4}vo22|'biv21x[N/C'xxoPC/r/\q%:|`wU3OVQ[qE^>$)]1m5:3:B(IoX.!$1h %Tx+0HtHfY\k`DM7EIrO`&|e_wW1Ahb5]{]\{_@C%g^UfQU [...]
+
+
+foo
+bar
+buzz
\ No newline at end of file
diff --git a/extensions/standard-processors/tests/unit/ExtractTextTests.cpp b/extensions/standard-processors/tests/unit/ExtractTextTests.cpp
index db804e5..a67c853 100644
--- a/extensions/standard-processors/tests/unit/ExtractTextTests.cpp
+++ b/extensions/standard-processors/tests/unit/ExtractTextTests.cpp
@@ -38,150 +38,147 @@
#include "ExtractText.h"
#include "LogAttribute.h"
-const char* TEST_TEXT = "Test text\n";
+const char* TEST_TEXT = "Test text";
const char* REGEX_TEST_TEXT = "Speed limit 130 | Speed limit 80";
const char* TEST_FILE = "test_file.txt";
const char* TEST_ATTR = "ExtractedText";
TEST_CASE("Test creation of ExtractText", "[extracttextCreate]") {
- TestController testController;
- std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ExtractText>("processorname");
- REQUIRE(processor->getName() == "processorname");
- utils::Identifier processoruuid;
- REQUIRE(processor->getUUID(processoruuid));
+ TestController testController;
+ std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ExtractText>("processorname");
+ REQUIRE(processor->getName() == "processorname");
+ utils::Identifier processoruuid;
+ REQUIRE(processor->getUUID(processoruuid));
}
TEST_CASE("Test usage of ExtractText", "[extracttextTest]") {
- TestController testController;
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ExtractText>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GetFile>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
- LogTestController::getInstance().setTrace<core::ProcessSession>();
- LogTestController::getInstance().setTrace<core::repository::VolatileContentRepository>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::Connection>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::core::Connectable>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::core::FlowFile>();
-
- std::shared_ptr<TestPlan> plan = testController.createPlan();
- std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
-
- char dir[] = "/tmp/gt.XXXXXX";
-
- REQUIRE(testController.createTempDirectory(dir) != nullptr);
- std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
-
- std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ExtractText", "testExtractText", core::Relationship("success", "description"), true);
- plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::Attribute.getName(), TEST_ATTR);
-
- std::shared_ptr<core::Processor> laprocessor = plan->addProcessor("LogAttribute", "outputLogAttribute", core::Relationship("success", "description"), true);
- plan->setProperty(laprocessor, org::apache::nifi::minifi::processors::LogAttribute::AttributesToLog.getName(), TEST_ATTR);
-
- std::stringstream ss1;
- ss1 << dir << "/" << TEST_FILE;
- std::string test_file_path = ss1.str();
-
- std::ofstream test_file(test_file_path);
- if (test_file.is_open()) {
- test_file << TEST_TEXT << std::endl;
- test_file.close();
- }
-
- plan->runNextProcessor(); // GetFile
- plan->runNextProcessor(); // ExtractText
- plan->runNextProcessor(); // LogAttribute
-
- std::stringstream ss2;
- ss2 << "key:" << TEST_ATTR << " value:" << TEST_TEXT;
- std::string log_check = ss2.str();
+ TestController testController;
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ExtractText>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GetFile>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setTrace<core::ProcessSession>();
+ LogTestController::getInstance().setTrace<core::repository::VolatileContentRepository>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::Connection>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::core::Connectable>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::core::FlowFile>();
- REQUIRE(LogTestController::getInstance().contains(log_check));
+ std::shared_ptr<TestPlan> plan = testController.createPlan();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
- plan->reset();
+ char dirtemplate[] = "/tmp/gt.XXXXXX";
- plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::SizeLimit.getName(), "4");
+ auto temp_dir = testController.createTempDirectory(dirtemplate);
+ REQUIRE(!temp_dir.empty());
+ std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), temp_dir);
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
- LogTestController::getInstance().reset();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
+ std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ExtractText", "testExtractText", core::Relationship("success", "description"), true);
+ plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::Attribute.getName(), TEST_ATTR);
- std::ofstream test_file_2(test_file_path + "2");
- if (test_file_2.is_open()) {
- test_file_2 << TEST_TEXT << std::endl;
- test_file_2.close();
- }
+ std::shared_ptr<core::Processor> laprocessor = plan->addProcessor("LogAttribute", "outputLogAttribute", core::Relationship("success", "description"), true);
+ plan->setProperty(laprocessor, org::apache::nifi::minifi::processors::LogAttribute::AttributesToLog.getName(), TEST_ATTR);
- plan->runNextProcessor(); // GetFile
- plan->runNextProcessor(); // ExtractText
- plan->runNextProcessor(); // LogAttribute
+ std::stringstream ss1;
+ ss1 << temp_dir << utils::file::FileUtils::get_separator() << TEST_FILE;
+ std::string test_file_path = ss1.str();
- REQUIRE(LogTestController::getInstance().contains(log_check, std::chrono::seconds(0)) == false);
+ std::ofstream test_file(test_file_path);
+ if (test_file.is_open()) {
+ test_file << TEST_TEXT;
+ test_file.close();
+ }
- ss2.str("");
- ss2 << "key:" << TEST_ATTR << " value:" << "Test";
- log_check = ss2.str();
- REQUIRE(LogTestController::getInstance().contains(log_check));
+ plan->runNextProcessor(); // GetFile
+ plan->runNextProcessor(); // ExtractText
+ plan->runNextProcessor(); // LogAttribute
+
+ std::stringstream ss2;
+ ss2 << "key:" << TEST_ATTR << " value:" << TEST_TEXT;
+ std::string log_check = ss2.str();
+
+ REQUIRE(LogTestController::getInstance().contains(log_check));
+
+ plan->reset();
+
+ plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::SizeLimit.getName(), "4");
+
+ LogTestController::getInstance().reset();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
+
+ std::ofstream test_file_2(test_file_path + "2");
+ if (test_file_2.is_open()) {
+ test_file_2 << TEST_TEXT << std::endl;
+ test_file_2.close();
+ }
- LogTestController::getInstance().reset();
+ plan->runNextProcessor(); // GetFile
+ plan->runNextProcessor(); // ExtractText
+ plan->runNextProcessor(); // LogAttribute
+
+ REQUIRE(LogTestController::getInstance().contains(log_check, std::chrono::seconds(0)) == false);
+
+ ss2.str("");
+ ss2 << "key:" << TEST_ATTR << " value:" << "Test";
+ log_check = ss2.str();
+ REQUIRE(LogTestController::getInstance().contains(log_check));
+
+ LogTestController::getInstance().reset();
}
TEST_CASE("Test usage of ExtractText in regex mode", "[extracttextRegexTest]") {
- TestController testController;
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ExtractText>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GetFile>();
- LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
-
- std::shared_ptr<TestPlan> plan = testController.createPlan();
- std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
-
- char dir[] = "/tmp/gt.XXXXXX";
-
- REQUIRE(testController.createTempDirectory(dir) != nullptr);
- std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
-
- std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ExtractText", "testExtractText",
- core::Relationship("success", "description"),
- true);
- plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::RegexMode.getName(), "true");
- plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::IgnoreCaptureGroupZero.getName(), "true");
- plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::EnableRepeatingCaptureGroup.getName(), "true");
- plan->setProperty(maprocessor, "RegexAttr", "Speed limit ([0-9]+)", true);
- plan->setProperty(maprocessor, "InvalidRegex", "[Invalid)A(F)", true);
-
- std::shared_ptr<core::Processor> laprocessor = plan->addProcessor("LogAttribute", "outputLogAttribute",
- core::Relationship("success", "description"),
- true);
- plan->setProperty(laprocessor, org::apache::nifi::minifi::processors::LogAttribute::AttributesToLog.getName(),
- TEST_ATTR);
-
- std::stringstream ss;
- ss << dir << "/" << TEST_FILE;
- std::string test_file_path = ss.str();
-
- std::ofstream test_file(test_file_path);
- if (test_file.is_open()) {
- test_file << REGEX_TEST_TEXT << std::endl;
- test_file.close();
- }
-
- plan->runNextProcessor(); // GetFile
- plan->runNextProcessor(); // ExtractText
- plan->runNextProcessor(); // LogAttribute
-
- std::list<std::string> suffixes = {"", ".0", ".1"};
-
- for (const auto& suffix : suffixes) {
- ss.str("");
- ss << "key:" << "RegexAttr" << suffix << " value:" << ((suffix == ".1") ? "80" : "130");
- std::string log_check = ss.str();
- REQUIRE(LogTestController::getInstance().contains(log_check));
- }
-
- std::string error_str = "error encountered when trying to construct regular expression from property (key: InvalidRegex)";
-
- REQUIRE(LogTestController::getInstance().contains(error_str));
-
- LogTestController::getInstance().reset();
+ TestController testController;
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ExtractText>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GetFile>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
+
+ std::shared_ptr<TestPlan> plan = testController.createPlan();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
+
+ char dirtemplate[] = "/tmp/gt.XXXXXX";
+
+ auto dir = testController.createTempDirectory(dirtemplate);
+ REQUIRE(!dir.empty());
+ std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
+
+ std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ExtractText", "testExtractText", core::Relationship("success", "description"), true);
+ plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::RegexMode.getName(), "true");
+ plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::IgnoreCaptureGroupZero.getName(), "true");
+ plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::EnableRepeatingCaptureGroup.getName(), "true");
+ plan->setProperty(maprocessor, "RegexAttr", "Speed limit ([0-9]+)", true);
+ plan->setProperty(maprocessor, "InvalidRegex", "[Invalid)A(F)", true);
+
+ std::shared_ptr<core::Processor> laprocessor = plan->addProcessor("LogAttribute", "outputLogAttribute", core::Relationship("success", "description"), true);
+ plan->setProperty(laprocessor, org::apache::nifi::minifi::processors::LogAttribute::AttributesToLog.getName(), TEST_ATTR);
+
+ std::stringstream ss;
+ ss << dir << utils::file::FileUtils::get_separator() << TEST_FILE;
+ std::string test_file_path = ss.str();
+
+ std::ofstream test_file(test_file_path);
+ if (test_file.is_open()) {
+ test_file << REGEX_TEST_TEXT;
+ test_file.close();
+ }
+
+ plan->runNextProcessor(); // GetFile
+ plan->runNextProcessor(); // ExtractText
+ plan->runNextProcessor(); // LogAttribute
+
+ std::list<std::string> suffixes = { "", ".0", ".1" };
+
+ for (const auto& suffix : suffixes) {
+ ss.str("");
+ ss << "key:" << "RegexAttr" << suffix << " value:" << ((suffix == ".1") ? "80" : "130");
+ std::string log_check = ss.str();
+ REQUIRE(LogTestController::getInstance().contains(log_check));
+ }
+
+ std::string error_str = "error encountered when trying to construct regular expression from property (key: InvalidRegex)";
+
+ REQUIRE(LogTestController::getInstance().contains(error_str));
+
+ LogTestController::getInstance().reset();
}
diff --git a/extensions/standard-processors/tests/unit/GetFileTests.cpp b/extensions/standard-processors/tests/unit/GetFileTests.cpp
index 7289034..0464df9 100644
--- a/extensions/standard-processors/tests/unit/GetFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/GetFileTests.cpp
@@ -22,12 +22,14 @@
#include <set>
#include <fstream>
-
#include "TestBase.h"
#include "LogAttribute.h"
#include "GetFile.h"
-TEST_CASE("GetFile: FIFO", "[getFileFifo]") { // NOLINT
+/**
+ * This is an invalidly named test as we can't guarantee order, nor shall we.
+ */
+TEST_CASE("GetFile: MaxSize", "[getFileFifo]") { // NOLINT
TestController testController;
LogTestController::getInstance().setTrace<TestPlan>();
@@ -38,46 +40,41 @@ TEST_CASE("GetFile: FIFO", "[getFileFifo]") { // NOLINT
auto repo = std::make_shared<TestRepository>();
// Define directory for input
- std::string in_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&in_dir[0]) != nullptr);
+ char in_dir[] = "/tmp/gt.XXXXXX";
+ auto temp_path = testController.createTempDirectory(in_dir);
+ REQUIRE(!temp_path.empty());
// Define test input file
- std::string in_file(in_dir);
- in_file.append("/testfifo");
+ std::string in_file = temp_path + utils::file::FileUtils::get_separator() + "testfifo";
// Build MiNiFi processing graph
- auto get_file = plan->addProcessor(
- "GetFile",
- "Get");
- plan->setProperty(
- get_file,
- processors::GetFile::Directory.getName(), in_dir);
- plan->setProperty(
- get_file,
- processors::GetFile::KeepSourceFile.getName(),
- "true");
- plan->addProcessor(
- "LogAttribute",
- "Log",
- core::Relationship("success", "description"),
- true);
+ auto get_file = plan->addProcessor("GetFile", "Get");
+ plan->setProperty(get_file, processors::GetFile::Directory.getName(), temp_path);
+ plan->setProperty(get_file, processors::GetFile::KeepSourceFile.getName(), "true");
+ plan->setProperty(get_file, processors::GetFile::MaxSize.getName(), "50 B");
+ plan->addProcessor("LogAttribute", "Log", core::Relationship("success", "description"), true);
- // Write test input
- REQUIRE(0 == mkfifo(in_file.c_str(), 0777));
+ // Write test input.
+ std::ofstream in_file_stream(in_file);
+ in_file_stream << "The quick brown fox jumps over the lazy dog" << std::endl;
+ in_file_stream.close();
- // Run test flow
- std::thread write_thread([&] {
- std::ofstream in_file_stream(in_file);
- in_file_stream << "The quick brown fox jumps over the lazy dog" << std::endl;
- });
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+
+ in_file_stream.open(in_file + "2");
+ in_file_stream << "The quick brown fox jumps over the lazy dog who is 2 legit to quit" << std::endl;
+ in_file_stream.close();
plan->runNextProcessor(); // Get
plan->runNextProcessor(); // Log
- write_thread.join();
-
- // Check log output
+ // Check log output on windows std::endl; will produce \r\n can write manually but might as well just
+ // account for the size difference here
REQUIRE(LogTestController::getInstance().contains("key:flow.id"));
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("Size:45 Offset:0"));
+#else
REQUIRE(LogTestController::getInstance().contains("Size:44 Offset:0"));
+#endif
}
diff --git a/extensions/standard-processors/tests/unit/GetTCPTests.cpp b/extensions/standard-processors/tests/unit/GetTCPTests.cpp
index 9b7b29d..f8ae3ea 100644
--- a/extensions/standard-processors/tests/unit/GetTCPTests.cpp
+++ b/extensions/standard-processors/tests/unit/GetTCPTests.cpp
@@ -39,8 +39,6 @@
TEST_CASE("GetTCPWithoutEOM", "[GetTCP1]") {
utils::Identifier ident = utils::Identifier();
- std::cout << (ident == nullptr) << std::endl;
- std::cout << ident.to_string() << std::endl;
TestController testController;
std::vector<uint8_t> buffer;
for (auto c : "Hello World\nHello Warld\nGoodByte Cruel world") {
@@ -51,7 +49,7 @@ TEST_CASE("GetTCPWithoutEOM", "[GetTCP1]") {
content_repo->initialize(std::make_shared<minifi::Configure>());
std::shared_ptr<org::apache::nifi::minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(std::make_shared<minifi::Configure>());
- org::apache::nifi::minifi::io::RandomServerSocket server("localhost");
+ org::apache::nifi::minifi::io::RandomServerSocket server(org::apache::nifi::minifi::io::Socket::getMyHostName());
LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
LogTestController::getInstance().setDebug<minifi::processors::GetTCP>();
@@ -101,7 +99,7 @@ TEST_CASE("GetTCPWithoutEOM", "[GetTCP1]") {
std::shared_ptr<core::controller::ControllerServiceProvider> controller_services_provider = nullptr;
std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider, repo, repo, content_repo);
std::shared_ptr<core::ProcessContext> context2 = std::make_shared<core::ProcessContext>(node2, controller_services_provider, repo, repo, content_repo);
- context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, "localhost:" + std::to_string(server.getPort()));
+ context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, org::apache::nifi::minifi::io::Socket::getMyHostName() + ":" + std::to_string(server.getPort()));
context->setProperty(org::apache::nifi::minifi::processors::GetTCP::ReconnectInterval, "100 msec");
auto session = std::make_shared<core::ProcessSession>(context);
auto session2 = std::make_shared<core::ProcessSession>(context2);
@@ -161,7 +159,7 @@ TEST_CASE("GetTCPWithOEM", "[GetTCP2]") {
TestController testController;
- org::apache::nifi::minifi::io::RandomServerSocket server("localhost");
+ org::apache::nifi::minifi::io::RandomServerSocket server(org::apache::nifi::minifi::io::Socket::getMyHostName());
LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
LogTestController::getInstance().setTrace<core::repository::VolatileContentRepository >();
@@ -211,7 +209,7 @@ TEST_CASE("GetTCPWithOEM", "[GetTCP2]") {
std::shared_ptr<core::controller::ControllerServiceProvider> controller_services_provider = nullptr;
std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider, repo, repo, content_repo);
std::shared_ptr<core::ProcessContext> context2 = std::make_shared<core::ProcessContext>(node2, controller_services_provider, repo, repo, content_repo);
- context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, "localhost:" + std::to_string(server.getPort()));
+ context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, org::apache::nifi::minifi::io::Socket::getMyHostName() + ":" + std::to_string(server.getPort()));
context->setProperty(org::apache::nifi::minifi::processors::GetTCP::ReconnectInterval, "100 msec");
// we're using new lines above
context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndOfMessageByte, "10");
@@ -285,7 +283,7 @@ TEST_CASE("GetTCPWithOnlyOEM", "[GetTCP3]") {
LogTestController::getInstance().setDebug<minifi::io::Socket>();
- org::apache::nifi::minifi::io::RandomServerSocket server("localhost");
+ org::apache::nifi::minifi::io::RandomServerSocket server(org::apache::nifi::minifi::io::Socket::getMyHostName());
LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
@@ -333,7 +331,7 @@ TEST_CASE("GetTCPWithOnlyOEM", "[GetTCP3]") {
std::shared_ptr<core::controller::ControllerServiceProvider> controller_services_provider = nullptr;
std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider, repo, repo, content_repo);
std::shared_ptr<core::ProcessContext> context2 = std::make_shared<core::ProcessContext>(node2, controller_services_provider, repo, repo, content_repo);
- context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, "localhost:" + std::to_string(server.getPort()));
+ context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndpointList, org::apache::nifi::minifi::io::Socket::getMyHostName() + ":" + std::to_string(server.getPort()));
context->setProperty(org::apache::nifi::minifi::processors::GetTCP::ReconnectInterval, "100 msec");
// we're using new lines above
context->setProperty(org::apache::nifi::minifi::processors::GetTCP::EndOfMessageByte, "10");
@@ -399,7 +397,7 @@ TEST_CASE("GetTCPEmptyNoConnect", "[GetTCP3]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetTCP::EndpointList.getName(), "localhost:9182");
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetTCP::EndpointList.getName(), org::apache::nifi::minifi::io::Socket::getMyHostName() + ":9182");
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetTCP::ReconnectInterval.getName(), "100 msec");
// we're using new lines above
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetTCP::EndOfMessageByte.getName(), "10");
@@ -410,7 +408,7 @@ TEST_CASE("GetTCPEmptyNoConnect", "[GetTCP3]") {
REQUIRE(record == nullptr);
REQUIRE(records.size() == 0);
- REQUIRE(true == LogTestController::getInstance().contains("Could not create socket during initialization for localhost:9182"));
+ REQUIRE(true == LogTestController::getInstance().contains("Could not create socket during initialization for " + org::apache::nifi::minifi::io::Socket::getMyHostName() + ":9182"));
LogTestController::getInstance().reset();
}
diff --git a/extensions/standard-processors/tests/unit/HashContentTest.cpp b/extensions/standard-processors/tests/unit/HashContentTest.cpp
index 8cdac33..55b964a 100644
--- a/extensions/standard-processors/tests/unit/HashContentTest.cpp
+++ b/extensions/standard-processors/tests/unit/HashContentTest.cpp
@@ -35,6 +35,7 @@
#include "core/ProcessContext.h"
#include "core/ProcessSession.h"
#include "core/ProcessorNode.h"
+#include "utils/ScopeGuard.h"
#include "GetFile.h"
#include "HashContent.h"
@@ -51,7 +52,6 @@ const char* MD5_CHECKSUM = "4FE8A693C64F93F65C5FAF42DC49AB23";
const char* SHA1_CHECKSUM = "03840DEB949D6CF0C0A624FA7EBA87FBDBCB7783";
const char* SHA256_CHECKSUM = "66D5B2CC06203137F8A0E9714638DC1085C57A3F1FA26C8823AE5CF89AB26488";
-
TEST_CASE("Test Creation of HashContent", "[HashContentCreate]") {
TestController testController;
std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::HashContent>("processorname");
@@ -63,43 +63,51 @@ TEST_CASE("Test Creation of HashContent", "[HashContentCreate]") {
TEST_CASE("Test usage of ExtractText", "[extracttextTest]") {
TestController testController;
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GetFile>();
+ LogTestController::getInstance().setTrace<core::ProcessSession>();
+ LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::HashContent>();
std::shared_ptr<TestPlan> plan = testController.createPlan();
std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
char dir[] = "/tmp/gt.XXXXXX";
- REQUIRE(testController.createTempDirectory(dir) != nullptr);
+ auto tempdir = testController.createTempDirectory(dir);
+ REQUIRE(!tempdir.empty());
std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
- plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
+ plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), tempdir);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
std::shared_ptr<core::Processor> md5processor = plan->addProcessor("HashContent", "HashContentMD5",
- core::Relationship("success", "description"), true);
+ core::Relationship("success", "description"), true);
plan->setProperty(md5processor, org::apache::nifi::minifi::processors::HashContent::HashAttribute.getName(), MD5_ATTR);
plan->setProperty(md5processor, org::apache::nifi::minifi::processors::HashContent::HashAlgorithm.getName(), "MD5");
std::shared_ptr<core::Processor> shaprocessor = plan->addProcessor("HashContent", "HashContentSHA1",
- core::Relationship("success", "description"), true);
+ core::Relationship("success", "description"), true);
plan->setProperty(shaprocessor, org::apache::nifi::minifi::processors::HashContent::HashAttribute.getName(), SHA1_ATTR);
plan->setProperty(shaprocessor, org::apache::nifi::minifi::processors::HashContent::HashAlgorithm.getName(), "sha1");
std::shared_ptr<core::Processor> sha2processor = plan->addProcessor("HashContent", "HashContentSHA256",
- core::Relationship("success", "description"), true);
+ core::Relationship("success", "description"), true);
plan->setProperty(sha2processor, org::apache::nifi::minifi::processors::HashContent::HashAttribute.getName(), SHA256_ATTR);
plan->setProperty(sha2processor, org::apache::nifi::minifi::processors::HashContent::HashAlgorithm.getName(), "sha-256");
std::shared_ptr<core::Processor> laprocessor = plan->addProcessor("LogAttribute", "outputLogAttribute",
- core::Relationship("success", "description"), true);
+ core::Relationship("success", "description"), true);
std::stringstream ss1;
- ss1 << dir << "/" << TEST_FILE;
+ ss1 << tempdir << utils::file::FileUtils::get_separator() << TEST_FILE;
std::string test_file_path = ss1.str();
- std::ofstream test_file(test_file_path);
+ std::ofstream test_file(test_file_path, std::ios::binary);
+
if (test_file.is_open()) {
- test_file << TEST_TEXT << std::endl;
+ test_file << TEST_TEXT;
+ // the standard allows << std::endl; to replace, in line, with \r\n on windows
+ char newline = '\n';
+ test_file.write(&newline, 1);
test_file.close();
}
diff --git a/extensions/standard-processors/tests/unit/ManifestTests.cpp b/extensions/standard-processors/tests/unit/ManifestTests.cpp
index e111636..82f5297 100644
--- a/extensions/standard-processors/tests/unit/ManifestTests.cpp
+++ b/extensions/standard-processors/tests/unit/ManifestTests.cpp
@@ -82,6 +82,7 @@ TEST_CASE("Test Relationships", "[rel1]") {
proc_0 = node;
}
}
+#ifndef WIN32
REQUIRE(proc_0.children.size() > 0);
const auto &relationships = proc_0.children[1];
REQUIRE("supportedRelationships" == relationships.name);
@@ -93,6 +94,7 @@ TEST_CASE("Test Relationships", "[rel1]") {
REQUIRE("success" == relationships.children[1].children[0].value.to_string());
REQUIRE("description" == relationships.children[1].children[1].name);
+#endif
}
TEST_CASE("Test Dependent", "[dependent]") {
@@ -109,6 +111,7 @@ TEST_CASE("Test Dependent", "[dependent]") {
proc_0 = node;
}
}
+#ifndef WIN32
REQUIRE(proc_0.children.size() > 0);
const auto &prop_descriptors = proc_0.children[0];
REQUIRE(prop_descriptors.children.size() > 0);
@@ -119,6 +122,7 @@ TEST_CASE("Test Dependent", "[dependent]") {
REQUIRE("defaultValue" == prop_0.children[5].name);
const auto &prop_0_dependent_0 = prop_descriptors.children[2];
REQUIRE("Directory" == prop_0_dependent_0.name);
+#endif
}
TEST_CASE("Test Scheduling Defaults", "[schedDef]") {
@@ -167,6 +171,6 @@ TEST_CASE("Test operatingSystem Defaults", "[opsys]") {
}
}
REQUIRE(!proc_0.value.empty());
- std::set<std::string> expected({"Linux", "Windows 32", "Windows 64", "Mac OSX", "Unix"});
+ std::set<std::string> expected({"Linux", "Windows", "Mac OSX", "Unix"});
REQUIRE(expected.find(proc_0.value.to_string()) != std::end(expected));
}
diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
index afbc22f..5c382f1 100644
--- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp
+++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
@@ -51,7 +51,7 @@ TEST_CASE("Test GetFileMultiple", "[getfileCreate3]") {
std::shared_ptr<TestRepository> repo = std::static_pointer_cast<TestRepository>(test_repo);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
utils::Identifier processoruuid;
REQUIRE(true == processor->getUUID(processoruuid));
@@ -68,7 +68,7 @@ TEST_CASE("Test GetFileMultiple", "[getfileCreate3]") {
connection->setDestinationUUID(processoruuid);
processor->addConnection(connection);
- REQUIRE(dir != NULL);
+ REQUIRE(!dir.empty());
std::shared_ptr<core::ProcessorNode> node = std::make_shared<core::ProcessorNode>(processor);
std::shared_ptr<core::controller::ControllerServiceProvider> controller_services_provider = nullptr;
@@ -99,7 +99,7 @@ TEST_CASE("Test GetFileMultiple", "[getfileCreate3]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -135,7 +135,7 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") {
std::shared_ptr<TestRepository> repo = std::static_pointer_cast<TestRepository>(test_repo);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
utils::Identifier processoruuid;
REQUIRE(true == processor->getUUID(processoruuid));
@@ -152,7 +152,7 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") {
connection->setDestinationUUID(processoruuid);
processor->addConnection(connection);
- REQUIRE(dir != NULL);
+ REQUIRE(!dir.empty());
std::shared_ptr<core::ProcessorNode> node = std::make_shared<core::ProcessorNode>(processor);
std::shared_ptr<core::controller::ControllerServiceProvider> controller_services_provider = nullptr;
@@ -183,7 +183,7 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << ".filewithoutanext";
+ ss << dir << utils::file::FileUtils::get_separator() << ".filewithoutanext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -218,7 +218,7 @@ TEST_CASE("LogAttributeTest", "[getfileCreate3]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
testController.runSession(plan, false);
@@ -229,7 +229,7 @@ TEST_CASE("LogAttributeTest", "[getfileCreate3]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -262,7 +262,7 @@ TEST_CASE("LogAttributeTestInvalid", "[TestLogAttribute]") {
auto loggattr = plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::BatchSize.getName(), "1");
@@ -281,7 +281,7 @@ void testMultiplesLogAttribute(int fileCount, int flowsToLog, std::string verify
auto loggattr = plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
auto flowsToLogStr = std::to_string(flowsToLog);
if (verifyStringFlowsLogged.empty())
@@ -300,7 +300,7 @@ void testMultiplesLogAttribute(int fileCount, int flowsToLog, std::string verify
for (int i = 0; i < fileCount; i++) {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile" << i << ".ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile" << i << ".ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -349,7 +349,7 @@ TEST_CASE("Test Find file", "[getfileCreate3]") {
minifi::io::StreamFactory::getInstance(std::make_shared<org::apache::nifi::minifi::Configure>()), std::make_shared<org::apache::nifi::minifi::Configure>());
plan->addProcessor(processorReport, "reporter", core::Relationship("success", "description"), false);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
plan->setProperty(processor, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
testController.runSession(plan, false);
@@ -360,7 +360,7 @@ TEST_CASE("Test Find file", "[getfileCreate3]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
diff --git a/extensions/standard-processors/tests/unit/PutFileTests.cpp b/extensions/standard-processors/tests/unit/PutFileTests.cpp
index e21c6a7..ebf121d 100644
--- a/extensions/standard-processors/tests/unit/PutFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/PutFileTests.cpp
@@ -63,9 +63,9 @@ TEST_CASE("PutFileTest", "[getfileputpfile]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
char format2[] = "/tmp/ft.XXXXXX";
- char *putfiledir = testController.createTempDirectory(format2);
+ auto putfiledir = testController.createTempDirectory(format2);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), putfiledir);
@@ -78,7 +78,7 @@ TEST_CASE("PutFileTest", "[getfileputpfile]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -100,7 +100,7 @@ TEST_CASE("PutFileTest", "[getfileputpfile]") {
// verify that the fle was moved
REQUIRE(false == std::ifstream(ss.str()).good());
std::stringstream movedFile;
- movedFile << putfiledir << "/" << "tstFile.ext";
+ movedFile << putfiledir << utils::file::FileUtils::get_separator() << "tstFile.ext";
REQUIRE(true == std::ifstream(movedFile.str()).good());
file.open(movedFile.str(), std::ios::in);
@@ -128,9 +128,9 @@ TEST_CASE("PutFileTestFileExists", "[getfileputpfile]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("failure", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
char format2[] = "/tmp/ft.XXXXXX";
- char *putfiledir = testController.createTempDirectory(format2);
+ auto putfiledir = testController.createTempDirectory(format2);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), putfiledir);
@@ -143,13 +143,13 @@ TEST_CASE("PutFileTestFileExists", "[getfileputpfile]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
//
std::stringstream movedFile;
- movedFile << putfiledir << "/" << "tstFile.ext";
+ movedFile << putfiledir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(movedFile.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -193,9 +193,9 @@ TEST_CASE("PutFileTestFileExistsIgnore", "[getfileputpfile]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
char format2[] = "/tmp/ft.XXXXXX";
- char *putfiledir = testController.createTempDirectory(format2);
+ auto putfiledir = testController.createTempDirectory(format2);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), putfiledir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(), "ignore");
@@ -209,13 +209,13 @@ TEST_CASE("PutFileTestFileExistsIgnore", "[getfileputpfile]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
//
std::stringstream movedFile;
- movedFile << putfiledir << "/" << "tstFile.ext";
+ movedFile << putfiledir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(movedFile.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -236,7 +236,7 @@ TEST_CASE("PutFileTestFileExistsIgnore", "[getfileputpfile]") {
REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path value:" + ss.str()));
REQUIRE(true == LogTestController::getInstance().contains("Size:8 Offset:0"));
- REQUIRE(true == LogTestController::getInstance().contains("key:path value:" + std::string(dir)));
+ REQUIRE(true == LogTestController::getInstance().contains("key:path value:" + dir));
// verify that the fle was moved
REQUIRE(false == std::ifstream(ss.str()).good());
REQUIRE(true == std::ifstream(movedFile.str()).good());
@@ -258,12 +258,12 @@ TEST_CASE("PutFileTestFileExistsReplace", "[getfileputpfile]") {
std::shared_ptr<core::Processor> putfile = plan->addProcessor("PutFile", "putfile", core::Relationship("success", "description"), true);
- plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
+ plan->addProcessor("LogAttribute", "logattribute", { core::Relationship("success", "d"), core::Relationship("failure", "d") }, true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
char format2[] = "/tmp/ft.XXXXXX";
- char *putfiledir = testController.createTempDirectory(format2);
+ auto putfiledir = testController.createTempDirectory(format2);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), putfiledir);
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(), "replace");
@@ -277,13 +277,13 @@ TEST_CASE("PutFileTestFileExistsReplace", "[getfileputpfile]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
//
std::stringstream movedFile;
- movedFile << putfiledir << "/" << "tstFile.ext";
+ movedFile << putfiledir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(movedFile.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -308,13 +308,19 @@ TEST_CASE("PutFileTestFileExistsReplace", "[getfileputpfile]") {
// verify that the fle was moved
REQUIRE(false == std::ifstream(ss.str()).good());
REQUIRE(true == std::ifstream(movedFile.str()).good());
+#ifndef WIN32
REQUIRE(filemodtime != fileutils::FileUtils::last_write_time(movedFile.str()));
+#endif
LogTestController::getInstance().reset();
}
TEST_CASE("Test generation of temporary write path", "[putfileTmpWritePath]") {
auto processor = std::make_shared<org::apache::nifi::minifi::processors::PutFile>("processorname");
- REQUIRE(processor->tmpWritePath("a/b/c", "").substr(1, strlen("a/b/.c")) == "a/b/.c");
+ std::stringstream prefix;
+ prefix << "a" << utils::file::FileUtils::get_separator() << "b" << utils::file::FileUtils::get_separator();
+ std::string path = prefix.str() + "c";
+ std::string expected_path = prefix.str() + ".c";
+ REQUIRE(processor->tmpWritePath(path, "").substr(1, expected_path.length()) == expected_path);
}
TEST_CASE("PutFileMaxFileCountTest", "[getfileputpfilemaxcount]") {
@@ -334,9 +340,9 @@ TEST_CASE("PutFileMaxFileCountTest", "[getfileputpfilemaxcount]") {
plan->addProcessor("LogAttribute", "logattribute", { core::Relationship("success", "d"), core::Relationship("failure", "d") }, true);
char format[] = "/tmp/gt.XXXXXX";
- const char *dir = testController.createTempDirectory(format);
+ const auto dir = testController.createTempDirectory(format);
char format2[] = "/tmp/ft.XXXXXX";
- const char *putfiledir = testController.createTempDirectory(format2);
+ auto putfiledir = testController.createTempDirectory(format2);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::BatchSize.getName(), "1");
plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), putfiledir);
@@ -346,7 +352,7 @@ TEST_CASE("PutFileMaxFileCountTest", "[getfileputpfilemaxcount]") {
for (int i = 0; i < 2; ++i) {
std::stringstream ss;
- ss << dir << "/" << "tstFile" << i << ".ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile" << i << ".ext";
std::fstream file;
file.open(ss.str(), std::ios::out);
file << "tempFile";
@@ -362,7 +368,7 @@ TEST_CASE("PutFileMaxFileCountTest", "[getfileputpfilemaxcount]") {
testController.runSession(plan);
- REQUIRE(LogTestController::getInstance().contains("key:absolute.path value:" + std::string(dir) + "/tstFile0.ext"));
+ REQUIRE(LogTestController::getInstance().contains("key:absolute.path value:" + std::string(dir) + utils::file::FileUtils::get_separator() + "tstFile0.ext"));
REQUIRE(LogTestController::getInstance().contains("Size:8 Offset:0"));
REQUIRE(LogTestController::getInstance().contains("key:path value:" + std::string(dir)));
@@ -372,7 +378,7 @@ TEST_CASE("PutFileMaxFileCountTest", "[getfileputpfilemaxcount]") {
for (int i = 0; i < 2; ++i) {
std::stringstream ss;
- ss << putfiledir << "/" << "tstFile" << i << ".ext";
+ ss << putfiledir << utils::file::FileUtils::get_separator() << "tstFile" << i << ".ext";
std::ifstream file(ss.str());
if (file.is_open() && file.good()) {
files_in_dir++;
diff --git a/extensions/standard-processors/tests/unit/TailFileTests.cpp b/extensions/standard-processors/tests/unit/TailFileTests.cpp
index 217284f..e0d2991 100644
--- a/extensions/standard-processors/tests/unit/TailFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/TailFileTests.cpp
@@ -44,19 +44,13 @@
static std::string NEWLINE_FILE = "" // NOLINT
"one,two,three\n"
"four,five,six, seven";
-static const char *TMP_FILE = "/tmp/minifi-tmpfile.txt";
-static const char *STATE_FILE = "/tmp/minifi-state-file.txt";
-
+static const char *TMP_FILE = "minifi-tmpfile.txt";
+static const char *STATE_FILE = "minifi-state-file.txt";
TEST_CASE("TailFileWithDelimiter", "[tailfiletest2]") {
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << NEWLINE_FILE;
- tmpfile.close();
TestController testController;
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
std::shared_ptr<TestPlan> plan = testController.createPlan();
@@ -65,10 +59,21 @@ TEST_CASE("TailFileWithDelimiter", "[tailfiletest2]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
+
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << NEWLINE_FILE;
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
testController.runSession(plan, false);
@@ -78,22 +83,21 @@ TEST_CASE("TailFileWithDelimiter", "[tailfiletest2]") {
testController.runSession(plan, false);
REQUIRE(LogTestController::getInstance().contains("Logged 1 flow files"));
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("Size:" + std::to_string(NEWLINE_FILE.find_first_of('\n')+1) + " Offset:0"));
+#else
REQUIRE(LogTestController::getInstance().contains("Size:" + std::to_string(NEWLINE_FILE.find_first_of('\n')) + " Offset:0"));
+#endif
LogTestController::getInstance().reset();
// Delete the test and state file.
- remove(TMP_FILE);
+
remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
}
TEST_CASE("TestNewContent", "[tailFileWithDelimiterState]") {
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << NEWLINE_FILE;
- tmpfile.close();
-
TestController testController;
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
LogTestController::getInstance().setDebug<core::ProcessSession>();
@@ -107,10 +111,21 @@ TEST_CASE("TestNewContent", "[tailFileWithDelimiterState]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
+
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << NEWLINE_FILE;
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
testController.runSession(plan, true);
@@ -120,7 +135,7 @@ TEST_CASE("TestNewContent", "[tailFileWithDelimiterState]") {
plan->reset(true); // start a new but with state file
std::ofstream appendStream;
- appendStream.open(TMP_FILE, std::ios_base::app);
+ appendStream.open(temp_file.str(), std::ios_base::app);
appendStream << std::endl;
testController.runSession(plan, true);
@@ -131,16 +146,12 @@ TEST_CASE("TestNewContent", "[tailFileWithDelimiterState]") {
LogTestController::getInstance().reset();
// Delete the test and state file.
- remove(TMP_FILE);
+
remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
}
TEST_CASE("TestDeleteState", "[tailFileWithDelimiterState]") {
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << NEWLINE_FILE;
- tmpfile.close();
TestController testController;
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
@@ -155,38 +166,49 @@ TEST_CASE("TestDeleteState", "[tailFileWithDelimiterState]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << NEWLINE_FILE;
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
testController.runSession(plan, true);
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-14.txt"));
+#else
REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-13.txt"));
+#endif
plan->reset(true); // start a new but with state file
-
- remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
+ remove(std::string(state_file.str() + "." + id).c_str());
testController.runSession(plan, true);
REQUIRE(LogTestController::getInstance().contains("position 0"));
// if we lose state we restart
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-14.txt"));
+#else
REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-13.txt"));
+#endif
// Delete the test and state file.
- remove(TMP_FILE);
}
TEST_CASE("TestChangeState", "[tailFileWithDelimiterState]") {
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << NEWLINE_FILE << std::endl;
- tmpfile.close();
-
TestController testController;
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
LogTestController::getInstance().setDebug<core::ProcessSession>();
@@ -200,27 +222,45 @@ TEST_CASE("TestChangeState", "[tailFileWithDelimiterState]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << NEWLINE_FILE;
+ tmpfile.close();
+
+ std::ofstream appendStream;
+ appendStream.open(temp_file.str(), std::ios_base::app);
+ appendStream.write("\n", 1);
+ appendStream.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
testController.runSession(plan, true);
-
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-14.txt"));
+#else
REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-13.txt"));
+#endif
// should stay the same
for (int i = 0; i < 5; i++) {
plan->reset(true); // start a new but with state file
- auto statefile = std::string(STATE_FILE) + "." + id;
+ auto statefile = state_file.str() + "." + id;
remove(statefile.c_str());
std::ofstream newstatefile;
newstatefile.open(statefile);
- newstatefile << "FILENAME=" << TMP_FILE << std::endl;
+ newstatefile << "FILENAME=" << temp_file.str() << std::endl;
newstatefile << "POSITION=14" << std::endl;
newstatefile.close();
@@ -234,13 +274,13 @@ TEST_CASE("TestChangeState", "[tailFileWithDelimiterState]") {
for (int i = 14; i < 34; i++) {
plan->reset(true); // start a new but with state file
- auto statefile = std::string(STATE_FILE) + "." + id;
+ auto statefile = state_file.str() + "." + id;
remove(statefile.c_str());
std::ofstream newstatefile;
newstatefile.open(statefile);
- newstatefile << "FILENAME=" << TMP_FILE << std::endl;
+ newstatefile << "FILENAME=" << temp_file.str() << std::endl;
newstatefile << "POSITION=" << i << std::endl;
newstatefile.close();
testController.runSession(plan, true);
@@ -252,18 +292,12 @@ TEST_CASE("TestChangeState", "[tailFileWithDelimiterState]") {
REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile." + std::to_string(i) + "-34.txt"));
}
// Delete the test and state file.
- remove(TMP_FILE);
- remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
+ remove(std::string(state_file.str() + "." + id).c_str());
}
TEST_CASE("TestInvalidState", "[tailFileWithDelimiterState]") {
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << NEWLINE_FILE;
- tmpfile.close();
-
TestController testController;
LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
LogTestController::getInstance().setDebug<core::ProcessSession>();
@@ -277,19 +311,38 @@ TEST_CASE("TestInvalidState", "[tailFileWithDelimiterState]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << NEWLINE_FILE;
+ tmpfile.close();
+
+ std::ofstream appendStream;
+ appendStream.open(temp_file.str(), std::ios_base::app);
+ appendStream.write("\n", 1);
+ appendStream.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
testController.runSession(plan, true);
+#ifdef WIN32
+ REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-14.txt"));
+#else
REQUIRE(LogTestController::getInstance().contains("minifi-tmpfile.0-13.txt"));
+#endif
plan->reset(true); // start a new but with state file
- auto statefile = std::string(STATE_FILE) + "." + id;
+ auto statefile = state_file.str() + "." + id;
remove(statefile.c_str());
@@ -299,7 +352,7 @@ TEST_CASE("TestInvalidState", "[tailFileWithDelimiterState]") {
newstatefile << "POSITION=14" << std::endl;
newstatefile.close();
REQUIRE_THROWS(testController.runSession(plan, true));
-}
+ }
SECTION("Invalid current filename") {
std::ofstream newstatefile;
@@ -309,7 +362,7 @@ TEST_CASE("TestInvalidState", "[tailFileWithDelimiterState]") {
newstatefile << "POSITION=14" << std::endl;
newstatefile.close();
REQUIRE_THROWS(testController.runSession(plan, true));
-}
+ }
SECTION("No current filename and partial path") {
std::ofstream newstatefile;
newstatefile.open(statefile);
@@ -317,10 +370,9 @@ TEST_CASE("TestInvalidState", "[tailFileWithDelimiterState]") {
newstatefile << "POSITION=14" << std::endl;
newstatefile.close();
REQUIRE_THROWS(testController.runSession(plan, true));
-}
+ }
// Delete the test and state file.
- remove(TMP_FILE);
remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
}
@@ -340,25 +392,20 @@ TEST_CASE("TailFileWithOutDelimiter", "[tailfiletest2]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
- std::stringstream temp_file_ss;
- temp_file_ss << dir << utils::file::FileUtils::get_separator() << "minifi-tmpfile.txt";
- auto temp_file = temp_file_ss.str();
+ auto dir = testController.createTempDirectory(format);
+
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
std::ofstream tmpfile;
- tmpfile.open(temp_file);
+ tmpfile.open(temp_file.str());
tmpfile << NEWLINE_FILE;
tmpfile.close();
- SECTION("Single") {
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file);
-}
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
- SECTION("Multiple") {
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), "minifi-.*\\.txt");
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::TailMode.getName(), "Multiple file");
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::BaseDirectory.getName(), dir);
-}
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
testController.runSession(plan, false);
auto records = plan->getProvenanceRecords();
@@ -370,10 +417,6 @@ TEST_CASE("TailFileWithOutDelimiter", "[tailfiletest2]") {
REQUIRE(LogTestController::getInstance().contains("Size:" + std::to_string(NEWLINE_FILE.size()) + " Offset:0"));
LogTestController::getInstance().reset();
-
- // Delete the test and state file.
- remove(TMP_FILE);
- remove(STATE_FILE);
}
TEST_CASE("TailFileLongWithDelimiter", "[tailfiletest2]") {
@@ -386,12 +429,6 @@ TEST_CASE("TailFileLongWithDelimiter", "[tailfiletest2]") {
std::string line3("bar");
std::string line4("buzz");
- // Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << line1 << "\n" << line2 << "\n" << line3 << "\n" << line4;
- tmpfile.close();
-
TestController testController;
LogTestController::getInstance().setTrace<TestPlan>();
LogTestController::getInstance().setTrace<processors::TailFile>();
@@ -402,10 +439,20 @@ TEST_CASE("TailFileLongWithDelimiter", "[tailfiletest2]") {
std::shared_ptr<core::Processor> tailfile = plan->addProcessor("TailFile", "tailfileProc");
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << line1 << "\n" << line2 << "\n" << line3 << "\n" << line4;
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
std::shared_ptr<core::Processor> log_attr = plan->addProcessor("LogAttribute", "Log", core::Relationship("success", "description"), true);
@@ -447,12 +494,7 @@ TEST_CASE("TailFileLongWithDelimiter", "[tailfiletest2]") {
REQUIRE(LogTestController::getInstance().contains(utils::StringUtils::to_hex(line3)));
REQUIRE(false == LogTestController::getInstance().contains(utils::StringUtils::to_hex(line4), std::chrono::seconds(0)));
-
LogTestController::getInstance().reset();
-
- // Delete the test and state file.
- remove(TMP_FILE);
- remove(STATE_FILE);
}
TEST_CASE("TailFileWithDelimiterMultipleDelimiters", "[tailfiletest2]") {
@@ -460,17 +502,13 @@ TEST_CASE("TailFileWithDelimiterMultipleDelimiters", "[tailfiletest2]") {
std::string line1(4097, '\n');
std::mt19937 gen(std::random_device { }());
std::generate_n(line1.begin(), 4095, [&]() -> char {
- return 32 + gen() % (127 - 32);
+ return 32 + gen() % (127 - 32);
});
std::string line2("foo");
std::string line3("bar");
std::string line4("buzz");
// Create and write to the test file
- std::ofstream tmpfile;
- tmpfile.open(TMP_FILE);
- tmpfile << line1 << "\n" << line2 << "\n" << line3 << "\n" << line4;
- tmpfile.close();
TestController testController;
LogTestController::getInstance().setTrace<TestPlan>();
@@ -483,10 +521,20 @@ TEST_CASE("TailFileWithDelimiterMultipleDelimiters", "[tailfiletest2]") {
auto id = tailfile->getUUIDStr();
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), TMP_FILE);
- plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::FileUtils::get_separator() << TMP_FILE;
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str());
+ tmpfile << line1 << "\n" << line2 << "\n" << line3 << "\n" << line4;
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::FileUtils::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), state_file.str());
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
std::shared_ptr<core::Processor> log_attr = plan->addProcessor("LogAttribute", "Log", core::Relationship("success", "description"), true);
@@ -508,9 +556,6 @@ TEST_CASE("TailFileWithDelimiterMultipleDelimiters", "[tailfiletest2]") {
REQUIRE(false == LogTestController::getInstance().contains(utils::StringUtils::to_hex(line4), std::chrono::seconds(0)));
LogTestController::getInstance().reset();
-
- // Delete the test and state file.
- remove(std::string(std::string(STATE_FILE) + "." + id).c_str());
}
TEST_CASE("TailWithInvalid", "[tailfiletest2]") {
@@ -524,16 +569,16 @@ TEST_CASE("TailWithInvalid", "[tailfiletest2]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
SECTION("No File and No base") {
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::TailMode.getName(), "Multiple file");
-}
+ }
SECTION("No base") {
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), "minifi-.*\\.txt");
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::TailMode.getName(), "Multiple file");
-}
+ }
plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::StateFile.getName(), STATE_FILE);
REQUIRE_THROWS(plan->runNextProcessor());
@@ -548,16 +593,20 @@ TEST_CASE("TailFileWithRealDelimiterAndRotate", "[tailfiletest2]") {
LogTestController::getInstance().setTrace<TestPlan>();
LogTestController::getInstance().setTrace<processors::TailFile>();
LogTestController::getInstance().setTrace<processors::LogAttribute>();
- LogTestController::getInstance().setTrace<core::ProcessSession>();
auto plan = testController.createPlan();
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
// Define test input file
std::string in_file(dir);
- in_file.append("/testfifo.txt");
+#ifndef WIN32
+ in_file.append("/");
+#else
+ in_file.append("\\");
+#endif
+ in_file.append("testfifo.txt");
std::string state_file(dir);
state_file.append("tailfile.state");
@@ -569,16 +618,17 @@ TEST_CASE("TailFileWithRealDelimiterAndRotate", "[tailfiletest2]") {
// Build MiNiFi processing graph
auto tail_file = plan->addProcessor("TailFile", "Tail");
plan->setProperty(tail_file, processors::TailFile::Delimiter.getName(), std::string(1, DELIM));
+
SECTION("single") {
plan->setProperty(
tail_file,
processors::TailFile::FileName.getName(), in_file);
-}
+ }
SECTION("Multiple") {
plan->setProperty(tail_file, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), "test.*");
plan->setProperty(tail_file, org::apache::nifi::minifi::processors::TailFile::TailMode.getName(), "Multiple file");
plan->setProperty(tail_file, org::apache::nifi::minifi::processors::TailFile::BaseDirectory.getName(), dir);
-}
+ }
plan->setProperty(tail_file, processors::TailFile::StateFile.getName(), state_file);
auto log_attr = plan->addProcessor("LogAttribute", "Log", core::Relationship("success", "description"), true);
plan->setProperty(log_attr, processors::LogAttribute::FlowFilesToLog.getName(), "0");
@@ -587,7 +637,7 @@ TEST_CASE("TailFileWithRealDelimiterAndRotate", "[tailfiletest2]") {
plan->runNextProcessor(); // Tail
plan->runNextProcessor(); // Log
-
+ std::cout << " find " << expected_pieces << std::endl;
REQUIRE(LogTestController::getInstance().contains(std::string("Logged ") + std::to_string(expected_pieces) + " flow files"));
in_file_stream << DELIM;
@@ -626,19 +676,17 @@ TEST_CASE("TailFileWithMultileRolledOverFiles", "[tailfiletest2]") {
LogTestController::getInstance().setTrace<TestPlan>();
LogTestController::getInstance().setTrace<processors::TailFile>();
LogTestController::getInstance().setTrace<processors::LogAttribute>();
- LogTestController::getInstance().setTrace<core::ProcessSession>();
-
auto plan = testController.createPlan();
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::string state_file(dir);
state_file.append("tailfile.state");
// Define test input file
std::string in_file(dir);
- in_file.append("/fruits.txt");
+ in_file.append("fruits.txt");
for (int i = 2; 0 <= i; --i) {
if (i < 2) {
@@ -679,4 +727,3 @@ TEST_CASE("TailFileWithMultileRolledOverFiles", "[tailfiletest2]") {
REQUIRE(LogTestController::getInstance().contains(std::string("Logged 2 flow files")));
}
-
diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp
index fc07e0f..26ae3d9 100644
--- a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp
+++ b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp
@@ -34,6 +34,7 @@
#include "io/DataStream.h"
#include "core/ProcessContext.h"
#include "core/ProcessSession.h"
+#include "utils/OsUtils.h"
#pragma comment(lib, "wevtapi.lib")
@@ -93,10 +94,25 @@ core::Property ConsumeWindowsEventLog::InactiveDurationToReconnect(
" Setting no duration, e.g. '0 ms' disables auto-reconnection.")->
build());
+core::Property ConsumeWindowsEventLog::IdentifierMatcher(
+ core::PropertyBuilder::createProperty("Identifier Match Regex")->
+ isRequired(false)->
+ withDefaultValue(".*Sid")->
+ withDescription("Regular Expression to match Subject Identifier Fields. These will be placed into the attributes of the FlowFile")->
+ build());
+
+
+core::Property ConsumeWindowsEventLog::IdentifierFunction(
+ core::PropertyBuilder::createProperty("Apply Identifier Function")->
+ isRequired(false)->
+ withDefaultValue<bool>(true)->
+ withDescription("If true it will resolve SIDs matched in the 'Identifier Match Regex' to the DOMAIN\\USERNAME associated with that ID")->
+ build());
+
core::Relationship ConsumeWindowsEventLog::Success("success", "Relationship for successfully consumed events.");
ConsumeWindowsEventLog::ConsumeWindowsEventLog(const std::string& name, utils::Identifier uuid)
- : core::Processor(name, uuid), logger_(logging::LoggerFactory<ConsumeWindowsEventLog>::getLogger()) {
+ : core::Processor(name, uuid), logger_(logging::LoggerFactory<ConsumeWindowsEventLog>::getLogger()), apply_identifier_function_(false) {
// Initializes COM for current thread, it is needed to MSXML parser.
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
@@ -118,13 +134,15 @@ ConsumeWindowsEventLog::~ConsumeWindowsEventLog() {
void ConsumeWindowsEventLog::initialize() {
//! Set the supported properties
- setSupportedProperties({Channel, Query, RenderFormatXML, MaxBufferSize, InactiveDurationToReconnect});
+ setSupportedProperties({Channel, Query, RenderFormatXML, MaxBufferSize, InactiveDurationToReconnect, IdentifierMatcher, IdentifierFunction });
//! Set the supported relationships
setSupportedRelationships({Success});
}
void ConsumeWindowsEventLog::onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) {
+ context->getProperty(IdentifierMatcher.getName(), regex_);
+ context->getProperty(IdentifierFunction.getName(), apply_identifier_function_);
if (subscriptionHandle_) {
logger_->log_error("Processor already subscribed to Event Log, expected cleanup to unsubscribe.");
} else {
@@ -157,6 +175,50 @@ void ConsumeWindowsEventLog::onTrigger(const std::shared_ptr<core::ProcessContex
}
}
+void ConsumeWindowsEventLog::matchRegex(const MSXML2::IXMLDOMElementPtr pRoot, std::map<std::string, std::string> &fieldsAndValues, std::wregex match) {
+ const auto pNodeChildren = pRoot->childNodes;
+ using convert_type = std::codecvt_utf8<wchar_t>;
+ std::wstring_convert<convert_type, wchar_t> converter;
+ for (long i = 0; i < pNodeChildren->length; i++) {
+ const auto pNode = pNodeChildren->item[i];
+ const auto nodeType = pNode->GetnodeType();
+ if (DOMNodeType::NODE_ELEMENT == nodeType) {
+ auto nodeName = pNode->nodeName;
+
+ std::wstring wstringNodeName(nodeName, SysStringLen(nodeName));
+ bool matched = false;
+ if (std::regex_match(wstringNodeName, match)) {
+ matched = true;
+ }
+ else {
+ const auto pAttributes = pNode->attributes;
+ for (long iAttr = 0; iAttr < pAttributes->length; iAttr++) {
+ const auto pAttribute = pAttributes->item[iAttr];
+ if (pAttribute->nodeName == static_cast<_bstr_t>("Name")) {
+ auto attributeNodeName = static_cast<_bstr_t>(pAttribute->nodeValue);
+ std::wstring wAttributeNodeName(attributeNodeName, SysStringLen(attributeNodeName));
+ if (std::regex_match(wAttributeNodeName, match)) {
+ wstringNodeName = attributeNodeName;
+ matched = true;
+ }
+ }
+ }
+
+ }
+ if (matched) {
+ auto value = static_cast<_bstr_t>(pNode->Gettext());
+ std::wstring wstringValue(value, SysStringLen(value));
+ auto matched_field_name = converter.to_bytes(wstringNodeName);
+ auto matched_field_value = converter.to_bytes(wstringValue);
+
+ fieldsAndValues[matched_field_name] = apply_identifier_function_ ? utils::OsUtils::userIdToUsername(matched_field_value) : matched_field_value;
+ }
+ matchRegex(pNode, fieldsAndValues, match);
+ }
+ }
+
+}
+
void ConsumeWindowsEventLog::createTextOutput(const MSXML2::IXMLDOMElementPtr pRoot, std::wstringstream& stream, std::vector<std::wstring>& ancestors) {
const auto pNodeChildren = pRoot->childNodes;
@@ -219,18 +281,22 @@ bool ConsumeWindowsEventLog::subscribe(const std::shared_ptr<core::ProcessContex
context->getProperty(Query.getName(), query);
context->getProperty(RenderFormatXML.getName(), renderXML_);
- if (!renderXML_) {
- HRESULT hr = xmlDoc_.CreateInstance(__uuidof(MSXML2::DOMDocument60));
- if (FAILED(hr)) {
+
+ if (xmlDoc_) {
+ xmlDoc_.Release();
+ }
+
+ HRESULT hr = xmlDoc_.CreateInstance(__uuidof(MSXML2::DOMDocument60));
+ if (FAILED(hr)) {
logger_->log_error("!xmlDoc_.CreateInstance %x", hr);
return false;
- }
-
- xmlDoc_->async = VARIANT_FALSE;
- xmlDoc_->validateOnParse = VARIANT_FALSE;
- xmlDoc_->resolveExternals = VARIANT_FALSE;
}
+ xmlDoc_->async = VARIANT_FALSE;
+ xmlDoc_->validateOnParse = VARIANT_FALSE;
+ xmlDoc_->resolveExternals = VARIANT_FALSE;
+
+
context->getProperty(MaxBufferSize.getName(), maxBufferSize_);
logger_->log_debug("ConsumeWindowsEventLog: maxBufferSize_ %lld", maxBufferSize_);
@@ -282,20 +348,28 @@ bool ConsumeWindowsEventLog::subscribe(const std::shared_ptr<core::ProcessContex
if (EvtRender(NULL, hEvent, EvtRenderEventXml, size, &buf[0], &used, &propertyCount)) {
const auto xml = to_string(&buf[0]);
+ EventRender renderedData;
+ if (VARIANT_FALSE == pConsumeWindowsEventLog->xmlDoc_->loadXML(_bstr_t(xml.c_str()))) {
+ logger->log_error("'loadXML' failed");
+ return 0UL;
+ }
+ if (!pConsumeWindowsEventLog->regex_.empty()) {
+ std::wstring wstring_regex_;
+ wstring_regex_.assign(pConsumeWindowsEventLog->regex_.begin(), pConsumeWindowsEventLog->regex_.end());
+ std::wregex regex(wstring_regex_);
+ pConsumeWindowsEventLog->matchRegex(pConsumeWindowsEventLog->xmlDoc_->documentElement, renderedData.matched_fields_, regex);
+ }
+
if (pConsumeWindowsEventLog->renderXML_) {
- pConsumeWindowsEventLog->listRenderedData_.enqueue(std::move(xml));
+ renderedData.text_ = std::move(xml);
} else {
- if (VARIANT_FALSE == pConsumeWindowsEventLog->xmlDoc_->loadXML(_bstr_t(xml.c_str()))) {
- logger->log_error("'loadXML' failed");
- return 0UL;
- }
std::wstringstream stream;
std::vector<std::wstring> ancestors;
pConsumeWindowsEventLog->createTextOutput(pConsumeWindowsEventLog->xmlDoc_->documentElement, stream, ancestors);
-
- pConsumeWindowsEventLog->listRenderedData_.enqueue(to_string(stream.str().c_str()));
+ renderedData.text_ = std::move(to_string(stream.str().c_str()));
}
+ pConsumeWindowsEventLog->listRenderedData_.enqueue(std::move(renderedData));
} else {
logger->log_error("EvtRender returned the following error code: %d.", GetLastError());
}
@@ -340,12 +414,17 @@ int ConsumeWindowsEventLog::processQueue(const std::shared_ptr<core::ProcessSess
};
int flowFileCount = 0;
-
- std::string xml;
- while (listRenderedData_.try_dequeue(xml)) {
+
+ EventRender evt;
+ while (listRenderedData_.try_dequeue(evt)) {
auto flowFile = session->create();
- session->write(flowFile, &WriteCallback(xml));
+ session->write(flowFile, &WriteCallback(evt.text_));
+ for (const auto &fieldMapping : evt.matched_fields_) {
+ if (!fieldMapping.second.empty()) {
+ session->putAttribute(flowFile, fieldMapping.first, fieldMapping.second);
+ }
+ }
session->putAttribute(flowFile, FlowAttributeKey(MIME_TYPE), "application/xml");
session->getProvenanceReporter()->receive(flowFile, provenanceUri_, getUUIDStr(), "Consume windows event logs", 0);
session->transfer(flowFile, Success);
diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.h b/extensions/windows-event-log/ConsumeWindowsEventLog.h
index e7372be..25d2322 100644
--- a/extensions/windows-event-log/ConsumeWindowsEventLog.h
+++ b/extensions/windows-event-log/ConsumeWindowsEventLog.h
@@ -27,6 +27,7 @@
#include "core/ProcessSession.h"
#include <winevt.h>
#include <sstream>
+#include <regex>
#import <msxml6.dll>
@@ -36,6 +37,12 @@ namespace nifi {
namespace minifi {
namespace processors {
+struct EventRender {
+ std::map<std::string, std::string> matched_fields_;
+ std::string text_;
+};
+
+
//! ConsumeWindowsEventLog Class
class ConsumeWindowsEventLog : public core::Processor
{
@@ -58,6 +65,8 @@ public:
static core::Property RenderFormatXML;
static core::Property MaxBufferSize;
static core::Property InactiveDurationToReconnect;
+ static core::Property IdentifierMatcher;
+ static core::Property IdentifierFunction;
//! Supported Relationships
static core::Relationship Success;
@@ -80,6 +89,7 @@ protected:
bool subscribe(const std::shared_ptr<core::ProcessContext> &context);
void unsubscribe();
int processQueue(const std::shared_ptr<core::ProcessSession> &session);
+ void matchRegex(const MSXML2::IXMLDOMElementPtr pRoot, std::map<std::string,std::string> &fieldsAndValues, std::wregex match);
void createTextOutput(const MSXML2::IXMLDOMElementPtr pRoot, std::wstringstream& stream, std::vector<std::wstring>& ancestors);
@@ -87,7 +97,9 @@ protected:
private:
// Logger
std::shared_ptr<logging::Logger> logger_;
- moodycamel::ConcurrentQueue<std::string> listRenderedData_;
+ std::string regex_;
+ bool apply_identifier_function_;
+ moodycamel::ConcurrentQueue<EventRender> listRenderedData_;
std::string provenanceUri_;
std::string computerName_;
int64_t inactiveDurationToReconnect_{};
diff --git a/extensions/windows-event-log/tests/CMakeLists.txt b/extensions/windows-event-log/tests/CMakeLists.txt
new file mode 100644
index 0000000..fc29e2a
--- /dev/null
+++ b/extensions/windows-event-log/tests/CMakeLists.txt
@@ -0,0 +1,35 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+file(GLOB WEL_INTEGRATION_TESTS "*.cpp")
+SET(WEL_TEST_COUNT 0)
+FOREACH(testfile ${WEL_INTEGRATION_TESTS})
+ get_filename_component(testfilename "${testfile}" NAME_WE)
+ add_executable("${testfilename}" "${testfile}")
+ target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/WEL/")
+ createTests("${testfilename}")
+ if (APPLE)
+ target_link_libraries (${testfilename} -Wl,-all_load minifi-WEL)
+ else ()
+ target_link_libraries (${testfilename} -Wl,--whole-archive minifi-WEL -Wl,--no-whole-archive)
+ endif ()
+ MATH(EXPR WEL_TEST_COUNT "${WEL_TEST_COUNT}+1")
+ add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR})
+ENDFOREACH()
+message("-- Finished building ${WEL_TEST_COUNT} WEL related test file(s)...")
diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt
index 9959890..80a7119 100644
--- a/libminifi/CMakeLists.txt
+++ b/libminifi/CMakeLists.txt
@@ -116,10 +116,7 @@ target_link_libraries(core-minifi ${CMAKE_DL_LIBS} ${UUID_LIBRARIES} yaml-cpp)
include_directories(${ZLIB_INCLUDE_DIRS})
-target_link_libraries(core-minifi minifi-expression-language-extensions)
target_link_libraries (core-minifi ${ZLIB_LIBRARIES})
-set_target_properties(core-minifi PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
-
# Include OpenSSL
@@ -163,12 +160,7 @@ endif()
include_directories(${ZLIB_INCLUDE_DIRS})
-target_link_libraries(core-minifi-shared minifi-expression-language-extensions)
target_link_libraries (core-minifi-shared ${ZLIB_LIBRARIES})
-if (WIN32)
-set_target_properties(core-minifi-shared PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
-endif()
-
# Include OpenSSL
diff --git a/libminifi/include/core/ClassLoader.h b/libminifi/include/core/ClassLoader.h
index 41d683e..ff2d7b6 100644
--- a/libminifi/include/core/ClassLoader.h
+++ b/libminifi/include/core/ClassLoader.h
@@ -20,6 +20,7 @@
#include <mutex>
#include <vector>
+#include <string>
#include <map>
#include <memory>
#include "utils/StringUtils.h"
@@ -102,6 +103,7 @@ class ObjectFactory {
*/
virtual std::shared_ptr<CoreComponent> create(const std::string &name) {
return nullptr;
+
}
/**
@@ -156,7 +158,6 @@ class ObjectFactory {
std::string group_;
};
-
/**
* Factory that is used as an interface for
* creating processors from shared objects.
@@ -379,6 +380,15 @@ class ClassLoader {
/**
* Instantiate object based on class_name
* @param class_name class to create
+ * @param make_shared_ptr creates a shared ptr of the given type name
+ * @return nullptr, object created from class_name definition, or make_shared of T
+ */
+ template<class T>
+ std::shared_ptr<T> instantiate(const std::string &class_name, bool make_shared_ptr = true);
+
+ /**
+ * Instantiate object based on class_name
+ * @param class_name class to create
* @param uuid uuid of object
* @return nullptr or object created from class_name definition.
*/
@@ -569,6 +579,15 @@ class ClassLoader {
};
template<class T>
+std::shared_ptr<T> ClassLoader::instantiate(const std::string &class_name, bool make_shared_ptr) {
+ const auto ret = instantiate<T>(class_name, class_name);
+ if (nullptr == ret && make_shared_ptr) {
+ return std::make_shared<T>(class_name);
+ }
+ return ret;
+}
+
+template<class T>
std::shared_ptr<T> ClassLoader::instantiate(const std::string &class_name, const std::string &name) {
std::lock_guard<std::mutex> lock(internal_mutex_);
auto factory_entry = loaded_factories_.find(class_name);
diff --git a/libminifi/include/core/Core.h b/libminifi/include/core/Core.h
index 4168bf3..e18999c 100644
--- a/libminifi/include/core/Core.h
+++ b/libminifi/include/core/Core.h
@@ -95,7 +95,13 @@ static inline std::string getClassName() {
std::free(b);
return name;
#else
- return typeid(T).name();
+ std::string adjusted_name = typeid(T).name();
+ // can probably skip class manually for slightly higher performance
+ const std::string clazz = "class ";
+ auto haz_clazz = adjusted_name.find(clazz);
+ if (haz_clazz == 0)
+ adjusted_name = adjusted_name.substr(clazz.length(), adjusted_name.length() - clazz.length());
+ return adjusted_name;
#endif
}
diff --git a/libminifi/include/core/Deprecated.h b/libminifi/include/core/Deprecated.h
index faed844..9428aec 100644
--- a/libminifi/include/core/Deprecated.h
+++ b/libminifi/include/core/Deprecated.h
@@ -19,11 +19,11 @@
#define LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_
#ifdef _MSC_VER
-#define DEPRECATED __declspec(deprecated)
+#define DEPRECATED(v,ev) __declspec(deprecated)
#elif defined(__GNUC__) | defined(__clang__)
-#define DEPRECATED __attribute__((__deprecated__))
+#define DEPRECATED(v,ev) __attribute__((__deprecated__))
#else
-#define DEPRECATED
+#define DEPRECATED(v,ev)
#endif
#endif /* LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_ */
diff --git a/libminifi/include/core/ProcessContext.h b/libminifi/include/core/ProcessContext.h
index 932a54a..424e306 100644
--- a/libminifi/include/core/ProcessContext.h
+++ b/libminifi/include/core/ProcessContext.h
@@ -26,8 +26,8 @@
#include <atomic>
#include <algorithm>
#include <memory>
-#include <expression/Expression.h>
#include "Property.h"
+#include "core/Core.h"
#include "core/ContentRepository.h"
#include "core/repository/FileSystemRepository.h"
#include "core/controller/ControllerServiceProvider.h"
@@ -91,11 +91,15 @@ class ProcessContext : public controller::ControllerServiceLookup, public core::
return getPropertyImp<typename std::common_type<T>::type>(name, value);
}
- bool getProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file);
+ virtual bool getProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
+ return getProperty(property.getName(), value);
+ }
bool getDynamicProperty(const std::string &name, std::string &value) const {
return processor_node_->getDynamicProperty(name, value);
}
- bool getDynamicProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file);
+ virtual bool getDynamicProperty(const Property &property, std::string &value, const std::shared_ptr<FlowFile> &flow_file) {
+ return getDynamicProperty(property.getName(), value);
+ }
std::vector<std::string> getDynamicPropertyKeys() const {
return processor_node_->getDynamicPropertyKeys();
}
@@ -211,9 +215,6 @@ class ProcessContext : public controller::ControllerServiceLookup, public core::
// Processor
std::shared_ptr<ProcessorNode> processor_node_;
- std::map<std::string, org::apache::nifi::minifi::expression::Expression> expressions_;
- std::map<std::string, org::apache::nifi::minifi::expression::Expression> dynamic_property_expressions_;
-
// Logger
std::shared_ptr<logging::Logger> logger_;
diff --git a/libminifi/include/core/ProcessContextBuilder.h b/libminifi/include/core/ProcessContextBuilder.h
new file mode 100644
index 0000000..7975024
--- /dev/null
+++ b/libminifi/include/core/ProcessContextBuilder.h
@@ -0,0 +1,91 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __PROCESS_CONTEXT_BUILDER_H__
+#define __PROCESS_CONTEXT_BUILDER_H__
+
+#include <uuid/uuid.h>
+#include <vector>
+#include <queue>
+#include <map>
+#include <mutex>
+#include <atomic>
+#include <algorithm>
+#include <memory>
+#include "Property.h"
+#include "core/Core.h"
+#include "utils/Id.h"
+#include "core/ContentRepository.h"
+#include "properties/Configure.h"
+#include "core/repository/FileSystemRepository.h"
+#include "core/controller/ControllerServiceProvider.h"
+#include "core/controller/ControllerServiceLookup.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "ProcessContext.h"
+#include "ProcessorNode.h"
+#include "core/Repository.h"
+#include "core/FlowFile.h"
+#include "VariableRegistry.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+/**
+ * Could use instantiate<T> from core, which uses a simple compile time check to figure out if a destructor is defined
+ * and thus that will allow us to know if the context instance exists, but I like using the build because it allows us
+ * to eventually share the builder across different contexts and shares up the construction ever so slightly.
+ *
+ * While this incurs a tiny cost to look up, it allows us to have a replaceable builder that erases the type we are
+ * constructing.
+ */
+class ProcessContextBuilder : public core::CoreComponent, public std::enable_shared_from_this<ProcessContextBuilder> {
+ public:
+ ProcessContextBuilder(const std::string &name, minifi::utils::Identifier &uuid);
+
+ ProcessContextBuilder(const std::string &name);
+
+ virtual ~ProcessContextBuilder() {
+ }
+
+ std::shared_ptr<ProcessContextBuilder> withProvider(const std::shared_ptr<controller::ControllerServiceProvider> &controller_service_provider);
+
+ std::shared_ptr<ProcessContextBuilder> withProvenanceRepository(const std::shared_ptr<core::Repository> &repo);
+
+ std::shared_ptr<ProcessContextBuilder> withFlowFileRepository(const std::shared_ptr<core::Repository> &repo);
+
+ std::shared_ptr<ProcessContextBuilder> withContentRepository(const std::shared_ptr<core::ContentRepository> &repo);
+
+ std::shared_ptr<ProcessContextBuilder> withConfiguration(const std::shared_ptr<minifi::Configure> &configuration);
+
+ virtual std::shared_ptr<core::ProcessContext> build(const std::shared_ptr<ProcessorNode> &processor);
+
+ protected:
+ std::shared_ptr<minifi::Configure> configuration_;
+ std::shared_ptr<controller::ControllerServiceProvider> controller_service_provider_;
+ std::shared_ptr<core::Repository> prov_repo_;
+ std::shared_ptr<core::Repository> flow_repo_;
+ std::shared_ptr<core::ContentRepository> content_repo_;
+};
+
+} /* namespace core */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
+#endif
diff --git a/libminifi/include/core/ProcessSession.h b/libminifi/include/core/ProcessSession.h
index 7bcd7f5..26b8184 100644
--- a/libminifi/include/core/ProcessSession.h
+++ b/libminifi/include/core/ProcessSession.h
@@ -111,7 +111,7 @@ class ProcessSession : public ReferenceContainer {
void importFrom(io::DataStream &stream, const std::shared_ptr<core::FlowFile> &flow);
// import from the data source.
void import(std::string source, const std::shared_ptr<core::FlowFile> &flow, bool keepSource = true, uint64_t offset = 0);
- DEPRECATED void import(std::string source, std::vector<std::shared_ptr<FlowFileRecord>> &flows, bool keepSource, uint64_t offset, char inputDelimiter);
+ DEPRECATED(/*deprecated in*/ 0.7.0, /*will remove in */ 2.0) void import(std::string source, std::vector<std::shared_ptr<FlowFileRecord>> &flows, bool keepSource, uint64_t offset, char inputDelimiter);
void import(const std::string& source, std::vector<std::shared_ptr<FlowFileRecord>> &flows, uint64_t offset, char inputDelimiter);
/**
diff --git a/libminifi/include/core/PropertyValue.h b/libminifi/include/core/PropertyValue.h
index 468c4f7..3c32c86 100644
--- a/libminifi/include/core/PropertyValue.h
+++ b/libminifi/include/core/PropertyValue.h
@@ -82,7 +82,12 @@ class PropertyValue : public state::response::ValueNode {
}
ValidationResult validate(const std::string &subject) const {
- return validator_->validate(subject, getValue());
+ if (validator_) {
+ return validator_->validate(subject, getValue());
+ }
+ else {
+ return ValidationResult::Builder::createBuilder().isValid(true).build();
+ }
}
operator uint64_t() const {
diff --git a/libminifi/include/core/TypedValues.h b/libminifi/include/core/TypedValues.h
index 212635a..bd37a46 100644
--- a/libminifi/include/core/TypedValues.h
+++ b/libminifi/include/core/TypedValues.h
@@ -154,8 +154,10 @@ class DataSizeValue : public TransformableValue, public state::response::UInt64V
: state::response::UInt64Value(value) {
}
- // Convert String to Integer
- template<typename T>
+
+// Convert String to Integer
+ template<typename T, typename std::enable_if<
+ std::is_integral<T>::value>::type* = nullptr>
static bool StringToInt(const std::string &input, T &output) {
if (input.size() == 0) {
return false;
diff --git a/libminifi/include/core/repository/VolatileRepository.h b/libminifi/include/core/repository/VolatileRepository.h
index 4ba6fe7..5c67395 100644
--- a/libminifi/include/core/repository/VolatileRepository.h
+++ b/libminifi/include/core/repository/VolatileRepository.h
@@ -215,7 +215,7 @@ bool VolatileRepository<T>::initialize(const std::shared_ptr<Configure> &configu
if (configure->get(strstream.str(), value)) {
if (core::Property::StringToInt(value, max_bytes)) {
if (max_bytes <= 0) {
- max_size_ = std::numeric_limits<uint32_t>::max();
+ max_size_ = (std::numeric_limits<uint32_t>::max)();
} else {
max_size_ = max_bytes;
}
diff --git a/libminifi/include/core/Deprecated.h b/libminifi/include/utils/OsUtils.h
similarity index 56%
copy from libminifi/include/core/Deprecated.h
copy to libminifi/include/utils/OsUtils.h
index faed844..7ae7994 100644
--- a/libminifi/include/core/Deprecated.h
+++ b/libminifi/include/utils/OsUtils.h
@@ -1,5 +1,4 @@
/**
-
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -15,15 +14,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_
-#define LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_
+#ifndef LIBMINIFI_INCLUDE_UTILS_OSUTILS_H_
+#define LIBMINIFI_INCLUDE_UTILS_OSUTILS_H_
+
+#include <string>
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace utils {
+namespace OsUtils {
+
+/**
+ * Resolves a user ID to a username
+ */
+extern std::string userIdToUsername(const std::string &uid);
-#ifdef _MSC_VER
-#define DEPRECATED __declspec(deprecated)
-#elif defined(__GNUC__) | defined(__clang__)
-#define DEPRECATED __attribute__((__deprecated__))
-#else
-#define DEPRECATED
+#ifdef WIN32
+/*
+ Resolves common identifiers
+*/
+extern std::string resolve_common_identifiers(const std::string &id);
#endif
+} /* namespace OsUtils */
+} /* namespace utils */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
-#endif /* LIBMINIFI_INCLUDE_CORE_DEPRECATED_H_ */
+#endif /* LIBMINIFI_INCLUDE_UTILS_OSUTILS_H_ */
diff --git a/libminifi/include/utils/file/FileUtils.h b/libminifi/include/utils/file/FileUtils.h
index 3267321..2d7aaa8 100644
--- a/libminifi/include/utils/file/FileUtils.h
+++ b/libminifi/include/utils/file/FileUtils.h
@@ -25,7 +25,9 @@
#include <cstring>
#include <cstdlib>
#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
+#ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+#endif
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <Windows.h>
@@ -45,6 +47,8 @@
#include <fcntl.h>
#ifdef WIN32
#include <direct.h>
+#include "utils/Id.h"
+#include "properties/Properties.h"
#include <windows.h> // winapi
#include <sys/stat.h> // stat
#include <tchar.h> // _tcscpy,_tcscat,_tcscmp
@@ -99,6 +103,34 @@ class FileUtils {
#endif
}
+ static std::string create_temp_directory(char *format) {
+#ifdef WIN32
+ std::string tempDirectory;
+ char tempBuffer[MAX_PATH];
+ auto ret = GetTempPath(MAX_PATH, tempBuffer);
+ if (ret <= MAX_PATH && ret != 0)
+ {
+ static std::shared_ptr<minifi::utils::IdGenerator> generator;
+ if (!generator) {
+ generator = minifi::utils::IdGenerator::getIdGenerator();
+ generator->initialize(std::make_shared<minifi::Properties>());
+ }
+ tempDirectory = tempBuffer;
+ minifi::utils::Identifier id;
+ generator->generate(id);
+ tempDirectory += id.to_string();
+ create_dir(tempDirectory);
+ }
+ return tempDirectory;
+#else
+ auto dir = mkdtemp(format);
+ if (nullptr == dir) {
+ return "";
+ }
+ else return dir;
+#endif
+ }
+
static int64_t delete_dir(const std::string &path, bool delete_files_recursively = true) {
#ifdef BOOST_VERSION
try {
@@ -122,10 +154,10 @@ class FileUtils {
DWORD Attributes;
std::string str;
+
std::stringstream pathstr;
- pathstr << path << "\\.*";
+ pathstr << path << "\\*";
str = pathstr.str();
-
//List files
hFind = FindFirstFile(str.c_str(), &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
diff --git a/libminifi/opsys/win/io/ClientSocket.h b/libminifi/opsys/win/io/ClientSocket.h
index 3621215..d5d279f 100644
--- a/libminifi/opsys/win/io/ClientSocket.h
+++ b/libminifi/opsys/win/io/ClientSocket.h
@@ -128,7 +128,7 @@ public:
* Return the port for this socket
* @returns port
*/
- uint16_t getPort();
+ uint16_t getPort() const;
// data stream extensions
/**
@@ -234,6 +234,11 @@ public:
protected:
+ void setPort(uint16_t port) {
+ port_ = port;
+ }
+
+
/**
* Constructor that accepts host name, port and listeners. With this
* contructor we will be creating a server socket
@@ -309,6 +314,9 @@ private:
#ifdef WIN32
static WSADATA s_wsaData;
int iWinSockInitResult = WSAStartup(MAKEWORD(2, 2), &s_wsaData);
+ if (0 != iWinSockInitResult) {
+ throw std::exception("Cannot start client");
+ }
#endif
}
~SocketInitializer() {
@@ -326,6 +334,7 @@ private:
static std::string init_hostname() {
+ initialize_socket();
char hostname[1024];
gethostname(hostname, 1024);
Socket mySock(nullptr, hostname, 0);
diff --git a/libminifi/src/Properties.cpp b/libminifi/src/Properties.cpp
index 95cb18e..fdcacdf 100644
--- a/libminifi/src/Properties.cpp
+++ b/libminifi/src/Properties.cpp
@@ -85,7 +85,7 @@ bool Properties::parseConfigureFileLine(char *buf, std::string &prop_key, std::s
++line;
char first = line[0];
- if ((first == '\0') || (first == '#') || (first == '\r') || (first == '\n') || (first == '=')) {
+ if ((first == '\0') || (first == '#') || (first == '[') || (first == '\r') || (first == '\n') || (first == '=')) {
return true;
}
@@ -198,12 +198,14 @@ bool Properties::persistProperties() {
char first = line[0];
- if ((first == '\0') || (first == '#') || (first == '\r') || (first == '\n') || (first == '=')) {
+ if ((first == '\0') || (first == '#') || (first == '[') || (first == '\r') || (first == '\n') || (first == '=')) {
// persist comments and newlines
output_file << line << std::endl;
continue;
}
+
+
char *equal = strchr(line, '=');
if (equal == NULL) {
output_file << line << std::endl;
diff --git a/libminifi/src/RemoteProcessorGroupPort.cpp b/libminifi/src/RemoteProcessorGroupPort.cpp
index 54329f8..1dc9201 100644
--- a/libminifi/src/RemoteProcessorGroupPort.cpp
+++ b/libminifi/src/RemoteProcessorGroupPort.cpp
@@ -68,7 +68,13 @@ std::unique_ptr<sitetosite::SiteToSiteClient> RemoteProcessorGroupPort::getNextP
if (bypass_rest_api_) {
if (nifi_instances_.size() > 0) {
auto rpg = nifi_instances_.front();
- sitetosite::SiteToSiteClientConfiguration config(stream_factory_, std::make_shared<sitetosite::Peer>(protocol_uuid_, rpg.host_, rpg.port_, ssl_service != nullptr), this->getInterface(),
+ auto host = rpg.host_;
+#ifdef WIN32
+ if ("localhost" == host) {
+ host = org::apache::nifi::minifi::io::Socket::getMyHostName();
+ }
+#endif
+ sitetosite::SiteToSiteClientConfiguration config(stream_factory_, std::make_shared<sitetosite::Peer>(protocol_uuid_, host, rpg.port_, ssl_service != nullptr), this->getInterface(),
client_type_);
config.setHTTPProxy(this->proxy_);
nextProtocol = sitetosite::createClient(config);
@@ -261,6 +267,11 @@ std::pair<std::string, int> RemoteProcessorGroupPort::refreshRemoteSite2SiteInfo
for (auto nifi : nifi_instances_) {
std::string host = nifi.host_;
+#ifdef WIN32
+ if ("localhost" == host) {
+ host = org::apache::nifi::minifi::io::Socket::getMyHostName();
+ }
+#endif
std::string protocol = nifi.protocol_;
int port = nifi.port_;
std::stringstream fullUrl;
@@ -278,12 +289,12 @@ std::pair<std::string, int> RemoteProcessorGroupPort::refreshRemoteSite2SiteInfo
std::unique_ptr<utils::BaseHTTPClient> client = nullptr;
if (!rest_user_name_.empty()) {
std::stringstream loginUrl;
- fullUrl << protocol << host;
+ loginUrl << protocol << host;
// don't append port if it is 0 ( undefined )
if (port > 0) {
- fullUrl << ":" << std::to_string(port);
+ loginUrl << ":" << std::to_string(port);
}
- fullUrl << "/nifi-api/access/token";
+ loginUrl << "/nifi-api/access/token";
auto client_ptr = core::ClassLoader::getDefaultClassLoader().instantiateRaw("HTTPClient", "HTTPClient");
if (nullptr == client_ptr) {
diff --git a/libminifi/src/ThreadedSchedulingAgent.cpp b/libminifi/src/ThreadedSchedulingAgent.cpp
index 88b39f3..c677c59 100644
--- a/libminifi/src/ThreadedSchedulingAgent.cpp
+++ b/libminifi/src/ThreadedSchedulingAgent.cpp
@@ -25,9 +25,11 @@
#include <map>
#include <thread>
#include <iostream>
+#include "core/ClassLoader.h"
#include "core/Connectable.h"
#include "core/ProcessorNode.h"
#include "core/ProcessContext.h"
+#include "core/ProcessContextBuilder.h"
#include "core/ProcessSession.h"
#include "core/ProcessSessionFactory.h"
@@ -69,7 +71,13 @@ void ThreadedSchedulingAgent::schedule(std::shared_ptr<core::Processor> processo
std::shared_ptr<core::ProcessorNode> processor_node = std::make_shared<core::ProcessorNode>(processor);
- auto processContext = std::make_shared<core::ProcessContext>(processor_node, controller_service_provider_, repo_, flow_repo_, configure_, content_repo_);
+ auto contextBuilder = core::ClassLoader::getDefaultClassLoader().instantiate<core::ProcessContextBuilder>("ProcessContextBuilder");
+
+ contextBuilder = contextBuilder->withContentRepository(content_repo_)->withFlowFileRepository(flow_repo_)->withProvider(controller_service_provider_)->withProvenanceRepository(repo_)
+ ->withConfiguration(configure_);
+
+ auto processContext = contextBuilder->build(processor_node);
+
auto sessionFactory = std::make_shared<core::ProcessSessionFactory>(processContext);
processor->onSchedule(processContext, sessionFactory);
diff --git a/libminifi/src/core/ProcessContextBuilder.cpp b/libminifi/src/core/ProcessContextBuilder.cpp
new file mode 100644
index 0000000..b1b794c
--- /dev/null
+++ b/libminifi/src/core/ProcessContextBuilder.cpp
@@ -0,0 +1,84 @@
+/**
+ * @file ProcessGroup.cpp
+ * ProcessGroup class implementation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "core/ProcessContextBuilder.h"
+#include <time.h>
+#include <vector>
+#include <memory>
+#include <string>
+#include <queue>
+#include <map>
+#include <set>
+#include <chrono>
+#include <thread>
+#include "core/Processor.h"
+#include "core/logging/LoggerConfiguration.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+ProcessContextBuilder::ProcessContextBuilder(const std::string &name, minifi::utils::Identifier &uuid)
+ : core::CoreComponent(name, uuid) {
+ content_repo_ = std::make_shared<core::repository::FileSystemRepository>();
+ configuration_ = std::make_shared<minifi::Configure>();
+}
+
+ProcessContextBuilder::ProcessContextBuilder(const std::string &name)
+ : core::CoreComponent(name) {
+ content_repo_ = std::make_shared<core::repository::FileSystemRepository>();
+ configuration_ = std::make_shared<minifi::Configure>();
+}
+
+std::shared_ptr<ProcessContextBuilder> ProcessContextBuilder::withProvider(const std::shared_ptr<controller::ControllerServiceProvider> &controller_service_provider) {
+ controller_service_provider_ = controller_service_provider;
+ return this->shared_from_this();
+}
+
+std::shared_ptr<ProcessContextBuilder> ProcessContextBuilder::withProvenanceRepository(const std::shared_ptr<core::Repository> &repo) {
+ prov_repo_ = repo;
+ return this->shared_from_this();
+}
+
+std::shared_ptr<ProcessContextBuilder> ProcessContextBuilder::withFlowFileRepository(const std::shared_ptr<core::Repository> &repo) {
+ flow_repo_ = repo;
+ return this->shared_from_this();
+}
+
+std::shared_ptr<ProcessContextBuilder> ProcessContextBuilder::withContentRepository(const std::shared_ptr<core::ContentRepository> &repo) {
+ content_repo_ = repo;
+ return this->shared_from_this();
+}
+
+std::shared_ptr<ProcessContextBuilder> ProcessContextBuilder::withConfiguration(const std::shared_ptr<minifi::Configure> &configuration) {
+ configuration_ = configuration;
+ return this->shared_from_this();
+}
+
+std::shared_ptr<core::ProcessContext> ProcessContextBuilder::build(const std::shared_ptr<ProcessorNode> &processor) {
+ return std::make_shared<core::ProcessContext>(processor, controller_service_provider_, prov_repo_, flow_repo_, configuration_, content_repo_);
+}
+
+} /* namespace core */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
diff --git a/libminifi/src/core/ProcessSession.cpp b/libminifi/src/core/ProcessSession.cpp
index 42271b8..fb1f17d 100644
--- a/libminifi/src/core/ProcessSession.cpp
+++ b/libminifi/src/core/ProcessSession.cpp
@@ -566,13 +566,17 @@ void ProcessSession::import(const std::string& source, std::vector<std::shared_p
if (read == 0) {
logger_->log_trace("Finished reading input %s", source);
break;
+ } else {
+ logging::LOG_TRACE(logger_) << "Read input of " << read;
}
uint8_t* begin = buffer.data();
uint8_t* end = begin + read;
while (true) {
+ startTime = getTimeMillis();
uint8_t* delimiterPos = std::find(begin, end, static_cast<uint8_t>(inputDelimiter));
int len = delimiterPos - begin;
+ logging::LOG_TRACE(logger_) << "Read input of " << read << " length is " << len << " is at end?" << (delimiterPos == end);
/*
* We do not want to process the rest of the buffer after the last delimiter if
* - we have reached EOF in the file (we would discard it anyway)
@@ -615,8 +619,8 @@ void ProcessSession::import(const std::string& source, std::vector<std::shared_p
}
flowFile->setResourceClaim(claim);
claim->increaseFlowFileRecordOwnedCount();
- logger_->log_debug("Import offset %u length %u into content %s for FlowFile UUID %s", flowFile->getOffset(), flowFile->getSize(), flowFile->getResourceClaim()->getContentFullPath(),
- flowFile->getUUIDStr());
+ logging::LOG_DEBUG(logger_) << "Import offset " << flowFile->getOffset() << " length " << flowFile->getSize() << " content " << flowFile->getResourceClaim()->getContentFullPath()
+ << ", FlowFile UUID " << flowFile->getUUIDStr();
stream->closeStream();
std::string details = process_context_->getProcessorNode()->getName() + " modify flow record content " + flowFile->getUUIDStr();
uint64_t endTime = getTimeMillis();
diff --git a/libminifi/src/core/logging/LoggerConfiguration.cpp b/libminifi/src/core/logging/LoggerConfiguration.cpp
index 27db9e6..862baaf 100644
--- a/libminifi/src/core/logging/LoggerConfiguration.cpp
+++ b/libminifi/src/core/logging/LoggerConfiguration.cpp
@@ -95,7 +95,12 @@ void LoggerConfiguration::initialize(const std::shared_ptr<LoggerProperties> &lo
std::shared_ptr<Logger> LoggerConfiguration::getLogger(const std::string &name) {
std::lock_guard<std::mutex> lock(mutex);
- std::shared_ptr<LoggerImpl> result = std::make_shared<LoggerImpl>(name, controller_, get_logger(logger_, root_namespace_, name, formatter_));
+ std::string adjusted_name = name;
+ const std::string clazz = "class ";
+ auto haz_clazz = name.find(clazz);
+ if (haz_clazz == 0)
+ adjusted_name = name.substr(clazz.length(), name.length() - clazz.length());
+ std::shared_ptr<LoggerImpl> result = std::make_shared<LoggerImpl>(adjusted_name, controller_, get_logger(logger_, root_namespace_, adjusted_name, formatter_));
loggers.push_back(result);
return result;
}
diff --git a/libminifi/src/io/DataStream.cpp b/libminifi/src/io/DataStream.cpp
index 871e21a..d558b69 100644
--- a/libminifi/src/io/DataStream.cpp
+++ b/libminifi/src/io/DataStream.cpp
@@ -97,12 +97,8 @@ int DataStream::readData(std::vector<uint8_t> &buf, int buflen) {
if (static_cast<int>(buf.capacity()) < buflen)
buf.resize(buflen+1);
-#ifdef WIN32
// back inserter works differently on win32 versions
- buf.insert(buf.begin(), &buffer[readBuffer], &buffer[(readBuffer + buflen-1)]);
-#else
buf.insert(buf.begin(), &buffer[readBuffer], &buffer[(readBuffer + buflen)]);
-#endif
readBuffer += buflen;
return buflen;
@@ -113,12 +109,7 @@ int DataStream::readData(uint8_t *buf, int buflen) {
// if read exceed
return -1;
}
-#ifdef WIN32
- // back inserter works differently on win32 versions
- std::copy(&buffer[readBuffer], &buffer[(readBuffer + buflen-1)], buf);
-#else
std::copy(&buffer[readBuffer], &buffer[(readBuffer + buflen)], buf);
-#endif
readBuffer += buflen;
return buflen;
}
diff --git a/libminifi/src/io/posix/ClientSocket.cpp b/libminifi/src/io/posix/ClientSocket.cpp
index 7fa4d22..fd69bb5 100644
--- a/libminifi/src/io/posix/ClientSocket.cpp
+++ b/libminifi/src/io/posix/ClientSocket.cpp
@@ -233,6 +233,7 @@ int16_t Socket::initialize() {
gethostbyname_r(host, &he, buf, sizeof(buf), &h, &hh_errno);
#endif
if (h == nullptr) {
+ logger_->log_error("hostname not defined for %s", requested_hostname_);
return -1;
}
memcpy(reinterpret_cast<char*>(&addr), h->h_addr_list[0], h->h_length);
diff --git a/libminifi/src/io/tls/TLSSocket.cpp b/libminifi/src/io/tls/TLSSocket.cpp
index a6a6ef5..e7909a0 100644
--- a/libminifi/src/io/tls/TLSSocket.cpp
+++ b/libminifi/src/io/tls/TLSSocket.cpp
@@ -210,7 +210,11 @@ int16_t TLSSocket::initialize(bool blocking) {
logger_->log_error("SSL socket connect failed to %s %d", requested_hostname_, port_);
SSL_free(ssl_);
ssl_ = NULL;
+#ifdef WIN32
+ closesocket(socket_file_descriptor_);
+#else
close(socket_file_descriptor_);
+#endif
return -1;
} else {
connected_ = true;
@@ -230,7 +234,11 @@ void TLSSocket::close_ssl(int fd) {
if (nullptr != fd_ssl) {
SSL_free(fd_ssl);
ssl_map_[fd] = nullptr;
+#ifdef WIN32
+ closesocket(fd);
+#else
close(fd);
+#endif
}
}
}
@@ -297,7 +305,11 @@ int16_t TLSSocket::select_descriptor(const uint16_t msec) {
logger_->log_error("SSL socket connect failed to %s %d", requested_hostname_, port_);
SSL_free(ssl_);
ssl_ = NULL;
+#ifdef WIN32
+ closesocket(socket_file_descriptor_);
+#else
close(socket_file_descriptor_);
+#endif
return -1;
} else {
connected_ = true;
@@ -366,7 +378,9 @@ int TLSSocket::readData(uint8_t *buf, int buflen, bool retrieve_all_bytes) {
}
int TLSSocket::readData(std::vector<uint8_t> &buf, int buflen) {
- if (buf.capacity() < buflen) {
+ if (buflen < 0)
+ return -1;
+ if (buf.capacity() < static_cast<size_t>(buflen)) {
buf.reserve(buflen);
}
int total_read = 0;
@@ -443,7 +457,11 @@ int TLSSocket::readData(uint8_t *buf, int buflen) {
while (buflen) {
int16_t fd = select_descriptor(1000);
if (fd <= 0) {
+#ifdef WIN32
+ closesocket(socket_file_descriptor_);
+#else
close(socket_file_descriptor_);
+#endif
return -1;
}
diff --git a/libminifi/src/io/win/ClientSocket.cpp b/libminifi/src/io/win/ClientSocket.cpp
index 261c2af..2b75951 100644
--- a/libminifi/src/io/win/ClientSocket.cpp
+++ b/libminifi/src/io/win/ClientSocket.cpp
@@ -244,7 +244,7 @@ int16_t Socket::initialize() {
int errcode = getaddrinfo(requested_hostname_.c_str(), 0, &hints, &addr_info_);
if (errcode != 0) {
- logger_->log_error("Saw error during getaddrinfo, error: %s", strerror(errno));
+ logger_->log_error("Saw error during getaddrinfo, error: %lu", WSAGetLastError());
return -1;
}
@@ -406,6 +406,9 @@ int Socket::writeData(uint8_t *value, int size) {
int ret = 0, bytes = 0;
int fd = select_descriptor(1000);
+ if (fd < 0) {
+ return -1;
+ }
while (bytes < size) {
#ifdef WIN32
const char *vts = (const char*)value;
@@ -436,6 +439,14 @@ inline std::vector<uint8_t> Socket::readBuffer(const T& t) {
return buf;
}
+/**
+ * Return the port for this socket
+ * @returns port
+ */
+uint16_t Socket::getPort() const {
+ return port_;
+}
+
int Socket::write(uint64_t base_value, bool is_little_endian) {
return Serializable::write(base_value, this, is_little_endian);
}
diff --git a/libminifi/src/sitetosite/SiteToSiteClient.cpp b/libminifi/src/sitetosite/SiteToSiteClient.cpp
index db145d7..81e8ac3 100644
--- a/libminifi/src/sitetosite/SiteToSiteClient.cpp
+++ b/libminifi/src/sitetosite/SiteToSiteClient.cpp
@@ -237,7 +237,7 @@ bool SiteToSiteClient::confirm(std::string transactionID) {
// be listening. As a result, it will re-send the data. By doing this two-phase commit, we narrow the
// Critical Section involved in this transaction so that rather than the Critical Section being the
// time window involved in the entire transaction, it is reduced to a simple round-trip conversation.
- int64_t crcValue = transaction->getCRC();
+ uint64_t crcValue = transaction->getCRC();
std::string crc = std::to_string(crcValue);
logger_->log_debug("Site2Site Send confirm with CRC %d to transaction %s", transaction->getCRC(), transactionID);
ret = writeResponse(transaction, CONFIRM_TRANSACTION, crc);
diff --git a/libminifi/src/utils/OsUtils.cpp b/libminifi/src/utils/OsUtils.cpp
new file mode 100644
index 0000000..f1cc21e
--- /dev/null
+++ b/libminifi/src/utils/OsUtils.cpp
@@ -0,0 +1,156 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utils/OsUtils.h"
+#include <iostream>
+#include <map>
+
+#ifdef WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <Windows.h>
+#include <sddl.h>
+#pragma comment(lib, "Ws2_32.lib")
+#else
+#include <mutex>
+#include <pwd.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#endif
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace utils {
+
+#ifdef WIN32
+/*
+ These are common translations for SIDs in windows
+ */
+std::string OsUtils::resolve_common_identifiers(const std::string &id) {
+ static std::map<std::string, std::string> nameMap;
+ if (nameMap.empty()) {
+ nameMap["S-1-0"] = "Null Authority";
+ nameMap["S-1-0-0"] = "Nobody";
+ nameMap["S-1-1-0"] = "Everyone";
+ nameMap["S-1-2"] = "Local Authority";
+ nameMap["S-1-2-0"] = "Local";
+ nameMap["S-1-2-1"] = "Console Logon";
+ nameMap["S-1-3-0"] = "Creator Owner";
+ nameMap["S-1-3-1"] = "Creator Group";
+ }
+ auto name = nameMap.find(id);
+ if (name != std::end(nameMap)) {
+ return name->second;
+ }
+ return "";
+}
+#endif
+
+std::string OsUtils::userIdToUsername(const std::string &uid) {
+ std::string name;
+ name = uid;
+ if (!name.empty()) {
+#ifdef WIN32
+ const auto resolved_name = resolve_common_identifiers(name);
+ if (!resolved_name.empty()) {
+ return resolved_name;
+ }
+ // First call to LookupAccountSid to get the buffer sizes.
+ PSID pSidOwner = NULL;
+ if (ConvertStringSidToSidA(name.c_str(), &pSidOwner)) {
+ SID_NAME_USE sidType = SidTypeUnknown;
+ DWORD windowsAccountNameSize = 0, dwwindowsDomainSize = 0;
+ /*
+ We can use a unique ptr with a deleter here but some of the calls
+ below require we use global alloc -- so a global deleter to call GlobalFree
+ won't buy us a ton unless we anticipate requiring more of this. If we do
+ I suggest we break this out until a subset of OsUtils into our own convenience functions.
+ */
+ LPTSTR windowsDomain = NULL;
+ LPTSTR windowsAccount = NULL;
+
+ /*
+ The first call will be to obtain sizes for domain and account,
+ after which we will allocate the memory and free it after.
+ In some cases youc an replace GlobalAlloc with
+ */
+ LookupAccountSid(NULL /** local computer **/, pSidOwner,
+ windowsAccount,
+ (LPDWORD)&windowsAccountNameSize,
+ windowsDomain,
+ (LPDWORD)&dwwindowsDomainSize,
+ &sidType);
+
+ if (windowsAccountNameSize > 0) {
+ windowsAccount = (LPTSTR)GlobalAlloc(
+ GMEM_FIXED,
+ windowsAccountNameSize);
+
+ if (dwwindowsDomainSize > 0) {
+ windowsDomain = (LPTSTR)GlobalAlloc(
+ GMEM_FIXED,
+ dwwindowsDomainSize);
+ }
+
+ if (LookupAccountSid(
+ NULL,
+ pSidOwner,
+ windowsAccount,
+ (LPDWORD)&windowsAccountNameSize,
+ windowsDomain,
+ (LPDWORD)&dwwindowsDomainSize,
+ &sidType)) {
+ if (dwwindowsDomainSize > 0) {
+ std::string domain = std::string(windowsDomain);
+ name = domain + "\\";
+ name += std::string(windowsAccount);
+ } else {
+ name = std::string(windowsAccount);
+ }
+ }
+ GlobalFree(windowsAccount);
+ if (dwwindowsDomainSize > 0)
+ GlobalFree(windowsDomain);
+ }
+ }
+#else
+ auto ptr = name.c_str();
+ char *end = nullptr; // it will be unused
+ uid_t ret = std::strtol(ptr, &end, 10);
+ if (ret > 0) {
+ struct passwd pass;
+ struct passwd *result;
+ char localbuf[1024];
+ if (!getpwuid_r(ret, &pass, localbuf, sizeof localbuf, &result)) {
+ name = pass.pw_name;
+ }
+ }
+#endif
+ }
+ return name;
+}
+
+} /* namespace utils */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
+
diff --git a/libminifi/test/TestBase.cpp b/libminifi/test/TestBase.cpp
index be42952..4904682 100644
--- a/libminifi/test/TestBase.cpp
+++ b/libminifi/test/TestBase.cpp
@@ -32,7 +32,8 @@ TestPlan::TestPlan(std::shared_ptr<core::ContentRepository> content_repo, std::s
stream_factory = org::apache::nifi::minifi::io::StreamFactory::getInstance(std::make_shared<minifi::Configure>());
}
-std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string &name, const std::initializer_list<core::Relationship>& relationships, bool linkToPrevious) {
+std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string &name, const std::initializer_list<core::Relationship>& relationships,
+ bool linkToPrevious) {
if (finalized) {
return nullptr;
}
@@ -64,7 +65,7 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<co
logger_->log_info("Creating %s connection for proc %d", connection_name.str(), processor_queue_.size() + 1);
std::shared_ptr<minifi::Connection> connection = std::make_shared<minifi::Connection>(flow_repo_, content_repo_, connection_name.str());
- for(const auto& relationship: relationships) {
+ for (const auto& relationship : relationships) {
connection->addRelationship(relationship);
}
@@ -88,7 +89,14 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<co
processor_nodes_.push_back(node);
- std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider_, prov_repo_, flow_repo_, configuration_, content_repo_);
+ // std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider_, prov_repo_, flow_repo_, configuration_, content_repo_);
+
+ auto contextBuilder = core::ClassLoader::getDefaultClassLoader().instantiate<core::ProcessContextBuilder>("ProcessContextBuilder");
+
+ contextBuilder = contextBuilder->withContentRepository(content_repo_)->withFlowFileRepository(flow_repo_)->withProvider(controller_services_provider_)->withProvenanceRepository(prov_repo_)->withConfiguration(configuration_);
+
+ auto context = contextBuilder->build(node);
+
processor_contexts_.push_back(context);
processor_queue_.push_back(processor);
@@ -96,7 +104,8 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<co
return processor;
}
-std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &processor_name, utils::Identifier& uuid, const std::string &name, const std::initializer_list<core::Relationship>& relationships, bool linkToPrevious) {
+std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &processor_name, utils::Identifier& uuid, const std::string &name,
+ const std::initializer_list<core::Relationship>& relationships, bool linkToPrevious) {
if (finalized) {
return nullptr;
}
@@ -113,7 +122,8 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &proce
return addProcessor(processor, name, relationships, linkToPrevious);
}
-std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &processor_name, const std::string &name, const std::initializer_list<core::Relationship>& relationships, bool linkToPrevious) {
+std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &processor_name, const std::string &name, const std::initializer_list<core::Relationship>& relationships,
+ bool linkToPrevious) {
if (finalized) {
return nullptr;
}
@@ -123,8 +133,6 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &proce
utils::IdGenerator::getIdGenerator()->generate(uuid);
- std::cout << "generated " << uuid.to_string() << std::endl;
-
return addProcessor(processor_name, uuid, name, relationships, linkToPrevious);
}
diff --git a/libminifi/test/TestBase.h b/libminifi/test/TestBase.h
index 71013c6..f7af0c1 100644
--- a/libminifi/test/TestBase.h
+++ b/libminifi/test/TestBase.h
@@ -18,11 +18,11 @@
#ifndef LIBMINIFI_TEST_TESTBASE_H_
#define LIBMINIFI_TEST_TESTBASE_H_
-#include <dirent.h>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include "ResourceClaim.h"
+#include "utils/file/FileUtils.h"
#include "catch.hpp"
#include <vector>
#include <set>
@@ -40,6 +40,7 @@
#include "core/FlowFile.h"
#include "core/Processor.h"
#include "core/ProcessContext.h"
+#include "core/ProcessContextBuilder.h"
#include "core/ProcessSession.h"
#include "core/ProcessorNode.h"
#include "core/reporting/SiteToSiteProvenanceReportingTask.h"
@@ -160,7 +161,12 @@ class LogTestController {
void setLevel(const std::string name, spdlog::level::level_enum level) {
logger_->log_info("Setting log level for %s to %s", name, spdlog::level::to_str(level));
- spdlog::get(name)->set_level(level);
+ std::string adjusted_name = name;
+ const std::string clazz = "class ";
+ auto haz_clazz = name.find(clazz);
+ if (haz_clazz == 0)
+ adjusted_name = name.substr(clazz.length(), name.length() - clazz.length());
+ spdlog::get(adjusted_name)->set_level(level);
}
std::vector<std::string> modified_loggers;
};
@@ -173,16 +179,16 @@ class TestPlan {
std::shared_ptr<core::Processor> addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string &name,
core::Relationship relationship = core::Relationship("success", "description"), bool linkToPrevious = false) {
- return addProcessor(processor, name, {relationship}, linkToPrevious);
+ return addProcessor(processor, name, { relationship }, linkToPrevious);
}
std::shared_ptr<core::Processor> addProcessor(const std::string &processor_name, const std::string &name, core::Relationship relationship = core::Relationship("success", "description"),
bool linkToPrevious = false) {
- return addProcessor(processor_name, name, {relationship}, linkToPrevious);
+ return addProcessor(processor_name, name, { relationship }, linkToPrevious);
}
- std::shared_ptr<core::Processor> addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string &name,
- const std::initializer_list<core::Relationship>& relationships, bool linkToPrevious = false);
+ std::shared_ptr<core::Processor> addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string &name, const std::initializer_list<core::Relationship>& relationships,
+ bool linkToPrevious = false);
std::shared_ptr<core::Processor> addProcessor(const std::string &processor_name, const std::string &name, const std::initializer_list<core::Relationship>& relationships,
bool linkToPrevious = false);
@@ -294,37 +300,16 @@ class TestController {
~TestController() {
for (auto dir : directories) {
- DIR *created_dir;
- struct dirent *dir_entry;
- created_dir = opendir(dir.c_str());
- if (created_dir != NULL) {
- while ((dir_entry = readdir(created_dir)) != NULL) {
- if (dir_entry->d_name[0] != '.') {
-
- std::string file(dir);
- file += "/";
- file += dir_entry->d_name;
- unlink(file.c_str());
- }
- }
- closedir(created_dir);
- }
-
- rmdir(dir.c_str());
+ utils::file::FileUtils::delete_dir(dir, true);
}
}
/**
* format will be changed by mkdtemp, so don't rely on a shared variable.
*/
- char *createTempDirectory(char *format) {
- char *dir = mkdtemp(format);
- if (NULL == dir) {
- perror("mkdtemp failed: ");
- }
+ std::string createTempDirectory(char *format) {
+ auto dir = utils::file::FileUtils::create_temp_directory(format);
directories.push_back(dir);
- // TODO: return const char or don't return char* at all and use the format passed in as mkdtemp
- // but I'm inclined to keep as-is for the time being.
return dir;
}
diff --git a/libminifi/test/archive-tests/FocusArchiveTests.cpp b/libminifi/test/archive-tests/FocusArchiveTests.cpp
index 2d5cd84..721e974 100644
--- a/libminifi/test/archive-tests/FocusArchiveTests.cpp
+++ b/libminifi/test/archive-tests/FocusArchiveTests.cpp
@@ -79,7 +79,7 @@ TEST_CASE("FocusArchive", "[testFocusArchive]") {
char dir2[] = "/tmp/gt.XXXXXX";
char dir3[] = "/tmp/gt.XXXXXX";
- REQUIRE(testController.createTempDirectory(dir1) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir1).empty());
std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir1);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
@@ -87,7 +87,7 @@ TEST_CASE("FocusArchive", "[testFocusArchive]") {
std::shared_ptr<core::Processor> fprocessor = plan->addProcessor("FocusArchiveEntry", "focusarchiveCreate", core::Relationship("success", "description"), true);
plan->setProperty(fprocessor, org::apache::nifi::minifi::processors::FocusArchiveEntry::Path.getName(), FOCUSED_FILE);
- REQUIRE(testController.createTempDirectory(dir2) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir2).empty());
std::shared_ptr<core::Processor> putfile1 = plan->addProcessor("PutFile", "PutFile1", core::Relationship("success", "description"), true);
plan->setProperty(putfile1, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), dir2);
plan->setProperty(putfile1, org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(),
@@ -95,7 +95,7 @@ TEST_CASE("FocusArchive", "[testFocusArchive]") {
std::shared_ptr<core::Processor> ufprocessor = plan->addProcessor("UnfocusArchiveEntry", "unfocusarchiveCreate", core::Relationship("success", "description"), true);
- REQUIRE(testController.createTempDirectory(dir3) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir3).empty());
std::shared_ptr<core::Processor> putfile2 = plan->addProcessor("PutFile", "PutFile2", core::Relationship("success", "description"), true);
plan->setProperty(putfile2, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), dir3);
plan->setProperty(putfile2, org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(),
diff --git a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
index c254a39..ee85d15 100644
--- a/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
+++ b/libminifi/test/archive-tests/ManipulateArchiveTests.cpp
@@ -63,7 +63,7 @@ bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive outpu
char dir1[] = "/tmp/gt.XXXXXX";
char dir2[] = "/tmp/gt.XXXXXX";
- REQUIRE(testController.createTempDirectory(dir1) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir1).empty());
std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getfileCreate2");
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir1);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), "true");
@@ -74,7 +74,7 @@ bool run_archive_test(OrderedTestArchive input_archive, OrderedTestArchive outpu
plan->setProperty(maprocessor, kv.first, kv.second);
}
- REQUIRE(testController.createTempDirectory(dir2) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir2).empty());
std::shared_ptr<core::Processor> putfile2 = plan->addProcessor("PutFile", "PutFile2", core::Relationship("success", "description"), true);
plan->setProperty(putfile2, org::apache::nifi::minifi::processors::PutFile::Directory.getName(), dir2);
plan->setProperty(putfile2, org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(),
diff --git a/libminifi/test/bustache-tests/ApplyTemplateTests.cpp b/libminifi/test/bustache-tests/ApplyTemplateTests.cpp
index e83167e..e986b5a 100644
--- a/libminifi/test/bustache-tests/ApplyTemplateTests.cpp
+++ b/libminifi/test/bustache-tests/ApplyTemplateTests.cpp
@@ -73,9 +73,9 @@ TEST_CASE("Test usage of ApplyTemplate", "[ApplyTemplateTest]") {
char dir2[] = "/tmp/gt.XXXXXX"; // Template source
char dir3[] = "/tmp/gt.XXXXXX"; // PutFile destionation
- REQUIRE(testController.createTempDirectory(dir1) != nullptr);
- REQUIRE(testController.createTempDirectory(dir2) != nullptr);
- REQUIRE(testController.createTempDirectory(dir3) != nullptr);
+ REQUIRE(!testController.createTempDirectory(dir1).empty());
+ REQUIRE(!testController.createTempDirectory(dir2).empty());
+ REQUIRE(!testController.createTempDirectory(dir3).empty());
std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getFile");
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir1);
diff --git a/libminifi/test/civetweb-tests/CMakeLists.txt b/libminifi/test/civetweb-tests/CMakeLists.txt
deleted file mode 100644
index 3b77db5..0000000
--- a/libminifi/test/civetweb-tests/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-if(NOT DISABLE_CURL)
-file(GLOB CIVETWEB_INTEGRATION_TESTS "*.cpp")
-SET(CIVETWEB-EXTENSIONS_TEST_COUNT 0)
-FOREACH(testfile ${CIVETWEB_INTEGRATION_TESTS})
- get_filename_component(testfilename "${testfile}" NAME_WE)
- add_executable("${testfilename}" "${testfile}")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/civetweb")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/civetweb-1.10/include")
-
- if (APPLE)
- target_link_libraries (${testfilename} -Wl,-all_load ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} minifi-civet-extensions minifi-http-curl minifi-standard-processors)
- else ()
- target_link_libraries (${testfilename} -Wl,--whole-archive ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} minifi-civet-extensions minifi-http-curl minifi-standard-processors -Wl,--no-whole-archive)
- endif ()
-
- createTests("${testfilename}")
- target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
- MATH(EXPR CIVETWEB-EXTENSIONS_TEST_COUNT "${CIVETWEB-EXTENSIONS_TEST_COUNT}+1")
- add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR})
-ENDFOREACH()
-message("-- Finished building ${CIVETWEB-EXTENSIONS_TEST_COUNT} civetweb related test file(s)...")
-endif()
\ No newline at end of file
diff --git a/libminifi/test/expression-language-tests/CMakeLists.txt b/libminifi/test/expression-language-tests/CMakeLists.txt
deleted file mode 100644
index 320a1e4..0000000
--- a/libminifi/test/expression-language-tests/CMakeLists.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-
-file(GLOB EXPRESSION_LANGUAGE_TESTS "*.cpp")
-
-SET(EXTENSIONS_TEST_COUNT 0)
-
-FOREACH(testfile ${EXPRESSION_LANGUAGE_TESTS})
- get_filename_component(testfilename "${testfile}" NAME_WE)
- add_executable("${testfilename}" "${testfile}")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors")
- target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language")
- createTests("${testfilename}")
- target_link_libraries(${testfilename} ${CATCH_MAIN_LIB})
- if (APPLE)
- target_link_libraries ("${testfilename}" -Wl,-all_load minifi-expression-language-extensions minifi-standard-processors)
- else ()
- target_link_libraries ("${testfilename}" -Wl,--whole-archive minifi-expression-language-extensions minifi-standard-processors -Wl,--no-whole-archive)
- endif()
- MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1")
- add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR})
-ENDFOREACH()
-
-
-### integration tests
-
-file(GLOB INT_EXPRESSION_LANGUAGE_TESTS "integration/*.cpp")
-
-SET(INT_EXTENSIONS_TEST_COUNT 0)
-
-FOREACH(testfile ${INT_EXPRESSION_LANGUAGE_TESTS})
- get_filename_component(testfilename "${testfile}" NAME_WE)
- add_executable("${testfilename}" "${testfile}")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors")
- target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors")
- target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language")
- createTests("${testfilename}")
- if (APPLE)
- target_link_libraries ("${testfilename}" -Wl,-all_load minifi-expression-language-extensions minifi-standard-processors)
- else ()
- target_link_libraries ("${testfilename}" -Wl,--whole-archive minifi-expression-language-extensions minifi-standard-processors -Wl,--no-whole-archive)
- endif()
- MATH(EXPR EXTENSIONS_TEST_COUNT "${INT_EXTENSIONS_TEST_COUNT}+1")
-ENDFOREACH()
-
-
-add_test(NAME UpdateAttributeIntegrationTest COMMAND UpdateAttributeIntegrationTest "${TEST_RESOURCES}/TestUpdateAttribute.yml" "${TEST_RESOURCES}/")
-
-message("-- Finished building ${EXTENSIONS_TEST_COUNT} expression language related test file(s)...")
diff --git a/libminifi/test/gps-tests/GPSTests.cpp b/libminifi/test/gps-tests/GPSTests.cpp
index f2cd777..4446bca 100644
--- a/libminifi/test/gps-tests/GPSTests.cpp
+++ b/libminifi/test/gps-tests/GPSTests.cpp
@@ -51,7 +51,7 @@ TEST_CASE("GPSD Create", "[gpsdtest1]") {
plan->addProcessor("LogAttribute", "logattribute", core::Relationship("success", "description"), true);
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir);
testController.runSession(plan, false);
diff --git a/libminifi/test/integration/IntegrationBase.h b/libminifi/test/integration/IntegrationBase.h
index ac3d892..d6d437f 100644
--- a/libminifi/test/integration/IntegrationBase.h
+++ b/libminifi/test/integration/IntegrationBase.h
@@ -76,11 +76,9 @@ class IntegrationBase {
IntegrationBase::IntegrationBase(uint64_t waitTime)
: configuration(std::make_shared<minifi::Configure>()),
wait_time_(waitTime) {
- mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}
IntegrationBase::~IntegrationBase() {
- rmdir("./content_repository");
}
void IntegrationBase::configureSecurity() {
diff --git a/libminifi/test/integration/ProvenanceReportingTest.cpp b/libminifi/test/integration/ProvenanceReportingTest.cpp
index 7fe3c3e..c968230 100644
--- a/libminifi/test/integration/ProvenanceReportingTest.cpp
+++ b/libminifi/test/integration/ProvenanceReportingTest.cpp
@@ -27,6 +27,7 @@
#include <thread>
#include <type_traits>
#include <vector>
+#include "utils/file/FileUtils.h"
#include "utils/StringUtils.h"
#include "core/Core.h"
#include "core/logging/Logger.h"
@@ -47,6 +48,8 @@ int main(int argc, char **argv) {
if (argc > 1) {
test_file_location = argv[1];
}
+ // need to change test to not use temp dir
+#ifndef WIN32
mkdir("/tmp/aljs39/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
mkdir("content_repository", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
@@ -85,5 +88,6 @@ int main(int argc, char **argv) {
LogTestController::getInstance().reset();
rmdir("./content_repository");
rmdir("/tmp/aljs39/");
+#endif
return 0;
}
diff --git a/libminifi/test/resources/TestUpdateAttribute.yml b/libminifi/test/resources/TestUpdateAttribute.yml
index f22aed4..f741bfb 100644
--- a/libminifi/test/resources/TestUpdateAttribute.yml
+++ b/libminifi/test/resources/TestUpdateAttribute.yml
@@ -120,7 +120,6 @@ Connections:
source relationship name: success
max work queue size: 0
max work queue data size: 1 MB
- flowfile expiration: 60 sec
-
+ flowfile expiration: 60 sec
Remote Processing Groups:
diff --git a/libminifi/test/rocksdb-tests/DBContentRepositoryTests.cpp b/libminifi/test/rocksdb-tests/DBContentRepositoryTests.cpp
index 15fb81d..8d7742b 100644
--- a/libminifi/test/rocksdb-tests/DBContentRepositoryTests.cpp
+++ b/libminifi/test/rocksdb-tests/DBContentRepositoryTests.cpp
@@ -28,7 +28,7 @@
TEST_CASE("Write Claim", "[TestDBCR1]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -69,7 +69,7 @@ TEST_CASE("Write Claim", "[TestDBCR1]") {
TEST_CASE("Delete Claim", "[TestDBCR2]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -108,7 +108,7 @@ TEST_CASE("Delete Claim", "[TestDBCR2]") {
TEST_CASE("Test Empty Claim", "[TestDBCR3]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -144,7 +144,7 @@ TEST_CASE("Test Empty Claim", "[TestDBCR3]") {
TEST_CASE("Test Null Claim", "[TestDBCR4]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -165,7 +165,7 @@ TEST_CASE("Test Null Claim", "[TestDBCR4]") {
TEST_CASE("Delete Null Claim", "[TestDBCR5]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -205,7 +205,7 @@ TEST_CASE("Delete Null Claim", "[TestDBCR5]") {
TEST_CASE("Delete NonExistent Claim", "[TestDBCR5]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
@@ -247,7 +247,7 @@ TEST_CASE("Delete NonExistent Claim", "[TestDBCR5]") {
TEST_CASE("Delete Remove Count Claim", "[TestDBCR6]") {
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+auto dir = testController.createTempDirectory(format);
auto content_repo = std::make_shared<core::repository::DatabaseContentRepository>();
auto configuration = std::make_shared<org::apache::nifi::minifi::Configure>();
diff --git a/libminifi/test/rocksdb-tests/RepoTests.cpp b/libminifi/test/rocksdb-tests/RepoTests.cpp
index f8b26a3..70d05fd 100644
--- a/libminifi/test/rocksdb-tests/RepoTests.cpp
+++ b/libminifi/test/rocksdb-tests/RepoTests.cpp
@@ -44,7 +44,7 @@ TEST_CASE("Test Repo Empty Value Attribute", "[TestFFR1]") {
LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>();
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1);
repository->initialize(std::make_shared<minifi::Configure>());
@@ -67,7 +67,7 @@ TEST_CASE("Test Repo Empty Key Attribute ", "[TestFFR2]") {
LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>();
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1);
repository->initialize(std::make_shared<minifi::Configure>());
@@ -91,7 +91,7 @@ TEST_CASE("Test Repo Key Attribute Verify ", "[TestFFR3]") {
LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>();
TestController testController;
char format[] = "/tmp/testRepo.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1);
repository->initialize(std::make_shared<org::apache::nifi::minifi::Configure>());
@@ -141,7 +141,7 @@ TEST_CASE("Test Delete Content ", "[TestFFR4]") {
LogTestController::getInstance().setDebug<core::repository::FileSystemRepository>();
LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>();
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1);
@@ -149,7 +149,7 @@ TEST_CASE("Test Delete Content ", "[TestFFR4]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -180,7 +180,7 @@ TEST_CASE("Test Delete Content ", "[TestFFR4]") {
repository->stop();
- std::ifstream fileopen(ss.str());
+ std::ifstream fileopen(ss.str(), std::ios::in);
REQUIRE(false == fileopen.good());
utils::file::FileUtils::delete_dir(FLOWFILE_CHECKPOINT_DIRECTORY, true);
@@ -197,7 +197,7 @@ TEST_CASE("Test Validate Checkpoint ", "[TestFFR5]") {
LogTestController::getInstance().setTrace<minifi::ResourceClaim>();
LogTestController::getInstance().setTrace<minifi::FlowFileRecord>();
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1);
@@ -205,7 +205,7 @@ TEST_CASE("Test Validate Checkpoint ", "[TestFFR5]") {
std::fstream file;
std::stringstream ss;
- ss << dir << "/" << "tstFile.ext";
+ ss << dir << utils::file::FileUtils::get_separator() << "tstFile.ext";
file.open(ss.str(), std::ios::out);
file << "tempFile";
file.close();
@@ -242,8 +242,7 @@ TEST_CASE("Test Validate Checkpoint ", "[TestFFR5]") {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
- std::ifstream fileopen(ss.str());
-
+ std::ifstream fileopen(ss.str(), std::ios::in);
REQUIRE(true == fileopen.fail());
utils::file::FileUtils::delete_dir(FLOWFILE_CHECKPOINT_DIRECTORY, true);
diff --git a/libminifi/test/script-tests/LuaExecuteScriptTests.cpp b/libminifi/test/script-tests/LuaExecuteScriptTests.cpp
index d06b0c8..07306c0 100644
--- a/libminifi/test/script-tests/LuaExecuteScriptTests.cpp
+++ b/libminifi/test/script-tests/LuaExecuteScriptTests.cpp
@@ -53,7 +53,7 @@ TEST_CASE("Lua: Test Log", "[executescriptLuaLog]") { // NOLINT
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
std::fstream file;
@@ -115,7 +115,7 @@ TEST_CASE("Lua: Test Read File", "[executescriptLuaRead]") { // NOLINT
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
char putFileDirFmt[] = "/tmp/ft.XXXXXX";
@@ -205,7 +205,7 @@ TEST_CASE("Lua: Test Write File", "[executescriptLuaWrite]") { // NOLINT
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
char putFileDirFmt[] = "/tmp/ft.XXXXXX";
@@ -287,7 +287,7 @@ TEST_CASE("Lua: Test Update Attribute", "[executescriptLuaUpdateAttribute]") { /
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
std::fstream file;
diff --git a/libminifi/test/script-tests/PythonExecuteScriptTests.cpp b/libminifi/test/script-tests/PythonExecuteScriptTests.cpp
index f2d6c12..9e85d72 100644
--- a/libminifi/test/script-tests/PythonExecuteScriptTests.cpp
+++ b/libminifi/test/script-tests/PythonExecuteScriptTests.cpp
@@ -68,11 +68,11 @@ TEST_CASE("Python: Test Read File", "[executescriptPythonRead]") { // NOLINT
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
char putFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *putFileDir = testController.createTempDirectory(putFileDirFmt);
+ auto putFileDir = testController.createTempDirectory(putFileDirFmt);
plan->setProperty(putFile, processors::PutFile::Directory.getName(), putFileDir);
testController.runSession(plan, false);
@@ -152,11 +152,11 @@ TEST_CASE("Python: Test Write File", "[executescriptPythonWrite]") { // NOLINT
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
char putFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *putFileDir = testController.createTempDirectory(putFileDirFmt);
+ auto putFileDir = testController.createTempDirectory(putFileDirFmt);
plan->setProperty(putFile, processors::PutFile::Directory.getName(), putFileDir);
testController.runSession(plan, false);
@@ -261,7 +261,7 @@ TEST_CASE("Python: Test Update Attribute", "[executescriptPythonUpdateAttribute]
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
std::fstream file;
@@ -307,7 +307,7 @@ TEST_CASE("Python: Test Get Context Property", "[executescriptPythonGetContextPr
)");
char getFileDirFmt[] = "/tmp/ft.XXXXXX";
- char *getFileDir = testController.createTempDirectory(getFileDirFmt);
+ auto getFileDir = testController.createTempDirectory(getFileDirFmt);
plan->setProperty(getFile, processors::GetFile::Directory.getName(), getFileDir);
std::fstream file;
diff --git a/libminifi/test/sqlite-tests/SQLiteTests.cpp b/libminifi/test/sqlite-tests/SQLiteTests.cpp
index 5c7ea06..87b3070 100644
--- a/libminifi/test/sqlite-tests/SQLiteTests.cpp
+++ b/libminifi/test/sqlite-tests/SQLiteTests.cpp
@@ -55,7 +55,7 @@ TEST_CASE("Test Put", "[PutSQLPut]") { // NOLINT
// Define directory for test db
std::string test_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_dir[0]).empty());
// Define test db file
std::string test_db(test_dir);
@@ -137,7 +137,7 @@ TEST_CASE("Test Put Content", "[PutSQLPutContent]") { // NOLINT
// Define directory for test db
std::string test_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_dir[0]).empty());
// Define test db file
std::string test_db(test_dir);
@@ -145,7 +145,7 @@ TEST_CASE("Test Put Content", "[PutSQLPutContent]") { // NOLINT
// Define directory for test input file
std::string test_in_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_in_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_in_dir[0]).empty());
// Define test input file
std::string test_file(test_in_dir);
@@ -230,7 +230,7 @@ TEST_CASE("Test Exec", "[ExecuteSQL]") { // NOLINT
// Define directory for test db
std::string test_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_dir[0]).empty());
// Define test db file
std::string test_db(test_dir);
@@ -289,7 +289,7 @@ TEST_CASE("Test Exec 2", "[ExecuteSQL2]") { // NOLINT
// Define directory for test db
std::string test_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_dir[0]).empty());
// Define test db file
std::string test_db(test_dir);
@@ -382,7 +382,7 @@ TEST_CASE("Test Exec 3", "[ExecuteSQL3]") { // NOLINT
// Define directory for test db
std::string test_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_dir[0]).empty());
// Define test db file
std::string test_db(test_dir);
@@ -390,7 +390,7 @@ TEST_CASE("Test Exec 3", "[ExecuteSQL3]") { // NOLINT
// Define directory for test input file
std::string test_in_dir("/tmp/gt.XXXXXX");
- REQUIRE(testController.createTempDirectory(&test_in_dir[0]) != nullptr);
+ REQUIRE(!testController.createTempDirectory(&test_in_dir[0]).empty());
// Define test input file
std::string test_file(test_in_dir);
diff --git a/libminifi/test/unit/C2MetricsTests.cpp b/libminifi/test/unit/C2MetricsTests.cpp
index b21b3ee..526812e 100644
--- a/libminifi/test/unit/C2MetricsTests.cpp
+++ b/libminifi/test/unit/C2MetricsTests.cpp
@@ -32,11 +32,12 @@ TEST_CASE("TestProcessMetrics", "[c2m1]") {
minifi::state::response::ProcessMetrics metrics;
REQUIRE("ProcessMetrics" == metrics.getName());
-
+#ifndef WIN32
REQUIRE(2 == metrics.serialize().size());
REQUIRE("MemoryMetrics" == metrics.serialize().at(0).name);
REQUIRE("CpuMetrics" == metrics.serialize().at(1).name);
+#endif
}
TEST_CASE("TestSystemMetrics", "[c2m5]") {
@@ -44,10 +45,12 @@ TEST_CASE("TestSystemMetrics", "[c2m5]") {
REQUIRE("systeminfo" == metrics.getName());
+#ifndef WIN32
REQUIRE(2 == metrics.serialize().size());
REQUIRE("systemInfo" == metrics.serialize().at(0).name);
REQUIRE("identifier" == metrics.serialize().at(1).name);
+#endif
}
TEST_CASE("QueueMetricsTestNoConnections", "[c2m2]") {
diff --git a/libminifi/test/unit/ControllerTests.cpp b/libminifi/test/unit/ControllerTests.cpp
index f3df5ce..843e301 100644
--- a/libminifi/test/unit/ControllerTests.cpp
+++ b/libminifi/test/unit/ControllerTests.cpp
@@ -95,8 +95,8 @@ class TestUpdateSink : public minifi::state::StateMonitor {
}
virtual std::string getComponentUUID() const {
- return "uuid";
- }
+ return "uuid";
+ }
/**
* Start the client
*/
@@ -175,7 +175,11 @@ class TestUpdateSink : public minifi::state::StateMonitor {
std::shared_ptr<StateController> controller;
std::atomic<uint32_t> update_calls;
};
-
+#ifdef WIN32
+TEST_CASE("TestWindows", "[test1]") {
+ std::cout << "Controller Tests are not supported on windows";
+}
+#else
TEST_CASE("TestGet", "[test1]") {
auto controller = std::make_shared<TestStateController>();
std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
@@ -273,3 +277,4 @@ TEST_CASE("TestUpdate", "[test1]") {
REQUIRE(1 == ptr->update_calls);
REQUIRE(0 == ptr->clear_calls);
}
+#endif
diff --git a/libminifi/test/unit/FileStreamTests.cpp b/libminifi/test/unit/FileStreamTests.cpp
index 68e9d3e..be1b2b8 100644
--- a/libminifi/test/unit/FileStreamTests.cpp
+++ b/libminifi/test/unit/FileStreamTests.cpp
@@ -25,7 +25,7 @@
TEST_CASE("TestFileOverWrite", "[TestFiles]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -63,7 +63,7 @@ TEST_CASE("TestFileOverWrite", "[TestFiles]") {
TEST_CASE("TestFileBadArgumentNoChange", "[TestLoader]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -101,7 +101,7 @@ TEST_CASE("TestFileBadArgumentNoChange", "[TestLoader]") {
TEST_CASE("TestFileBadArgumentNoChange2", "[TestLoader]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -139,7 +139,7 @@ TEST_CASE("TestFileBadArgumentNoChange2", "[TestLoader]") {
TEST_CASE("TestFileBadArgumentNoChange3", "[TestLoader]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -177,7 +177,7 @@ TEST_CASE("TestFileBadArgumentNoChange3", "[TestLoader]") {
TEST_CASE("TestFileBeyondEnd3", "[TestLoader]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -211,7 +211,7 @@ TEST_CASE("TestFileBeyondEnd3", "[TestLoader]") {
TEST_CASE("TestFileExceedSize", "[TestLoader]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
diff --git a/libminifi/test/unit/FileTriggerTests.cpp b/libminifi/test/unit/FileTriggerTests.cpp
index c05327c..b4168d3 100644
--- a/libminifi/test/unit/FileTriggerTests.cpp
+++ b/libminifi/test/unit/FileTriggerTests.cpp
@@ -50,7 +50,7 @@ TEST_CASE("test valid file no update", "[t3]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
@@ -73,7 +73,7 @@ TEST_CASE("test valid file update", "[t4]") {
TestController testController;
char format[] = "/tmp/gt.XXXXXX";
- char *dir = testController.createTempDirectory(format);
+ auto dir = testController.createTempDirectory(format);
std::fstream file;
std::stringstream ss;
diff --git a/libminifi/test/unit/FileUtilsTests.cpp b/libminifi/test/unit/FileUtilsTests.cpp
index d40ae99..ca888e5 100644
--- a/libminifi/test/unit/FileUtilsTests.cpp
+++ b/libminifi/test/unit/FileUtilsTests.cpp
@@ -102,11 +102,12 @@ SECTION("NO FILE VALID PATH") {
REQUIRE(filename.empty());
}
SECTION("FILE NO PATH") {
- std::string path = "/file";
+ std::stringstream path;
+ path << FileUtils::get_separator() << "file";
std::string filename, filepath;
std::string expectedPath;
expectedPath += FileUtils::get_separator();
- REQUIRE(true == utils::file::PathUtils::getFileNameAndPath(path, filepath, filename) );
+ REQUIRE(true == utils::file::PathUtils::getFileNameAndPath(path.str(), filepath, filename) );
REQUIRE(expectedPath == filepath);
REQUIRE("file" == filename);
}
diff --git a/libminifi/test/unit/LoggerConfigurationTests.cpp b/libminifi/test/unit/LoggerConfigurationTests.cpp
index 8a1ce9b..bdb16b9 100644
--- a/libminifi/test/unit/LoggerConfigurationTests.cpp
+++ b/libminifi/test/unit/LoggerConfigurationTests.cpp
@@ -20,6 +20,8 @@
#include <memory>
#include <string>
#include <vector>
+#include <sstream>
+#include <iostream>
#include "../TestBase.h"
#include "core/logging/LoggerConfiguration.h"
@@ -48,7 +50,7 @@ class TestLoggerConfiguration : public logging::LoggerConfiguration {
return logging::LoggerConfiguration::get_logger(LogTestController::getInstance().logger_, root_namespace, name, formatter);
}
};
-
+#ifndef WIN32
TEST_CASE("TestLoggerConfiguration::initialize_namespaces", "[test initialize_namespaces]") {
TestController test_controller;
LogTestController &logTestController = LogTestController::getInstance();
@@ -96,3 +98,4 @@ TEST_CASE("TestLoggerConfiguration::initialize_namespaces", "[test initialize_na
logTestController.resetStream(stdout);
logTestController.resetStream(stderr);
}
+#endif
diff --git a/libminifi/test/unit/SocketTests.cpp b/libminifi/test/unit/SocketTests.cpp
index 0809211..7e943b4 100644
--- a/libminifi/test/unit/SocketTests.cpp
+++ b/libminifi/test/unit/SocketTests.cpp
@@ -29,16 +29,17 @@
#include "io/ServerSocket.h"
#include "io/tls/TLSSocket.h"
#include "utils/ThreadPool.h"
+using Sockets = org::apache::nifi::minifi::io::Socket;
TEST_CASE("TestSocket", "[TestSocket1]") {
- org::apache::nifi::minifi::io::Socket socket(std::make_shared<org::apache::nifi::minifi::io::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>()), Sockets::getMyHostName(), 8183);
REQUIRE(-1 == socket.initialize());
- REQUIRE(socket.getHostname().rfind("localhost", 0) == 0);
+ REQUIRE(socket.getHostname().rfind(Sockets::getMyHostName(), 0) == 0);
socket.closeStream();
}
TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") {
- org::apache::nifi::minifi::io::Socket socket(std::make_shared<org::apache::nifi::minifi::io::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>()), Sockets::getMyHostName(), 8183);
REQUIRE(-1 == socket.initialize());
socket.writeData(0, 0);
@@ -55,12 +56,11 @@ TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") {
std::vector<uint8_t> buffer;
buffer.push_back('a');
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::ServerSocket server(socket_context, "localhost", 9183, 1);
+ org::apache::nifi::minifi::io::ServerSocket server(socket_context, Sockets::getMyHostName(), 9183, 1);
REQUIRE(-1 != server.initialize());
- org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
+ org::apache::nifi::minifi::io::Socket client(socket_context, Sockets::getMyHostName(), 9183);
REQUIRE(-1 != client.initialize());
@@ -79,7 +79,7 @@ TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") {
}
TEST_CASE("TestGetHostName", "[TestSocket4]") {
- REQUIRE(org::apache::nifi::minifi::io::Socket::getMyHostName().length() > 0);
+ REQUIRE(Sockets::getMyHostName().length() > 0);
}
TEST_CASE("TestWriteEndian64", "[TestSocket5]") {
@@ -87,11 +87,11 @@ TEST_CASE("TestWriteEndian64", "[TestSocket5]") {
buffer.push_back('a');
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::ServerSocket server(socket_context, "localhost", 9183, 1);
+ org::apache::nifi::minifi::io::ServerSocket server(socket_context, Sockets::getMyHostName(), 9183, 1);
REQUIRE(-1 != server.initialize());
- org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
+ org::apache::nifi::minifi::io::Socket client(socket_context, Sockets::getMyHostName(), 9183);
REQUIRE(-1 != client.initialize());
@@ -114,10 +114,10 @@ TEST_CASE("TestWriteEndian32", "[TestSocket6]") {
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::ServerSocket server(socket_context, "localhost", 9183, 1);
+ org::apache::nifi::minifi::io::ServerSocket server(socket_context, Sockets::getMyHostName(), 9183, 1);
REQUIRE(-1 != server.initialize());
- org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
+ org::apache::nifi::minifi::io::Socket client(socket_context, Sockets::getMyHostName(), 9183);
REQUIRE(-1 != client.initialize());
{
@@ -149,11 +149,11 @@ TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket7]") {
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::ServerSocket server(socket_context, "localhost", 9183, 1);
+ org::apache::nifi::minifi::io::ServerSocket server(socket_context, Sockets::getMyHostName(), 9183, 1);
REQUIRE(-1 != server.initialize());
- org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
+ org::apache::nifi::minifi::io::Socket client(socket_context, Sockets::getMyHostName(), 9183);
REQUIRE(-1 != client.initialize());
@@ -221,7 +221,7 @@ TEST_CASE("TestTLSContextCreation2", "[TestSocket9]") {
std::shared_ptr<minifi::Configure> configure = std::make_shared<minifi::Configure>();
configure->set("nifi.remote.input.secure", "false");
auto factory = minifi::io::StreamFactory::getInstance(configure);
- std::string host = "localhost";
+ std::string host = Sockets::getMyHostName();
minifi::io::Socket *socket = factory->createSocket(host, 10001).release();
minifi::io::TLSSocket *tls = dynamic_cast<minifi::io::TLSSocket*>(socket);
REQUIRE(tls == nullptr);
@@ -235,9 +235,8 @@ TEST_CASE("TestTLSContextCreationNullptr", "[TestSocket10]") {
std::shared_ptr<minifi::Configure> configure = std::make_shared<minifi::Configure>();
configure->set("nifi.remote.input.secure", "false");
auto factory = minifi::io::StreamFactory::getInstance(configure);
- std::string host = "localhost";
+ std::string host = Sockets::getMyHostName();
minifi::io::Socket *socket = factory->createSecureSocket(host, 10001, nullptr).release();
minifi::io::TLSSocket *tls = dynamic_cast<minifi::io::TLSSocket*>(socket);
REQUIRE(tls == nullptr);
}
-
diff --git a/libminifi/test/unit/StreamTests.cpp b/libminifi/test/unit/StreamTests.cpp
index c01e68a..6c2f6a6 100644
--- a/libminifi/test/unit/StreamTests.cpp
+++ b/libminifi/test/unit/StreamTests.cpp
@@ -31,7 +31,7 @@ TEST_CASE("TestReadData", "[testread]") {
uint64_t b = 8;
base->write(b);
uint64_t c = 0;
- base->readData(reinterpret_cast<uint8_t*>(&c), 8);
+ REQUIRE(8 == base->readData(reinterpret_cast<uint8_t*>(&c), 8));
if (minifi::io::EndiannessCheck::IS_LITTLE)
REQUIRE(c == 576460752303423488);
else
@@ -61,7 +61,7 @@ TEST_CASE("TestRead1", "[testread]") {
uint8_t b = 8;
base->write(&b, 1);
uint8_t c = 0;
- base->read(c);
+ REQUIRE(1 == base->read(c));
REQUIRE(c == 8);
}
diff --git a/libminifi/test/unit/StringUtilsTests.cpp b/libminifi/test/unit/StringUtilsTests.cpp
index 16704b4..d5149c3 100644
--- a/libminifi/test/unit/StringUtilsTests.cpp
+++ b/libminifi/test/unit/StringUtilsTests.cpp
@@ -29,6 +29,12 @@
using org::apache::nifi::minifi::utils::StringUtils;
+#ifdef WIN32
+void setenv(std::string var, std::string value, int val) {
+ _putenv_s(var.c_str(), value.c_str());
+}
+#endif
+
TEST_CASE("TestStringUtils::split", "[test split no delimiter]") {
std::vector<std::string> expected = { "hello" };
REQUIRE(expected == StringUtils::split("hello", ","));
@@ -52,6 +58,7 @@ TEST_CASE("TestStringUtils::split4", "[test split classname]") {
TEST_CASE("TestStringUtils::testEnv1", "[test split classname]") {
std::string test_string = "hello world ${blahblahnamenamenotexist}";
+
setenv("blahblahnamenamenotexist", "computer", 0);
std::string expected = "hello world computer";
diff --git a/main/MiNiFiMain.cpp b/main/MiNiFiMain.cpp
index 5028eb2..3d719e9 100644
--- a/main/MiNiFiMain.cpp
+++ b/main/MiNiFiMain.cpp
@@ -52,6 +52,7 @@
#include "core/FlowConfiguration.h"
#include "core/ConfigurationFactory.h"
#include "core/RepositoryFactory.h"
+#include "utils/file/PathUtils.h"
#include "FlowController.h"
#include "Main.h"
@@ -177,10 +178,23 @@ int main(int argc, char **argv) {
char cwd[PATH_MAX];
#ifdef WIN32
_getcwd(cwd, PATH_MAX);
+ auto handle = GetModuleHandle(0);
+ GetModuleFileNameA(NULL, cwd, sizeof(cwd));
+ std::string fullPath = cwd;
+ std::string minifiFileName, minifiPath;
+ minifi::utils::file::PathUtils::getFileNameAndPath(fullPath, minifiPath, minifiFileName);
+ if (utils::StringUtils::endsWith(minifiPath, "bin")) {
+ minifiHome = minifiPath.substr(0, minifiPath.size()-3);
+ }
+ else {
+ minifiHome = minifiPath;
+ }
+
#else
getcwd(cwd, PATH_MAX);
-#endif
minifiHome = cwd;
+#endif
+
}
diff --git a/msi/WixWin.wsi b/msi/WixWin.wsi
new file mode 100644
index 0000000..d178eef
--- /dev/null
+++ b/msi/WixWin.wsi
@@ -0,0 +1,332 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?include "cpack_variables.wxi"?>
+
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
+ RequiredVersion="3.6.3303.0">
+
+ <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)"
+ Name="Apache NiFi MiNiFi"
+ Language="1033"
+ UpgradeCode="87658309-9038-fec8-8633-f54ffaaa4921"
+ Version="$(var.CPACK_PACKAGE_VERSION)"
+ Manufacturer="$(var.CPACK_PACKAGE_VENDOR)">
+
+
+ <Package InstallerVersion="301" Compressed="yes"/>
+
+ <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>
+
+ <WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/>
+ <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/>
+
+ <?ifdef CPACK_WIX_PRODUCT_ICON?>
+ <Property Id="ARPPRODUCTICON">ProductIcon.ico</Property>
+ <Icon Id="ProductIcon.ico" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)"/>
+ <?endif?>
+
+ <?ifdef CPACK_WIX_UI_BANNER?>
+ <WixVariable Id="WixUIBannerBmp" Value="$(var.CPACK_WIX_UI_BANNER)"/>
+ <?endif?>
+ <!-- <InstallExecuteSequence>
+
+ <Custom Action="UpdateConfig" After="InstallFiles">NOT Installed</Custom>
+ </InstallExecuteSequence> -->
+
+ <DirectoryRef Id="TARGETDIR">
+ <!-- <?if $(var.Platform) = x64 ?>
+ <Merge Id="VCRedist" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_x64.msm" DiskId="1" Language="0" />
+ <?else ?>-->
+ <Merge Id="VCRedist" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_x86.msm" DiskId="1" Language="0" />
+ <!-- <?endif ?>-->
+ </DirectoryRef>
+
+ <Feature Id="VCRedist" Title="Visual C++ 14.0 Runtime" AllowAdvertise="yes" Level="1">
+ <MergeRef Id="VCRedist"/>
+ </Feature>
+
+ <Feature Id="InstallService" Title="Apache NiFi MiNiFi C++ Service" AllowAdvertise="no" Display="hidden" Level="1">
+ <ComponentRef Id="minifiService"/>
+ </Feature>
+
+ <Feature Id="Install" Title="Apache NiFi MiNiFi C++ Runtimes" AllowAdvertise="no" Display="hidden" Level="1">
+ <ComponentRef Id="LICENSE"/>
+ <ComponentRef Id="README"/>
+ <ComponentRef Id="NOTICE"/>
+ </Feature>
+
+ <Feature Id="InstallConf" Title="Apache NiFi MiNiFi C++ Configuration" AllowAdvertise="yes" Level="1">
+ <!-- <ComponentRef Id="MINIFIPROP"/> -->
+ <ComponentRef Id="LOGPROP"/>
+ <ComponentRef Id="UIDPROP"/>
+ <ComponentRef Id="CONFIGFILE"/>
+ <ComponentRef Id="UpdateConfig"/>
+ <ComponentRef Id="UpdateConfigNotExist"/>
+ </Feature>
+
+
+ <?ifdef CPACK_WIX_UI_DIALOG?>
+ <WixVariable Id="WixUIDialogBmp" Value="$(var.CPACK_WIX_UI_DIALOG)"/>
+ <?endif?>
+ <UI Id="WixUI_HK">
+ <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
+ <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
+ <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
+
+ <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
+ <Property Id="WixUI_Mode" Value="InstallDir" />
+
+ <DialogRef Id="BrowseDlg" />
+ <DialogRef Id="DiskCostDlg" />
+ <DialogRef Id="ErrorDlg" />
+ <DialogRef Id="FatalError" />
+ <DialogRef Id="FilesInUse" />
+ <DialogRef Id="MsiRMFilesInUse" />
+ <DialogRef Id="PrepareDlg" />
+ <DialogRef Id="ProgressDlg" />
+ <DialogRef Id="ResumeDlg" />
+ <DialogRef Id="ResumeDlg" />
+ <DialogRef Id="UserExit" />
+
+ <!-- Make sure to include custom dialogs in the installer database via a DialogRef command,
+ especially if they are not included explicitly in the publish chain below -->
+ <DialogRef Id="ApacheLicenseDlg"/>
+ <DialogRef Id="PropertiesDialog" />
+
+ <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
+ <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
+
+ <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
+
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="ApacheLicenseDlg">NOT Installed</Publish>
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
+
+ <Publish Dialog="ApacheLicenseDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
+ <Publish Dialog="ApacheLicenseDlg" Control="Next" Event="NewDialog" Value="PropertiesDialog">LicenseAccepted = "1"</Publish>
+<!--
+ <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="ApacheLicenseDlg">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="PropertiesDialog" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
+ <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
+-->
+ <Publish Dialog="PropertiesDialog" Control="Back" Event="NewDialog" Value="ApacheLicenseDlg">1</Publish>
+ <Publish Dialog="PropertiesDialog" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="PropertiesDialog" Order="1">NOT Installed</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>
+
+ <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
+
+ <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
+ </UI>
+
+ <UIRef Id="WixUI_Common" />
+ <UI>
+ <!-- Define the installer UI -->
+
+
+
+ <Dialog Id="ApacheLicenseDlg" Width="370" Height="270" Title="Please review our license">
+ <Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="LicenseAccepted" Text="Click here to accept this license" />
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back" />
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
+ <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
+ <Condition Action="disable"><![CDATA[LicenseAccepted <> "1"]]></Condition>
+ <Condition Action="enable">LicenseAccepted = "1"</Condition>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
+ <Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">
+
+ <Text SourceFile="$(var.CPACK_WIX_LICENSE_RTF)" />
+ </Control>
+ <Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="Print">
+ <Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="340" Height="15" Transparent="yes" NoPrefix="yes" Text="Please read and accept our license agreement." />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Apache NiFi MiNiFi License" />
+ </Dialog>
+
+ <Dialog Id="PropertiesDialog" Width="370" Height="320" Title="Agent Properties">
+ <Control Id="Next" Type="PushButton" X="236" Y="290" Width="56" Height="17" Default="yes" Text="Next" />
+ <Control Id="Back" Type="PushButton" X="180" Y="290" Width="56" Height="17" Text="Back" />
+ <Control Id="Cancel" Type="PushButton" X="304" Y="290" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please enter values for properties you wish to use. " />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Apache NiFi MiNiFi Properties" />
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ <Control Id="BottomLine" Type="Line" X="0" Y="283" Width="370" Height="0" />
+
+
+ <Control Id="EnableC2" Type="CheckBox" X="20" Y="60"
+ Width="200" Height="17" Property="ENABLEC2"
+ CheckBoxValue="1"
+ Text="Enable interactive Command and Control." Default="no" />
+
+ <Control Id="AgentClassLabel" Type="Text" X="20" Y="80" Width="290" Height="20" NoPrefix="yes" Text="Agent Class" />
+ <Control Id="AgentClass" Type="Edit" X="20" Y="100" Width="320" Height="18" Property="AGENT_CLASS" Indirect="no" ><Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
+ <Condition Action="enable">ENABLEC2="1"</Condition>
+ </Control>
+
+ <Control Id="AgentIdentifierLabel" Type="Text" X="20" Y="120" Width="60" Height="20" NoPrefix="yes" Text="Agent Identifier" />
+ <Control Id="AgentIdentifier" Type="Edit" X="20" Y="140" Width="320" Height="18" Property="AGENT_IDENTIFIER" Indirect="no" >
+ <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
+ <Condition Action="enable">ENABLEC2="1"</Condition>
+ </Control>
+
+ <Control Id="ServertHeartbeatIdentifierLabel" Type="Text" X="20" Y="160" Width="60" Height="20" NoPrefix="yes" Text="Server Heartbeat URL" />
+ <Control Id="ServerHeartbeatIdentifier" Type="Edit" X="20" Y="180" Width="320" Height="18" Property="SERVER_HEARTBEAT" Indirect="no" >
+ <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
+ <Condition Action="enable">ENABLEC2="1"</Condition>
+ </Control>
+
+ <Control Id="ServerAckIdentifierLabel" Type="Text" X="20" Y="200" Width="60" Height="20" NoPrefix="yes" Text="Server Ack URL" />
+ <Control Id="ServeAckrIdentifier" Type="Edit" X="20" Y="220" Width="320" Height="18" Property="SERVER_ACK" Indirect="no" >
+ <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
+ <Condition Action="enable">ENABLEC2="1"</Condition>
+ </Control>
+
+ <Control Id="AgentProtocolLabel" Type="Text" X="20" Y="240" Width="60" Height="20" NoPrefix="yes" Text="Agent Protocol" />
+ <Control Id="AgentProtocolComboBreaker" Type="ComboBox" X="20" Y="260" Width="300" Height="17" Property="AGENT_PROTOCOL" >
+
+
+ <ComboBox Property="AGENT_PROTOCOL">
+ <ListItem Value="RESTSender" />
+ <ListItem Value="COAPProtocol" />
+ </ComboBox>
+ <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
+ <Condition Action="enable">ENABLEC2="1"</Condition>
+ </Control>
+
+ </Dialog>
+
+
+ <UIRef Id="WixUI_HK" />
+
+
+
+ </UI>
+
+ <Property Id="AGENT_CLASS" Value="Your Agent Class" />
+ <Property Id="AGENT_IDENTIFIER" Value="Your Agent Identifier" />
+ <Property Id="AGENT_PROTOCOL" Value="RESTSender" />
+ <Property Id="SERVER_HEARTBEAT" Value="http://localhost:8181/heartbeat" />
+ <Property Id="SERVER_ACK" Value="http://localhost:8181/ack" />
+ <Property Id="ENABLEC2" />
+ <SetProperty Id="ENABLEC2" After="AppSearch" Value="0" Sequence="first" >
+ <![CDATA[ENABLEC2 = 0]]>
+ </SetProperty>
+ </Product>
+
+ <Fragment>
+ <DirectoryRef Id="ProgramFilesFolder">
+ <Directory Id="RootMiNiFiDir" Name="ApacheNiFiMiNiFi">
+ <Directory Id="RootInstallDir" Name="nifi-minifi-cpp">
+ <Directory Id="AgentInstallDir" Name="minifi-agent-0.7.0">
+ <Directory Id="CONFIGDIR" Name="conf">
+ <!--
+ <Component Id="MINIFIPROP" Guid="87658309-0339-425c-8633-f54ffaaa4941">
+ <File Id="MINIFI" Source="conf/minifi.properties" KeyPath="yes"/>
+ </Component>-->
+
+ <Component Id="LOGPROP" Guid="87658309-0339-425c-8633-f54ffaaa4942">
+ <File Id="LOG" Source="conf/minifi-log.properties" KeyPath="yes"/>
+ </Component>
+
+ <Component Id="UIDPROP" Guid="87658309-0339-425c-8633-f54ffaaa4943">
+ <File Id="UID" Source="conf/minifi-uid.properties" KeyPath="yes"/>
+ </Component>
+
+ <Component Id="CONFIGFILE" Guid="87658309-0339-425c-8633-f54ffaaa4944">
+ <File Id="CONFIG" Source="conf/config.yml" KeyPath="yes"/>
+ </Component>
+
+ <Component Id="UpdateConfig" Guid="87658309-0339-425c-8633-f54ffaaa4945">
+
+ <File Source="conf/minifi.properties" Id="minifiprops" KeyPath="yes" />
+
+ <IniFile Id="ConfigFileA" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.class" Value="[AGENT_CLASS]" />
+ <IniFile Id="ConfigFileI" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.identifier" Value="[AGENT_IDENTIFIER]" />
+ <IniFile Id="ConfigFileE" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.enable" Value="true" />
+ <IniFile Id="ConfigFileP" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.protocol.class" Value="[AGENT_PROTOCOL]" />
+ <IniFile Id="ConfigFileH" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="c2.rest.url" Value="[SERVER_HEARTBEAT]" />
+ <IniFile Id="ConfigFileAck" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="c2.rest.url.ack" Value="[SERVER_ACK]" />
+ <Condition><![CDATA[ENABLEC2="1"]]></Condition>
+ </Component>
+ <Component Id="UpdateConfigNotExist" Guid="87658309-0339-425c-8633-f54ffaaa4946">
+
+ <File Source="conf/minifi.properties" Id="minifiprops2" KeyPath="yes" />
+ <Condition><![CDATA[ENABLEC2<>"1"]]></Condition>
+ </Component>
+ </Directory>
+ <Component Id="NOTICE" Guid="87658309-0339-425c-8633-f54ffaaa4931">
+ <File Id="NOTICE" Source="NOTICE" KeyPath="yes"/>
+ </Component>
+
+ <Component Id="LICENSE" Guid="87658309-0339-425c-8633-f54ffaaa4932">
+ <File Id="LICENSE" Source="LICENSE" KeyPath="yes"/>
+ </Component>
+
+ <Component Id="README" Guid="87658309-0339-425c-8633-f54ffaaa4933">
+ <File Id="README" Source="README.MD" KeyPath="yes"/>
+ </Component>
+
+ <Directory Id="INSTALLDIR" Name="bin">
+ <Component Id="minifiService" Guid="87658309-0339-425c-8633-f54ffaaa4921">
+ <File Id="MiNiFiExe"
+ Name="minifi.exe"
+ KeyPath="yes"
+ Source="main\minifi.exe"/>
+ <ServiceInstall Id="MiNiFiExeService"
+ Type="ownProcess"
+ Vital="yes"
+ Name="Apache NiFi MiNiFi"
+ DisplayName="Apache NiFi MiNiFi"
+ Description="Apache NiFi MiNifi Service"
+ ErrorControl="ignore"
+ Start="auto"
+ Interactive="no" />
+
+ <ServiceControl Id="ServiceControl_Start"
+ Name="Apache NiFi MiNiFi"
+ Start="install"
+ Wait="no" />
+ <ServiceControl Id="ServiceControl_Stop"
+ Name="Apache NiFi MiNiFi"
+ Stop="both"
+ Remove="uninstall"
+ Wait="yes" />
+ </Component>
+ </Directory>
+ </Directory>
+ </Directory>
+ </Directory>
+ </DirectoryRef>
+ </Fragment>
+ <Fragment>
+
+ <!-- i#1761: ideally we'd have a dialog where the user picks
+ whether to do this and whether system or user, but for
+ now we always do it for user (the zip file can be used
+ instead of installer if this is undesirable).
+ -->
+ <ComponentGroup Id="CG_ADD_TO_PATH" Directory="INSTALL_ROOT">
+ <Component Id="CM_ADD_TO_PATH" Guid="208034b8-7cc5-4718-9b99-ac50201c3f90"
+ KeyPath="yes">
+ <Environment Id="ENV_PATH" Name="MINIFI_HOME" Value="[INSTALL_ROOT]minifi-agent-0.7.0\"
+ Permanent="no" Part="last" Action="set" System="no" />
+ </Component>
+ </ComponentGroup>
+ </Fragment>
+</Wix>
diff --git a/msi/WixWin64.wsi b/msi/WixWin64.wsi
deleted file mode 100644
index ff326f8..0000000
--- a/msi/WixWin64.wsi
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<?include "cpack_variables.wxi"?>
-
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
- RequiredVersion="3.6.3303.0">
-
- <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)"
- Name="Apache NiFi MiNiFi C++"
- Language="1033"
- Version="$(var.CPACK_PACKAGE_VERSION)"
- Manufacturer="$(var.CPACK_PACKAGE_VENDOR)">
-
- <Package InstallerVersion="301" Compressed="yes"/>
-
- <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>
-
- <WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/>
- <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/>
-
- <?ifdef CPACK_WIX_PRODUCT_ICON?>
- <Property Id="ARPPRODUCTICON">ProductIcon.ico</Property>
- <Icon Id="ProductIcon.ico" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)"/>
- <?endif?>
-
- <?ifdef CPACK_WIX_UI_BANNER?>
- <WixVariable Id="WixUIBannerBmp" Value="$(var.CPACK_WIX_UI_BANNER)"/>
- <?endif?>
-
- <DirectoryRef Id="TARGETDIR">
- <Merge Id="VCRedist" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_x64.msm" DiskId="1" Language="0" />
- </DirectoryRef>
-
- <Feature Id="VCRedist" Title="Visual C++ 14.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
- <MergeRef Id="VCRedist"/>
- </Feature>
-
-
- <?ifdef CPACK_WIX_UI_DIALOG?>
- <WixVariable Id="WixUIDialogBmp" Value="$(var.CPACK_WIX_UI_DIALOG)"/>
- <?endif?>
-
- <FeatureRef Id="ProductFeature"/>
-
- <UIRef Id="WixUI_Minimal" />
- </Product>
-</Wix>
diff --git a/msi/bgr.png b/msi/bgr.png
new file mode 100644
index 0000000..bf44cbb
Binary files /dev/null and b/msi/bgr.png differ
diff --git a/msi/minifi-logo-ico.ico b/msi/minifi-logo-ico.ico
new file mode 100644
index 0000000..ae0b483
Binary files /dev/null and b/msi/minifi-logo-ico.ico differ
diff --git a/msi/minifi-logo-png-banner.png b/msi/minifi-logo-png-banner.png
new file mode 100644
index 0000000..c95df8f
Binary files /dev/null and b/msi/minifi-logo-png-banner.png differ
diff --git a/nanofi/include/api/nanofi.h b/nanofi/include/api/nanofi.h
index 6180952..074ae70 100644
--- a/nanofi/include/api/nanofi.h
+++ b/nanofi/include/api/nanofi.h
@@ -122,7 +122,7 @@ flow *create_new_flow(nifi_instance * instance);
* @attention in case first processor is empty or doesn't name any existing processor, an empty flow is returned.
* @return a pointer to the created flow
**/
-DEPRECATED flow *create_flow(nifi_instance * instance, const char * first_processor);
+DEPRECATED(0.6.0,2.0) flow *create_flow(nifi_instance * instance, const char * first_processor);
/**
* Add a getfile processor to "parent" flow.
@@ -273,7 +273,7 @@ flow_file_record *invoke_file(standalone_processor* proc, const char* path);
**/
flow_file_record *invoke_chunk(standalone_processor *proc, uint8_t *buf, uint64_t size);
-DEPRECATED int transfer(processor_session* session, flow *flow, const char *rel);
+DEPRECATED(0.6.0, 2.0) int transfer(processor_session* session, flow *flow, const char *rel);
/**
* Creates a flow file record based on a file
diff --git a/nanofi/include/core/cstructs.h b/nanofi/include/core/cstructs.h
index 9ad2783..23688d2 100644
--- a/nanofi/include/core/cstructs.h
+++ b/nanofi/include/core/cstructs.h
@@ -26,13 +26,14 @@
#define NOMINMAX
#include <winsock2.h>
#endif
-
+#ifndef DEPRECATED
#ifdef _MSC_VER
-#define DEPRECATED __declspec(deprecated)
+#define DEPRECATED(v,ev) __declspec(deprecated)
#elif defined(__GNUC__) | defined(__clang__)
-#define DEPRECATED __attribute__((__deprecated__))
+#define DEPRECATED(v,ev) __attribute__((__deprecated__))
#else
-#define DEPRECATED
+#define DEPRECATED(v,ev)
+#endif
#endif
/**
diff --git a/nanofi/tests/CAPITests.cpp b/nanofi/tests/CAPITests.cpp
index ec2f2d5..9a63c4a 100644
--- a/nanofi/tests/CAPITests.cpp
+++ b/nanofi/tests/CAPITests.cpp
@@ -145,8 +145,8 @@ TEST_CASE("get file and put file", "[getAndPutFile]") {
char src_format[] = "/tmp/gt.XXXXXX";
char put_format[] = "/tmp/pt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
- const char *putfiledir = testController.createTempDirectory(put_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
+ auto putfiledir = testController.createTempDirectory(put_format);
auto instance = create_instance_obj();
REQUIRE(instance != nullptr);
flow *test_flow = create_new_flow(instance);
@@ -155,10 +155,10 @@ TEST_CASE("get file and put file", "[getAndPutFile]") {
REQUIRE(get_proc != nullptr);
processor *put_proc = add_processor(test_flow, "PutFile");
REQUIRE(put_proc != nullptr);
- REQUIRE(set_property(get_proc, "Input Directory", sourcedir) == 0);
- REQUIRE(set_property(put_proc, "Directory", putfiledir) == 0);
+ REQUIRE(set_property(get_proc, "Input Directory", sourcedir.c_str()) == 0);
+ REQUIRE(set_property(put_proc, "Directory", putfiledir.c_str()) == 0);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
flow_file_record *record = get_next_flow_file(instance, test_flow);
REQUIRE(record != nullptr);
@@ -193,9 +193,9 @@ TEST_CASE("Test manipulation of attributes", "[testAttributes]") {
TestController testController;
char src_format[] = "/tmp/gt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
auto instance = create_instance_obj();
REQUIRE(instance != nullptr);
@@ -204,7 +204,7 @@ TEST_CASE("Test manipulation of attributes", "[testAttributes]") {
processor *get_proc = add_processor(test_flow, "GetFile");
REQUIRE(get_proc != nullptr);
- REQUIRE(set_property(get_proc, "Input Directory", sourcedir) == 0);
+ REQUIRE(set_property(get_proc, "Input Directory", sourcedir.c_str()) == 0);
processor *extract_test = add_processor(test_flow, "ExtractText");
REQUIRE(extract_test != nullptr);
REQUIRE(set_property(extract_test, "Attribute", "TestAttr") == 0);
@@ -268,7 +268,7 @@ TEST_CASE("Test manipulation of attributes", "[testAttributes]") {
TEST_CASE("Test error handling callback", "[errorHandling]") {
TestController testController;
char src_format[] = "/tmp/gt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
auto instance = create_instance_obj();
REQUIRE(instance != nullptr);
@@ -283,11 +283,11 @@ TEST_CASE("Test error handling callback", "[errorHandling]") {
REQUIRE(get_proc != nullptr);
processor *put_proc = add_processor(test_flow, "PutFile");
REQUIRE(put_proc != nullptr);
- REQUIRE(set_property(get_proc, "Input Directory", sourcedir) == 0);
+ REQUIRE(set_property(get_proc, "Input Directory", sourcedir.c_str()) == 0);
REQUIRE(set_property(put_proc, "Directory", "/tmp/never_existed") == 0);
REQUIRE(set_property(put_proc, "Create Missing Directories", "false") == 0);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
REQUIRE(get_next_flow_file(instance, test_flow) == nullptr);
@@ -299,7 +299,7 @@ TEST_CASE("Test error handling callback", "[errorHandling]") {
REQUIRE(set_failure_strategy(test_flow, FailureStrategy::ROLLBACK) == 0);
// Create new testfile to trigger failure again
- create_testfile_for_getfile(sourcedir, test_file_name + "2");
+ create_testfile_for_getfile(sourcedir.c_str(), test_file_name + "2");
REQUIRE(get_next_flow_file(instance, test_flow) == nullptr);
REQUIRE(failure_count > 100);
@@ -314,12 +314,12 @@ TEST_CASE("Test standalone processors", "[testStandalone]") {
TestController testController;
char src_format[] = "/tmp/gt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
standalone_processor* getfile_proc = create_processor("GetFile");
- REQUIRE(set_standalone_property(getfile_proc, "Input Directory", sourcedir) == 0);
+ REQUIRE(set_standalone_property(getfile_proc, "Input Directory", sourcedir.c_str()) == 0);
flow_file_record* ffr = invoke(getfile_proc);
@@ -362,10 +362,10 @@ TEST_CASE("Test interaction of flow and standlone processors", "[testStandaloneW
char src_format[] = "/tmp/gt.XXXXXX";
char put_format[] = "/tmp/pt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
- const char *putfiledir = testController.createTempDirectory(put_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
+ auto putfiledir = testController.createTempDirectory(put_format);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
auto instance = create_instance_obj();
REQUIRE(instance != nullptr);
@@ -374,13 +374,13 @@ TEST_CASE("Test interaction of flow and standlone processors", "[testStandaloneW
processor *get_proc = add_processor(test_flow, "GetFile");
REQUIRE(get_proc != nullptr);
- REQUIRE(set_property(get_proc, "Input Directory", sourcedir) == 0);
+ REQUIRE(set_property(get_proc, "Input Directory", sourcedir.c_str()) == 0);
flow_file_record *record = get_next_flow_file(instance, test_flow);
REQUIRE(record != nullptr);
standalone_processor* putfile_proc = create_processor("PutFile");
- REQUIRE(set_standalone_property(putfile_proc, "Directory", putfiledir) == 0);
+ REQUIRE(set_standalone_property(putfile_proc, "Directory", putfiledir.c_str()) == 0);
flow_file_record* put_record = invoke_ff(putfile_proc, record);
REQUIRE(put_record != nullptr);
@@ -406,8 +406,8 @@ TEST_CASE("Test standalone processors with file input", "[testStandaloneWithFile
enable_logging();
char src_format[] = "/tmp/gt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
- std::string path = create_testfile_for_getfile(sourcedir);
+ auto sourcedir = testController.createTempDirectory(src_format);
+ std::string path = create_testfile_for_getfile(sourcedir.c_str());
standalone_processor* extract_test = create_processor("ExtractText");
REQUIRE(extract_test != nullptr);
@@ -432,9 +432,9 @@ TEST_CASE("Test custom processor", "[TestCutomProcessor]") {
TestController testController;
char src_format[] = "/tmp/gt.XXXXXX";
- const char *sourcedir = testController.createTempDirectory(src_format);
+ auto sourcedir = testController.createTempDirectory(src_format);
- create_testfile_for_getfile(sourcedir);
+ create_testfile_for_getfile(sourcedir.c_str());
add_custom_processor("myproc", custom_ontrigger_logic, custom_onschedule_logic);
@@ -446,7 +446,7 @@ TEST_CASE("Test custom processor", "[TestCutomProcessor]") {
processor *get_proc = add_processor(test_flow, "GetFile");
REQUIRE(get_proc != nullptr);
- REQUIRE(set_property(get_proc, "Input Directory", sourcedir) == 0);
+ REQUIRE(set_property(get_proc, "Input Directory", sourcedir.c_str()) == 0);
processor *my_proc = add_processor(test_flow, "myproc");
REQUIRE(my_proc != nullptr);
diff --git a/thirdparty/rocksdb/CMakeLists.txt b/thirdparty/rocksdb/CMakeLists.txt
index f20d09a..d4e2820 100644
--- a/thirdparty/rocksdb/CMakeLists.txt
+++ b/thirdparty/rocksdb/CMakeLists.txt
@@ -620,15 +620,15 @@ target_link_libraries(${ROCKSDB_STATIC_LIB}
${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
if(WIN32)
- add_library(${ROCKSDB_IMPORT_LIB} SHARED ${SOURCES})
+# add_library(${ROCKSDB_IMPORT_LIB} SHARED ${SOURCES})
#target_link_libraries(${ROCKSDB_IMPORT_LIB} ${SYSTEM_LIBS})
- set_target_properties(${ROCKSDB_IMPORT_LIB} PROPERTIES
- COMPILE_DEFINITIONS "ROCKSDB_DLL;ROCKSDB_LIBRARY_EXPORTS")
+ #set_target_properties(${ROCKSDB_IMPORT_LIB} PROPERTIES
+ # COMPILE_DEFINITIONS "ROCKSDB_DLL;ROCKSDB_LIBRARY_EXPORTS")
if(MSVC)
set_target_properties(${ROCKSDB_STATIC_LIB} PROPERTIES
COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/${ROCKSDB_STATIC_LIB}.pdb")
- set_target_properties(${ROCKSDB_IMPORT_LIB} PROPERTIES
- COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/${ROCKSDB_IMPORT_LIB}.pdb")
+ #set_target_properties(${ROCKSDB_IMPORT_LIB} PROPERTIES
+ #COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/${ROCKSDB_IMPORT_LIB}.pdb")
endif()
endif()
diff --git a/win_build_vs.bat b/win_build_vs.bat
new file mode 100644
index 0000000..9499b23
--- /dev/null
+++ b/win_build_vs.bat
@@ -0,0 +1,72 @@
+@echo off
+SETLOCAL enabledelayedexpansion
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+TITLE Apache NiFi MiNiFi C++ Windows Build Helper
+
+set builddir=%1
+set builddir=%builddir:"=%
+set skiptests=OFF
+set cmake_build_type=Release
+set build_type=Release
+set build_kafka=off
+set build_coap=off
+set build_jni=off
+set generator="Visual Studio 15 2017"
+set cpack=OFF
+
+set arg_counter=0
+for %%x in (%*) do (
+ set /A arg_counter+=1
+ echo %%~x
+ if [%%~x] EQU [/T] (
+ set skiptests=ON
+ )
+ if [%%~x] EQU [/P] (
+ set cpack=ON
+ )
+ if [%%~x] EQU [/K] (
+ set build_kafka=ON
+ )
+ if [%%~x] EQU [/J] (
+ set build_JNI=ON
+ )
+ if [%%~x] EQU [/C] (
+ set build_co=ON
+ )
+ if [%%~x] EQU [/64] (
+ set generator="Visual Studio 15 2017 Win64"
+ )
+ if [%%~x] EQU [/D] (
+ set cmake_build_type=RelwithDebInfo
+ )
+)
+
+
+mkdir %builddir%
+
+cd %builddir%\
+
+
+
+cmake -G %generator% -DCMAKE_BUILD_TYPE_INIT=%cmake_build_type% -DCMAKE_BUILD_TYPE=%cmake_build_type% -DWIN32=WIN32 -DENABLE_LIBRDKAFKA=%build_kafka% -DENABLE_JNI=%build_jni% -DOPENSSL_OFF=OFF -DENABLE_COAP=%build_coap% -DUSE_SHARED_LIBS=OFF -DDISABLE_CONTROLLER=ON -DBUILD_ROCKSDB=ON -DFORCE_WINDOWS=ON -DUSE_SYSTEM_UUID=OFF -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DEXCLUDE_BOOST=ON -DENABLE_WEL=TRUE -DSKIP_TESTS=ON -DFAIL_ON_WARNINGS=OFF -DSKIP_TESTS=%skiptests% .. && msbuild /m [...]
+if [cpack] EQU [ON] (
+ cpack
+ )
+if [skiptests] NEQ [OFF] (
+ ctest -C %build_type%
+ )
+cd ..