Codota Logo
JobRepositoryTestUtils
Code IndexAdd Codota to your IDE (free)

How to use
JobRepositoryTestUtils
in
org.springframework.batch.test

Best Java code snippets using org.springframework.batch.test.JobRepositoryTestUtils (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-batch

/**
 * Use the {@link JobRepository} to create some {@link JobExecution}
 * instances each with a single step execution.
 *
 * @param count the required number of instances of {@link JobExecution} to
 * create
 * @return a collection of {@link JobExecution}
 * @throws JobExecutionAlreadyRunningException thrown if Job is already running.
 * @throws JobRestartException thrown if Job is not restartable.
 * @throws JobInstanceAlreadyCompleteException thrown if Job Instance is already complete.
 */
public List<JobExecution> createJobExecutions(int count) throws JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException {
  return createJobExecutions("job", new String[] { "step" }, count);
}
origin: spring-projects/spring-batch

/**
 * Create a {@link JobRepositoryTestUtils} with all its mandatory
 * properties.
 *
 * @param jobRepository a {@link JobRepository} backed by a database
 * @param dataSource a {@link DataSource}
 */
public JobRepositoryTestUtils(JobRepository jobRepository, DataSource dataSource) {
  super();
  this.jobRepository = jobRepository;
  setDataSource(dataSource);
}
origin: spring-projects/spring-batch

@Test(expected=IllegalArgumentException.class)
public void testMandatoryDataSource() throws Exception {
  utils = new JobRepositoryTestUtils();
  utils.setJobRepository(jobRepository);
  utils.afterPropertiesSet();
}
origin: spring-projects/spring-batch

@Test
public void testRemoveJobExecutionsIncrementally() throws Exception {
  utils = new JobRepositoryTestUtils(jobRepository, dataSource);
  List<JobExecution> list1 = utils.createJobExecutions(3);
  List<JobExecution> list2 = utils.createJobExecutions(2);
  assertEquals(beforeJobs + 5, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  utils.removeJobExecutions(list2);
  assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  utils.removeJobExecutions(list1);
  assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
origin: spring-projects/spring-batch

  @Test
  public void testCreateJobExecutionsWithIncrementer() throws Exception {
    utils = new JobRepositoryTestUtils(jobRepository, dataSource);
    utils.setJobParametersIncrementer(new JobParametersIncrementer() {
      @Override
      public JobParameters getNext(JobParameters parameters) {
        return new JobParametersBuilder().addString("foo","bar").toJobParameters();
      }
    });
    List<JobExecution> list = utils.createJobExecutions(1);
    assertEquals(1, list.size());
    assertEquals("bar", list.get(0).getJobParameters().getString("foo"));
    utils.removeJobExecutions(list);
    assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  }
}
origin: spring-projects/spring-batch

@Test(expected=IllegalArgumentException.class)
public void testMandatoryProperties() throws Exception {
  utils = new JobRepositoryTestUtils();
  utils.afterPropertiesSet();
}
origin: spring-projects/spring-batch

@Test
public void testRemoveJobExecutionsWithSameJobInstance() throws Exception {
  utils = new JobRepositoryTestUtils(jobRepository, dataSource);
  List<JobExecution> list = new ArrayList<>();
  JobExecution jobExecution = jobRepository.createJobExecution("job", new JobParameters());
  jobExecution.setEndTime(new Date());
  list.add(jobExecution);
  jobRepository.update(jobExecution);
  jobExecution = jobRepository.createJobExecution("job", new JobParameters());
  list.add(jobExecution);
  assertEquals(beforeJobs + 2, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  utils.removeJobExecutions(list);
  assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
origin: spring-projects/spring-batch

/**
 * Remove all the {@link JobExecution} instances, and all associated
 * {@link JobInstance} and {@link StepExecution} instances from the standard
 * RDBMS locations used by Spring Batch.
 *
 * @throws DataAccessException if there is a problem
 */
public void removeJobExecutions() throws DataAccessException {
  jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT"));
  jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION"));
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT"));
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS"));
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION"));
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE"));
}
origin: spring-projects/spring-batch

@Before
public void setUp() {
  this.jobRepositoryTestUtils.removeJobExecutions();
}
origin: spring-projects/spring-batch

@Test
public void testCreateJobExecutions() throws Exception {
  utils = new JobRepositoryTestUtils(jobRepository, dataSource);
  List<JobExecution> list = utils.createJobExecutions(3);
  assertEquals(3, list.size());
  assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  assertEquals(beforeSteps + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
  utils.removeJobExecutions(list);
  assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  assertEquals(beforeSteps, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
}
origin: spring-projects/spring-batch

for (JobExecution jobExecution : list) {
  List<Long> stepExecutionIds = jdbcTemplate.query(
      getQuery("select STEP_EXECUTION_ID from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID=?"),
      new RowMapper<Long>() {
        @Override
    jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT where STEP_EXECUTION_ID=?"),
        stepExecutionId);
    jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION where STEP_EXECUTION_ID=?"),
        stepExecutionId);
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?"),
      jobExecution.getId());
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID=?"), jobExecution
      .getId());
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION where JOB_EXECUTION_ID=?"), jobExecution
      .getId());
  jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE where JOB_INSTANCE_ID=?"), jobExecution
      .getJobId());
origin: spring-projects/spring-batch

@Test
public void testCreateJobExecutionsByName() throws Exception {
  utils = new JobRepositoryTestUtils(jobRepository, dataSource);
  List<JobExecution> list = utils.createJobExecutions("foo",new String[] {"bar", "spam"}, 3);
  assertEquals(3, list.size());
  assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  assertEquals(beforeSteps + 6, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
  utils.removeJobExecutions(list);
  assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
  assertEquals(beforeSteps, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
}
origin: org.springframework.batch/org.springframework.batch.test

/**
 * Create a {@link JobRepositoryTestUtils} with all its mandatory
 * properties.
 * 
 * @param jobRepository a {@link JobRepository} backed by a database
 * @param dataSource a {@link DataSource}
 */
public JobRepositoryTestUtils(JobRepository jobRepository, DataSource dataSource) {
  super();
  this.jobRepository = jobRepository;
  setDataSource(dataSource);
}
org.springframework.batch.testJobRepositoryTestUtils

Javadoc

Convenience class for creating and removing JobExecution instances from a database. Typical usage in test case would be to create instances before a transaction, save the result, and then use it to remove them after the transaction.

Most used methods

  • createJobExecutions
    Use the JobRepository to create some JobExecutioninstances each with the given job name and each hav
  • setDataSource
  • <init>
    Create a JobRepositoryTestUtils with all its mandatory properties.
  • afterPropertiesSet
  • getQuery
  • removeJobExecutions
    Remove the JobExecution instances provided from the standard RDBMS locations used by Spring Batch.
  • setJobParametersIncrementer
  • setJobRepository

Popular in Java

  • Updating database using SQL prepared statement
  • putExtra (Intent)
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now