Package org.springframework.batch.core.repository

Examples of org.springframework.batch.core.repository.JobRepository


  @Before
  public void init() throws Exception {
    context.register(BatchConfiguration.class);
    context.refresh();
    JobRepository jobRepository = context.getBean(JobRepository.class);
    jobLauncher = context.getBean(JobLauncher.class);
    jobs = new JobBuilderFactory(jobRepository);
    PlatformTransactionManager transactionManager = this.context.getBean(PlatformTransactionManager.class);
    steps = new StepBuilderFactory(jobRepository, transactionManager);
    step = steps.get("step").tasklet(new Tasklet() {
View Full Code Here


*/
public class StepBuilderTests {

  @Test
  public void test() throws Exception {
    JobRepository jobRepository = new MapJobRepositoryFactoryBean().getObject();
    StepExecution execution = jobRepository.createJobExecution("foo", new JobParameters()).createStepExecution(
        "step");
    jobRepository.add(execution);
    PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
    TaskletStepBuilder builder = new StepBuilder("step").repository(jobRepository)
        .transactionManager(transactionManager).tasklet(new Tasklet() {
          @Override
          public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
View Full Code Here

    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
  }

  @Test
  public void testListeners() throws Exception {
    JobRepository jobRepository = new MapJobRepositoryFactoryBean().getJobRepository();
    StepExecution execution = jobRepository.createJobExecution("foo", new JobParameters()).createStepExecution("step");
    jobRepository.add(execution);
    PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
    TaskletStepBuilder builder = new StepBuilder("step")
                       .repository(jobRepository)
                       .transactionManager(transactionManager)
                       .listener(new InterfaceBasedStepExecutionListener())
View Full Code Here

    assertEquals(1, AnnotationBasedStepExecutionListener.afterStepCount);
  }

  @Test
  public void testItemListeners() throws Exception {
    JobRepository jobRepository = new MapJobRepositoryFactoryBean().getJobRepository();
    StepExecution execution = jobRepository.createJobExecution("foo", new JobParameters()).createStepExecution("step");
    jobRepository.add(execution);
    PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();

    List<String> items = new ArrayList<String>() {{
      add("1");
      add("2");
View Full Code Here

  @Override
  public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    if(bean instanceof JobFactoryBean) {
      JobFactoryBean fb = (JobFactoryBean) bean;
      JobRepository jobRepository = fb.getJobRepository();
      if (jobRepository == null) {
        fb.setJobRepository((JobRepository) applicationContext.getBean(DEFAULT_JOB_REPOSITORY_NAME));
      }
    }
View Full Code Here

    JobRepositoryFactoryBean repositoryFactory = new JobRepositoryFactoryBean();
    repositoryFactory.setDataSource(dataSource);
    repositoryFactory.setTransactionManager(transactionManager);
    repositoryFactory.afterPropertiesSet();
    JobRepository repository = repositoryFactory.getObject();
    factory.setJobRepository(repository);

    JobExecution jobExecution = repository.createJobExecution("job", new JobParameters());
    StepExecution stepExecution = jobExecution.createStepExecution(factory.getName());
    repository.add(stepExecution);

    Step step = factory.getObject();

    step.execute(stepExecution);
    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
View Full Code Here

   * @return
   */
  private Object injectDefaults(Object bean) {
    if (bean instanceof JobParserJobFactoryBean) {
      JobParserJobFactoryBean fb = (JobParserJobFactoryBean) bean;
      JobRepository jobRepository = fb.getJobRepository();
      if (jobRepository == null) {
        fb.setJobRepository((JobRepository) applicationContext.getBean(DEFAULT_JOB_REPOSITORY_NAME));
      }
    } else if (bean instanceof StepParserStepFactoryBean) {
      StepParserStepFactoryBean<?, ?> fb = (StepParserStepFactoryBean<?, ?>) bean;
      JobRepository jobRepository = fb.getJobRepository();
      if (jobRepository == null) {
        fb.setJobRepository((JobRepository) applicationContext.getBean(DEFAULT_JOB_REPOSITORY_NAME));
      }
      PlatformTransactionManager transactionManager = fb.getTransactionManager();
      if (transactionManager == null && fb.requiresTransactionManager()) {
View Full Code Here

   * created executions.
   */
  @Test
  public void testCreateRepository() throws Exception {
    tested.afterPropertiesSet();
    JobRepository repository = tested.getObject();
    Job job = new JobSupport("jobName");
    JobParameters jobParameters = new JobParameters();

    repository.createJobExecution(job.getName(), jobParameters);

    try {
      repository.createJobExecution(job.getName(), jobParameters);
      fail("Expected JobExecutionAlreadyRunningException");
    }
    catch (JobExecutionAlreadyRunningException e) {
      // expected
    }
View Full Code Here

    assertDummyTransactionManager("overrideTxMgrOnParentStep", "dummyTxMgr2", ctx);
  }

  private void assertDummyJobRepository(String beanName, String jobRepoName, ApplicationContext ctx) throws Exception {
    JobRepository jobRepository = getJobRepository(beanName, ctx);
    assertTrue(jobRepository instanceof DummyJobRepository);
    assertEquals(jobRepoName, ((DummyJobRepository) jobRepository).getName());
  }
View Full Code Here

  public void testRunningJobExecution() throws Exception {

    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean();
    repositoryFactory.afterPropertiesSet();
    JobRepository jobRepository = repositoryFactory.getObject();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    jobLauncher.afterPropertiesSet();

    SimpleJob job = new SimpleJob("job");
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.repository.JobRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.