|
51 | 51 | import org.junit.jupiter.api.*; |
52 | 52 |
|
53 | 53 | import java.sql.Connection; |
| 54 | +import java.sql.DriverManager; |
54 | 55 | import java.sql.ResultSet; |
55 | 56 | import java.util.ArrayList; |
56 | 57 | import java.util.List; |
|
59 | 60 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) |
60 | 61 | public class BloomFilterTableTest { |
61 | 62 |
|
62 | | - final String username = "sa"; |
63 | | - final String password = ""; |
64 | | - final String connectionUrl = "jdbc:h2:mem:test;MODE=MariaDB;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE"; |
65 | | - |
66 | | - @BeforeAll |
67 | | - void setEnv() { |
68 | | - Config config = ConfigFactory.parseProperties(getDefaultProperties()); |
69 | | - Connection connection = new LazyConnection(config).get(); |
70 | | - Assertions.assertDoesNotThrow(() -> { |
71 | | - connection.prepareStatement("DROP ALL OBJECTS").execute(); // h2 clear database |
72 | | - }); |
73 | | - Assertions.assertDoesNotThrow(() -> { |
74 | | - Class.forName("org.h2.Driver"); |
75 | | - }); |
76 | | - } |
| 63 | + private final String username = "sa"; |
| 64 | + private final String password = ""; |
| 65 | + private final String connectionUrl = "jdbc:h2:mem:test;MODE=MariaDB;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE"; |
| 66 | + private final Connection connection = Assertions |
| 67 | + .assertDoesNotThrow(() -> DriverManager.getConnection(connectionUrl, username, password)); |
77 | 68 |
|
78 | 69 | @AfterAll |
79 | 70 | void tearDown() { |
80 | | - Assertions.assertDoesNotThrow(() -> { |
81 | | - Config config = ConfigFactory.parseProperties(getDefaultProperties()); |
82 | | - Connection connection = new LazyConnection(config).get(); |
83 | | - connection.prepareStatement("DROP ALL OBJECTS").execute(); // h2 clear database |
84 | | - }); |
| 71 | + Assertions.assertDoesNotThrow(connection::close); |
85 | 72 | } |
86 | 73 |
|
87 | 74 | @Test |
@@ -121,7 +108,7 @@ void testCreateToDatabase() { |
121 | 108 | table.create(); |
122 | 109 | String sql = "SHOW COLUMNS FROM " + tableName + ";"; |
123 | 110 | Assertions.assertDoesNotThrow(() -> { |
124 | | - ResultSet rs = new LazyConnection(config).get().prepareStatement(sql).executeQuery(); |
| 111 | + ResultSet rs = connection.prepareStatement(sql).executeQuery(); |
125 | 112 | int cols = 0; |
126 | 113 | List<String> columnList = new ArrayList<>(4); |
127 | 114 | while (rs.next()) { |
|
0 commit comments