use of org.springframework.batch.core.configuration.JobRegistry in project camel by apache.
the class SpringBatchEndpointTest method shouldInjectJobRegistryByReferenceName.
@Test
public void shouldInjectJobRegistryByReferenceName() throws Exception {
// Given
Job mockJob = mock(Job.class);
when(jobRegistry.getJob(eq("mockJob"))).thenReturn(mockJob);
context().addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:jobRegistryRefTest").to("spring-batch:mockJob?jobRegistry=#jobRegistry");
}
});
// When
template.sendBody("direct:jobRegistryRefTest", "Start the job, please.");
// Then
SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobRegistry=#jobRegistry", SpringBatchEndpoint.class);
JobRegistry batchEndpointJobRegistry = (JobRegistry) FieldUtils.readField(batchEndpoint, "jobRegistry", true);
assertSame(jobRegistry, batchEndpointJobRegistry);
}
use of org.springframework.batch.core.configuration.JobRegistry in project camel by apache.
the class SpringBatchEndpointTest method shouldUseJobRegistryFromComponent.
@Test
public void shouldUseJobRegistryFromComponent() throws Exception {
// Given
SpringBatchComponent batchComponent = new SpringBatchComponent();
batchComponent.setJobRegistry(jobRegistry);
batchComponent.setJobLauncher(jobLauncher);
context.addComponent("customBatchComponent", batchComponent);
// When
context().addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:startCustom").to("customBatchComponent:mockJob");
}
});
// Then
SpringBatchEndpoint batchEndpoint = context().getEndpoint("customBatchComponent:mockJob", SpringBatchEndpoint.class);
JobRegistry batchEndpointJobRegistry = (JobRegistry) FieldUtils.readField(batchEndpoint, "jobRegistry", true);
assertSame(jobRegistry, batchEndpointJobRegistry);
}
Aggregations