@Test public void testPropertyFileLoaderJob() { try { logger.debug("Begin Testing File Loader"); SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setTaskExecutor(new SyncTaskExecutor()); jobLauncher.setJobRepository(jobRepository); jobLauncherTestUtils.setJobLauncher(jobLauncher); SimpleJob job = importProductsJob(); logJobDetails(job); jobLauncherTestUtils.setJob(job); JobExecution exec = jobLauncherTestUtils.launchJob(new JobParameters()); Collection<String> stepNames = job.getStepNames(); for (String stepName : stepNames) { TaskletStep step = (TaskletStep) job.getStep(stepName); step.setTransactionManager(transactionManager); } assertTrue("Steps MUST exist", stepNames != null); assertTrue("At least ONE step MUST exist", stepNames.size() > 0); Assert.assertTrue( "Product Repository MUST have records", jobRepository.isJobInstanceExists(job.getName(), new JobParameters())); logger.debug("Job Execution Status {}", exec.getExitStatus()); logJobRepository(exec); Assert.assertEquals(BatchStatus.COMPLETED, exec.getStatus()); } catch (Exception e) { logger.error(e.getMessage(), e); Assert.fail(e.getMessage()); } }
private void logJobDetails(SimpleJob job) { logger.debug("*** Logging Job Details for {} ****", job); Collection<String> steps = job.getStepNames(); logger.debug("Job {} contains {} steps", job.getName(), steps.size()); for (String stepName : steps) { logger.debug("\t --> Step Name '{}'", job.getName(), stepName); TaskletStep step = (TaskletStep) job.getStep(stepName); logger.debug("\t --> Step Details {}", step); } }