Package org.springframework.batch.core.launch

Examples of org.springframework.batch.core.launch.JobLauncher


        // When
        template.sendBody("direct:launcherRefTest", "Start the job, please.");

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobLauncherRef=alternativeJobLauncher", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here


        // When
        camelContext.start();

        // Then
        SpringBatchEndpoint batchEndpoint = camelContext.getEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(jobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

            }
        });

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("customBatchComponent:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

        }
    }

    private JobLauncher resolveJobLauncher() {
        if (jobLauncherRef != null) {
            JobLauncher jobLauncher = getCamelContext().getRegistry().lookupByNameAndType(jobLauncherRef, JobLauncher.class);
            if (jobLauncher == null) {
                throw new IllegalStateException(String.format("No JobLauncher named %s found in the registry.", jobLauncherRef));
            }
            return jobLauncher;
        }
View Full Code Here

    System.out.println("TEST");
        AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/*-context.xml");
        log.info("Batch Tweet Influencers Hive Job Running");
        context.registerShutdownHook();

        JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        Job job = context.getBean(Job.class);
        jobLauncher.run(job, new JobParameters());

    }
View Full Code Here

    setUp("JobLaunchingGatewayParserTestsWithEnableBatchProcessing-context.xml", getClass());
    final JobLaunchingMessageHandler jobLaunchingMessageHandler = TestUtils.getPropertyValue(this.consumer, "handler.jobLaunchingMessageHandler", JobLaunchingMessageHandler.class);
    assertNotNull(jobLaunchingMessageHandler);

    final JobLauncher jobLauncher = TestUtils.getPropertyValue(jobLaunchingMessageHandler, "jobLauncher", JobLauncher.class);
    assertNotNull(jobLauncher);

  }
View Full Code Here

  public void testExceptionRaised() throws Exception {

    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
View Full Code Here

  public void testExceptionRaised() throws Exception {

    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
View Full Code Here

      public Set<String> getJobNames() {
        return new HashSet<String>(Arrays.asList(new String[] { "foo", "bar" }));
      }
    });

    jobOperator.setJobLauncher(new JobLauncher() {
      @Override
      public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
      JobRestartException, JobInstanceAlreadyCompleteException {
        return new JobExecution(new JobInstance(123L, job.getName()), 999L, jobParameters, null);
      }
View Full Code Here

  @Test
  public void testAsyncStopOfStartingJob() throws Exception {
    ApplicationContext applicationContext =
        new ClassPathXmlApplicationContext("org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests-context.xml");
    Job job = applicationContext.getBean(Job.class);
    JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);
    JobOperator jobOperator = applicationContext.getBean(JobOperator.class);

    JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder()
        .addLong("test", 1L)
        .toJobParameters());

    Thread.sleep(1000);

    jobOperator.stop(jobExecution.getId());

    while(jobExecution.isRunning()) {
      // wait for async launched job to complete execution
    }

    int numStepExecutions = jobExecution.getStepExecutions().size();
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    String stepName = stepExecution.getStepName();
    BatchStatus stepExecutionStatus = stepExecution.getStatus();
    BatchStatus jobExecutionStatus = jobExecution.getStatus();

    assertTrue("Should only be one StepExecution but got: " + numStepExecutions, numStepExecutions == 1);
    assertTrue("Step name for execution should be step1 but got: " + stepName, "step1".equals(stepName));
    assertTrue("Step execution status should be STOPPED but got: " + stepExecutionStatus, stepExecutionStatus.equals(BatchStatus.STOPPED));
    assertTrue("Job execution status should be STOPPED but got:" + jobExecutionStatus, jobExecutionStatus.equals(BatchStatus.STOPPED));

    JobExecution restartJobExecution = jobLauncher.run(job, new JobParametersBuilder()
        .addLong("test", 1L)
        .toJobParameters());

    while(restartJobExecution.isRunning()) {
      // wait for async launched job to complete execution
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.launch.JobLauncher

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.