Search in sources :

Example 41 with JobExecution

use of org.springframework.batch.core.JobExecution in project hub-alert by blackducksoftware.

the class CommonConfig method createJobExecution.

public JobExecution createJobExecution() throws Exception {
    final JobParameters param = new JobParametersBuilder().addString(JOB_ID_PROPERTY_NAME, createJobID()).toJobParameters();
    final JobExecution execution = jobLauncher.run(createJob(reader(), processor(), writer()), param);
    return execution;
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobParametersBuilder(org.springframework.batch.core.JobParametersBuilder) JobParameters(org.springframework.batch.core.JobParameters)

Example 42 with JobExecution

use of org.springframework.batch.core.JobExecution in project camel by apache.

the class SpringBatchEndpointTest method shouldReturnJobExecution.

@Test
public void shouldReturnJobExecution() throws Exception {
    // Given
    JobExecution jobExecution = mock(JobExecution.class);
    when(jobLauncher.run(eq(job), any(JobParameters.class))).thenReturn(jobExecution);
    // When
    sendBody("direct:start", "Start the job, please.");
    // Then
    mockEndpoint.expectedBodiesReceived(jobExecution);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobParameters(org.springframework.batch.core.JobParameters) Test(org.junit.Test)

Example 43 with JobExecution

use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.

the class KrameriusHarvestJobTest method execute.

@Test
public void execute() throws Exception {
    init();
    Job job = jobRegistry.getJob("krameriusHarvestJob");
    Map<String, JobParameter> params = new HashMap<String, JobParameter>();
    params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(99002L));
    JobParameters jobParams = new JobParameters(params);
    JobExecution execution = jobLauncher.run(job, jobParams);
    Assert.assertEquals(execution.getExitStatus(), ExitStatus.COMPLETED);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) Job(org.springframework.batch.core.Job) JobParameter(org.springframework.batch.core.JobParameter) Test(org.testng.annotations.Test)

Example 44 with JobExecution

use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.

the class DeleteAllHarvestsJobTest method execute.

@Test
public void execute() throws Exception {
    JobExecution exec = jobExecutor.execute("deleteAllHarvestsJob", new JobParameters());
    Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobParameters(org.springframework.batch.core.JobParameters) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 45 with JobExecution

use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.

the class OAIHarvestJobTest method testJobParamsTransformation.

@Test
public void testJobParamsTransformation() throws Exception {
    reset(httpClient);
    InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
    InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsFrom.xml");
    expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
    expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListRecords&metadataPrefix=marc21&from=2015-01-02T01%3A00%3A00Z")).andReturn(response1);
    replay(httpClient);
    Map<String, JobParameter> params = new HashMap<>();
    params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
    params.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter(new Date(1420156800000L)));
    JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST, new JobParameters(params));
    Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
    reset(httpClient);
    response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
    response1 = this.getClass().getResourceAsStream("/sample/ListRecordsFrom.xml");
    expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
    expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListRecords&metadataPrefix=marc21&from=2015-01-03T01%3A00%3A00Z")).andReturn(response1);
    replay(httpClient);
    params = new HashMap<>();
    params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter("300"));
    params.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter("2015-01-03T01:00:00Z"));
    exec = jobExecutor.execute(Constants.JOB_ID_HARVEST, new JobParameters(params));
    Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) InputStream(java.io.InputStream) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) Date(java.util.Date) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

JobExecution (org.springframework.batch.core.JobExecution)75 JobParameters (org.springframework.batch.core.JobParameters)52 JobParameter (org.springframework.batch.core.JobParameter)42 HashMap (java.util.HashMap)41 Test (org.testng.annotations.Test)36 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)30 InputStream (java.io.InputStream)25 Job (org.springframework.batch.core.Job)16 Date (java.util.Date)15 JobInstance (org.springframework.batch.core.JobInstance)14 Test (org.junit.Test)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 JobExplorer (org.springframework.batch.core.explore.JobExplorer)11 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)9 OAIHarvestConfiguration (cz.mzk.recordmanager.server.model.OAIHarvestConfiguration)9 JobExecutionFailure (cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)6 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)5 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)5 Record (org.marc4j.marc.Record)5 JobLauncher (org.springframework.batch.core.launch.JobLauncher)5