Mercurial > hg > monetdb-java
comparison tests/ConnectionTests.java @ 681:32e7ac7b979e
Tests should always cleanup their created objects, so added cleanup() method.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 03 Nov 2022 22:29:30 +0100 (2022-11-03) |
parents | b25d838b4bcf |
children | aeb268156580 |
comparison
equal
deleted
inserted
replaced
680:238d6a3a6469 | 681:32e7ac7b979e |
---|---|
75 tester.withSuffix("autocommit=false").checkAutoCommit(false); | 75 tester.withSuffix("autocommit=false").checkAutoCommit(false); |
76 tester.withProp("autocommit", "true").checkAutoCommit(true); | 76 tester.withProp("autocommit", "true").checkAutoCommit(true); |
77 tester.withProp("autocommit", "false").checkAutoCommit(false); | 77 tester.withProp("autocommit", "false").checkAutoCommit(false); |
78 | 78 |
79 tester.testTimeZone(); | 79 tester.testTimeZone(); |
80 | |
81 tester.cleanup(); | |
80 } | 82 } |
81 | 83 |
82 Connection connect() throws SQLException { | 84 Connection connect() throws SQLException { |
83 TimeZone restore = null; | 85 TimeZone restore = null; |
84 try { | 86 try { |
154 String s = rs.getString(1); | 156 String s = rs.getString(1); |
155 if (!s.endsWith(suffix)) { | 157 if (!s.endsWith(suffix)) { |
156 String msg = String.format("Expected suffix '%s', got timestamp '%s'", suffix, s); | 158 String msg = String.format("Expected suffix '%s', got timestamp '%s'", suffix, s); |
157 throw new Failure(msg); | 159 throw new Failure(msg); |
158 } | 160 } |
161 } | |
162 } | |
163 | |
164 private void cleanup() throws SQLException { | |
165 try (Connection conn = connect(); Statement stmt = conn.createStatement()) { | |
166 stmt.execute("DROP TABLE IF EXISTS connectiontests"); | |
167 stmt.execute("DROP TABLE IF EXISTS connectiontests_ts"); | |
159 } | 168 } |
160 } | 169 } |
161 | 170 |
162 public class Failure extends Exception { | 171 public class Failure extends Exception { |
163 private static final long serialVersionUID = 1L; | 172 private static final long serialVersionUID = 1L; |