final boolean testIsCommand = true;
final File testScriptFile = null;
final String[] testArgs = {"id"};
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
final ExecTaskParameterGenerator testGen = new ExecTaskParameterGeneratorImpl(
);
final ExecTaskParameters params = testGen.generate(nodeentry, testIsCommand, testScriptFile,
testArgs);
assertEquals("Wrong executable for local unix command", "/bin/sh", params.getCommandexecutable());
assertArrayEquals("Wrong argline for local command", new String[]{"-c", "id"}, params.getCommandArgs());
}
{
//command input with unix os-family
final String testOs = "unix";
final boolean testIsCommand = true;
final File testScriptFile = null;
final String[] testArgs = {"id","&&","hostname"};
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
nodeentry.setOsFamily(testOs);
final ExecTaskParameterGenerator testGen = new ExecTaskParameterGeneratorImpl(
);
final ExecTaskParameters params = testGen.generate(nodeentry, testIsCommand, testScriptFile,
testArgs);
assertEquals("Wrong executable for local unix command", "/bin/sh", params.getCommandexecutable());
assertArrayEquals("Wrong argline for local command", new String[]{"-c","id && hostname"},
params.getCommandArgs());
}
{
//basic command with windows os-family
final String testOs = "windows";
final boolean testIsCommand = true;
final File testScriptFile = null;
final String[] testArgs = {"id"};
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
nodeentry.setOsFamily(testOs);
final ExecTaskParameterGenerator testGen = new ExecTaskParameterGeneratorImpl(
);
final ExecTaskParameters params = testGen.generate(nodeentry, testIsCommand, testScriptFile,
testArgs);
assertEquals("Wrong executable for local windows command", "cmd.exe", params.getCommandexecutable());
assertArrayEquals("Wrong argline for local command", new String[]{"/c", "id"}, params.getCommandArgs());
}
{
// command with windows os-family
final String testOs = "windows";
final boolean testIsCommand = true;
final File testScriptFile = null;
final String[] testArgs = {"id","potato","hell"};
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
nodeentry.setOsFamily(testOs);
final ExecTaskParameterGenerator testGen = new ExecTaskParameterGeneratorImpl(
);
final ExecTaskParameters params = testGen.generate(nodeentry, testIsCommand, testScriptFile,
testArgs);
assertEquals("Wrong executable for local windows command", "cmd.exe", params.getCommandexecutable());
assertArrayEquals("Wrong argline for local command", new String[]{"/c", "id", "potato", "hell"},
params.getCommandArgs());
}
{// quoted command with windows os-family
final String testOs = "windows";
final boolean testIsCommand = true;
final File testScriptFile = null;
final String[] testArgs = {"echo","test belief"};
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
nodeentry.setOsFamily(testOs);
final ExecTaskParameterGenerator testGen = new ExecTaskParameterGeneratorImpl(
);
final ExecTaskParameters params = testGen.generate(nodeentry, testIsCommand, testScriptFile,
testArgs);