Skip to content

Commit

Permalink
NIFI-8074 Switched ReplaceText to use line by line evaluation as its …
Browse files Browse the repository at this point in the history
…default evaluation mode.

This closes apache#4711

Signed-off-by: Mike Thomsen <[email protected]>
  • Loading branch information
MikeThomsen committed Dec 10, 2020
1 parent 1f8b4e4 commit 8e49483
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public class ReplaceText extends AbstractProcessor {
.description("Run the 'Replacement Strategy' against each line separately (Line-by-Line) or buffer the entire file "
+ "into memory (Entire Text) and run against that.")
.allowableValues(LINE_BY_LINE, ENTIRE_TEXT)
.defaultValue(ENTIRE_TEXT)
.defaultValue(LINE_BY_LINE)
.required(true)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ public void testRoutesToFailureIfTooLarge() throws IOException {
runner.setProperty(ReplaceText.SEARCH_VALUE, "[123]");
runner.setProperty(ReplaceText.MAX_BUFFER_SIZE, "1 b");
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}");
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT);

final Map<String, String> attributes = new HashMap<>();
attributes.put("abc", "Good");
Expand Down Expand Up @@ -823,6 +824,7 @@ public void testGetExistingContent() throws IOException {
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");
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT);

final Map<String, String> attributes = new HashMap<>();
attributes.put("filename", "abc.txt");
Expand Down Expand Up @@ -879,6 +881,7 @@ public void testDefaultMultilineReplacement() throws Exception {
// leave the default regex settings
final TestRunner runner = getRunner();
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, defaultValue);
runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT);

final Map<String, String> attributes = new HashMap<>();
runner.enqueue(("original-text-line-1" + System.lineSeparator() + "original-text-line-2").getBytes(StandardCharsets.UTF_8), attributes);
Expand Down

0 comments on commit 8e49483

Please sign in to comment.