Minor polish
This commit is contained in:
@@ -73,7 +73,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
tasklet = new SystemCommandTasklet();
|
||||
tasklet.setEnvironmentParams(null); // inherit from parent process
|
||||
tasklet.setWorkingDirectory(null); // inherit from parent process
|
||||
tasklet.setSystemProcessExitCodeMapper(new TestExitCodeMapper());
|
||||
tasklet.setSystemProcessExitCodeMapper(new SimpleSystemProcessExitCodeMapper());
|
||||
tasklet.setTimeout(5000); // long enough timeout
|
||||
tasklet.setTerminationCheckInterval(500);
|
||||
tasklet.setCommand("invalid command, change value for successful execution");
|
||||
@@ -136,7 +136,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteTimeout() throws Exception {
|
||||
String command = System.getProperty("os.name").toLowerCase().contains("win") ?
|
||||
String command = isRunningOnWindows() ?
|
||||
"ping 127.0.0.1" :
|
||||
"sleep 3";
|
||||
tasklet.setCommand(command);
|
||||
@@ -158,7 +158,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void testInterruption() throws Exception {
|
||||
String command = System.getProperty("os.name").toLowerCase().contains("win") ?
|
||||
String command = isRunningOnWindows() ?
|
||||
"ping 127.0.0.1" :
|
||||
"sleep 5";
|
||||
tasklet.setCommand(command);
|
||||
@@ -269,7 +269,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
|
||||
when(jobExplorer.getJobExecution(1L)).thenReturn(stepExecution.getJobExecution(), stepExecution.getJobExecution(), stoppedJobExecution);
|
||||
|
||||
String command = System.getProperty("os.name").toLowerCase().contains("win") ?
|
||||
String command = isRunningOnWindows() ?
|
||||
"ping 127.0.0.1 -n 5" :
|
||||
"sleep 15";
|
||||
tasklet.setCommand(command);
|
||||
@@ -281,7 +281,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
ChunkContext chunkContext = new ChunkContext(stepContext);
|
||||
tasklet.execute(contribution, chunkContext);
|
||||
|
||||
assertEquals(contribution.getExitStatus().getExitCode(),ExitStatus.STOPPED.getExitCode());
|
||||
assertEquals(ExitStatus.STOPPED.getExitCode(), contribution.getExitStatus().getExitCode());
|
||||
}
|
||||
|
||||
private String getJavaCommand() {
|
||||
@@ -294,29 +294,15 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
command.append(fileSeparator);
|
||||
command.append("java");
|
||||
|
||||
if(System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) {
|
||||
if(isRunningOnWindows()) {
|
||||
command.append(".exe");
|
||||
}
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit code mapper containing mapping logic expected by the tests. 0 means
|
||||
* finished successfully, other value means failure.
|
||||
*/
|
||||
private static class TestExitCodeMapper implements SystemProcessExitCodeMapper {
|
||||
|
||||
@Override
|
||||
public ExitStatus getExitStatus(int exitCode) {
|
||||
if (exitCode == 0) {
|
||||
return ExitStatus.COMPLETED;
|
||||
}
|
||||
else {
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRunningOnWindows() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("win");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user