You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2018/08/03 21:27:12 UTC
nifi-minifi-cpp git commit: MINIFICPP-583: Allow Expression language
to compile if CURL is disabled while also honoring the request to disable
CURL functionality
Repository: nifi-minifi-cpp
Updated Branches:
refs/heads/master fedc4f7fb -> 82557dec8
MINIFICPP-583: Allow Expression language to compile if CURL is disabled while also honoring the request to disable CURL functionality
This closes #387.
This closes #380.
Signed-off-by: Aldrin Piri <al...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/82557dec
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/82557dec
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/82557dec
Branch: refs/heads/master
Commit: 82557dec8b66adee9ee5a6b1b6fe1aef6edae637
Parents: fedc4f7
Author: Marc Parisi <ph...@apache.org>
Authored: Fri Aug 3 12:31:21 2018 -0400
Committer: Aldrin Piri <al...@apache.org>
Committed: Fri Aug 3 17:26:35 2018 -0400
----------------------------------------------------------------------
CMakeLists.txt | 14 +++++-----
extensions/expression-language/CMakeLists.txt | 2 ++
extensions/expression-language/Expression.cpp | 10 ++++++++
libminifi/test/civetweb-tests/CMakeLists.txt | 2 ++
.../ExpressionLanguageTests.cpp | 27 ++++++++++++++++++++
5 files changed, 47 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/82557dec/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4a76b4..3c33509 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,15 +216,13 @@ else()
set(UUID_LIBRARIES "uuid")
endif()
-set (NEEDS_CURL FALSE)
-
-if(ENABLE_ALL OR (NOT DISABLE_EXPRESSION_LANGUAGE) OR (NOT DISABLE_CURL))
- set(NEEDS_CURL TRUE)
-endif()
-
-if(NEEDS_CURL AND (NOT USE_SYSTEM_CURL))
+if (DISABLE_CURL)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_CURL")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_CURL")
+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}")
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/82557dec/extensions/expression-language/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/extensions/expression-language/CMakeLists.txt b/extensions/expression-language/CMakeLists.txt
index 1b44302..cf1afbf 100644
--- a/extensions/expression-language/CMakeLists.txt
+++ b/extensions/expression-language/CMakeLists.txt
@@ -60,9 +60,11 @@ target_link_libraries(minifi-expression-language-extensions ${LIBMINIFI} tz)
find_package(UUID REQUIRED)
target_link_libraries(minifi-expression-language-extensions ${LIBMINIFI} ${UUID_LIBRARIES})
+if (NOT DISABLE_CURL)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(minifi-expression-language-extensions ${CURL_LIBRARIES})
+endif()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(minifi-expression-language-extensions ${CMAKE_DL_LIBS})
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/82557dec/extensions/expression-language/Expression.cpp
----------------------------------------------------------------------
diff --git a/extensions/expression-language/Expression.cpp b/extensions/expression-language/Expression.cpp
index 5681c05..daeb09f 100644
--- a/extensions/expression-language/Expression.cpp
+++ b/extensions/expression-language/Expression.cpp
@@ -28,7 +28,9 @@
#include <utils/StringUtils.h>
#include <expression/Expression.h>
#include <regex>
+#ifndef DISABLE_CURL
#include <curl/curl.h>
+#endif
#include <netdb.h>
#include <arpa/inet.h>
#include "base64.h"
@@ -1345,6 +1347,7 @@ Value expr_unescapeCsv(const std::vector<Value> &args) {
}
Value expr_urlEncode(const std::vector<Value> &args) {
+#ifndef DISABLE_CURL
auto arg_0 = args[0].asString();
CURL *curl = curl_easy_init();
if (curl != nullptr) {
@@ -1363,9 +1366,13 @@ Value expr_urlEncode(const std::vector<Value> &args) {
} else {
throw std::runtime_error("Failed to initialize cURL");
}
+#else
+ throw std::runtime_error("Failed to initialize cURL");
+#endif
}
Value expr_urlDecode(const std::vector<Value> &args) {
+#ifndef DISABLE_CURL
auto arg_0 = args[0].asString();
CURL *curl = curl_easy_init();
if (curl != nullptr) {
@@ -1386,6 +1393,9 @@ Value expr_urlDecode(const std::vector<Value> &args) {
} else {
throw std::runtime_error("Failed to initialize cURL");
}
+#else
+ throw std::runtime_error("Failed to initialize cURL");
+#endif
}
Value expr_base64Encode(const std::vector<Value> &args) {
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/82557dec/libminifi/test/civetweb-tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libminifi/test/civetweb-tests/CMakeLists.txt b/libminifi/test/civetweb-tests/CMakeLists.txt
index eb0fe27..9a6d894 100644
--- a/libminifi/test/civetweb-tests/CMakeLists.txt
+++ b/libminifi/test/civetweb-tests/CMakeLists.txt
@@ -17,6 +17,7 @@
# under the License.
#
+if(NOT DISABLE_CURL)
file(GLOB CIVETWEB_INTEGRATION_TESTS "*.cpp")
SET(CIVETWEB-EXTENSIONS_TEST_COUNT 0)
FOREACH(testfile ${CIVETWEB_INTEGRATION_TESTS})
@@ -37,3 +38,4 @@ FOREACH(testfile ${CIVETWEB_INTEGRATION_TESTS})
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
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/82557dec/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp b/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
index 4099636..3ee6ec3 100644
--- a/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
+++ b/libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp
@@ -1185,6 +1185,7 @@ TEST_CASE("Decode CSV 2", "[expressionDecodeCSV2]") { // NOLINT
REQUIRE("\"quoted\"" == expr({flow_file_a}).asString());
}
+
TEST_CASE("Encode Decode CSV", "[expressionEncodeDecodeCSV]") { // NOLINT
auto expr = expression::compile("${message:escapeCsv():unescapeCsv()}");
@@ -1193,6 +1194,7 @@ TEST_CASE("Encode Decode CSV", "[expressionEncodeDecodeCSV]") { // NOLINT
REQUIRE("Zero > One < \"two!\" & 'true'" == expr({flow_file_a}).asString());
}
+#ifndef DISABLE_CURL
TEST_CASE("Encode URL", "[expressionEncodeURL]") { // NOLINT
auto expr = expression::compile("${message:urlEncode()}");
@@ -1216,6 +1218,31 @@ TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURL]") { // NOLINT
flow_file_a->addAttribute("message", "some value with spaces");
REQUIRE("some value with spaces" == expr({flow_file_a}).asString());
}
+#else
+TEST_CASE("Encode URL", "[expressionEncodeURLExcept]") { // 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_THROWS(expr({flow_file_a}).asString());
+}
+
+TEST_CASE("Decode URL", "[expressionDecodeURLExcept]") { // NOLINT
+ auto expr = expression::compile("${message:urlDecode()}");
+
+ auto flow_file_a = std::make_shared<MockFlowFile>();
+ flow_file_a->addAttribute("message", "some%20value%20with%20spaces");
+ REQUIRE_THROWS(expr({flow_file_a}).asString());
+}
+
+TEST_CASE("Encode Decode URL", "[expressionEncodeDecodeURLExcept]") { // NOLINT
+ auto expr = expression::compile("${message:urlEncode():urlDecode()}");
+
+ auto flow_file_a = std::make_shared<MockFlowFile>();
+ flow_file_a->addAttribute("message", "some value with spaces");
+ REQUIRE_THROWS(expr({flow_file_a}).asString());
+}
+#endif
#ifdef EXPRESSION_LANGUAGE_USE_DATE