Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
refactor DemoTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ArloL committed Nov 28, 2022
1 parent 78dad49 commit 26c7dc3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/test/java/com/example/demo/DemoTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.demo;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.Connection;
import java.sql.DriverManager;
Expand Down Expand Up @@ -90,7 +90,7 @@ private void insertAndRemoveMessages(Connection connection)
int step = 3;

for (int i = 0; i < total; i += step) {
System.out.println(i);
connection.setAutoCommit(true);

try (PreparedStatement insertStatement = connection
.prepareStatement(
Expand All @@ -102,6 +102,8 @@ private void insertAndRemoveMessages(Connection connection)
}
}

connection.setAutoCommit(false);

try (PreparedStatement statement = connection
.prepareStatement(NEXT_SYNC_EVENT_QUERY)) {
for (int j = 0; j < step; j++) {
Expand All @@ -110,11 +112,22 @@ private void insertAndRemoveMessages(Connection connection)
while (resultSet.next()) {
count++;
}
assertEquals(1, count);
if (count > 1) {
System.out.println(
"Got " + count + " results after approx. "
+ i + " entries"
);
connection.rollback();
return;
}
} finally {
connection.commit();
}
}
}
}

assertTrue(false, "Never got too many query results");
}

}

0 comments on commit 26c7dc3

Please sign in to comment.