Repository navigation
Commit fe91f99
authored
test(jdbc): pin attached schema, date time, and savepoint edges (#215)
## What
Tests only, for the four behaviors Wave 0 of #195 names. No production
code, `pom.xml`, or dependency change; no existing assertion edited.
1. **Attached-schema table metadata** (`LibsqlResultSetMetaDataTest`).
`SELECT id, name FROM aux.People` drives `pragma_database_list` and the
per-schema lookup, so `findSchema` and `loadAttachedTableInfo` run. The
stub answers a *different* `People` in `main` (nullable, no
autoincrement) and in the attached schema `Aux` (NOT NULL, `INTEGER
PRIMARY KEY AUTOINCREMENT`), so the assertions on
`getTableName`/`isNullable`/`isAutoIncrement` only pass when the
attached catalogue wins. A second test queries `ghost.People` with
`ghost` absent from the database list and asserts no table metadata.
2. **Date/time tails** (`LibsqlResultSetTest`). `+02:00` suffix, `Z`
suffix, bare `10:30:45` defaulting to `2000-01-01`, and BLOB rejection
with `"Bad value for type LocalDate"` / `LocalTime` / `LocalDateTime`
(exact target-type spelling from the code).
3. **Savepoint edges** (`LibsqlSavepointTest`). Two savepoints named
`dup`: releasing the later one must keep the earlier active, so the next
statement runs on the same stream with no `BEGIN`, and `rollback` to the
earlier one still works. Releasing the only savepoint of a transaction
started in auto-commit ends the transaction, so the following `commit()`
sends nothing and exactly one stream close is issued.
4. **Batch vs `close()`** (`LibsqlStatementConcurrencyTest`). A batch is
held inside the connection round trip with the existing `Pause` seam
while `close()` lands on the statement, so the interleaving is
deterministic; `executeBatch` then fails with `Statement is closed`.
## Mutation probe
Each new test was run alone against a scratch break of the behavior it
pins, then the break was reverted with `git checkout -- <file>`. All
nine bite; none stayed green.
Probe lane: `./mvnw -pl libsql-jdbc -am -Dtest='<Class>#<method>'
-DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false test`
| Test | Break | Observed failure |
|---|---|---|
|
`LibsqlResultSetMetaDataTest#resolvesAttachedTableMetadataThroughPragmaDatabaseList`
| `findSchema`: `name.equalsIgnoreCase(schema)` → `name.equals(schema)`
| `:65` expected `"People"` but was `""` |
|
`LibsqlResultSetMetaDataTest#reportsNoTableMetadataForASchemaMissingFromPragmaDatabaseList`
| `findSchema`: `return null` → `return schema` when no database matches
| `:81` Expecting empty but was: `"People"` |
|
`LibsqlResultSetTest#textDateTimeWithAnOffsetSuffixIsConvertedToTheSystemZone`
| `parseSqliteDateTime`: guard `if (sign > 9)` → `if (false && sign >
9)` | `:290` `SQLException: Bad value for type LocalDateTime: 2024-03-15
10:30:00+02:00` |
| `LibsqlResultSetTest#textDateTimeWithAZSuffixIsReadAsUtc` |
`parseSqliteDateTime`: skip the `Z` branch (`if (false && ...)`) |
`:305` `SQLException: Bad value for type LocalDateTime:
2024-03-15T10:30:00Z` |
| `LibsqlResultSetTest#bareTimeTextGetsTheYear2000DefaultDate` |
`LocalDate.of(2000, 1, 1)` → `LocalDate.of(1970, 1, 1)` | `:316`
expected `2000-01-01T10:30:45` but was `1970-01-01T10:30:45` |
|
`LibsqlResultSetTest#blobRejectsDateAndTimeGettersWithTheTargetTypeName`
| BLOB branch message → `"Cannot read " + targetType + " from a BLOB"` |
`:328` Expecting message `"Bad value for type LocalDate"` |
|
`LibsqlSavepointTest#releasingTheLaterOfTwoSavepointsWithTheSameNameKeepsTheEarlierOneActive`
| `releaseSavepoint`: `savepointNames.lastIndexOf` → `indexOf` | `:225`
actual statements contain a `BEGIN` before the first `INSERT` (the
transaction was ended early) |
|
`LibsqlSavepointTest#releasingTheOnlySavepointOfAnAutoCommitTransactionLeavesCommitWithNothingToSend`
| `releaseSavepoint`: drop `closeStreamQuietly()` in the outermost
branch | `:250` actual statements end with `"COMMIT"` (unexpected) |
|
`LibsqlStatementConcurrencyTest#executeBatchThatLosesTheRaceToCloseFailsWithStatementClosed`
| `executeBatch` finally: `clearBatch()` → `batchStatements.clear()` |
`:200` Expecting code to raise a throwable |
## Lanes
| Command | Result |
|---|---|
| `./mvnw -pl libsql-jdbc -am test` | `EXIT=0`, 383 tests, 0 failures, 0
errors (baseline 374 + 9 new) |
| `./mvnw spotless:apply` | no changes |
| `./mvnw spotless:check` | `BUILD SUCCESS` |
| probe lane (9 runs, table above) | each `EXIT=1`, production file
reverted after every run |
## Discovery
`executeBatch`'s `finally { clearBatch(); }` calls `checkClosed()`
through `clearBatch`. When a statement `close()` lands while the batch
round trip is in flight, a batch whose steps all succeeded reports
`SQLException("Statement is closed")` instead of the update counts.
Pinned as the current behavior and **not** fixed here, since a fix
changes behavior under a race; it sits next to the `#197` update-count
snapshot and `#211` close-path work, so the root can decide.
The `socketTimeout` URL case from the wave list is deliberately absent:
#196 owns it.
Fixes #1951 parent 404bba6 commit fe91f99
4 files changed
Lines changed: 235 additions & 0 deletions
File tree
- libsql-jdbc/src/test/java/com/github/magnusp/libsql/jdbc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
57 | 85 | | |
58 | 86 | | |
59 | 87 | | |
| |||
752 | 780 | | |
753 | 781 | | |
754 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
755 | 838 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
279 | 337 | | |
280 | 338 | | |
281 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
211 | 257 | | |
212 | 258 | | |
213 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
184 | 211 | | |
185 | 212 | | |
186 | 213 | | |
| |||
300 | 327 | | |
301 | 328 | | |
302 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
303 | 351 | | |
304 | 352 | | |
305 | 353 | | |
| |||
0 commit comments