RESOLVED - BATCH-608: JobExecutionListener.onInterrupt() is never called by spring batch framework

This commit is contained in:
robokaso
2008-05-05 08:45:12 +00:00
parent 97e0c9478a
commit b684aab2db
2 changed files with 27 additions and 0 deletions

View File

@@ -22,9 +22,11 @@ import java.util.Properties;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
@@ -345,6 +347,30 @@ public class SimpleJobTests extends TestCase {
}
public void testInterruptWithListener() throws Exception {
step1.setProcessException(new JobInterruptedException("job interrupted!"));
MockControl control = MockControl.createStrictControl(JobExecutionListener.class);
JobExecutionListener listener = (JobExecutionListener) control.getMock();
listener.beforeJob(jobExecution);
control.setVoidCallable();
listener.onInterrupt(jobExecution);
control.setVoidCallable();
control.replay();
job.setJobExecutionListeners(new JobExecutionListener[] { listener });
try {
job.execute(jobExecution);
fail();
}
catch (UnexpectedJobExecutionException e){
// expected
}
control.verify();
}
/*
* Check JobRepository to ensure status is being saved.
*/