@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());
    }
  }
  @Before
  public void beforeEachTest() {
    logger.debug("Before Test");

    dataSource = Mockito.mock(DataSource.class);
    Connection connection = Mockito.mock(Connection.class);
    DatabaseMetaData databaseMetaData = Mockito.mock(DatabaseMetaData.class);
    try {
      Mockito.stub(dataSource.getConnection()).toReturn(connection);
      Mockito.stub(connection.getMetaData()).toReturn(databaseMetaData);
    } catch (Exception e) {
      logger.error("Error Occurred Stubbing Datasource or connection", e);
    }
    transactionManager = new DataSourceTransactionManager();
    transactionManager.setTransactionSynchronization(
        DataSourceTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
    transactionManager = Mockito.spy(transactionManager);
    transactionManager.setDataSource(dataSource);

    MapJobInstanceDao jobInstanceDao = new MapJobInstanceDao();
    MapJobExecutionDao jobExecutionDao = new MapJobExecutionDao();
    MapStepExecutionDao stepExecutionDao = new MapStepExecutionDao();
    MapExecutionContextDao ecDao = new MapExecutionContextDao();

    jobLauncherTestUtils = new JobLauncherTestUtils();
    jobRepository =
        new SimpleJobRepository(jobInstanceDao, jobExecutionDao, stepExecutionDao, ecDao);

    jobLauncherTestUtils.setJobRepository(jobRepository);
    // jobConfig = new ProductJobConfig();
    // jobConfig.setJobRepository(jobRepository);
    executionContext = new ExecutionContext();
  }
  @Test
  public void testGenerateIrsReplacementsDataStep() {

    //		Map<String, JobParameter> jobParamsMap = new HashMap<String, JobParameter>();
    //        jobParamsMap.put("time", new JobParameter(System.currentTimeMillis(), false));
    //        jobParamsMap.put("irs1095FormReaderType", new
    // JobParameter("replacement1095ReaderType", false));
    //        JobParameters jobParams = new JobParameters(jobParamsMap);
    //
    //        JobExecution jobExecution =
    // jobLauncherTestUtils.launchStep("generateIrsReplacementsData", jobParams);
    //
    //        Assert.assertEquals("Same status", BatchStatus.COMPLETED, jobExecution.getStatus());

    Map<String, JobParameter> jobParamsMap2 = new HashMap<String, JobParameter>();
    jobParamsMap2.put("time", new JobParameter(System.currentTimeMillis(), false));
    jobParamsMap2.put(
        "irs1095FormReaderType", new JobParameter("replacement1095ReaderType", false));
    JobParameters jobParams2 = new JobParameters(jobParamsMap2);

    // JobExecution jobExecution2 =
    // jobLauncherTestUtils.launchStep("generateXmlAttachmentsForIrsReplacements", jobParams2);

    JobExecution jobExecution2 = null;
    try {
      jobExecution2 = jobLauncherTestUtils.launchJob(jobParams2);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Assert.assertEquals("Same status", BatchStatus.COMPLETED, jobExecution2.getStatus());
  }
 @Test
 public void test() throws Exception {
   Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
   JobExecution jobExecution = jobLauncherTestUtils.launchJob(new JobParameters(parameters));
   Assert.assertEquals(
       jobExecution.getExitStatus().getExitDescription(),
       BatchStatus.COMPLETED,
       jobExecution.getStatus());
   Map<String, Meter> meters = metricRegistry.getMeters();
   assertThat(meters).hasSize(2);
   assertThat(meters)
       .containsKey("batch.sampleJob.job.metered")
       .containsKey("batch.sampleJob.step.chunkStep.step.metered");
   assertThat(extractProperty("count", Number.class).from(meters.values()))
       .contains(1L)
       .doesNotContain(0L);
   Map<String, Timer> timers = metricRegistry.getTimers();
   assertThat(timers).hasSize(6);
   assertThat(timers)
       .containsKey("batch.sampleJob.job.timed")
       .containsKey("batch.sampleJob.step.chunkStep.chunk.timed")
       .containsKey("batch.sampleJob.step.chunkStep.step.timed")
       .containsKey("batch.sampleJob.step.chunkStep.read.timed")
       .containsKey("batch.sampleJob.step.chunkStep.process.timed")
       .containsKey("batch.sampleJob.step.chunkStep.write.timed");
   assertThat(extractProperty("count", Number.class).from(timers.values()))
       .contains(1L, 3L, 4L)
       .doesNotContain(0L);
   Map<String, Gauge> gauges = metricRegistry.getGauges();
   assertThat(gauges).hasSize(0);
 }
  @Test
  public void testJobLaunch() throws Exception {
    jdbcTemplate.update("DELETE from TRADE");
    int before = jdbcTemplate.queryForObject("SELECT COUNT(*) from TRADE", Integer.class);

    jobLauncherTestUtils.launchJob();

    checkOutputFile("target/test-outputs/CustomerReport1.txt");
    checkOutputFile("target/test-outputs/CustomerReport2.txt");
    checkOutputTable(before);
  }
  /** Launch Test. */
  @Test
  public void launchJob() throws Exception {
    // Job parameters
    Map<String, JobParameter> jobParametersMap = new HashMap<String, JobParameter>();
    jobParametersMap.put("time", new JobParameter(System.currentTimeMillis()));
    jobParametersMap.put(
        "input.file.1",
        new JobParameter("file:src/test/resources/input/parallel-flows/input1.txt"));
    jobParametersMap.put(
        "input.file.2",
        new JobParameter("file:src/test/resources/input/parallel-flows/input2.txt"));
    jobParametersMap.put(
        "input.file.3",
        new JobParameter("file:src/test/resources/input/parallel-flows/input3.txt"));

    // launch the job
    JobExecution jobExecution = jobLauncherTestUtils.launchJob(new JobParameters(jobParametersMap));

    // assert job run status
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
  }