LoggerContextJobListener implements JobExecutionListener { @Override public void beforeJob(JobExecution jobExecution) { MDC.put(JOB_EXECUTION_ID, jobExecution.getId().toString()); MDC.put(JOB_INSTANCE_ID, jobExecution.getJobId().toString()); }  @Override void beforeJob(JobExecution jobExecution); @Override void afterJob(JobExecution jobExecution); static final String JOB_EXECUTION_ID; static final String JOB_INSTANCE_ID; }
@Test public void testBeforeJob() throws Exception { listener.beforeJob(jobExecution); Assert.assertEquals(EXECUTION_ID.toString(), MDC.get(LoggerContextJobListener.JOB_EXECUTION_ID)); Assert.assertEquals(INSTANCE_ID.toString(), MDC.get(LoggerContextJobListener.JOB_INSTANCE_ID)); }