Reputation: 4719
Using Spring Integration, is there a way to to mock the result set that a jdbc:inbound-channel-adapter
retrieves when unit testing? If not, what would be the recommended testing strategy?
Thanks
Upvotes: 0
Views: 1021
Reputation: 121542
Anyway the ResultSet
to return is a responsibility of JdbcOperations
, not JdbcPollingChannelAdapter
.
So, just mock JdbcOperations#query
method and inject it into <int-jdbc:inbound-channel-adapter>
UPDATE
I mean this:
<int-jdbc:inbound-channel-adapter jdbc-operations="jdbcTemplate"/>
Where the jdbcTemplate
bean is your custom implementation with mocked query(String sql, ResultSetExtractor<T> rse)
method.
Upvotes: 1
Reputation: 174729
Alternatives would be to use an embedded database in your test cases or, probably easiest, is to simply send test data to the channel adapter's channel.
This technique is used in the testing samples.
Upvotes: 1