1616package com .datastax .oss .driver .core .cql ;
1717
1818import static org .assertj .core .api .Assertions .assertThat ;
19+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
1920
2021import com .datastax .oss .driver .api .core .CqlSession ;
2122import com .datastax .oss .driver .api .core .config .DefaultDriverOption ;
@@ -338,16 +339,20 @@ public void should_fail_counter_batch_with_non_counter_increment() {
338339 sessionRule .session ().execute (batchStatement );
339340 }
340341
341- @ Test ( expected = IllegalStateException . class )
342+ @ Test
342343 public void should_not_allow_unset_value_when_protocol_less_than_v4 () {
343344 // CREATE TABLE test (k0 text, k1 int, v int, PRIMARY KEY (k0, k1))
344345 DriverConfigLoader loader =
345346 SessionUtils .configLoaderBuilder ()
346347 .withString (DefaultDriverOption .PROTOCOL_VERSION , "V3" )
347348 .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
349352 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 ()));
351356
352357 BatchStatementBuilder builder = BatchStatement .builder (DefaultBatchType .LOGGED );
353358 builder .addStatements (
@@ -361,7 +366,9 @@ public void should_not_allow_unset_value_when_protocol_less_than_v4() {
361366 .unset (2 )
362367 .build ());
363368
364- v3Session .execute (builder .build ());
369+ assertThatThrownBy (() -> v3Session .execute (builder .build ()))
370+ .isInstanceOf (IllegalStateException .class )
371+ .hasMessageContaining ("Unset value at index" );
365372 }
366373 }
367374
0 commit comments