Skip to content

Commit 435e5d6

Browse files
authored
A test fix about the expected Exception caught from query prepared before table evolved.(#140)
1 parent e6db2e8 commit 435e5d6

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

driver/src/test/java/oracle/nosql/driver/ProxyTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ protected static String stringVersion(int ver) {
678678
(ver % 1000);
679679
}
680680

681-
private static int getMinimumKVVersion() {
681+
protected static int getMinimumKVVersion() {
682682
/*
683683
* Use the minimum of the kv client and server versions to
684684
* determine what features should be valid to test.

driver/src/test/java/oracle/nosql/driver/QueryTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,15 +1583,31 @@ public void testEvolution() {
15831583
assertEquals(10, qres.getResults().size());
15841584

15851585
/*
1586-
* evolve and try the query again. It will fail because the ???
1586+
* Evolve and try the query again. It will fail because table schema
1587+
* has been changed, the query need to be prepared again.
15871588
*
1589+
* The exception caught from query may vary depending on the
1590+
* different proxy and KV version. PrepareQueryException will be
1591+
* thrown for proxy(KVClient 25.1.1) + KV server 25.1.1 or higher.
1592+
* Otherwise, IllegalArgumentException will be thrown.
15881593
*/
15891594
tableOperation(handle, "alter table testTable(drop age)", null);
1595+
15901596
try {
15911597
qres = handle.query(qreq);
15921598
fail("Query should have failed");
1593-
} catch (IllegalArgumentException iae) {
1594-
/* success */
1599+
} catch (PrepareQueryException | IllegalArgumentException ex) {
1600+
/*
1601+
* If can't determine the versions of KV client and server, skip
1602+
* checking the specific exception.
1603+
*/
1604+
if (getMinimumKVVersion() > 0) {
1605+
if (checkKVVersion(25, 1, 1)) {
1606+
assertTrue(ex instanceof PrepareQueryException);
1607+
} else {
1608+
assertTrue(ex instanceof IllegalArgumentException);
1609+
}
1610+
}
15951611
}
15961612
}
15971613
}

0 commit comments

Comments
 (0)