16
16
package com .datastax .oss .driver .core .cql ;
17
17
18
18
import static org .assertj .core .api .Assertions .assertThat ;
19
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
19
20
20
21
import com .datastax .oss .driver .api .core .CqlSession ;
21
22
import com .datastax .oss .driver .api .core .config .DefaultDriverOption ;
@@ -338,16 +339,20 @@ public void should_fail_counter_batch_with_non_counter_increment() {
338
339
sessionRule .session ().execute (batchStatement );
339
340
}
340
341
341
- @ Test ( expected = IllegalStateException . class )
342
+ @ Test
342
343
public void should_not_allow_unset_value_when_protocol_less_than_v4 () {
343
344
// CREATE TABLE test (k0 text, k1 int, v int, PRIMARY KEY (k0, k1))
344
345
DriverConfigLoader loader =
345
346
SessionUtils .configLoaderBuilder ()
346
347
.withString (DefaultDriverOption .PROTOCOL_VERSION , "V3" )
347
348
.build ();
348
- try (CqlSession v3Session = SessionUtils .newSession (ccmRule , sessionRule .keyspace (), loader )) {
349
+ try (CqlSession v3Session = SessionUtils .newSession (ccmRule , loader )) {
350
+ // Intentionally use fully qualified table here to avoid warnings as these are not supported
351
+ // by v3 protocol version, see JAVA-3068
349
352
PreparedStatement prepared =
350
- v3Session .prepare ("INSERT INTO test (k0, k1, v) values (?, ?, ?)" );
353
+ v3Session .prepare (
354
+ String .format (
355
+ "INSERT INTO %s.test (k0, k1, v) values (?, ?, ?)" , sessionRule .keyspace ()));
351
356
352
357
BatchStatementBuilder builder = BatchStatement .builder (DefaultBatchType .LOGGED );
353
358
builder .addStatements (
@@ -361,7 +366,9 @@ public void should_not_allow_unset_value_when_protocol_less_than_v4() {
361
366
.unset (2 )
362
367
.build ());
363
368
364
- v3Session .execute (builder .build ());
369
+ assertThatThrownBy (() -> v3Session .execute (builder .build ()))
370
+ .isInstanceOf (IllegalStateException .class )
371
+ .hasMessageContaining ("Unset value at index" );
365
372
}
366
373
}
367
374
0 commit comments