Skip to content

Conversation

hogimn
Copy link
Contributor

@hogimn hogimn commented Feb 19, 2023

I wrote several unit tests for PooledDataSource.

1. shouldBlockUntilConnectionIsAvailableInPooledDataSource

If program tries to get a connection beyond the number of dataSource.getPoolMaximumActiveConnections, it should be blocked.

2. PoppedConnectionShouldBeNotEqualToClosedConnection

The Popped Connection should be not equal to previously closed connection. When closing a connection, it should generate new connection and stash away it to idleConnections in PoolState.

3. shouldEnsureCorrectIdleConnectionCount

When closing a connection, the number of idle connection in idleConnections in PoolState increases by one, but not beyond dataSource.setPoolMaximumIdleConnections

4. connectionShouldBeAvailableAfterMaximumCheckoutTime

It is the test extending test 1. If program tries to get a connection beyond the number of dataSource.getPoolMaximumActiveConnections, program is blocked. But If time passes beyond dataSource.getPoolMaximumCheckoutTime, a connection should be available.

5. forceCloseAllShouldRemoveAllActiveAndIdleConnection

forceCloseAll should remove all active and idle connections.

Thank you.

@coveralls
Copy link

Coverage Status

Coverage: 87.508% (+0.3%) from 87.183% when pulling 1640f1a on hogimn:test into 88ddca6 on mybatis:master.

@hazendaz
Copy link
Member

@hogimn Thanks!

@hazendaz hazendaz merged commit f35083d into mybatis:master Feb 20, 2023
@hazendaz hazendaz self-assigned this Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants