@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);
   }
 }
  private SimpleJob importProductsJob() throws Exception {
    // Create Job
    SimpleJob bean = new SimpleJob();
    bean.setName("importProductsJob");
    bean.setJobRepository(jobRepository);
    bean.afterPropertiesSet();

    // Create Steps
    List<Step> steps = new ArrayList<Step>();

    // Create Tasklet Step
    TaskletStep step = new TaskletStep();
    step.setName("importProducts");
    step.setTransactionManager(transactionManager);
    step.setJobRepository(jobRepository);
    step.setStartLimit(100);

    // Create repeat template for Chunk Size
    RepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate();
    repeatTemplate.setCompletionPolicy(new SimpleCompletionPolicy(5));
    // TaskletStep <- RepeatTemplate
    step.setStepOperations(repeatTemplate);

    // Create Chunk Tasklet with Provider (reader) and Chunk Processor
    // Tasklet <- ChunkProvider <- ItemReader, RepeatTemplate
    // Tasklet <- ChunkProcessor <- ItemProcessor, ItemWriter
    ChunkOrientedTasklet<Product> tasklet =
        new ChunkOrientedTasklet<Product>(
            new SimpleChunkProvider<Product>(productReader(), repeatTemplate),
            new SimpleChunkProcessor<Product, Product>(
                new PassThroughItemProcessor<Product>(), new ProductItemLoggerWriter()));

    // Job <- Steps <- TaskletStep <- Tasklet
    step.setTasklet(tasklet);
    // Job <- Steps <- TaskletStep
    steps.add(step);
    // Job <- Steps
    bean.setSteps(steps);
    return bean;
  }