Skip to content

JobRepositoryTestUtils should work against the JobRepository interface #4070

Closed
@aritzbastida

Description

@aritzbastida

The utility class JobRepositoryTestUtils (injected via @SpringBatchTest annotation), uses an incorrect datasource when there is more than one available in the application context, and the one defined as @Primary is not referring to the Spring Batch schema.

Sure, this is already documented in the Javadoc for @SpringBatchTest annotation, but it happens to be a limitation in the infrastructure, and also may lead unexpected behavior:

  • The inner JdbcTemplate instance used for removing job executions may refer to a different datasource as the one for JobRepository.
  • It does not take into account Spring Boot's @BatchDataSource qualifier, or any qualifier, for that matter.

In my scenario, the job is launched fine but then cannot be removed, because the DELETE statements are executed against another database schema.

Ideally, JdbcTemplate should not be needed, and should infer the DataSource from JobRepository, extending it with removal operations. If that's not possible, at least it should be possible to configure the datasource dependency, so that it is used the one annotated with @BatchDataSource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions