sunm2n opened a new pull request, #23636:
URL: https://github.com/apache/kafka/pull/23636
Replace the remaining straightforward try/fail/catch exception
assertions in the Streams tests with `assertThrows`, following #23277
and #23389.
In #23389, streams.internals, streams.state.internals,
streams.processor.internals, and streams.integration were left unchanged
because they overlapped with in-flight Hamcrest removal work.
The referenced PRs (#23307, #23386, and #23387) have since been merged,
and KAFKA-21028 has been resolved. This PR covers the remaining
straightforward assertions in streams.state.internals,
streams.processor.internals, and streams.integration, along with those
in streams.kstream.internals, streams.processor, and streams/test-utils.
Where the catch block checked the exception message, the `assertThrows`
return value is used to keep that check. Descriptive `fail()` messages
are kept, and generic ones are replaced with messages that name the
rejected operation. Unused `fail` imports are removed.
In `FineGrainedAutoResetIntegrationTest`, only `builder.build()` is
wrapped, because the overlapping source is rejected when the topology
is built, not when `stream()` is called. In
`TimeOrderedKeyValueBufferTest#shouldNotRestoreUnrecognizedVersionRecord`,
the `finally` block that cleans up the buffer is kept.
Left unchanged:
- `GlobalStateTaskTest`: `fail()` is conditional on a test parameter,
so it is not a direct try/fail/catch.
- `KafkaStreamsTest#shouldThrowTopologyExceptionOnEmptyTopology`: same
reason as in #23389 (the `fail()` sits inside try-with-resources).
- `TimeOrderedKeyValueBufferTest` still imports `fail` for the
`default` branch of a switch in a callback.
Testing:
```sh
./gradlew :streams:checkstyleTest :streams:spotlessCheck \
:streams:test-utils:checkstyleTest
:streams:integration-tests:checkstyleTest
./gradlew :streams:test \
--tests
org.apache.kafka.streams.state.internals.CompositeReadOnlyWindowStoreTest \
--tests
org.apache.kafka.streams.state.internals.CompositeReadOnlySessionStoreTest \
--tests org.apache.kafka.streams.state.internals.MaybeTest \
--tests
org.apache.kafka.streams.state.internals.TimeOrderedKeyValueBufferTest \
--tests
org.apache.kafka.streams.processor.internals.ProcessorContextImplTest \
--tests
org.apache.kafka.streams.processor.UsePartitionTimeOnInvalidTimestampTest \
--tests org.apache.kafka.streams.kstream.internals.KStreamPeekTest \
--tests
org.apache.kafka.streams.kstream.internals.KTableTransformValuesTest
./gradlew :streams:test-utils:test --tests
org.apache.kafka.streams.MockProcessorContextTest
./gradlew :streams:integration-tests:test \
--tests
org.apache.kafka.streams.integration.FineGrainedAutoResetIntegrationTest
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]