use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.
the class ProtocolVersionInitialNegotiationIT method should_downgrade_to_v4_dse.
@DseRequirement(min = "5.0", max = "5.1", description = "Only DSE in [5.0,5.1[ has V4 as its highest version")
@Test
public void should_downgrade_to_v4_dse() {
try (CqlSession session = SessionUtils.newSession(ccm)) {
assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(4);
session.execute("select * from system.local");
}
}
use of com.datastax.oss.driver.api.testinfra.DseRequirement in project java-driver by datastax.
the class BaseCcmRule method apply.
@Override
public Statement apply(Statement base, Description description) {
// If test is annotated with CassandraRequirement or DseRequirement, ensure configured CCM
// cluster meets those requirements.
CassandraRequirement cassandraRequirement = description.getAnnotation(CassandraRequirement.class);
if (cassandraRequirement != null) {
// if the configured cassandra cassandraRequirement exceeds the one being used skip this test.
if (!cassandraRequirement.min().isEmpty()) {
Version minVersion = Version.parse(cassandraRequirement.min());
if (minVersion.compareTo(ccmBridge.getCassandraVersion()) > 0) {
return buildErrorStatement(minVersion, cassandraRequirement.description(), false, false);
}
}
if (!cassandraRequirement.max().isEmpty()) {
// if the test version exceeds the maximum configured one, fail out.
Version maxVersion = Version.parse(cassandraRequirement.max());
if (maxVersion.compareTo(ccmBridge.getCassandraVersion()) <= 0) {
return buildErrorStatement(maxVersion, cassandraRequirement.description(), true, false);
}
}
}
DseRequirement dseRequirement = description.getAnnotation(DseRequirement.class);
if (dseRequirement != null) {
Optional<Version> dseVersionOption = ccmBridge.getDseVersion();
if (!dseVersionOption.isPresent()) {
return new Statement() {
@Override
public void evaluate() {
throw new AssumptionViolatedException("Test Requires DSE but C* is configured.");
}
};
} else {
Version dseVersion = dseVersionOption.get();
if (!dseRequirement.min().isEmpty()) {
Version minVersion = Version.parse(dseRequirement.min());
if (minVersion.compareTo(dseVersion) > 0) {
return buildErrorStatement(minVersion, dseRequirement.description(), false, true);
}
}
if (!dseRequirement.max().isEmpty()) {
Version maxVersion = Version.parse(dseRequirement.max());
if (maxVersion.compareTo(dseVersion) <= 0) {
return buildErrorStatement(maxVersion, dseRequirement.description(), true, true);
}
}
}
}
return super.apply(base, description);
}
Aggregations