mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-25 18:32:18 -05:00
Improve QueryRunner 50% failure rate test
This commit is contained in:
parent
64e500ca2a
commit
49296f1f2a
@ -25,10 +25,11 @@ public class PersonDAOQueryRunnerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testPerson() throws Exception {
|
public void testPerson() throws Exception {
|
||||||
//final QueryRunner<ListQueryMapper> lqr = pqr.withFactory(() -> new ListQueryMapper(QueryMapperTest::getConnection));
|
//final QueryRunner<ListQueryMapper> lqr = pqr.withFactory(() -> new ListQueryMapper(QueryMapperTest::getConnection));
|
||||||
|
final int[] failCount = new int[]{0};
|
||||||
assertEquals(fieldPerson1, pqr.runRetryFuture(new QueryRunner.Runner<PersonDAO, Person>() {
|
assertEquals(fieldPerson1, pqr.runRetryFuture(new QueryRunner.Runner<PersonDAO, Person>() {
|
||||||
@Override
|
@Override
|
||||||
public Person run(final PersonDAO dao) throws SQLException {
|
public Person run(final PersonDAO dao) throws SQLException {
|
||||||
if(Math.random() < 0.5) {
|
if(++failCount[0] < 5) {
|
||||||
System.out.println("fake fail");
|
System.out.println("fake fail");
|
||||||
throw new SQLException("fake 50% failure rate");
|
throw new SQLException("fake 50% failure rate");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user