user1052610
user1052610

Reputation: 4719

Spring Integration: mock testing jdbc:inbound-channel-adapter

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

Answers (2)

Artem Bilan
Artem Bilan

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

Gary Russell
Gary Russell

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

Related Questions