Commit Graph

175 Commits

Author SHA1 Message Date
Taeik Lim
fb180404cb Make util classes to follow style guide
Signed-off-by: Taeik Lim <sibera21@gmail.com>

Issue #4545
2024-03-07 11:15:35 +01:00
Mahmoud Ben Hassine
4b8e504972 Refine contribution #4471
- Update tests
- Move test class to the core module
2024-02-20 11:36:59 +01:00
Ilpyo-Yang
b9ba8ffb86 Add AbstractTaskletStepBuilder copy constructor
This commit includes tests for the copy constructor
of AbstractTaskletStepBuilder and for the faultTolerant
method, specifically after taskExecutor has been set.
2024-02-19 14:32:22 +01:00
Henning Poettker
0d1d89c82f Use annotation @Override consistently 2023-12-19 13:35:46 +01:00
Mahmoud Ben Hassine
ad50599d28 Fix disposable bean lifecycle in JobScope test utilities
Before this commit, the destroy method of a job-scoped
bean was not called after a test method.

This commit changes the listener to respect the
DisposableBean contract for job-scoped beans (and make it
consistent with the calls to the JobSynchronizationManager
in AbstractJob, ie calling register/release).

FTR, I did not find a clean way to test this with an
assertion (which should be made after the test method),
but a log message in the destroy method shows that the
method is now called as expected.

Resolves #1288
2023-11-21 09:41:28 +01:00
Shaoqiang Lu
1add2830f5 Auto-detect the class/interface to be mocked
Issue #4426
2023-08-03 09:51:59 +02:00
Mahmoud Ben Hassine
5e849c6c95 Document the type and name of the surrounding job in JobLauncherTestUtils#launchStep
Resolves #3825
2023-07-17 11:08:38 +02:00
Mahmoud Ben Hassine
52064c0541 Code cleanup
- Inline variables
- Remove unused variables
- Remove redundant array creation
- Remove redundant `@SuppressWarnings`
- Remove unnecessary exceptions from throws list
- Remove redundant initializers
- Use List.subList().clear() where appropriate
- Use try-with-resources where needed
- Use pattern variables where appropriate
2023-07-12 23:25:18 +02:00
Mahmoud Ben Hassine
f82c16b825 Fix javadoc errors and warnings
Resolves #1624
2023-07-06 06:46:26 +02:00
Mahmoud Ben Hassine
0a1cdb095f Mark fields as final where appropriate 2023-07-05 08:03:48 +02:00
Mahmoud Ben Hassine
5c8cb7663f Make inner classes static 2023-07-04 21:03:55 +02:00
Mahmoud Ben Hassine
167f3c427d Remove usage of raw parametrized types 2023-07-04 19:03:18 +02:00
Mahmoud Ben Hassine
96f8d6bd35 Replace anonymous types with lambda expressions or method references 2023-07-04 18:50:16 +02:00
Mahmoud Ben Hassine
07154909a1 Refactor tests in spring-batch-test
- Remove unused resources
- Merge duplicate data source configuration
2023-06-27 15:35:15 +02:00
Mahmoud Ben Hassine
51f6357e91 Move ObservabilitySampleStepTests to spring-batch-core
This test class dot not belong to the spring-batch-test module.
2023-06-22 10:22:46 +02:00
Mahmoud Ben Hassine
93d911e100 Use lambdas and method references where appropriate 2023-06-12 16:43:46 +02:00
Mahmoud Ben Hassine
98c426ca4f Remove System.out.println from tests 2023-06-07 15:47:56 +02:00
Mahmoud Ben Hassine
92159cbc2b Use diamond operator where appropriate 2023-06-05 13:48:49 +02:00
Mahmoud Ben Hassine
0dc5b63469 Replace identical catch sections with multi-catch blocks 2023-06-05 13:30:23 +02:00
Mahmoud Ben Hassine
c25cd55901 Upgrade spring-javaformat maven plugin to version 0.0.39 2023-06-05 11:11:48 +02:00
Mahmoud Ben Hassine
972951a40a Remove unused imports and apply imports code style 2023-04-11 16:28:36 +02:00
Mahmoud Ben Hassine
4629294b65 Fix object graph deletion in SimpleJobRepository#deleteJobExecution
Before this commit, SimpleJobRepository#deleteJobExecution
did not delete associated step executions as specified in the
contract of the method.

This commit fixes the implementation to delete the entire
object graph as specified.

Resolves #4249
2023-02-20 08:41:34 +01:00
Mahmoud Ben Hassine
e4efa24e57 Deprecate MetaDataInstanceFactory#createJobExecution
This method accepts job parameters as a string, which can
cause parsing issues.

Resolves #4303
2023-02-17 17:14:24 +01:00
Aleksandr Arshavskiy
ed4a318d26 Disable BatchTestContextCustomizer after AOT processing
Issue #4286
2023-02-16 17:22:00 +01:00
Mahmoud Ben Hassine
46c8ebbe7e Fix parameters parsing in JobOperator and MetaDataInstanceFactory
Before this commit, the parsing of job parameters in
JobOperator#start and MetaDataInstanceFactory#createJobExecution
was accepting the comma separated key=value pairs format,
which is incompatible with the new job parameters format
introduced in v5.

This commit updates the contract as well as the implementation
of those APIs to be compatible with v5.

Resolves #4253
Resolves #4301
2023-02-16 16:19:04 +01:00
Taeik Lim
15f3637ac8 Polish code indent in Javadocs 2023-02-13 13:42:52 +01:00
Mahmoud Ben Hassine
daaa0013b1 Fetch step executions in SimpleJobRepository#findJobExecutions
Resolves #4242
2022-11-23 17:23:44 +01:00
Danilo Piazzalunga
fc0ec01ff8 Throw IllegalStateException from afterPropertiesSet
Consistently use Assert.state in the afterPropertiesSet()
methods to throw IllegalStateException instead of
IllegalArgumentException when some properties are missing
and/or invalid.

Resolves #2244
2022-11-23 12:22:26 +01:00
Marvin Deng
bbf35b79f7 Make the meaning of running status consistent
- A running status is STARTING, STARTED, or STOPPING.
- Update related tests.

 Resolves #1483
2022-11-17 15:40:29 +01:00
Mahmoud Ben Hassine
930bb0243c Implement default methods in SimpleJobRepository
Resolves #4229
2022-11-16 16:11:33 +01:00
Mahmoud Ben Hassine
05bbd3f7ea Remove dependency autowiring in test utilities
Issue #4233
2022-11-16 14:21:17 +01:00
Mahmoud Ben Hassine
1527593a36 Refine contribution #4218
* Update Javadoc of SpringBatchTest about job autowiring
* Apply Spring code style conventions
2022-11-08 13:45:13 +01:00
Henning Poettker
3bb7ce532b Improve @SpringBatchTest to autowire the job under test in JobLauncherTestUtils if it is unique
Issue #4218
2022-11-08 13:16:36 +01:00
Mahmoud Ben Hassine
d889f84735 Remove the static configuration of Micrometer's observation registry
Resolves #4222
2022-11-08 07:48:45 +01:00
Mahmoud Ben Hassine
bef2588207 Deprecate DataSourceInitializer 2022-10-12 18:49:31 +02:00
Mahmoud Ben Hassine
1a65c00b8d Change type of timestamp fields in JobExecution/StepExecution to LocalDateTime
This commit changes the type of fields `startTime`, `endTime`,
`createTime` and `lastUpdated` in `JobExecution` and `StepExecution`
from `java.util.Date` to `java.time.LocalDateTime`.

Resolves #1014
2022-10-11 22:09:16 +02:00
Mahmoud Ben Hassine
2660f2bb27 Add support to use any type as a job parameter
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* https://github.com/spring-projects/spring-batch/issues/3960
* https://github.com/spring-projects/spring-batch/issues/2122
* https://github.com/spring-projects/spring-batch/issues/1035
* https://github.com/spring-projects/spring-batch/issues/1983
2022-10-04 20:35:50 +02:00
Mahmoud Ben Hassine
f39f07075a Improve Step/Job builder APIs to guide users to set mandatory properties
Before this commit, the user had to manually set the job repository and transaction
manager on `JobBuilder` and `StepBuilder` instances with a chained call to
`.repository(jobRepository)` and `.transactionManager(transactionManager)`.
This is error prone and can lead to runtime errors if these properties are not set.

This commit introduces new APIs to guide the user to set these properties at
builder creation time.

Resolves #4192
2022-09-17 22:31:12 +02:00
Mahmoud Ben Hassine
6e443cb1b1 Deprecate Job/Step builder factories
This commit deprecates JobBuilderFactory and StepBuilderFactory
in favor of the respective builders they create.

It also removes the exposure of such utilities as beans in the
application context when using `@EnableBatchProcessing`.

Resolves https://github.com/spring-projects/spring-batch/issues/4188
2022-09-13 16:56:01 +02:00
Tadaya Tsuyukubo
1ff720545f Adapt SampleTestRunner change in micrometer tracing
Accommodate the breaking change in `SampleTestRunner` introduced by
https://github.com/micrometer-metrics/tracing/pull/57
2022-09-09 15:38:30 +02:00
Mahmoud Ben Hassine
7c8fb172a7 Move the transaction manager configuration to AbstractTaskletStepBuilder
Before this commit, the transaction manager was configurable
at the StepBuilder level, which is inconsistent with the XML
config style in addition to be not needed for most step types.

This commit moves the configuration of the transaction manager
from the StepBuilder down to the AbstractTaskletStepBuilder,
which is the level where the transaction manager is needed.

Resolves #4130
2022-09-08 11:35:14 +02:00
Mahmoud Ben Hassine
4d0ed63dd7 Deprecate AssertFile
Resolves #4181
2022-08-24 15:17:34 +02:00
Glenn Renfro
8ca9802da4 Remove the JUnit dependency in AssertFile
The side effect is a breaking change in that it will now
throw IllegalStateException instead of the Compare and
AssertExceptions provided by JUnit.

Resolves #4111
2022-08-24 10:29:45 +02:00
Mahmoud Ben Hassine
c425137eec Remove datasource dependency in JobRepositoryTestUtils
Before this commit, the `JobRepositoryTestUtils` was
tied to the JDBC implementation of the `JobRepository`
as it was requiring a datasource. This makes it unusable
with implementations that do not rely on a datasource
to store batch meta-data (A MongoDB job repository for
instance where no datasource is used).

This commit decouples the `JobRepositoryTestUtils` from
the implementation details of the `JobRepository` by making
it working against the `JobRepository` interface.

This commit also introduces the necessary methods in the
`JobRepository` interface as well as various DAOs to
implement the utilities without having to deal with the
details of the underlying repository implementation.

Resolves #4070
2022-08-23 21:33:06 +02:00
Mahmoud Ben Hassine
f104baa417 Remove datasource autowiring in JobRepositoryTestUtils
Before this commit, trying to register a `JobRepositoryTestUtils` bean
in a test context that contains multiple datasources fails at startup,
because a datasource is autowired in `JobRepositoryTestUtils` while
multiple are defined.

This commit removes the autowiring of the datasource in JobRepositoryTestUtils.

Resolves #4178
2022-08-21 13:36:37 +02:00
Mahmoud Ben Hassine
c506a49988 Remove job autowiring in JobLauncherTestUtils
Before this commit, registering the JobLauncherTestUtils
as a bean in the test context (either manually or via
`@SpringBatchTest`) was failing when multiple jobs are
defined in the test context.

This commit removes the autowiring of the job under test
in JobLauncherTestUtils.

Resolves #1237
2022-08-20 12:39:02 +02:00
Mahmoud Ben Hassine
e67c0069f1 Use the Chunk API consistently
This commit replaces the usage of List with Chunk
where appropriate. Summary of changes:

- The Chunk class was moved from the `org.springframework.batch.core.step.item` package to the `org.springframework.batch.item` package
- The signature of the method `ItemWriter#write(List)` was changed to `ItemWriter#write(Chunk)`
- All implementations of `ItemWriter` were updated to use the Chunk API instead of List
- All methods in the `ItemWriteListener` interface were updated to use the Chunk API instead of List
- All implementations of `ItemWriteListener` were updated to use the Chunk API instead of List
- The constructor of `ChunkRequest` was changed to accept a Chunk instead of a Collection of items
- The return type of `ChunkRequest#getItems()` was changed from List to Chunk

Resolves #3954
2022-08-19 13:40:09 +02:00
Henning Poettker
6117c044fb Migrate Spring Batch Test to JUnit Jupiter 2022-08-02 17:07:43 +02:00
Marvin Deng
c0791039dc Rename SimpleJobLauncher to TaskExecutorJobLauncher
Resolves #4123
2022-07-19 13:34:23 +02:00
Mahmoud Ben Hassine
565ddcdf96 Change transaction manager type in default batch configuration
This commits changes the type of the transaction manager
from `DataSourceTransactionManager` to `JdbcTransactionManager`
in the default configuration of `@EnableBatchProcessing`.

The `JdbcTransactionManager` adds common JDBC exception translation
which is beneficial for Spring Batch to improve exception handling
and error reporting.

Resolves #4126
2022-07-16 17:52:43 +02:00