From 49296f1f2a8a722a2452335a2f5614cc4445c7e3 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 18 Apr 2018 00:18:19 -0400 Subject: [PATCH] Improve QueryRunner 50% failure rate test --- .../moparisthebest/jdbc/codegen/PersonDAOQueryRunnerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAOQueryRunnerTest.java b/test/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAOQueryRunnerTest.java index d9e5cfd..5b87323 100644 --- a/test/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAOQueryRunnerTest.java +++ b/test/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAOQueryRunnerTest.java @@ -25,10 +25,11 @@ public class PersonDAOQueryRunnerTest { @Test public void testPerson() throws Exception { //final QueryRunner lqr = pqr.withFactory(() -> new ListQueryMapper(QueryMapperTest::getConnection)); + final int[] failCount = new int[]{0}; assertEquals(fieldPerson1, pqr.runRetryFuture(new QueryRunner.Runner() { @Override public Person run(final PersonDAO dao) throws SQLException { - if(Math.random() < 0.5) { + if(++failCount[0] < 5) { System.out.println("fake fail"); throw new SQLException("fake 50% failure rate"); }