Assume.assumeTrue(Shell.WINDOWS);
// The tests are built on assuming 8191 max command line length
assertEquals(8191, Shell.WINDOWS_MAX_SHELL_LENGHT);
ShellScriptBuilder builder = ShellScriptBuilder.create();
// Basic tests: less length, exact length, max+1 length
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat("A", 1024)));
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat(
"E", Shell.WINDOWS_MAX_SHELL_LENGHT - callCmd.length())));
try {
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat(
"X", Shell.WINDOWS_MAX_SHELL_LENGHT -callCmd.length() + 1)));
fail("longCommand was expected to throw");
} catch(IOException e) {
assertThat(e.getMessage(), containsString(expectedMessage));
}
// Composite tests, from parts: less, exact and +
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat("A", 1024),
org.apache.commons.lang.StringUtils.repeat("A", 1024),
org.apache.commons.lang.StringUtils.repeat("A", 1024)));
// buildr.command joins the command parts with an extra space
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat("E", 4095),
org.apache.commons.lang.StringUtils.repeat("E", 2047),
org.apache.commons.lang.StringUtils.repeat("E", 2047 - callCmd.length())));
try {
builder.command(Arrays.asList(
org.apache.commons.lang.StringUtils.repeat("X", 4095),
org.apache.commons.lang.StringUtils.repeat("X", 2047),
org.apache.commons.lang.StringUtils.repeat("X", 2048 - callCmd.length())));
fail("long commands was expected to throw");
} catch(IOException e) {