diff --git a/integration-tests/src/test/java/com/datastax/oss/driver/api/core/cql/BoundStatementIT.java b/integration-tests/src/test/java/com/datastax/oss/driver/api/core/cql/BoundStatementIT.java index f843f4839a..065e9bdb31 100644 --- a/integration-tests/src/test/java/com/datastax/oss/driver/api/core/cql/BoundStatementIT.java +++ b/integration-tests/src/test/java/com/datastax/oss/driver/api/core/cql/BoundStatementIT.java @@ -19,6 +19,7 @@ import static com.datastax.oss.simulacron.common.stubbing.PrimeDsl.query; import static com.datastax.oss.simulacron.common.stubbing.PrimeDsl.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assumptions.assumeThat; import com.datastax.oss.driver.api.core.ConsistencyLevel; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -29,7 +30,6 @@ import com.datastax.oss.driver.api.core.config.DriverExecutionProfile; import com.datastax.oss.driver.api.core.metadata.token.Token; import com.datastax.oss.driver.api.core.type.codec.TypeCodecs; -import com.datastax.oss.driver.api.testinfra.CassandraRequirement; import com.datastax.oss.driver.api.testinfra.ccm.CcmRule; import com.datastax.oss.driver.api.testinfra.session.SessionRule; import com.datastax.oss.driver.api.testinfra.session.SessionUtils; @@ -71,6 +71,8 @@ public class BoundStatementIT { @ClassRule public static CcmRule ccm = CcmRule.getInstance(); + private static boolean atLeastV4 = ccm.getHighestProtocolVersion().getCode() >= 4; + @ClassRule public static SessionRule sessionRule = new SessionRule<>(ccm, "basic.request.page-size = 20"); @@ -131,8 +133,8 @@ public void should_not_allow_unset_value_when_protocol_less_than_v4() { } @Test - @CassandraRequirement(min = "2.2") public void should_not_write_tombstone_if_value_is_implicitly_unset() { + assumeThat(atLeastV4).as("unset values require protocol V4+").isTrue(); try (CqlSession session = SessionUtils.newSession(ccm, sessionRule.keyspace())) { PreparedStatement prepared = session.prepare("INSERT INTO test2 (k, v0) values (?, ?)"); @@ -146,8 +148,8 @@ public void should_not_write_tombstone_if_value_is_implicitly_unset() { } @Test - @CassandraRequirement(min = "2.2") public void should_write_tombstone_if_value_is_explicitly_unset() { + assumeThat(atLeastV4).as("unset values require protocol V4+").isTrue(); try (CqlSession session = SessionUtils.newSession(ccm, sessionRule.keyspace())) { PreparedStatement prepared = session.prepare("INSERT INTO test2 (k, v0) values (?, ?)"); @@ -165,8 +167,8 @@ public void should_write_tombstone_if_value_is_explicitly_unset() { } @Test - @CassandraRequirement(min = "2.2") public void should_write_tombstone_if_value_is_explicitly_unset_on_builder() { + assumeThat(atLeastV4).as("unset values require protocol V4+").isTrue(); try (CqlSession session = SessionUtils.newSession(ccm, sessionRule.keyspace())) { PreparedStatement prepared = session.prepare("INSERT INTO test2 (k, v0) values (?, ?)"); @@ -379,7 +381,6 @@ public void should_use_timeout() { } @Test - @CassandraRequirement(min = "2.2") public void should_propagate_attributes_when_preparing_a_simple_statement() { CqlSession session = sessionRule.session(); @@ -404,7 +405,7 @@ public void should_propagate_attributes_when_preparing_a_simple_statement() { ConsistencyLevel mockSerialCl = DefaultConsistencyLevel.LOCAL_SERIAL; int mockPageSize = 2000; - SimpleStatement simpleStatement = + SimpleStatementBuilder simpleStatementBuilder = SimpleStatement.builder("SELECT release_version FROM system.local") .withExecutionProfile(mockProfile) .withExecutionProfileName(mockConfigProfileName) @@ -413,16 +414,20 @@ public void should_propagate_attributes_when_preparing_a_simple_statement() { .withRoutingKeyspace(mockRoutingKeyspace) .withRoutingKey(mockRoutingKey) .withRoutingToken(mockRoutingToken) - .addCustomPayload("key1", mockCustomPayload.get("key1")) .withTimestamp(42) .withIdempotence(true) .withTracing() .withTimeout(mockTimeout) .withConsistencyLevel(mockCl) .withSerialConsistencyLevel(mockSerialCl) - .withPageSize(mockPageSize) - .build(); - PreparedStatement preparedStatement = session.prepare(simpleStatement); + .withPageSize(mockPageSize); + + if (atLeastV4) { + simpleStatementBuilder = + simpleStatementBuilder.addCustomPayload("key1", mockCustomPayload.get("key1")); + } + + PreparedStatement preparedStatement = session.prepare(simpleStatementBuilder.build()); // Cover all the ways to create bound statements: ImmutableList> createMethods = @@ -438,7 +443,9 @@ public void should_propagate_attributes_when_preparing_a_simple_statement() { .isEqualTo(mockKeyspace != null ? mockKeyspace : mockRoutingKeyspace); assertThat(boundStatement.getRoutingKey()).isEqualTo(mockRoutingKey); assertThat(boundStatement.getRoutingToken()).isEqualTo(mockRoutingToken); - assertThat(boundStatement.getCustomPayload()).isEqualTo(mockCustomPayload); + if (atLeastV4) { + assertThat(boundStatement.getCustomPayload()).isEqualTo(mockCustomPayload); + } assertThat(boundStatement.isIdempotent()).isTrue(); assertThat(boundStatement.isTracing()).isTrue(); assertThat(boundStatement.getTimeout()).isEqualTo(mockTimeout);