BATCH-2667: update warning message to be more explicit

Before this commit, when a job execution is stopped from a different
JVM than the one running the job, a warning says that the job cannot
be found. This was confusing to some users since the job can be found
in the database (but is actually not defined in the job registry of
the application context of the second JVM).

After this commit is applied, the warning will be more explicit to
inform the user that the job cannot be found in the job registry
(to not be confused with the database)

Resolves BATCH-2667
This commit is contained in:
Mahmoud Ben Hassine
2018-01-16 10:58:14 +01:00
parent 020d0519ac
commit d81ab76823
2 changed files with 21 additions and 1 deletions

View File

@@ -60,6 +60,8 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
@@ -365,6 +367,24 @@ public class SimpleJobOperatorTests {
jobOperator.stop(111L);
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
}
@Test
public void testStopTaskletWhenJobNotRegistered() throws Exception {
JobInstance jobInstance = new JobInstance(123L, job.getName());
JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
StoppableTasklet tasklet = mock(StoppableTasklet.class);
JobRegistry jobRegistry = mock(JobRegistry.class);
TaskletStep step = mock(TaskletStep.class);
when(step.getTasklet()).thenReturn(tasklet);
when(jobRegistry.getJob(job.getName())).thenThrow(new NoSuchJobException("Unable to find job"));
when(jobExplorer.getJobExecution(111L)).thenReturn(jobExecution);
jobOperator.setJobRegistry(jobRegistry);
jobOperator.stop(111L);
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
verify(tasklet, never()).stop();
}
@Test
public void testStopTaskletException() throws Exception {