You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2018/04/06 16:43:16 UTC
[02/15] nifi git commit: NIFI-4149 - Indicate if EL is evaluated
against FFs or not - take into account input requirement for documentation
rendering - Renamed variable registry scope and added comments - Doc + change
in mock framework to check scope + u
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java
index f36e306..3755883 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java
@@ -16,14 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -34,16 +26,35 @@ import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
public class TestReplaceText {
@Rule
public ExpectedException exception = ExpectedException.none();
- @Test
- public void testConfigurationCornerCase() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
+ public TestRunner getRunner() {
+ TestRunner runner = TestRunners.newTestRunner(ReplaceText.class);
+
+ /**
+ * we have to disable validation of expression language because the scope of the evaluation
+ * for the search value depends of another property (the evaluation mode). If not disabling
+ * the validation, it'll throw an error about the eval
+ */
runner.setValidateExpressionUsage(false);
+ return runner;
+ }
+
+ @Test
+ public void testConfigurationCornerCase() throws IOException {
+ final TestRunner runner = getRunner();
runner.run();
runner.enqueue(Paths.get("src/test/resources/hello.txt"));
runner.run();
@@ -55,8 +66,7 @@ public class TestReplaceText {
@Test
public void testSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "ell");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "lle");
@@ -70,8 +80,7 @@ public class TestReplaceText {
@Test
public void testWithEscaped$InReplacement() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a\\$b");
@@ -85,8 +94,7 @@ public class TestReplaceText {
@Test
public void testWithUnEscaped$InReplacement() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a$b");
@@ -100,8 +108,7 @@ public class TestReplaceText {
@Test
public void testPrependSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "TEST");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.PREPEND);
@@ -115,8 +122,7 @@ public class TestReplaceText {
@Test
public void testPrependLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "_");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.PREPEND);
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
@@ -131,8 +137,7 @@ public class TestReplaceText {
@Test
public void testAppendSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "TEST");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
@@ -146,8 +151,7 @@ public class TestReplaceText {
@Test
public void testAppendWithCarriageReturn() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "!");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
@@ -162,8 +166,7 @@ public class TestReplaceText {
@Test
public void testAppendWithNewLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "!");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
@@ -178,8 +181,7 @@ public class TestReplaceText {
@Test
public void testAppendWithCarriageReturnNewLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "!");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
@@ -194,8 +196,7 @@ public class TestReplaceText {
@Test
public void testLiteralSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "ell");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "lle");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.LITERAL_REPLACE);
@@ -210,8 +211,7 @@ public class TestReplaceText {
@Test
public void testLiteralBackReference() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "ell");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[$1]");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.LITERAL_REPLACE);
@@ -226,8 +226,7 @@ public class TestReplaceText {
@Test
public void testLiteral() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, ".ell.");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "test");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.LITERAL_REPLACE);
@@ -246,8 +245,7 @@ public class TestReplaceText {
@Test
public void testBackReference() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[$1]");
@@ -261,8 +259,7 @@ public class TestReplaceText {
@Test
public void testBackRefFollowedByNumbers() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
String expected = "Hell23o, World!";
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$123");
@@ -280,8 +277,7 @@ public class TestReplaceText {
@Test
public void testBackRefWithNoCapturingGroup() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "ell");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$0123");
@@ -297,8 +293,7 @@ public class TestReplaceText {
@Test
public void testReplacementWithExpressionLanguage() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "${replaceKey}");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "GoodBye");
@@ -315,8 +310,7 @@ public class TestReplaceText {
@Test
public void testReplacementWithExpressionLanguageIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[${abc}]");
@@ -333,8 +327,7 @@ public class TestReplaceText {
@Test
public void testRegexWithExpressionLanguage() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "${replaceKey}");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${replaceValue}");
@@ -352,8 +345,7 @@ public class TestReplaceText {
@Test
public void testRegexWithExpressionLanguageIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "${replaceKey}");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${replaceValue}");
@@ -371,8 +363,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$1$2");
@@ -390,8 +381,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceWithInvalidReferenceIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$d");
@@ -409,8 +399,7 @@ public class TestReplaceText {
@Test
public void testEscapingDollarSign() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "\\$1");
@@ -428,8 +417,7 @@ public class TestReplaceText {
@Test
public void testReplaceWithEmptyString() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ell)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "");
@@ -443,8 +431,7 @@ public class TestReplaceText {
@Test
public void testWithNoMatch() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "Z");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "Morning");
@@ -458,8 +445,7 @@ public class TestReplaceText {
@Test
public void testWithMultipleMatches() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "l");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "R");
@@ -473,8 +459,7 @@ public class TestReplaceText {
@Test
public void testAttributeToContent() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
@@ -491,8 +476,7 @@ public class TestReplaceText {
@Test
public void testRoutesToFailureIfTooLarge() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "[123]");
runner.setProperty(ReplaceText.MAX_BUFFER_SIZE, "1 b");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
@@ -508,8 +492,7 @@ public class TestReplaceText {
@Test
public void testRoutesToSuccessIfTooLargeButRegexIsDotAsterisk() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.MAX_BUFFER_SIZE, "1 b");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
@@ -527,8 +510,7 @@ public class TestReplaceText {
@Test
public void testProblematicCase1() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${filename}\t${now():format(\"yyyy/MM/dd'T'HHmmss'Z'\")}\t${fileSize}\n");
@@ -548,8 +530,7 @@ public class TestReplaceText {
@Test
public void testGetExistingContent() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s)(^.*)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "attribute header\n\n${filename}\n\ndata header\n\n$1\n\nfooter");
@@ -568,8 +549,7 @@ public class TestReplaceText {
@Test
public void testReplaceWithinCurlyBraces() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, ".+");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "{ ${filename} }");
@@ -589,8 +569,7 @@ public class TestReplaceText {
final String defaultValue = "default-replacement-value";
// leave the default regex settings
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, defaultValue);
final Map<String, String> attributes = new HashMap<>();
@@ -608,8 +587,7 @@ public class TestReplaceText {
final String defaultValue = "default-replacement-value";
// leave the default regex settings
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, defaultValue);
final Map<String, String> attributes = new HashMap<>();
@@ -626,8 +604,7 @@ public class TestReplaceText {
@Test
public void testSimpleLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "odo");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "ood");
@@ -642,8 +619,7 @@ public class TestReplaceText {
@Test
public void testPrependSimpleLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.PREPEND);
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "TEST ");
@@ -658,8 +634,7 @@ public class TestReplaceText {
@Test
public void testAppendSimpleLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, " TEST");
@@ -674,8 +649,7 @@ public class TestReplaceText {
@Test
public void testAppendEndlineCR() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "TEST");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
@@ -690,8 +664,7 @@ public class TestReplaceText {
@Test
public void testAppendEndlineCRLF() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "TEST");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.APPEND);
@@ -706,8 +679,7 @@ public class TestReplaceText {
@Test
public void testSimpleLiteral() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "odo");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "ood");
@@ -723,8 +695,7 @@ public class TestReplaceText {
@Test
public void testLiteralBackReferenceLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "jo");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[$1]");
@@ -741,8 +712,7 @@ public class TestReplaceText {
@Test
public void testLiteralLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, ".ell.");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "test");
@@ -758,8 +728,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(DODO)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[$1]");
@@ -774,8 +743,7 @@ public class TestReplaceText {
@Test
public void testReplacementWithExpressionLanguageIsEscapedLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(jo)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "[${abc}]");
@@ -793,8 +761,7 @@ public class TestReplaceText {
@Test
public void testRegexWithExpressionLanguageLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "${replaceKey}");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${replaceValue}");
@@ -813,8 +780,7 @@ public class TestReplaceText {
@Test
public void testRegexWithExpressionLanguageIsEscapedLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "${replaceKey}");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${replaceValue}");
@@ -833,8 +799,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscapedLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(lu)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$1$2");
@@ -853,8 +818,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceWithInvalidReferenceIsEscapedLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(ew)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$d");
@@ -873,8 +837,7 @@ public class TestReplaceText {
@Test
public void testEscapingDollarSignLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(DO)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "\\$1");
@@ -893,8 +856,7 @@ public class TestReplaceText {
@Test
public void testReplaceWithEmptyStringLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(jo)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "");
@@ -909,8 +871,7 @@ public class TestReplaceText {
@Test
public void testWithNoMatchLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "Z");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "Morning");
@@ -925,8 +886,7 @@ public class TestReplaceText {
@Test
public void testWithMultipleMatchesLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "l");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "R");
@@ -941,8 +901,7 @@ public class TestReplaceText {
@Test
public void testAttributeToContentLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
@@ -960,8 +919,7 @@ public class TestReplaceText {
@Test
public void testAttributeToContentWindows() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
@@ -979,8 +937,7 @@ public class TestReplaceText {
@Test
public void testProblematicCase1LineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, ".*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${filename}\t${now():format(\"yyyy/MM/dd'T'HHmmss'Z'\")}\t${fileSize}\n");
@@ -1001,8 +958,7 @@ public class TestReplaceText {
@Test
public void testGetExistingContentLineByLine() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s)(^.*)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "attribute header\n\n${filename}\n\ndata header\n\n$1\n\nfooter\n");
@@ -1023,8 +979,7 @@ public class TestReplaceText {
@Test
public void testCapturingGroupInExpressionLanguage() {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(.*?),(.*?),(\\d+.*)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$1,$2,${ '$3':toDate('ddMMMyyyy'):format('yyyy/MM/dd') }");
@@ -1049,8 +1004,7 @@ public class TestReplaceText {
@Test
public void testCapturingGroupInExpressionLanguage2() {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "(.*)/(.*?).jpg");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$1/${ '$2':substring(0,1) }.png");
@@ -1073,8 +1027,7 @@ public class TestReplaceText {
@Test
public void testAlwaysReplaceEntireText() {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT);
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.ALWAYS_REPLACE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "i do not exist anywhere in the text");
@@ -1093,8 +1046,7 @@ public class TestReplaceText {
@Test
public void testAlwaysReplaceLineByLine() {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.LINE_BY_LINE);
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.ALWAYS_REPLACE);
runner.setProperty(ReplaceText.SEARCH_VALUE, "i do not exist anywhere in the text");
@@ -1116,8 +1068,7 @@ public class TestReplaceText {
// Test the old Default Regex and with a custom Replacement Value that should fail because the
// Perl regex "(?s:^.*$)" must be written "(?s)(^.*$)" in Java for there to be a capture group.
// private static final String DEFAULT_REGEX = "(?s:^.*$)";
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${'$1':toUpper()}"); // should uppercase group but there is none
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.REGEX_REPLACE);
@@ -1134,8 +1085,7 @@ public class TestReplaceText {
@Test
public void testRegexWithGoodCaptureGroup() throws IOException {
// Test the new Default Regex and with a custom Replacement Values that should succeed.
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s)(^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${'$1':toUpper()}"); // will uppercase group with good Java regex
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.REGEX_REPLACE);
@@ -1153,8 +1103,7 @@ public class TestReplaceText {
public void testRegexNoCaptureDefaultReplacement() throws IOException {
// Test the old Default Regex and new Default Regex with the default replacement. This should fail
// because the regex does not create a capture group.
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "$1");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.REGEX_REPLACE);
@@ -1168,7 +1117,7 @@ public class TestReplaceText {
@Test
public void testProcessorConfigurationRegexNotValid() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?<!\\),*");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "hello");
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY, ReplaceText.REGEX_REPLACE);
@@ -1196,8 +1145,7 @@ public class TestReplaceText {
@Test
public void testBackReferenceEscapeWithRegexReplaceUsingEL() throws Exception {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceText());
- runner.setValidateExpressionUsage(false);
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s)(^.*$)");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${'$1':toUpper()}");
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
index 7a480a8..fad370a 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
@@ -28,14 +28,26 @@ import java.util.Map;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
-
import org.junit.Test;
public class TestReplaceTextWithMapping {
+ public TestRunner getRunner() {
+ TestRunner runner = TestRunners.newTestRunner(ReplaceTextWithMapping.class);
+
+ /**
+ * we have to disable validation of expression language because the processor will
+ * need to evaluate the REGEX field with AND without flow files. If not disabled,
+ * the test will throw an error about the evaluation scope
+ */
+ runner.setValidateExpressionUsage(false);
+
+ return runner;
+ }
+
@Test
public void testSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
@@ -54,7 +66,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
@@ -72,7 +84,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText2() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
runner.setProperty(ReplaceTextWithMapping.REGEX, "\\|(.*?)\\|");
@@ -92,7 +104,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText3() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
runner.setProperty(ReplaceTextWithMapping.REGEX, ".*\\|(.*?)\\|.*");
@@ -112,7 +124,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testWithMatchingGroupAndContext() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath());
@@ -132,7 +144,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReference() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "(\\S+)");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-backreference-mapping.txt").toFile().getAbsolutePath());
@@ -152,7 +164,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testRoutesToFailureIfTooLarge() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "[123]");
runner.setProperty(ReplaceTextWithMapping.MAX_BUFFER_SIZE, "1 b");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath());
@@ -168,7 +180,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping.txt").toFile().getAbsolutePath());
@@ -188,7 +200,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscapedSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE,
Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping-simple.txt").toFile().getAbsolutePath());
@@ -207,7 +219,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReferenceWithInvalidReferenceIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "(\\S+)");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-invalid-backreference-mapping.txt").toFile().getAbsolutePath());
@@ -227,7 +239,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testEscapingDollarSign() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").toFile().getAbsolutePath());
@@ -247,7 +259,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testEscapingDollarSignSimple() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").toFile().getAbsolutePath());
runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
@@ -265,7 +277,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testReplaceWithEmptyString() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-blank-mapping.txt").toFile().getAbsolutePath());
runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
@@ -283,7 +295,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testReplaceWithSpaceInString() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-space-mapping.txt").toFile().getAbsolutePath());
runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
@@ -301,7 +313,7 @@ public class TestReplaceTextWithMapping {
@Test
public void testWithNoMatch() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-no-match-mapping.txt").toFile().getAbsolutePath());
@@ -319,7 +331,7 @@ public class TestReplaceTextWithMapping {
@Test(expected = java.lang.AssertionError.class)
public void testMatchingGroupForLookupKeyTooLarge() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = getRunner();
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "2");
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-mapping.txt").toFile().getAbsolutePath());
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java
index ab16b96..e732695 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java
@@ -68,7 +68,6 @@ public class TestUpdateRecord {
public void testLiteralReplacementValue() {
runner.setProperty("/name", "Jane Doe");
runner.enqueue("");
- runner.setValidateExpressionUsage(false);
readerService.addRecord("John Doe", 35);
runner.run();
@@ -193,7 +192,6 @@ public class TestUpdateRecord {
public void testUpdateInArray() throws InitializationException, IOException {
final JsonTreeReader jsonReader = new JsonTreeReader();
runner.addControllerService("reader", jsonReader);
- runner.setValidateExpressionUsage(false);
final String inputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-address.avsc")));
final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-address.avsc")));
@@ -224,7 +222,6 @@ public class TestUpdateRecord {
public void testUpdateInNullArray() throws InitializationException, IOException {
final JsonTreeReader jsonReader = new JsonTreeReader();
runner.addControllerService("reader", jsonReader);
- runner.setValidateExpressionUsage(false);
final String inputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-address.avsc")));
final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-address.avsc")));
@@ -467,7 +464,6 @@ public class TestUpdateRecord {
public void testUpdateSimpleArray() throws InitializationException, IOException {
final JsonTreeReader jsonReader = new JsonTreeReader();
runner.addControllerService("reader", jsonReader);
- runner.setValidateExpressionUsage(false);
final String inputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/multi-arrays.avsc")));
final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/multi-arrays.avsc")));
@@ -558,7 +554,6 @@ public class TestUpdateRecord {
public void testUpdateComplexArrays() throws InitializationException, IOException {
final JsonTreeReader jsonReader = new JsonTreeReader();
runner.addControllerService("reader", jsonReader);
- runner.setValidateExpressionUsage(false);
final String inputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/multi-arrays.avsc")));
final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/multi-arrays.avsc")));
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java b/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
index 880e49b..8d59c1c 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
@@ -26,6 +26,7 @@ import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.expression.AttributeExpression;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.reporting.InitializationException;
@@ -47,7 +48,7 @@ import java.util.concurrent.TimeUnit;
*/
@Tags({ "dbcp", "jdbc", "database", "connection", "pooling", "store" })
@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage.")
-@DynamicProperty(name = "JDBC property name", value = "JDBC property value", supportsExpressionLanguage = true,
+@DynamicProperty(name = "JDBC property name", value = "JDBC property value", expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY,
description = "Specifies a property name and value to be set on the JDBC connection(s). "
+ "If Expression Language is used, evaluation will be performed upon the controller service being enabled. "
+ "Note that no flow file input (attributes, e.g.) is available for use in Expression Language constructs for these properties.")
@@ -60,7 +61,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(true)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
@@ -69,7 +70,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.defaultValue(null)
.required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor DB_DRIVER_LOCATION = new PropertyDescriptor.Builder()
@@ -79,7 +80,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.defaultValue(null)
.required(false)
.addValidator(StandardValidators.createListValidator(true, true, StandardValidators.createURLorFileValidator()))
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
@@ -87,7 +88,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.description("Database user name")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
@@ -97,7 +98,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.required(false)
.sensitive(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor MAX_WAIT_TIME = new PropertyDescriptor.Builder()
@@ -128,7 +129,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
+ "Note!! Using validation might have some performance penalty.")
.required(false)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
private static final List<PropertyDescriptor> properties;
@@ -161,7 +162,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
.required(false)
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.dynamic(true)
.build();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java
index 357529e..cff3fb6 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java
@@ -20,6 +20,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ControllerService;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.hbase.put.PutColumn;
import org.apache.nifi.hbase.put.PutFlowFile;
import org.apache.nifi.hbase.scan.Column;
@@ -72,7 +73,7 @@ public interface HBaseClientService extends ControllerService {
.name("Phoenix Client JAR Location")
.description("The full path to the Phoenix client JAR. Required if Phoenix is installed on top of HBase.")
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.dynamicallyModifiesClasspath(true)
.build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java
index ca3a1db..7c10800 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java
@@ -32,6 +32,7 @@ import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.distributed.cache.client.DistributedMapCacheClient;
import org.apache.nifi.distributed.cache.client.Serializer;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.distributed.cache.client.Deserializer;
import java.io.ByteArrayOutputStream;
import org.apache.nifi.reporting.InitializationException;
@@ -63,7 +64,7 @@ public class HBase_1_1_2_ClientMapCacheService extends AbstractControllerService
.name("HBase Cache Table Name")
.description("Name of the table on HBase to use for the cache.")
.required(true)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
@@ -71,7 +72,7 @@ public class HBase_1_1_2_ClientMapCacheService extends AbstractControllerService
.name("HBase Column Family")
.description("Name of the column family on HBase to use for the cache.")
.required(true)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.defaultValue("f")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
@@ -81,7 +82,7 @@ public class HBase_1_1_2_ClientMapCacheService extends AbstractControllerService
.description("Name of the column qualifier on HBase to use for the cache")
.defaultValue("q")
.required(true)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java b/nifi-nar-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java
index ba70e0c..c25ddbf 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java
@@ -40,6 +40,7 @@ import org.apache.nifi.annotation.lifecycle.OnShutdown;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
@Tags({"http", "request", "response"})
@@ -61,7 +62,7 @@ public class StandardHttpContextMap extends AbstractControllerService implements
.name("Request Expiration")
.description("Specifies how long an HTTP Request should be left unanswered before being evicted from the cache and being responded to with a Service Unavailable status code")
.required(true)
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.defaultValue("1 min")
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle/nifi-hwx-schema-registry-service/src/main/java/org/apache/nifi/schemaregistry/hortonworks/HortonworksSchemaRegistry.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle/nifi-hwx-schema-registry-service/src/main/java/org/apache/nifi/schemaregistry/hortonworks/HortonworksSchemaRegistry.java b/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle/nifi-hwx-schema-registry-service/src/main/java/org/apache/nifi/schemaregistry/hortonworks/HortonworksSchemaRegistry.java
index 88325ad..b33d5c8 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle/nifi-hwx-schema-registry-service/src/main/java/org/apache/nifi/schemaregistry/hortonworks/HortonworksSchemaRegistry.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle/nifi-hwx-schema-registry-service/src/main/java/org/apache/nifi/schemaregistry/hortonworks/HortonworksSchemaRegistry.java
@@ -32,6 +32,7 @@ import org.apache.nifi.avro.AvroTypeUtil;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.schema.access.SchemaField;
@@ -71,7 +72,7 @@ public class HortonworksSchemaRegistry extends AbstractControllerService impleme
.displayName("Schema Registry URL")
.description("URL of the schema registry that this Controller Service should connect to, including version. For example, http://localhost:9090/api/v1")
.addValidator(StandardValidators.URL_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(true)
.build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/CSVRecordLookupService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/CSVRecordLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/CSVRecordLookupService.java
index 793ed54..8bbb141 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/CSVRecordLookupService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/CSVRecordLookupService.java
@@ -27,6 +27,7 @@ import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.reporting.InitializationException;
@@ -74,14 +75,14 @@ public class CSVRecordLookupService extends AbstractControllerService implements
.description("A CSV file that will serve as the data source.")
.required(true)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
static final PropertyDescriptor CSV_FORMAT = new PropertyDescriptor.Builder()
.name("csv-format")
.displayName("CSV Format")
.description("Specifies which \"format\" the CSV data is in.")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues(Arrays.asList(CSVFormat.Predefined.values()).stream().map(e -> e.toString()).collect(Collectors.toSet()))
.defaultValue(CSVFormat.Predefined.Default.toString())
.required(true)
@@ -95,7 +96,7 @@ public class CSVRecordLookupService extends AbstractControllerService implements
"This is the field that will be matched against the property specified in the lookup processor.")
.required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor IGNORE_DUPLICATES =
@@ -193,9 +194,9 @@ public class CSVRecordLookupService extends AbstractControllerService implements
@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException, IOException {
- this.csvFile = context.getProperty(CSV_FILE).getValue();
+ this.csvFile = context.getProperty(CSV_FILE).evaluateAttributeExpressions().getValue();
this.csvFormat = CSVFormat.Predefined.valueOf(context.getProperty(CSV_FORMAT).getValue()).getFormat();
- this.lookupKeyColumn = context.getProperty(LOOKUP_KEY_COLUMN).getValue();
+ this.lookupKeyColumn = context.getProperty(LOOKUP_KEY_COLUMN).evaluateAttributeExpressions().getValue();
this.ignoreDuplicates = context.getProperty(IGNORE_DUPLICATES).asBoolean();
this.watcher = new SynchronousFileWatcher(Paths.get(csvFile), new LastModifiedMonitor(), 30000L);
try {
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java
index 878cbe8..7a2354a 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleCsvFileLookupService.java
@@ -44,6 +44,7 @@ import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.util.StandardValidators;
@@ -66,13 +67,13 @@ public class SimpleCsvFileLookupService extends AbstractControllerService implem
.description("A CSV file.")
.required(true)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
static final PropertyDescriptor CSV_FORMAT = new PropertyDescriptor.Builder()
.name("CSV Format")
.description("Specifies which \"format\" the CSV data is in, or specifies if custom formatting should be used.")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues(Arrays.asList(CSVFormat.Predefined.values()).stream().map(e -> e.toString()).collect(Collectors.toSet()))
.defaultValue(CSVFormat.Predefined.Default.toString())
.required(true)
@@ -85,7 +86,7 @@ public class SimpleCsvFileLookupService extends AbstractControllerService implem
.description("Lookup key column.")
.required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor LOOKUP_VALUE_COLUMN =
@@ -95,7 +96,7 @@ public class SimpleCsvFileLookupService extends AbstractControllerService implem
.description("Lookup value column.")
.required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor IGNORE_DUPLICATES =
@@ -180,10 +181,10 @@ public class SimpleCsvFileLookupService extends AbstractControllerService implem
@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException, IOException, FileNotFoundException {
- this.csvFile = context.getProperty(CSV_FILE).getValue();
+ this.csvFile = context.getProperty(CSV_FILE).evaluateAttributeExpressions().getValue();
this.csvFormat = CSVFormat.Predefined.valueOf(context.getProperty(CSV_FORMAT).getValue()).getFormat();
- this.lookupKeyColumn = context.getProperty(LOOKUP_KEY_COLUMN).getValue();
- this.lookupValueColumn = context.getProperty(LOOKUP_VALUE_COLUMN).getValue();
+ this.lookupKeyColumn = context.getProperty(LOOKUP_KEY_COLUMN).evaluateAttributeExpressions().getValue();
+ this.lookupValueColumn = context.getProperty(LOOKUP_VALUE_COLUMN).evaluateAttributeExpressions().getValue();
this.ignoreDuplicates = context.getProperty(IGNORE_DUPLICATES).asBoolean();
this.watcher = new SynchronousFileWatcher(Paths.get(csvFile), new LastModifiedMonitor(), 30000L);
try {
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java
index ec9371d..2f99c36 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/SimpleKeyValueLookupService.java
@@ -31,6 +31,7 @@ import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.Validator;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
@Tags({"lookup", "enrich", "key", "value"})
@CapabilityDescription("Allows users to add key/value pairs as User-defined Properties. Each property that is added can be looked up by Property Name. "
@@ -47,7 +48,7 @@ public class SimpleKeyValueLookupService extends AbstractControllerService imple
.required(false)
.dynamic(true)
.addValidator(Validator.VALID)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java
index 9248132..3957f80 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java
@@ -41,6 +41,7 @@ import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.lookup.LookupFailureException;
import org.apache.nifi.lookup.StringLookupService;
@@ -65,7 +66,7 @@ public abstract class CommonsConfigurationLookupService<T extends FileBasedConfi
.description("A configuration file")
.required(true)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
private final Class<T> resultClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
@@ -99,7 +100,7 @@ public abstract class CommonsConfigurationLookupService<T extends FileBasedConfi
@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException {
- final String config = context.getProperty(CONFIGURATION_FILE).getValue();
+ final String config = context.getProperty(CONFIGURATION_FILE).evaluateAttributeExpressions().getValue();
final FileBasedBuilderParameters params = new Parameters().fileBased().setFile(new File(config));
this.builder = new ReloadingFileBasedConfigurationBuilder<>(resultClass).configure(params);
builder.addEventListener(ConfigurationBuilderEvent.CONFIGURATION_REQUEST,
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java
index 5661b94..b2fb463 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java
@@ -42,6 +42,7 @@ import org.apache.nifi.annotation.lifecycle.OnStopped;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.lookup.LookupFailureException;
import org.apache.nifi.lookup.RecordLookupService;
import org.apache.nifi.processor.util.StandardValidators;
@@ -87,7 +88,7 @@ public class IPLookupService extends AbstractControllerService implements Record
.description("Path to Maxmind IP Enrichment Database File")
.required(true)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
static final PropertyDescriptor LOOKUP_CITY = new PropertyDescriptor.Builder()
.name("lookup-city")
@@ -95,14 +96,14 @@ public class IPLookupService extends AbstractControllerService implements Record
.description("Specifies whether or not information about the geographic information, such as cities, corresponding to the IP address should be returned")
.allowableValues("true", "false")
.defaultValue("true")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.required(true)
.build();
static final PropertyDescriptor LOOKUP_ISP = new PropertyDescriptor.Builder()
.name("lookup-isp")
.displayName("Lookup ISP")
.description("Specifies whether or not information about the Information Service Provider corresponding to the IP address should be returned")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues("true", "false")
.defaultValue("false")
.required(true)
@@ -112,7 +113,7 @@ public class IPLookupService extends AbstractControllerService implements Record
.displayName("Lookup Domain Name")
.description("Specifies whether or not information about the Domain Name corresponding to the IP address should be returned. "
+ "If true, the lookup will contain second-level domain information, such as foo.com but will not contain bar.foo.com")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues("true", "false")
.defaultValue("false")
.required(true)
@@ -122,7 +123,7 @@ public class IPLookupService extends AbstractControllerService implements Record
.displayName("Lookup Connection Type")
.description("Specifies whether or not information about the Connection Type corresponding to the IP address should be returned. "
+ "If true, the lookup will contain a 'connectionType' field that (if populated) will contain a value of 'Dialup', 'Cable/DSL', 'Corporate', or 'Cellular'")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues("true", "false")
.defaultValue("false")
.required(true)
@@ -131,7 +132,7 @@ public class IPLookupService extends AbstractControllerService implements Record
.name("lookup-anonymous-ip")
.displayName("Lookup Anonymous IP Information")
.description("Specifies whether or not information about whether or not the IP address belongs to an anonymous network should be returned.")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues("true", "false")
.defaultValue("false")
.required(true)
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVReader.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVReader.java b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVReader.java
index 9f133a6..858ef70 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVReader.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVReader.java
@@ -32,6 +32,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.schema.access.SchemaAccessStrategy;
import org.apache.nifi.schema.access.SchemaAccessUtils;
@@ -67,7 +68,7 @@ public class CSVReader extends SchemaRegistryService implements RecordReaderFact
.displayName("CSV Parser")
.description("Specifies which parser to use to read CSV records. NOTE: Different parsers may support different subsets of functionality "
+ "and may also exhibit different levels of performance.")
- .expressionLanguageSupported(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.allowableValues(APACHE_COMMONS_CSV, JACKSON_CSV)
.defaultValue(APACHE_COMMONS_CSV.getValue())
.required(true)
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/grok/GrokReader.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/grok/GrokReader.java b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/grok/GrokReader.java
index 6eea8e3..29e9636 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/grok/GrokReader.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/grok/GrokReader.java
@@ -35,6 +35,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.schema.access.SchemaAccessStrategy;
@@ -86,7 +87,7 @@ public class GrokReader extends SchemaRegistryService implements RecordReaderFac
+ "will be used. If specified, all patterns in the given pattern file will override the default patterns. See the Controller Service's "
+ "Additional Details for a list of pre-defined patterns.")
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
- .expressionLanguageSupported(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
.build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/4c787799/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/JsonPathReader.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/JsonPathReader.java b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/JsonPathReader.java
index cab4449..f8f1ea2 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/JsonPathReader.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/JsonPathReader.java
@@ -35,6 +35,7 @@ import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.schema.access.SchemaNotFoundException;
import org.apache.nifi.serialization.DateTimeUtils;
@@ -56,7 +57,7 @@ import com.jayway.jsonpath.JsonPath;
value="A JSONPath Expression that will be evaluated against each JSON record. The result of the JSONPath will be the value of the "
+ "field whose name is the same as the property name.",
description="User-defined properties identifiy how to extract specific fields from a JSON object in order to create a Record",
- supportsExpressionLanguage=false)
+ expressionLanguageScope=ExpressionLanguageScope.NONE)
public class JsonPathReader extends SchemaRegistryService implements RecordReaderFactory {
private volatile String dateFormat;