NIFI-604: Removed unused import, as it caused checkstyle violation

This commit is contained in:
Mark Payne 2015-09-24 10:06:39 -04:00
parent 193dbe6533
commit 24c080788f
1 changed files with 203 additions and 204 deletions

View File

@ -16,14 +16,9 @@
*/ */
package org.apache.nifi.processors.standard; package org.apache.nifi.processors.standard;
import org.apache.nifi.processor.Processor; import static org.junit.Assert.assertEquals;
import org.apache.nifi.processors.standard.util.ArgumentUtils; import static org.junit.Assert.assertFalse;
import org.apache.nifi.util.MockFlowFile; import static org.junit.Assert.assertTrue;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -35,220 +30,224 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.junit.Assert.assertEquals; import org.apache.nifi.processors.standard.util.ArgumentUtils;
import static org.junit.Assert.assertFalse; import org.apache.nifi.util.MockFlowFile;
import static org.junit.Assert.assertTrue; import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/** /**
* *
*/ */
public class TestExecuteStreamCommand { public class TestExecuteStreamCommand {
@BeforeClass @BeforeClass
public static void init() { public static void init() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
System.setProperty("org.slf4j.simpleLogger.showDateTime", "true"); System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.ExecuteStreamCommand", "debug"); System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.ExecuteStreamCommand", "debug");
System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestExecuteStreamCommand", "debug"); System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestExecuteStreamCommand", "debug");
} }
@Test @Test
public void testExecuteJar() throws Exception { public void testExecuteJar() throws Exception {
File exJar = new File("src/test/resources/ExecuteCommand/TestSuccess.jar"); File exJar = new File("src/test/resources/ExecuteCommand/TestSuccess.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
MockFlowFile outputFlowFile = flowFiles.get(0); MockFlowFile outputFlowFile = flowFiles.get(0);
byte[] byteArray = outputFlowFile.toByteArray(); byte[] byteArray = outputFlowFile.toByteArray();
String result = new String(byteArray); String result = new String(byteArray);
assertTrue(Pattern.compile("Test was a success\r?\n").matcher(result).find()); assertTrue(Pattern.compile("Test was a success\r?\n").matcher(result).find());
assertEquals("0", outputFlowFile.getAttribute("execution.status")); assertEquals("0", outputFlowFile.getAttribute("execution.status"));
assertEquals("java", outputFlowFile.getAttribute("execution.command")); assertEquals("java", outputFlowFile.getAttribute("execution.command"));
assertEquals("-jar;", outputFlowFile.getAttribute("execution.command.args").substring(0, 5)); assertEquals("-jar;", outputFlowFile.getAttribute("execution.command.args").substring(0, 5));
String attribute = outputFlowFile.getAttribute("execution.command.args"); String attribute = outputFlowFile.getAttribute("execution.command.args");
String expected = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ExecuteCommand" + File.separator + "TestSuccess.jar"; String expected = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ExecuteCommand" + File.separator + "TestSuccess.jar";
assertEquals(expected, attribute.substring(attribute.length() - expected.length())); assertEquals(expected, attribute.substring(attribute.length() - expected.length()));
MockFlowFile originalFlowFile = controller.getFlowFilesForRelationship(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP).get(0); MockFlowFile originalFlowFile = controller.getFlowFilesForRelationship(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP).get(0);
assertEquals(outputFlowFile.getAttribute("execution.status"), originalFlowFile.getAttribute("execution.status")); assertEquals(outputFlowFile.getAttribute("execution.status"), originalFlowFile.getAttribute("execution.status"));
assertEquals(outputFlowFile.getAttribute("execution.command"), originalFlowFile.getAttribute("execution.command")); assertEquals(outputFlowFile.getAttribute("execution.command"), originalFlowFile.getAttribute("execution.command"));
assertEquals(outputFlowFile.getAttribute("execution.command.args"), originalFlowFile.getAttribute("execution.command.args")); assertEquals(outputFlowFile.getAttribute("execution.command.args"), originalFlowFile.getAttribute("execution.command.args"));
} }
@Test @Test
public void testExecuteJarWithBadPath() throws Exception { public void testExecuteJarWithBadPath() throws Exception {
File exJar = new File("src/test/resources/ExecuteCommand/noSuchFile.jar"); File exJar = new File("src/test/resources/ExecuteCommand/noSuchFile.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
assertEquals(0, flowFiles.get(0).getSize()); assertEquals(0, flowFiles.get(0).getSize());
assertEquals("Error: Unable to access jarfile", flowFiles.get(0).getAttribute("execution.error").substring(0, 31)); assertEquals("Error: Unable to access jarfile", flowFiles.get(0).getAttribute("execution.error").substring(0, 31));
} }
@Test @Test
public void testExecuteIngestAndUpdate() throws IOException { public void testExecuteIngestAndUpdate() throws IOException {
File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar"); File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
File dummy100MBytes = new File("target/100MB.txt"); File dummy100MBytes = new File("target/100MB.txt");
FileInputStream fis = new FileInputStream(dummy); FileInputStream fis = new FileInputStream(dummy);
FileOutputStream fos = new FileOutputStream(dummy100MBytes); FileOutputStream fos = new FileOutputStream(dummy100MBytes);
byte[] bytes = new byte[1024]; byte[] bytes = new byte[1024];
assertEquals(1000, fis.read(bytes)); assertEquals(1000, fis.read(bytes));
fis.close(); fis.close();
for (int i = 0; i < 100000; i++) { for (int i = 0; i < 100000; i++) {
fos.write(bytes, 0, 1000); fos.write(bytes, 0, 1000);
} }
fos.close(); fos.close();
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy100MBytes.toPath()); controller.enqueue(dummy100MBytes.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
byte[] byteArray = flowFiles.get(0).toByteArray(); byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray); String result = new String(byteArray);
assertTrue(Pattern.compile("nifi-standard-processors:ModifiedResult\r?\n").matcher(result).find()); assertTrue(Pattern.compile("nifi-standard-processors:ModifiedResult\r?\n").matcher(result).find());
} }
@Test @Test
public void testExecuteIngestAndUpdateWithWorkingDir() throws IOException { public void testExecuteIngestAndUpdateWithWorkingDir() throws IOException {
File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar"); File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target"); controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target");
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
byte[] byteArray = flowFiles.get(0).toByteArray(); byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray); String result = new String(byteArray);
final String quotedSeparator = Pattern.quote(File.separator); final String quotedSeparator = Pattern.quote(File.separator);
assertTrue(Pattern.compile(quotedSeparator + "nifi-standard-processors" + quotedSeparator + "target:ModifiedResult\r?\n").matcher(result).find()); assertTrue(Pattern.compile(quotedSeparator + "nifi-standard-processors" + quotedSeparator + "target:ModifiedResult\r?\n").matcher(result).find());
} }
@Test @Test
public void testIgnoredStdin() throws IOException { public void testIgnoredStdin() throws IOException {
File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar"); File exJar = new File("src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target"); controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target");
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.setProperty(ExecuteStreamCommand.IGNORE_STDIN, "true"); controller.setProperty(ExecuteStreamCommand.IGNORE_STDIN, "true");
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
byte[] byteArray = flowFiles.get(0).toByteArray(); byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray); String result = new String(byteArray);
assertTrue("TestIngestAndUpdate.jar should not have received anything to modify", assertTrue("TestIngestAndUpdate.jar should not have received anything to modify",
Pattern.compile("target:ModifiedResult\r?\n$").matcher(result).find()); Pattern.compile("target:ModifiedResult\r?\n$").matcher(result).find());
} }
// this is dependent on window with cygwin...so it's not enabled // this is dependent on window with cygwin...so it's not enabled
@Ignore @Ignore
@Test @Test
public void testExecuteTouch() throws Exception { public void testExecuteTouch() throws Exception {
File testFile = new File("target/test.txt"); File testFile = new File("target/test.txt");
testFile.delete(); testFile.delete();
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target/xx1"); controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target/xx1");
controller.setThreadCount(6); controller.setThreadCount(6);
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "c:\\cygwin\\bin\\touch"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "c:\\cygwin\\bin\\touch");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "test.txt"); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "test.txt");
controller.assertValid(); controller.assertValid();
controller.run(6); controller.run(6);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
assertEquals(5, flowFiles.size()); assertEquals(5, flowFiles.size());
assertEquals(0, flowFiles.get(0).getSize()); assertEquals(0, flowFiles.get(0).getSize());
} }
@Test @Test
public void testDynamicEnvironment() throws Exception { public void testDynamicEnvironment() throws Exception {
File exJar = new File("src/test/resources/ExecuteCommand/TestDynamicEnvironment.jar"); File exJar = new File("src/test/resources/ExecuteCommand/TestDynamicEnvironment.jar");
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt"); File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath(); String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true); exJar.setExecutable(true);
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setProperty("NIFI_TEST_1", "testvalue1"); controller.setProperty("NIFI_TEST_1", "testvalue1");
controller.setProperty("NIFI_TEST_2", "testvalue2"); controller.setProperty("NIFI_TEST_2", "testvalue2");
controller.setValidateExpressionUsage(false); controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath()); controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target"); controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target");
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath); controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1); controller.run(1);
controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1); controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP); List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
byte[] byteArray = flowFiles.get(0).toByteArray(); byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray); String result = new String(byteArray);
Set<String> dynamicEnvironmentVariables = new HashSet<>(Arrays.asList(result.split("\r?\n"))); Set<String> dynamicEnvironmentVariables = new HashSet<>(Arrays.asList(result.split("\r?\n")));
assertFalse("Should contain at least two environment variables starting with NIFI", dynamicEnvironmentVariables.size() < 2); assertFalse("Should contain at least two environment variables starting with NIFI", dynamicEnvironmentVariables.size() < 2);
assertTrue("NIFI_TEST_1 environment variable is missing", dynamicEnvironmentVariables.contains("NIFI_TEST_1=testvalue1")); assertTrue("NIFI_TEST_1 environment variable is missing", dynamicEnvironmentVariables.contains("NIFI_TEST_1=testvalue1"));
assertTrue("NIFI_TEST_2 environment variable is missing", dynamicEnvironmentVariables.contains("NIFI_TEST_2=testvalue2")); assertTrue("NIFI_TEST_2 environment variable is missing", dynamicEnvironmentVariables.contains("NIFI_TEST_2=testvalue2"));
} }
@Test @Test
public void testQuotedArguments() throws Exception { public void testQuotedArguments() throws Exception {
List<String> args = ArgumentUtils.splitArgs("echo -n \"arg1 arg2 arg3\"", ' '); List<String> args = ArgumentUtils.splitArgs("echo -n \"arg1 arg2 arg3\"", ' ');
assertEquals(3, args.size()); assertEquals(3, args.size());
args = ArgumentUtils.splitArgs("echo;-n;\"arg1 arg2 arg3\"", ';'); args = ArgumentUtils.splitArgs("echo;-n;\"arg1 arg2 arg3\"", ';');
assertEquals(3, args.size()); assertEquals(3, args.size());
} }
@Test @Test
public void testInvalidDelimiter() throws Exception { public void testInvalidDelimiter() throws Exception {
final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class); final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "echo"); controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "echo");
controller.assertValid(); controller.assertValid();
controller.setProperty(ExecuteStreamCommand.ARG_DELIMITER, "foo"); controller.setProperty(ExecuteStreamCommand.ARG_DELIMITER, "foo");
controller.assertNotValid(); controller.assertNotValid();
controller.setProperty(ExecuteStreamCommand.ARG_DELIMITER, "f"); controller.setProperty(ExecuteStreamCommand.ARG_DELIMITER, "f");
controller.assertValid(); controller.assertValid();
} }
} }