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 2018/10/30 19:10:41 UTC
nifi-minifi-cpp git commit: MINIFICPP-640 - C API: how to support
dynamic properties?
Repository: nifi-minifi-cpp
Updated Branches:
refs/heads/master 2fb4021e1 -> fc1074a04
MINIFICPP-640 - C API: how to support dynamic properties?
This closes #430.
Signed-off-by: Marc Parisi <ph...@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/fc1074a0
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/fc1074a0
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/fc1074a0
Branch: refs/heads/master
Commit: fc1074a0495da8947fa8f6fa8a0fb258da2c13b3
Parents: 2fb4021
Author: Arpad Boda <ab...@hortonworks.com>
Authored: Tue Oct 30 14:48:04 2018 +0100
Committer: Marc Parisi <ph...@apache.org>
Committed: Tue Oct 30 15:09:31 2018 -0400
----------------------------------------------------------------------
libminifi/src/capi/api.cpp | 3 ++-
libminifi/test/capi/CAPITests.cpp | 11 ++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fc1074a0/libminifi/src/capi/api.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/capi/api.cpp b/libminifi/src/capi/api.cpp
index 58328ef..e135fe1 100644
--- a/libminifi/src/capi/api.cpp
+++ b/libminifi/src/capi/api.cpp
@@ -412,7 +412,8 @@ int set_failure_strategy(flow *flow, FailureStrategy strategy) {
int set_property(processor *proc, const char *name, const char *value) {
if (name != nullptr && value != nullptr && proc != nullptr) {
core::Processor *p = static_cast<core::Processor*>(proc->processor_ptr);
- return p->setProperty(name, value) ? 0 : -2;
+ bool success = p->setProperty(name, value) || (p->supportsDynamicProperties() && p->setDynamicProperty(name, value));
+ return success ? 0 : -2;
}
return -1;
}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fc1074a0/libminifi/test/capi/CAPITests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/capi/CAPITests.cpp b/libminifi/test/capi/CAPITests.cpp
index 368c9a1..b7bf784 100644
--- a/libminifi/test/capi/CAPITests.cpp
+++ b/libminifi/test/capi/CAPITests.cpp
@@ -165,10 +165,10 @@ TEST_CASE("Test manipulation of attributes", "[testAttributes]") {
processor *extract_test = add_processor_with_linkage(test_flow, "ExtractText");
REQUIRE(extract_test != nullptr);
REQUIRE(set_property(extract_test, "Attribute", "TestAttr") == 0);
- /*processor *update_attribute = add_processor_with_linkage(test_flow, "UpdateAttribute");
- REQUIRE(update_attribute != nullptr);
+ processor *update_attr = add_processor_with_linkage(test_flow, "UpdateAttribute");
+ REQUIRE(update_attr != nullptr);
- REQUIRE(set_property(update_attribute, "TestAttribute", "TestValue") == 0);*/
+ REQUIRE(set_property(update_attr, "UpdatedAttribute", "UpdatedValue") == 0);
flow_file_record *record = get_next_flow_file(instance, test_flow);
@@ -203,12 +203,17 @@ TEST_CASE("Test manipulation of attributes", "[testAttributes]") {
REQUIRE(get_all_attributes(record, &attr_set) == attr_set.size);
bool test_attr_found = false;
+ bool updated_attr_found = false;
for (int i = 0; i < attr_set.size; ++i) {
if (strcmp(attr_set.attributes[i].key, test_attr.key) == 0) {
test_attr_found = true;
REQUIRE(std::string(static_cast<char*>(attr_set.attributes[i].value), attr_set.attributes[i].value_size) == new_testattr_value);
+ } else if (strcmp(attr_set.attributes[i].key, "UpdatedAttribute") == 0) {
+ updated_attr_found = true;
+ REQUIRE(std::string(static_cast<char*>(attr_set.attributes[i].value), attr_set.attributes[i].value_size) == "UpdatedValue");
}
}
+ REQUIRE(updated_attr_found == true);
REQUIRE(test_attr_found == true);
free_flowfile(record);