diff --git a/nifi-commons/nifi-bootstrap-utils/pom.xml b/nifi-commons/nifi-bootstrap-utils/pom.xml index 8cb3ca15bb..c27062b418 100644 --- a/nifi-commons/nifi-bootstrap-utils/pom.xml +++ b/nifi-commons/nifi-bootstrap-utils/pom.xml @@ -29,7 +29,7 @@ language governing permissions and limitations under the License. --> net.java.dev.jna jna-platform - 4.4.0 + 5.10.0 diff --git a/nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/pom.xml b/nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/pom.xml index 7d6be6ecb5..59b3a0ec28 100644 --- a/nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/pom.xml +++ b/nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/pom.xml @@ -21,7 +21,7 @@ language governing permissions and limitations under the License. --> jar - 4.5.2 + 5.10.0 3.23.1-GA diff --git a/nifi-toolkit/nifi-toolkit-cli/pom.xml b/nifi-toolkit/nifi-toolkit-cli/pom.xml index 4bba01cdf8..58e2f02f00 100644 --- a/nifi-toolkit/nifi-toolkit-cli/pom.xml +++ b/nifi-toolkit/nifi-toolkit-cli/pom.xml @@ -23,6 +23,10 @@ nifi-toolkit-cli Tooling to make tls configuration easier + + 3.21.0 + + @@ -90,12 +94,12 @@ org.jline jline - 3.5.2 + ${jline.version} org.jline jline-terminal-jna - 3.5.2 + ${jline.version} commons-io diff --git a/nifi-toolkit/nifi-toolkit-cli/src/test/java/org/apache/nifi/toolkit/cli/TestCLICompleter.java b/nifi-toolkit/nifi-toolkit-cli/src/test/java/org/apache/nifi/toolkit/cli/TestCLICompleter.java index 35e1ee0716..b0ebac143f 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/test/java/org/apache/nifi/toolkit/cli/TestCLICompleter.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/test/java/org/apache/nifi/toolkit/cli/TestCLICompleter.java @@ -31,9 +31,10 @@ import org.apache.nifi.toolkit.cli.impl.command.registry.NiFiRegistryCommandGrou import org.apache.nifi.toolkit.cli.impl.context.StandardContext; import org.apache.nifi.toolkit.cli.impl.session.InMemorySession; import org.apache.nifi.toolkit.cli.impl.session.SessionVariable; +import org.apache.nifi.util.StringUtils; import org.jline.reader.Candidate; import org.jline.reader.LineReader; -import org.jline.reader.impl.DefaultParser; +import org.jline.reader.ParsedLine; import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -76,8 +77,7 @@ public class TestCLICompleter { @Test public void testCompletionWithWordIndexNegative() { - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Collections.emptyList(), -1, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Collections.emptyList(), -1); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -86,8 +86,7 @@ public class TestCLICompleter { @Test public void testCompletionWithWordIndexZero() { - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Collections.emptyList(), 0, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Collections.emptyList(), 0); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -98,8 +97,7 @@ public class TestCLICompleter { public void testCompletionWithWordIndexOneAndMatching() { final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Collections.singletonList(topCommand), 1, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Collections.singletonList(topCommand), 1); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -110,8 +108,7 @@ public class TestCLICompleter { public void testCompletionWithWordIndexOneAndNotMatching() { final String topCommand = "NOT-A-TOP-LEVEL-COMMAND"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Collections.singletonList(topCommand), 1, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Collections.singletonList(topCommand), 1); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -123,8 +120,7 @@ public class TestCLICompleter { final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP; final String subCommand = "list-buckets"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Arrays.asList(topCommand, subCommand), 2, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Arrays.asList(topCommand, subCommand), 2); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -137,8 +133,7 @@ public class TestCLICompleter { final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP; final String subCommand = "NOT-A-TOP-LEVEL-COMMAND"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Arrays.asList(topCommand, subCommand), 2, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Arrays.asList(topCommand, subCommand), 2); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -150,8 +145,7 @@ public class TestCLICompleter { final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP; final String subCommand = "list-buckets"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Arrays.asList(topCommand, subCommand, "-ks", "foo", "-kst", "JKS"), 6, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Arrays.asList(topCommand, subCommand, "-ks", "foo", "-kst", "JKS"), 5); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -164,8 +158,7 @@ public class TestCLICompleter { final String topCommand = NiFiRegistryCommandGroup.REGISTRY_COMMAND_GROUP; final String subCommand = "list-buckets"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Arrays.asList(topCommand, subCommand, "-p", "src/test/resources/"), 3, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Arrays.asList(topCommand, subCommand, "-p", "src/test/resources/"), 3); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -187,8 +180,7 @@ public class TestCLICompleter { final String topCommand = "session"; final String subCommand = "set"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList( - "", Arrays.asList(topCommand, subCommand), 2, -1, -1); + final ParsedLine parsedLine = new TestParsedLine(Arrays.asList(topCommand, subCommand), 2); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -201,13 +193,13 @@ public class TestCLICompleter { final String topCommand = "session"; final String subCommand = "set"; - final DefaultParser.ArgumentList parsedLine = new DefaultParser.ArgumentList("", + final ParsedLine parsedLine = new TestParsedLine( Arrays.asList( topCommand, subCommand, SessionVariable.NIFI_CLIENT_PROPS.getVariableName(), "src/test/resources/"), - 3, -1, -1); + 3); final List candidates = new ArrayList<>(); completer.complete(lineReader, parsedLine, candidates); @@ -224,4 +216,50 @@ public class TestCLICompleter { assertTrue(found); } + private static class TestParsedLine implements ParsedLine { + private final List words; + + private final int wordIndex; + + private TestParsedLine( + final List words, + final int wordIndex + ) { + this.words = words; + this.wordIndex = wordIndex; + } + + @Override + public String word() { + if (wordIndex >= words.size()) { + return StringUtils.EMPTY; + } + return words.get(wordIndex); + } + + @Override + public int wordCursor() { + return 0; + } + + @Override + public int wordIndex() { + return wordIndex; + } + + @Override + public List words() { + return words; + } + + @Override + public String line() { + return StringUtils.join(words, " "); + } + + @Override + public int cursor() { + return 0; + } + } }