Elffuss BraidHub

kikocis/java-driver public

Merge pull request #805 from datastax/consistentTestVersioning

Backport #791 and remove ambiguity in Cassandra and DSE versions in tests
Changesetfbbfd98238e60796415a07da8031013afe824ad8b3ff57bd6e377f01d550876a
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2017-02-17 13:08 -06:00
CommitterGitHub <noreply@github.com> · 2017-02-17 13:08 -06:00
Parents977288e0a12f, b19c57544376

Browse the files at this changeset

89 files changed

modified driver-core/src/test/java/com/datastax/driver/core/AggregateMetadataTest.java +5 −5
@@ -24,7 +24,7 @@
2424 import static com.datastax.driver.core.DataType.text;
2525 import static com.datastax.driver.core.TestUtils.serializeForDynamicCompositeType;
2626
27-@CassandraVersion(major = 2.2)
27+@CassandraVersion("2.2.0")
2828 @CCMConfig(config = "enable_user_defined_functions:true")
2929 public class AggregateMetadataTest extends CCMTestsSupport {
3030
@@ -183,9 +183,9 @@
183183 * @since 3.0.1
184184 */
185185 @Test(groups = "short")
186- @CassandraVersion(major = 2.2)
186+ @CassandraVersion("2.2.0")
187187 public void should_parse_and_format_aggregate_with_composite_type_literal_initcond() {
188- VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion());
188+ VersionNumber ver = ccm().getCassandraVersion();
189189 if (ver.getMajor() == 3) {
190190 if ((ver.getMinor() >= 1 && ver.getMinor() < 4) || (ver.getMinor() == 0 && ver.getPatch() < 4)) {
191191 throw new SkipException("Requires C* 2.2.X, 3.0.4+ or 3.4.X+");
@@ -204,9 +204,9 @@
204204 * @since 3.0.1
205205 */
206206 @Test(groups = "short")
207- @CassandraVersion(major = 3.0, minor = 4)
207+ @CassandraVersion("3.4")
208208 public void should_parse_and_format_aggregate_with_composite_type_hex_initcond() {
209- VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion());
209+ VersionNumber ver = ccm().getCassandraVersion();
210210 if ((ver.getMinor() >= 1 && ver.getMinor() < 4)) {
211211 throw new SkipException("Requires 3.0.4+ or 3.4.X+");
212212 }
modified driver-core/src/test/java/com/datastax/driver/core/AsyncQueryTest.java +1 −1
@@ -166,7 +166,7 @@
166166 }
167167
168168 @Test(groups = "short")
169- @CassandraVersion(major = 2.0, description = "Paging is not supported until 2.0")
169+ @CassandraVersion(value = "2.0.0", description = "Paging is not supported until 2.0")
170170 public void should_fail_when_auto_paging_on_io_thread() throws Exception {
171171 for (int i = 0; i < 1000; i++) {
172172 Statement statement = new SimpleStatement("select v from asyncquerytest.foo where k = 1");
modified driver-core/src/test/java/com/datastax/driver/core/AsyncResultSetTest.java +1 −1
@@ -27,7 +27,7 @@
2727
2828 import static org.assertj.core.api.Assertions.assertThat;
2929
30-@CassandraVersion(major = 2.0, description = "uses paging")
30+@CassandraVersion(value = "2.0.0", description = "uses paging")
3131 public class AsyncResultSetTest extends CCMTestsSupport {
3232
3333 @Override
modified driver-core/src/test/java/com/datastax/driver/core/AuthenticationTest.java +1 −1
@@ -41,7 +41,7 @@
4141 public void sleepIf12() {
4242 // For C* 1.2, sleep before attempting to connect as there is a small delay between
4343 // user being created.
44- if (ccm().getVersion().getMajor() < 2) {
44+ if (ccm().getCassandraVersion().getMajor() < 2) {
4545 Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
4646 }
4747 }
modified driver-core/src/test/java/com/datastax/driver/core/BatchStatementTest.java +1 −1
@@ -71,7 +71,7 @@
7171 }
7272
7373 @Test(groups = "short")
74- @CassandraVersion(major = 2.0, minor = 9, description = "This will only work with C* 2.0.9 (CASSANDRA-7337)")
74+ @CassandraVersion(value = "2.0.9", description = "This will only work with C* 2.0.9 (CASSANDRA-7337)")
7575 public void casBatchTest() {
7676 PreparedStatement st = session().prepare("INSERT INTO test (k, v) VALUES (?, ?) IF NOT EXISTS");
7777
modified driver-core/src/test/java/com/datastax/driver/core/CCMAccess.java +26 −3
@@ -32,13 +32,21 @@
3232 String getClusterName();
3333
3434 /**
35- * Returns the Cassandra version of this CCM cluster.
35+ * Returns the Cassandra version of this CCM cluster. If {@link #getDSEVersion()} is non-null it is assumed
36+ * that this value is only used for representing the compatible Cassandra version for that DSE version.
3637 * <p/>
37- * By default the version is equal to {@link CCMBridge#getCassandraVersion()}.
3838 *
3939 * @return The version of this CCM cluster.
4040 */
41- VersionNumber getVersion();
41+ VersionNumber getCassandraVersion();
42+
43+ /**
44+ * Returns the DSE version of this CCM cluster if this is a DSE cluster, otherwise null.
45+ * <p/>
46+ *
47+ * @return The version of this CCM cluster.
48+ */
49+ VersionNumber getDSEVersion();
4250
4351 /**
4452 * @return The config directory for this CCM cluster.
@@ -236,4 +244,19 @@
236244 */
237245 void waitForDown(int node);
238246
247+ /**
248+ * @return The target protocolVersion to use when connecting to this CCM cluster.
249+ * <p/>
250+ * This should be based on the highest protocol version that both the cluster and driver support.
251+ * <p/>
252+ * For example, C* 2.0.17 should return {@link ProtocolVersion#V2} since C* supports up to V2 and the driver
253+ * supports that version.
254+ */
255+ ProtocolVersion getProtocolVersion();
256+
257+ /**
258+ * @param maximumAllowed The maximum protocol version to use.
259+ * @return The target protocolVersion or maximumAllowed if {@link #getProtocolVersion} is greater.
260+ */
261+ ProtocolVersion getProtocolVersion(ProtocolVersion maximumAllowed);
239262 }
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +163 −134
@@ -40,11 +40,11 @@
4040
4141 private static final Logger logger = LoggerFactory.getLogger(CCMBridge.class);
4242
43- private static final String CASSANDRA_VERSION;
43+ private static final VersionNumber GLOBAL_CASSANDRA_VERSION_NUMBER;
4444
45- private static final Set<String> CASSANDRA_INSTALL_ARGS;
45+ private static final VersionNumber GLOBAL_DSE_VERSION_NUMBER;
4646
47- private static final boolean IS_DSE;
47+ private static final Set<String> CASSANDRA_INSTALL_ARGS;
4848
4949 public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "cassandra1sfun";
5050 public static final String DEFAULT_CLIENT_TRUSTSTORE_PATH = "/client.truststore";
@@ -81,8 +81,8 @@
8181 private static final Map<String, String> ENVIRONMENT_MAP;
8282
8383 /**
84- * A mapping of full DSE versions to their C* counterpart. This is not meant to be comprehensive. Used by
85- * {@link #getCassandraVersion()}. If C* version cannot be derived, the method makes a 'best guess'.
84+ * A mapping of full DSE versions to their C* counterpart. This is not meant to be comprehensive.
85+ * If C* version cannot be derived, the method makes a 'best guess'.
8686 */
8787 private static final Map<String, String> dseToCassandraVersions = ImmutableMap.<String, String>builder()
8888 .put("5.0.4", "3.0.10")
@@ -144,14 +144,14 @@
144144 private static final String CCM_COMMAND;
145145
146146 static {
147- CASSANDRA_VERSION = System.getProperty("cassandra.version");
147+ String inputCassandraVersion = System.getProperty("cassandra.version");
148148 String installDirectory = System.getProperty("cassandra.directory");
149149 String branch = System.getProperty("cassandra.branch");
150150
151151 String dseProperty = System.getProperty("dse");
152152 // If -Ddse, if the value is empty interpret it as enabled,
153153 // otherwise if there is a value, parse as boolean.
154- IS_DSE = dseProperty != null && (dseProperty.isEmpty() || Boolean.parseBoolean(dseProperty));
154+ boolean isDse = dseProperty != null && (dseProperty.isEmpty() || Boolean.parseBoolean(dseProperty));
155155
156156 ImmutableSet.Builder<String> installArgs = ImmutableSet.builder();
157157 if (installDirectory != null && !installDirectory.trim().isEmpty()) {
@@ -159,10 +159,10 @@
159159 } else if (branch != null && !branch.trim().isEmpty()) {
160160 installArgs.add("-v git:" + branch.trim().replaceAll("\"", ""));
161161 } else {
162- installArgs.add("-v " + CASSANDRA_VERSION);
162+ installArgs.add("-v " + inputCassandraVersion);
163163 }
164164
165- if (IS_DSE) {
165+ if (isDse) {
166166 installArgs.add("--dse");
167167 }
168168
@@ -193,12 +193,57 @@
193193 }
194194 ENVIRONMENT_MAP = ImmutableMap.copyOf(envMap);
195195
196- if (CCMBridge.isDSE()) {
196+ if (isDse) {
197+ GLOBAL_DSE_VERSION_NUMBER = VersionNumber.parse(inputCassandraVersion);
198+ GLOBAL_CASSANDRA_VERSION_NUMBER = CCMBridge.getCassandraVersion(GLOBAL_DSE_VERSION_NUMBER);
197199 logger.info("Tests requiring CCM will by default use DSE version {} (C* {}, install arguments: {})",
198- CCMBridge.getDSEVersion(), CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
200+ GLOBAL_DSE_VERSION_NUMBER, GLOBAL_CASSANDRA_VERSION_NUMBER, CASSANDRA_INSTALL_ARGS);
199201 } else {
202+ GLOBAL_CASSANDRA_VERSION_NUMBER = VersionNumber.parse(inputCassandraVersion);
203+ GLOBAL_DSE_VERSION_NUMBER = null;
200204 logger.info("Tests requiring CCM will by default use Cassandra version {} (install arguments: {})",
201- CCMBridge.getCassandraVersion(), CCMBridge.getInstallArguments());
205+ GLOBAL_CASSANDRA_VERSION_NUMBER, CASSANDRA_INSTALL_ARGS);
206+ }
207+ }
208+
209+ /**
210+ * @return {@link VersionNumber} configured for Cassandra based on system properties.
211+ */
212+ public static VersionNumber getGlobalCassandraVersion() {
213+ return GLOBAL_CASSANDRA_VERSION_NUMBER;
214+ }
215+
216+ /**
217+ * @return {@link VersionNumber} configured for DSE based on system properties.
218+ */
219+ public static VersionNumber getGlobalDSEVersion() {
220+ return GLOBAL_DSE_VERSION_NUMBER;
221+ }
222+
223+ /**
224+ * @return The mapped cassandra version to the given dseVersion.
225+ * If the DSE version can't be derived the following logic is used:
226+ * <ol>
227+ * <li>If <= 3.X, use C* 1.2</li>
228+ * <li>If 4.X, use 2.1 for >= 4.7, 2.0 otherwise.</li>
229+ * <li>Otherwise 3.0</li>
230+ * </ol>
231+ */
232+ public static VersionNumber getCassandraVersion(VersionNumber dseVersion) {
233+ String cassandraVersion = dseToCassandraVersions.get(dseVersion.toString());
234+ if (cassandraVersion != null) {
235+ return VersionNumber.parse(cassandraVersion);
236+ } else if (dseVersion.getMajor() <= 3) {
237+ return VersionNumber.parse("1.2");
238+ } else if (dseVersion.getMajor() == 4) {
239+ if (dseVersion.getMinor() >= 7) {
240+ return VersionNumber.parse("2.1");
241+ } else {
242+ return VersionNumber.parse("2.0");
243+ }
244+ } else {
245+ // Fallback on 3.0 by default.
246+ return VersionNumber.parse("3.0");
202247 }
203248 }
204249
@@ -215,7 +260,9 @@
215260
216261 private final String clusterName;
217262
218- private final VersionNumber version;
263+ private final VersionNumber cassandraVersion;
264+
265+ private final VersionNumber dseVersion;
219266
220267 private final int storagePort;
221268
@@ -237,75 +284,20 @@
237284
238285 private final int[] nodes;
239286
240- private CCMBridge(String clusterName, boolean isDSE, VersionNumber version, int storagePort, int thriftPort, int binaryPort, String jvmArgs, int[] nodes) {
287+ private CCMBridge(String clusterName, VersionNumber cassandraVersion, VersionNumber dseVersion,
288+ int storagePort, int thriftPort, int binaryPort, String jvmArgs, int[] nodes) {
241289 this.clusterName = clusterName;
242- this.version = version;
290+ this.cassandraVersion = cassandraVersion;
291+ this.dseVersion = dseVersion;
243292 this.storagePort = storagePort;
244293 this.thriftPort = thriftPort;
245294 this.binaryPort = binaryPort;
246- this.isDSE = isDSE;
295+ this.isDSE = dseVersion != null;
247296 this.jvmArgs = jvmArgs;
248297 this.nodes = nodes;
249298 this.ccmDir = Files.createTempDir();
250299 }
251300
252- /**
253- * @return The configured cassandra version. If -Ddse=true was used, this value is derived from the
254- * DSE version provided. If the DSE version can't be derived the following logic is used:
255- * <ol>
256- * <li>If <= 3.X, use C* 1.2</li>
257- * <li>If 4.X, use 2.1 for >= 4.7, 2.0 otherwise.</li>
258- * <li>Otherwise 3.0</li>
259- * </ol>
260- */
261- public static String getCassandraVersion() {
262- if (isDSE()) {
263- String cassandraVersion = dseToCassandraVersions.get(CASSANDRA_VERSION);
264- if (cassandraVersion != null) {
265- return cassandraVersion;
266- } else if (CASSANDRA_VERSION.startsWith("3.") || CASSANDRA_VERSION.compareTo("3") <= 0) {
267- return "1.2";
268- } else if (CASSANDRA_VERSION.startsWith("4.")) {
269- if (CASSANDRA_VERSION.compareTo("4.7") >= 0) {
270- return "2.1";
271- } else {
272- return "2.0";
273- }
274- } else {
275- // Fallback on 3.0 by default.
276- return "3.0";
277- }
278-
279- } else {
280- return CASSANDRA_VERSION;
281- }
282- }
283-
284- /**
285- * @return The configured DSE version if '-Ddse=true' specified, otherwise null.
286- */
287- public static String getDSEVersion() {
288- if (isDSE()) {
289- return CASSANDRA_VERSION;
290- } else {
291- return null;
292- }
293- }
294-
295- /**
296- * @return Whether or not DSE was configured via '-Ddse=true'.
297- */
298- public static boolean isDSE() {
299- return IS_DSE;
300- }
301-
302- /**
303- * @return The install arguments to pass to CCM when creating the cluster.
304- */
305- public static Set<String> getInstallArguments() {
306- return CASSANDRA_INSTALL_ARGS;
307- }
308-
309301 public static Builder builder() {
310302 return new Builder();
311303 }
@@ -321,8 +313,13 @@
321313 }
322314
323315 @Override
324- public VersionNumber getVersion() {
325- return version;
316+ public VersionNumber getCassandraVersion() {
317+ return cassandraVersion;
318+ }
319+
320+ @Override
321+ public VersionNumber getDSEVersion() {
322+ return dseVersion;
326323 }
327324
328325 @Override
@@ -404,7 +401,7 @@
404401 private String getStartWaitArguments() {
405402 // make a small exception for C* 1.2 as it has a bug where it starts listening on the binary
406403 // interface slightly before it joins the cluster.
407- if (getCassandraVersion().startsWith("1.")) {
404+ if (this.cassandraVersion.getMajor() == 1) {
408405 return " --wait-other-notice";
409406 } else {
410407 return " --no-wait";
@@ -419,7 +416,7 @@
419416 logger.debug("Starting: {} - free memory: {} MB", this, TestUtils.getFreeMemoryMB());
420417 try {
421418 String cmd = CCM_COMMAND + " start " + jvmArgs + getStartWaitArguments();
422- if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
419+ if (isWindows() && this.cassandraVersion.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
423420 cmd += " --quiet-windows";
424421 }
425422 execute(cmd);
@@ -493,7 +490,7 @@
493490 logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
494491 try {
495492 String cmd = CCM_COMMAND + " node%d start " + jvmArgs + getStartWaitArguments();
496- if (isWindows() && this.version.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
493+ if (isWindows() && this.cassandraVersion.compareTo(VersionNumber.parse("2.2.4")) >= 0) {
497494 cmd += " --quiet-windows";
498495 }
499496 execute(cmd, n);
@@ -549,7 +546,12 @@
549546 @Override
550547 public void decommission(int n) {
551548 logger.debug(String.format("Decommissioning: node %s (%s%s:%s) from %s", n, TestUtils.IP_PREFIX, n, binaryPort, this));
552- execute(CCM_COMMAND + " node%d decommission", n);
549+ // Special case for C* 3.12+, DSE 5.1+, force decommission (see CASSANDRA-12510)
550+ String cmd = CCM_COMMAND + " node%d decommission";
551+ if (this.cassandraVersion.compareTo(VersionNumber.parse("3.12")) >= 0) {
552+ cmd += " --force";
553+ }
554+ execute(cmd, n);
553555 }
554556
555557 @Override
@@ -688,6 +690,26 @@
688690 TestUtils.waitUntilPortIsDown(addressOfNode(node));
689691 }
690692
693+ @Override
694+ public ProtocolVersion getProtocolVersion() {
695+ VersionNumber version = getCassandraVersion();
696+ if (version.compareTo(VersionNumber.parse("2.0")) < 0) {
697+ return ProtocolVersion.V1;
698+ } else if (version.compareTo(VersionNumber.parse("2.1")) < 0) {
699+ return ProtocolVersion.V2;
700+ } else if (version.compareTo(VersionNumber.parse("2.2")) < 0) {
701+ return ProtocolVersion.V3;
702+ } else {
703+ return ProtocolVersion.V4;
704+ }
705+ }
706+
707+ @Override
708+ public ProtocolVersion getProtocolVersion(ProtocolVersion maximumAllowed) {
709+ ProtocolVersion versionToUse = getProtocolVersion();
710+ return versionToUse.compareTo(maximumAllowed) > 0 ? maximumAllowed : versionToUse;
711+ }
712+
691713 /**
692714 * <p>
693715 * Extracts a keystore from the classpath into a temporary file.
@@ -746,9 +768,9 @@
746768
747769 int[] nodes = {1};
748770 private boolean start = true;
749- private Boolean isDSE = null;
750- private String version = getCassandraVersion();
751- private Set<String> createOptions = new LinkedHashSet<String>(getInstallArguments());
771+ private boolean dse = false;
772+ private VersionNumber version = null;
773+ private Set<String> createOptions = new LinkedHashSet<String>();
752774 private Set<String> jvmArgs = new LinkedHashSet<String>();
753775 private final Map<String, Object> cassandraConfiguration = Maps.newLinkedHashMap();
754776 private final Map<String, Object> dseConfiguration = Maps.newLinkedHashMap();
@@ -804,41 +826,24 @@
804826 }
805827
806828 /**
807- * Sets this cluster to be a DSE cluster (defaults to {@link #isDSE()} if this is never called).
808- */
809- public Builder withDSE() {
810- this.isDSE = true;
811- return this;
812- }
813-
814- /**
815- * Sets this cluster to be a non-DSE cluster (defaults to {@link #isDSE()} if this is never called).
829+ * The Cassandra or DSE version to use. If not specified the globally configured version is used instead.
816830 */
817- public Builder withoutDSE() {
818- this.isDSE = false;
831+ public Builder withVersion(VersionNumber version) {
832+ this.version = version;
819833 return this;
820834 }
821835
822836 /**
823- * The Cassandra or DSE version to use (defaults to {@link #getCassandraVersion()} if this is never called).
837+ * Indicates whether or not this cluster is meant to be a DSE cluster.
824838 */
825- public Builder withVersion(String version) {
826- Iterator<String> it = createOptions.iterator();
827- while (it.hasNext()) {
828- String option = it.next();
829- // remove any version previously set and
830- // install-dir, which is incompatible
831- if (option.startsWith("-v ") || option.startsWith("--install-dir"))
832- it.remove();
833- }
834- this.createOptions.add("-v " + version);
835- this.version = version;
839+ public Builder withDSE(boolean dse) {
840+ this.dse = dse;
836841 return this;
837842 }
838843
839844 /**
840845 * Free-form options that will be added at the end of the {@code ccm create} command
841- * (defaults to {@link #getInstallArguments()} if this is never called).
846+ * (defaults to {@link #CASSANDRA_INSTALL_ARGS} if this is never called).
842847 */
843848 public Builder withCreateOptions(String... createOptions) {
844849 Collections.addAll(this.createOptions, createOptions);
@@ -901,14 +906,36 @@
901906 public CCMBridge build() {
902907 // be careful NOT to alter internal state (hashCode/equals) during build!
903908 String clusterName = TestUtils.generateIdentifier("ccm_");
904- boolean dse = isDSE == null ? isDSE() : isDSE;
909+
910+
911+ VersionNumber dseVersion;
912+ VersionNumber cassandraVersion;
913+ boolean versionConfigured = this.version != null;
914+ // No version was explicitly provided, fallback on global config.
915+ if (!versionConfigured) {
916+ dseVersion = GLOBAL_DSE_VERSION_NUMBER;
917+ cassandraVersion = GLOBAL_CASSANDRA_VERSION_NUMBER;
918+ } else if (dse) {
919+ // given version is the DSE version, base cassandra version on DSE version.
920+ dseVersion = this.version;
921+ cassandraVersion = getCassandraVersion(dseVersion);
922+ } else {
923+ // given version is cassandra version.
924+ dseVersion = null;
925+ cassandraVersion = this.version;
926+ }
905927
906928 Map<String, Object> cassandraConfiguration = randomizePorts(this.cassandraConfiguration);
907- VersionNumber version = VersionNumber.parse(this.version);
908929 int storagePort = Integer.parseInt(cassandraConfiguration.get("storage_port").toString());
909930 int thriftPort = Integer.parseInt(cassandraConfiguration.get("rpc_port").toString());
910931 int binaryPort = Integer.parseInt(cassandraConfiguration.get("native_transport_port").toString());
911- final CCMBridge ccm = new CCMBridge(clusterName, dse, version, storagePort, thriftPort, binaryPort, joinJvmArgs(), nodes);
932+ if (!isThriftSupported(cassandraVersion)) {
933+ // remove thrift configuration
934+ cassandraConfiguration.remove("start_rpc");
935+ cassandraConfiguration.remove("rpc_port");
936+ cassandraConfiguration.remove("thrift_prepared_statements_cache_size_mb");
937+ }
938+ final CCMBridge ccm = new CCMBridge(clusterName, cassandraVersion, dseVersion, storagePort, thriftPort, binaryPort, joinJvmArgs(), nodes);
912939
913940 Runtime.getRuntime().addShutdownHook(new Thread() {
914941 @Override
@@ -916,15 +943,12 @@
916943 ccm.close();
917944 }
918945 });
919- ccm.execute(buildCreateCommand(clusterName, dse));
946+ ccm.execute(buildCreateCommand(clusterName, versionConfigured, cassandraVersion, dseVersion));
920947 updateNodeConf(ccm);
921948 ccm.updateConfig(cassandraConfiguration);
922- if (dse) {
949+ if (dseVersion != null) {
923950 Map<String, Object> dseConfiguration = Maps.newLinkedHashMap(this.dseConfiguration);
924- /* TODO: Use version passed in if present, there is currently a conflation of C* and DSE versions
925- * when it comes to this that don't want to disturb. No tests are currently using withVersion with
926- * dse, so its not an issue at the moment. */
927- if (VersionNumber.parse(CCMBridge.getDSEVersion()).getMajor() >= 5) {
951+ if (dseVersion.getMajor() >= 5) {
928952 // randomize DSE specific ports if dse present and greater than 5.0
929953 dseConfiguration.put("lease_netty_server_port", RANDOM_PORT);
930954 dseConfiguration.put("internode_messaging_options.port", RANDOM_PORT);
@@ -941,6 +965,10 @@
941965 return ccm;
942966 }
943967
968+ private static boolean isThriftSupported(VersionNumber cassandraVersion) {
969+ return cassandraVersion.compareTo(VersionNumber.parse("4.0")) < 0;
970+ }
971+
944972 public int weight() {
945973 // the weight is simply function of the number of nodes
946974 int totalNodes = 0;
@@ -964,7 +992,7 @@
964992 return allJvmArgs.toString();
965993 }
966994
967- private String buildCreateCommand(String clusterName, boolean dse) {
995+ private String buildCreateCommand(String clusterName, boolean versionConfigured, VersionNumber cassandraVersion, VersionNumber dseVersion) {
968996 StringBuilder result = new StringBuilder(CCM_COMMAND + " create");
969997 result.append(" ").append(clusterName);
970998 result.append(" -i ").append(TestUtils.IP_PREFIX);
@@ -979,16 +1007,18 @@
9791007 }
9801008 }
9811009
982- // If not DSE, remove --dse if in createOptions.
9831010 Set<String> lCreateOptions = new LinkedHashSet<String>(createOptions);
984- if (!dse) {
985- Iterator<String> it = lCreateOptions.iterator();
986- while (it.hasNext()) {
987- String option = it.next();
988- // remove any version previously set and
989- // install-dir, which is incompatible
990- if (option.equals("--dse"))
991- it.remove();
1011+ if (!versionConfigured) {
1012+ // If no version was provided, use the default install ags.
1013+ lCreateOptions.addAll(CASSANDRA_INSTALL_ARGS);
1014+ } else {
1015+ if (dseVersion != null) {
1016+ lCreateOptions.add("--dse");
1017+ lCreateOptions.add("-v");
1018+ lCreateOptions.add(dseVersion.toString());
1019+ } else {
1020+ lCreateOptions.add("-v");
1021+ lCreateOptions.add(cassandraVersion.toString());
9921022 }
9931023 }
9941024 result.append(" ").append(Joiner.on(" ").join(randomizePorts(lCreateOptions)));
@@ -1077,14 +1107,15 @@
10771107 @Override
10781108 @SuppressWarnings("SimplifiableIfStatement")
10791109 public boolean equals(Object o) {
1080- // do not include cluster name and start, only
1081- // properties relevant to the settings of the cluster
1110+ // do not include start as it is not relevant to the settings of the cluster.
10821111 if (this == o) return true;
10831112 if (o == null || getClass() != o.getClass()) return false;
1113+
10841114 Builder builder = (Builder) o;
1115+
1116+ if (dse != builder.dse) return false;
10851117 if (!Arrays.equals(nodes, builder.nodes)) return false;
1086- if (isDSE != null ? !isDSE.equals(builder.isDSE) : builder.isDSE != null) return false;
1087- if (!version.equals(builder.version)) return false;
1118+ if (version != null ? !version.equals(builder.version) : builder.version != null) return false;
10881119 if (!createOptions.equals(builder.createOptions)) return false;
10891120 if (!jvmArgs.equals(builder.jvmArgs)) return false;
10901121 if (!cassandraConfiguration.equals(builder.cassandraConfiguration)) return false;
@@ -1094,19 +1125,17 @@
10941125
10951126 @Override
10961127 public int hashCode() {
1097- // do not include cluster name and start, only
1098- // properties relevant to the settings of the cluster
1128+ // do not include start as it is not relevant to the settings of the cluster.
10991129 int result = Arrays.hashCode(nodes);
1100- result = 31 * result + (isDSE != null ? isDSE.hashCode() : 0);
1130+ result = 31 * result + (dse ? 1 : 0);
1131+ result = 31 * result + (version != null ? version.hashCode() : 0);
11011132 result = 31 * result + createOptions.hashCode();
11021133 result = 31 * result + jvmArgs.hashCode();
11031134 result = 31 * result + cassandraConfiguration.hashCode();
11041135 result = 31 * result + dseConfiguration.hashCode();
11051136 result = 31 * result + workloads.hashCode();
1106- result = 31 * result + version.hashCode();
11071137 return result;
11081138 }
1109-
11101139 }
11111140
11121141 }
modified driver-core/src/test/java/com/datastax/driver/core/CCMCache.java +17 −2
@@ -49,8 +49,13 @@
4949 }
5050
5151 @Override
52- public VersionNumber getVersion() {
53- return ccm.getVersion();
52+ public VersionNumber getCassandraVersion() {
53+ return ccm.getCassandraVersion();
54+ }
55+
56+ @Override
57+ public VersionNumber getDSEVersion() {
58+ return ccm.getDSEVersion();
5459 }
5560
5661 @Override
@@ -215,6 +220,16 @@
215220 ccm.waitForDown(node);
216221 }
217222
223+ @Override
224+ public ProtocolVersion getProtocolVersion() {
225+ return ccm.getProtocolVersion();
226+ }
227+
228+ @Override
229+ public ProtocolVersion getProtocolVersion(ProtocolVersion maximumAllowed) {
230+ return ccm.getProtocolVersion(maximumAllowed);
231+ }
232+
218233 @Override
219234 public String toString() {
220235 return ccm.toString();
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +38 −17
@@ -78,13 +78,18 @@
7878 }
7979
8080 @Override
81- public InetSocketAddress addressOfNode(int n) {
82- return delegate.addressOfNode(n);
81+ public VersionNumber getCassandraVersion() {
82+ return delegate.getCassandraVersion();
83+ }
84+
85+ @Override
86+ public VersionNumber getDSEVersion() {
87+ return delegate.getDSEVersion();
8388 }
8489
8590 @Override
86- public VersionNumber getVersion() {
87- return delegate.getVersion();
91+ public InetSocketAddress addressOfNode(int n) {
92+ return delegate.addressOfNode(n);
8893 }
8994
9095 @Override
@@ -237,6 +242,16 @@
237242 throw new UnsupportedOperationException("This CCM cluster is read-only");
238243 }
239244
245+ @Override
246+ public ProtocolVersion getProtocolVersion() {
247+ return delegate.getProtocolVersion();
248+ }
249+
250+ @Override
251+ public ProtocolVersion getProtocolVersion(ProtocolVersion maximumAllowed) {
252+ return delegate.getProtocolVersion(maximumAllowed);
253+ }
254+
240255 @Override
241256 public String toString() {
242257 return delegate.toString();
@@ -318,9 +333,15 @@
318333 }
319334
320335 private void addConfigOptions(String[] conf, Map<String, Object> config) {
321- String versionStr = version();
322- VersionNumber version = VersionNumber.parse(versionStr != null ?
323- versionStr : CCMBridge.getCassandraVersion());
336+ VersionNumber version = VersionNumber.parse(version());
337+ if (version == null) {
338+ version = CCMBridge.getGlobalCassandraVersion();
339+ } else {
340+ Boolean dse = dse();
341+ if (dse != null && dse) {
342+ version = CCMBridge.getCassandraVersion(version);
343+ }
344+ }
324345 for (String aConf : conf) {
325346 String[] tokens = aConf.split(":");
326347 if (tokens.length != 2)
@@ -331,7 +352,7 @@
331352 // cannot be met.
332353 if (configVersionRequirements.containsKey(key)) {
333354 VersionNumber requirement = configVersionRequirements.get(key);
334- if (version.compareTo(requirement) < 0) {
355+ if (version != null && version.compareTo(requirement) < 0) {
335356 LOGGER.debug("Skipping inclusion of '{}' in cassandra.yaml since it requires >= C* {} and {} " +
336357 "was detected.", aConf, requirement, version);
337358 continue;
@@ -428,16 +449,16 @@
428449 if (ccmBuilder == null) {
429450 ccmBuilder = CCMBridge.builder().withNodes(numberOfNodes()).notStarted();
430451 }
431- if (version() != null)
432- ccmBuilder.withVersion(version());
433- Boolean dse = dse();
434- if (dse != null) {
435- if (dse) {
436- ccmBuilder.withDSE();
437- } else {
438- ccmBuilder.withoutDSE();
439- }
452+
453+ String versionStr = version();
454+ if (versionStr != null) {
455+ VersionNumber version = VersionNumber.parse(versionStr);
456+ ccmBuilder.withVersion(version);
440457 }
458+
459+ Boolean dse = dse();
460+ if (dse != null)
461+ ccmBuilder.withDSE(dse);
441462 if (ssl())
442463 ccmBuilder.withSSL();
443464 if (auth())
modified driver-core/src/test/java/com/datastax/driver/core/ConditionalUpdateTest.java +1 −1
@@ -24,7 +24,7 @@
2424 /**
2525 * Test {@link ResultSet#wasApplied()} for conditional updates.
2626 */
27-@CassandraVersion(major = 2.0, description = "Conditional Updates requires 2.0+.")
27+@CassandraVersion(value = "2.0.0", description = "Conditional Updates requires 2.0+.")
2828 public class ConditionalUpdateTest extends CCMTestsSupport {
2929
3030 @Override
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +1 −1
@@ -86,7 +86,7 @@
8686 * Therefore we use two different driver instances in this test.
8787 */
8888 @Test(groups = "short")
89- @CassandraVersion(major = 2.1)
89+ @CassandraVersion("2.1.0")
9090 public void should_parse_UDT_definitions_when_using_default_protocol_version() {
9191 // First driver instance: create UDT
9292 Cluster cluster = register(Cluster.builder()
modified driver-core/src/test/java/com/datastax/driver/core/CustomPayloadTest.java +1 −11
@@ -33,7 +33,7 @@
3333 import static org.assertj.core.api.Assertions.assertThat;
3434 import static org.assertj.core.api.Fail.fail;
3535
36-@CassandraVersion(major = 2.2)
36+@CassandraVersion("2.2.0")
3737 @CCMConfig(jvmArgs = "-Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler")
3838 public class CustomPayloadTest extends CCMTestsSupport {
3939
@@ -85,8 +85,6 @@
8585
8686 /**
8787 * Ensures that an incoming payload is propagated from prepared to bound statements.
88- *
89- * @throws Exception
9088 */
9189 @Test(groups = "short")
9290 public void should_propagate_incoming_payload_to_bound_statement() throws Exception {
@@ -113,8 +111,6 @@
113111 /**
114112 * Ensures that an incoming payload is overridden by an explicitly set outgoing payload
115113 * when propagated to bound statements.
116- *
117- * @throws Exception
118114 */
119115 @Test(groups = "short")
120116 public void should_override_incoming_payload_when_outgoing_payload_explicitly_set_on_preparing_statement() throws Exception {
@@ -141,8 +137,6 @@
141137 /**
142138 * Ensures that payloads can still be set individually on bound statements
143139 * if the prepared statement does not have a default payload.
144- *
145- * @throws Exception
146140 */
147141 @Test(groups = "short")
148142 public void should_not_set_any_payload_on_bound_statement() throws Exception {
@@ -171,8 +165,6 @@
171165
172166 /**
173167 * Ensures that a custom payload is propagated throughout pages.
174- *
175- * @throws Exception
176168 */
177169 @Test(groups = "short")
178170 public void should_echo_custom_payload_when_paginating() throws Exception {
@@ -253,8 +245,6 @@
253245
254246 /**
255247 * Ensures that when debugging custom payloads, the driver will print appropriate log messages.
256- *
257- * @throws Exception
258248 */
259249 @Test(groups = "short")
260250 public void should_print_log_message_when_level_trace() throws Exception {
modified driver-core/src/test/java/com/datastax/driver/core/CustomTypeTest.java +1 −2
@@ -19,7 +19,6 @@
1919 import org.testng.annotations.Test;
2020
2121 import java.nio.ByteBuffer;
22-import java.util.ArrayList;
2322 import java.util.List;
2423 import java.util.Map;
2524
@@ -153,7 +152,7 @@
153152 * @test_category metadata
154153 */
155154 @Test(groups = "short")
156- @CassandraVersion(major = 2.1)
155+ @CassandraVersion("2.1.0")
157156 public void should_handle_udt_with_custom_type() {
158157 // Given: a UDT with custom types, and a table using it.
159158 session().execute("CREATE TYPE custom_udt (regular int, c1 'DynamicCompositeType(s => UTF8Type, i => Int32Type)', c2 'LongType')");
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeClassNameParserTest.java +1 −1
@@ -25,7 +25,7 @@
2525
2626 public class DataTypeClassNameParserTest {
2727
28- private ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion();
28+ private ProtocolVersion protocolVersion = ProtocolVersion.NEWEST_SUPPORTED;
2929 private CodecRegistry codecRegistry = new CodecRegistry();
3030
3131 @Test(groups = "unit")
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeCqlNameParserTest.java +1 −1
@@ -23,7 +23,7 @@
2323 import static com.datastax.driver.core.DataTypeCqlNameParser.parse;
2424 import static com.datastax.driver.core.Metadata.quote;
2525
26-@CassandraVersion(major = 3.0)
26+@CassandraVersion("3.0")
2727 public class DataTypeCqlNameParserTest extends CCMTestsSupport {
2828
2929 @Test(groups = "short")
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeIntegrationTest.java +23 −18
@@ -36,17 +36,22 @@
3636 * (protocol > v2 only) and a prepared statement.
3737 * This is repeated with a large number of datatypes.
3838 */
39-@CCMConfig(clusterProvider = "createClusterBuilderNoDebouncing")
4039 public class DataTypeIntegrationTest extends CCMTestsSupport {
4140 private static final Logger logger = LoggerFactory.getLogger(DataTypeIntegrationTest.class);
4241
43- List<TestTable> tables = allTables();
44- VersionNumber cassandraVersion;
42+ private Map<DataType, Object> samples;
43+
44+ private List<TestTable> tables;
45+
46+ private VersionNumber cassandraVersion;
4547
4648 enum StatementType {RAW_STRING, SIMPLE_WITH_PARAM, PREPARED}
4749
4850 @Override
4951 public void onTestContextInitialized() {
52+ ProtocolVersion protocolVersion = ccm().getProtocolVersion();
53+ samples = PrimitiveTypeSamples.samples(protocolVersion);
54+ tables = allTables();
5055 Host host = cluster().getMetadata().getAllHosts().iterator().next();
5156 cassandraVersion = host.getCassandraVersion().nextStable();
5257 List<String> statements = Lists.newArrayList();
@@ -71,7 +76,7 @@
7176 }
7277
7378 @Test(groups = "long")
74- @CassandraVersion(major = 2.0, description = "Uses parameterized simple statements, which are only available with protocol v2")
79+ @CassandraVersion(value = "2.0", description = "Uses parameterized simple statements, which are only available with protocol v2")
7580 public void should_insert_and_retrieve_data_with_parameterized_simple_statements() {
7681 should_insert_and_retrieve_data(StatementType.SIMPLE_WITH_PARAM);
7782 }
@@ -189,7 +194,7 @@
189194 }
190195 }
191196
192- private static List<TestTable> allTables() {
197+ private List<TestTable> allTables() {
193198 List<TestTable> tables = Lists.newArrayList();
194199
195200 tables.addAll(tablesWithPrimitives());
@@ -202,18 +207,18 @@
202207 return ImmutableList.copyOf(tables);
203208 }
204209
205- private static List<TestTable> tablesWithPrimitives() {
210+ private List<TestTable> tablesWithPrimitives() {
206211 List<TestTable> tables = Lists.newArrayList();
207- for (Map.Entry<DataType, Object> entry : PrimitiveTypeSamples.ALL.entrySet())
212+ for (Map.Entry<DataType, Object> entry : samples.entrySet())
208213 tables.add(new TestTable(entry.getKey(), entry.getValue(), "1.2.0"));
209214 return tables;
210215 }
211216
212- private static List<TestTable> tablesWithPrimitivesNull() {
217+ private List<TestTable> tablesWithPrimitivesNull() {
213218 List<TestTable> tables = Lists.newArrayList();
214219 // Create a test table for each primitive type testing with null values. If the
215220 // type maps to a java primitive type it's value will by the default value instead of null.
216- for (DataType dataType : DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion())) {
221+ for (DataType dataType : DataType.allPrimitiveTypes(ccm().getProtocolVersion())) {
217222 Object expectedPrimitiveValue = null;
218223 switch (dataType.getName()) {
219224 case BIGINT:
@@ -248,9 +253,9 @@
248253
249254 }
250255
251- private static List<TestTable> tablesWithCollectionsOfPrimitives() {
256+ private List<TestTable> tablesWithCollectionsOfPrimitives() {
252257 List<TestTable> tables = Lists.newArrayList();
253- for (Map.Entry<DataType, Object> entry : PrimitiveTypeSamples.ALL.entrySet()) {
258+ for (Map.Entry<DataType, Object> entry : samples.entrySet()) {
254259
255260 DataType elementType = entry.getKey();
256261 Object elementSample = entry.getValue();
@@ -261,12 +266,12 @@
261266 return tables;
262267 }
263268
264- private static List<TestTable> tablesWithMapsOfPrimitives() {
269+ private List<TestTable> tablesWithMapsOfPrimitives() {
265270 List<TestTable> tables = Lists.newArrayList();
266- for (Map.Entry<DataType, Object> keyEntry : PrimitiveTypeSamples.ALL.entrySet()) {
271+ for (Map.Entry<DataType, Object> keyEntry : samples.entrySet()) {
267272 DataType keyType = keyEntry.getKey();
268273 Object keySample = keyEntry.getValue();
269- for (Map.Entry<DataType, Object> valueEntry : PrimitiveTypeSamples.ALL.entrySet()) {
274+ for (Map.Entry<DataType, Object> valueEntry : samples.entrySet()) {
270275 DataType valueType = valueEntry.getKey();
271276 Object valueSample = valueEntry.getValue();
272277
@@ -278,7 +283,7 @@
278283 return tables;
279284 }
280285
281- private static Collection<? extends TestTable> tablesWithNestedCollections() {
286+ private Collection<? extends TestTable> tablesWithNestedCollections() {
282287 List<TestTable> tables = Lists.newArrayList();
283288
284289 // To avoid combinatorial explosion, only use int as the primitive type, and two levels of nesting.
@@ -309,7 +314,7 @@
309314 return tables;
310315 }
311316
312- private static Collection<? extends TestTable> tablesWithRandomlyGeneratedNestedCollections() {
317+ private Collection<? extends TestTable> tablesWithRandomlyGeneratedNestedCollections() {
313318 List<TestTable> tables = Lists.newArrayList();
314319
315320 DataType nestedListType = buildNestedType(DataType.Name.LIST, 5);
@@ -325,7 +330,7 @@
325330 /**
326331 * Populate a nested collection based on the given type and it's arguments.
327332 */
328- public static Object nestedObject(DataType type) {
333+ public Object nestedObject(DataType type) {
329334
330335 int typeIdx = type.getTypeArguments().size() > 1 ? 1 : 0;
331336 DataType argument = type.getTypeArguments().get(typeIdx);
@@ -375,7 +380,7 @@
375380 * @return a DataType that is a nested collection with the given baseType with the
376381 * given depth.
377382 */
378- public static DataType buildNestedType(DataType.Name baseType, int depth) {
383+ public DataType buildNestedType(DataType.Name baseType, int depth) {
379384 Random r = new Random();
380385 DataType t = null;
381386
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeTest.java +1 −1
@@ -37,7 +37,7 @@
3737
3838 CodecRegistry codecRegistry = new CodecRegistry();
3939
40- ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion();
40+ ProtocolVersion protocolVersion = ProtocolVersion.NEWEST_SUPPORTED;
4141
4242 static boolean exclude(DataType t) {
4343 return t.getName() == DataType.Name.COUNTER;
modified driver-core/src/test/java/com/datastax/driver/core/DirectCompressionTest.java +1 −1
@@ -40,7 +40,7 @@
4040 * @expected_result session established and queries made successfully using it.
4141 */
4242 @Test(groups = "short")
43- @CassandraVersion(major = 2.0)
43+ @CassandraVersion("2.0.0")
4444 public void should_function_with_lz4_compression() throws Exception {
4545 compressionTest(ProtocolOptions.Compression.LZ4);
4646 }
modified driver-core/src/test/java/com/datastax/driver/core/FunctionMetadataTest.java +3 −2
@@ -19,10 +19,11 @@
1919 import org.testng.annotations.Test;
2020
2121 import static com.datastax.driver.core.Assertions.assertThat;
22-import static com.datastax.driver.core.DataType.*;
22+import static com.datastax.driver.core.DataType.cint;
23+import static com.datastax.driver.core.DataType.map;
2324 import static org.assertj.core.api.Assertions.entry;
2425
25-@CassandraVersion(major = 2.2)
26+@CassandraVersion("2.2.0")
2627 @CCMConfig(config = "enable_user_defined_functions:true")
2728 public class FunctionMetadataTest extends CCMTestsSupport {
2829
modified driver-core/src/test/java/com/datastax/driver/core/GettableDataIntegrationTest.java +1 −1
@@ -45,7 +45,7 @@
4545
4646 @Override
4747 public void onTestContextInitialized() {
48- is21 = ccm().getVersion().compareTo(VersionNumber.parse("2.1.3")) > 0;
48+ is21 = ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.1.3")) > 0;
4949 // only add tuples / nested collections at > 2.1.3.
5050 execute("CREATE TABLE codec_mapping (k int PRIMARY KEY, "
5151 + "v int, l list<int>, m map<int,int>" +
modified driver-core/src/test/java/com/datastax/driver/core/HeapCompressionTest.java +1 −1
@@ -47,7 +47,7 @@
4747 * @expected_result session established and queries made successfully using it.
4848 */
4949 @Test(groups = "isolated")
50- @CassandraVersion(major = 2.0)
50+ @CassandraVersion("2.0.0")
5151 public void should_function_with_lz4_compression() throws Exception {
5252 compressionTest(ProtocolOptions.Compression.LZ4);
5353 }
modified driver-core/src/test/java/com/datastax/driver/core/HostMetadataIntegrationTest.java +0 −43
@@ -15,7 +15,6 @@
1515 */
1616 package com.datastax.driver.core;
1717
18-import com.datastax.driver.core.utils.DseVersion;
1918 import org.apache.log4j.Level;
2019 import org.apache.log4j.Logger;
2120 import org.testng.annotations.Test;
@@ -23,52 +22,10 @@
2322 import java.net.InetAddress;
2423
2524 import static com.datastax.driver.core.Assertions.assertThat;
26-import static com.datastax.driver.core.CCMAccess.Workload.solr;
27-import static com.datastax.driver.core.CCMAccess.Workload.spark;
2825 import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
2926
3027 public class HostMetadataIntegrationTest {
3128
32- /**
33- * Validates that when given a DSE cluster that the workload and dse versions are properly
34- * parsed and set on the respective {@link Host} instances.
35- * <p/>
36- * This test is disabled as running DSE with workloads is intensive and has unreliable results
37- * when running CCM with multiple workloads.
38- * <p/>
39- *
40- * @test_category host:metadata
41- * @jira_ticket JAVA-1042
42- * @see HostMetadataIntegrationTest#should_parse_dse_workload_and_version_if_available()
43- */
44- @Test(groups = "long")
45- @DseVersion(major = 5.0)
46- public void test_mixed_dse_workload() {
47- CCMBridge.Builder builder = CCMBridge.builder()
48- .withNodes(3)
49- .withDSE()
50- .withWorkload(2, solr)
51- .withWorkload(3, spark);
52- CCMAccess ccm = CCMCache.get(builder);
53-
54- VersionNumber version = VersionNumber.parse(CCMBridge.getDSEVersion());
55-
56- Cluster cluster = Cluster.builder()
57- .addContactPoints(ccm.addressOfNode(1).getAddress())
58- .withPort(ccm.getBinaryPort())
59- .build();
60- try {
61- cluster.connect();
62-
63- assertThat(cluster).host(1).hasWorkload("Cassandra").hasDseVersion(version);
64- assertThat(cluster).host(2).hasWorkload("Search").hasDseVersion(version);
65- assertThat(cluster).host(3).hasWorkload("Analytics").hasDseVersion(version);
66- } finally {
67- cluster.close();
68- ccm.close();
69- }
70- }
71-
7229 /**
7330 * Validates that {@link Host#getDseVersion()} and {@link Host#getDseWorkload()} return values defined in
7431 * the <code>dse_version</code> and <code>workload</code> columns if they are present in <code>system.local</code>
modified driver-core/src/test/java/com/datastax/driver/core/IndexMetadataTest.java +14 −14
@@ -32,7 +32,7 @@
3232 import static com.datastax.driver.core.DataType.*;
3333 import static com.datastax.driver.core.IndexMetadata.Kind.*;
3434
35-@CassandraVersion(major = 1.2)
35+@CassandraVersion("1.2.0")
3636 public class IndexMetadataTest extends CCMTestsSupport {
3737
3838 /**
@@ -75,7 +75,7 @@
7575 + "\"MixedCaseColumn\" list<text>,"
7676 +
7777 // Frozen collections was introduced only in C* 2.1.3
78- (ccm().getVersion().compareTo(VersionNumber.parse("2.1.3")) >= 0
78+ (ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.1.3")) >= 0
7979 ?
8080 ", map_full frozen<map<text, int>>,"
8181 + "set_full frozen<set<text>>,"
@@ -103,10 +103,10 @@
103103 }
104104
105105 @Test(groups = "short")
106- @CassandraVersion(major = 2.1, description = "index names with quoted identifiers and collection indexes not supported until 2.1")
106+ @CassandraVersion(value = "2.1", description = "index names with quoted identifiers and collection indexes not supported until 2.1")
107107 public void should_create_metadata_for_values_index_on_mixed_case_column() {
108108 // 3.0 assumes the 'values' keyword if index on a collection
109- String createValuesIndex = ccm().getVersion().getMajor() > 2 ?
109+ String createValuesIndex = ccm().getCassandraVersion().getMajor() > 2 ?
110110 String.format("CREATE INDEX \"MixedCaseIndex\" ON %s.indexing (values(\"MixedCaseColumn\"));", keyspace) :
111111 String.format("CREATE INDEX \"MixedCaseIndex\" ON %s.indexing (\"MixedCaseColumn\");", keyspace);
112112 session().execute(createValuesIndex);
@@ -116,17 +116,17 @@
116116 .hasName("MixedCaseIndex")
117117 .hasParent((TableMetadata) column.getParent())
118118 .isNotCustomIndex()
119- .hasTarget(ccm().getVersion().getMajor() > 2 ? "values(\"MixedCaseColumn\")" : "\"MixedCaseColumn\"")
119+ .hasTarget(ccm().getCassandraVersion().getMajor() > 2 ? "values(\"MixedCaseColumn\")" : "\"MixedCaseColumn\"")
120120 .hasKind(COMPOSITES)
121121 .asCqlQuery(createValuesIndex);
122122 assertThat((TableMetadata) column.getParent()).hasIndex(index);
123123 }
124124
125125 @Test(groups = "short")
126- @CassandraVersion(major = 2.1)
126+ @CassandraVersion("2.1.0")
127127 public void should_create_metadata_for_index_on_map_values() {
128128 // 3.0 assumes the 'values' keyword if index on a collection
129- String createValuesIndex = ccm().getVersion().getMajor() > 2 ?
129+ String createValuesIndex = ccm().getCassandraVersion().getMajor() > 2 ?
130130 String.format("CREATE INDEX map_values_index ON %s.indexing (values(map_values));", keyspace) :
131131 String.format("CREATE INDEX map_values_index ON %s.indexing (map_values);", keyspace);
132132 session().execute(createValuesIndex);
@@ -136,14 +136,14 @@
136136 .hasName("map_values_index")
137137 .hasParent((TableMetadata) column.getParent())
138138 .isNotCustomIndex()
139- .hasTarget(ccm().getVersion().getMajor() > 2 ? "values(map_values)" : "map_values")
139+ .hasTarget(ccm().getCassandraVersion().getMajor() > 2 ? "values(map_values)" : "map_values")
140140 .hasKind(COMPOSITES)
141141 .asCqlQuery(createValuesIndex);
142142 assertThat((TableMetadata) column.getParent()).hasIndex(index);
143143 }
144144
145145 @Test(groups = "short")
146- @CassandraVersion(major = 2.1)
146+ @CassandraVersion("2.1.0")
147147 public void should_create_metadata_for_index_on_map_keys() {
148148 String createKeysIndex = String.format("CREATE INDEX map_keys_index ON %s.indexing (keys(map_keys));", keyspace);
149149 session().execute(createKeysIndex);
@@ -160,7 +160,7 @@
160160 }
161161
162162 @Test(groups = "short")
163- @CassandraVersion(major = 2.1, minor = 3)
163+ @CassandraVersion("2.1.3")
164164 public void should_create_metadata_for_full_index_on_map() {
165165 String createFullIndex = String.format("CREATE INDEX map_full_index ON %s.indexing (full(map_full));", keyspace);
166166 session().execute(createFullIndex);
@@ -177,7 +177,7 @@
177177 }
178178
179179 @Test(groups = "short")
180- @CassandraVersion(major = 2.1, minor = 3)
180+ @CassandraVersion("2.1.3")
181181 public void should_create_metadata_for_full_index_on_set() {
182182 String createFullIndex = String.format("CREATE INDEX set_full_index ON %s.indexing (full(set_full));", keyspace);
183183 session().execute(createFullIndex);
@@ -194,7 +194,7 @@
194194 }
195195
196196 @Test(groups = "short")
197- @CassandraVersion(major = 2.1, minor = 3)
197+ @CassandraVersion("2.1.3")
198198 public void should_create_metadata_for_full_index_on_list() {
199199 String createFullIndex = String.format("CREATE INDEX list_full_index ON %s.indexing (full(list_full));", keyspace);
200200 session().execute(createFullIndex);
@@ -211,7 +211,7 @@
211211 }
212212
213213 @Test(groups = "short")
214- @CassandraVersion(major = 2.2)
214+ @CassandraVersion("2.2.0")
215215 public void should_create_metadata_for_index_on_map_entries() {
216216 String createEntriesIndex = String.format("CREATE INDEX map_entries_index ON %s.indexing (entries(map_entries));", keyspace);
217217 session().execute(createEntriesIndex);
@@ -228,7 +228,7 @@
228228 }
229229
230230 @Test(groups = "short")
231- @CassandraVersion(major = 3.0)
231+ @CassandraVersion("3.0")
232232 public void should_allow_multiple_indexes_on_map_column() {
233233 String createEntriesIndex = String.format("CREATE INDEX map_all_entries_index ON %s.indexing (entries(map_all));", keyspace);
234234 session().execute(createEntriesIndex);
modified driver-core/src/test/java/com/datastax/driver/core/LargeDataTest.java +2 −14
@@ -180,11 +180,9 @@
180180
181181 /**
182182 * Test a wide row of size 1,000,000
183- *
184- * @throws Throwable
185183 */
186184 @Test(groups = "stress")
187- @CassandraVersion(major = 2.0, minor = 0, description = "< 2.0 is skipped as 1.2 does not handle reading wide rows well.")
185+ @CassandraVersion(value = "2.0.0", description = "< 2.0 is skipped as 1.2 does not handle reading wide rows well.")
188186 public void wideRows() throws Throwable {
189187 session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "large_data", 1));
190188 session().execute("USE large_data");
@@ -194,11 +192,9 @@
194192
195193 /**
196194 * Test a batch that writes a row of size 4,000 (just below the error threshold for 2.2).
197- *
198- * @throws Throwable
199195 */
200196 @Test(groups = "stress")
201- @CassandraVersion(major = 2.0, minor = 0, description = "< 2.0 is skipped as 1.2 does not handle large batches well.")
197+ @CassandraVersion(value = "2.0.0", description = "< 2.0 is skipped as 1.2 does not handle large batches well.")
202198 public void wideBatchRows() throws Throwable {
203199 session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "large_data", 1));
204200 session().execute("USE large_data");
@@ -208,8 +204,6 @@
208204
209205 /**
210206 * Test a wide row of size 1,000,000 consisting of a ByteBuffer
211- *
212- * @throws Throwable
213207 */
214208 @Test(groups = "stress")
215209 public void wideByteRows() throws Throwable {
@@ -221,8 +215,6 @@
221215
222216 /**
223217 * Test a row with a single extra large text value
224- *
225- * @throws Throwable
226218 */
227219 @Test(groups = "stress")
228220 public void largeText() throws Throwable {
@@ -234,8 +226,6 @@
234226
235227 /**
236228 * Creates a table with 330 columns
237- *
238- * @throws Throwable
239229 */
240230 @Test(groups = "stress")
241231 public void wideTable() throws Throwable {
@@ -255,8 +245,6 @@
255245
256246 /**
257247 * Tests 10 random tests consisting of the other methods in this class
258- *
259- * @throws Throwable
260248 */
261249 @Test(groups = "duration")
262250 @CCMConfig(numberOfNodes = 3)
modified driver-core/src/test/java/com/datastax/driver/core/MaterializedViewMetadataTest.java +1 −1
@@ -22,7 +22,7 @@
2222 import static com.datastax.driver.core.ClusteringOrder.DESC;
2323 import static com.datastax.driver.core.DataType.cint;
2424
25-@CassandraVersion(major = 3)
25+@CassandraVersion("3.0")
2626 public class MaterializedViewMetadataTest extends CCMTestsSupport {
2727
2828 /**
modified driver-core/src/test/java/com/datastax/driver/core/PagingStateTest.java +3 −3
@@ -25,7 +25,7 @@
2525
2626 import static org.assertj.core.api.Assertions.assertThat;
2727
28-@CassandraVersion(major = 2.0)
28+@CassandraVersion("2.0.0")
2929 public class PagingStateTest extends CCMTestsSupport {
3030
3131 private static final Logger logger = LoggerFactory.getLogger(PagingStateTest.class);
@@ -141,7 +141,7 @@
141141 * from the first query.
142142 */
143143 @Test(groups = "short")
144- @CassandraVersion(major = 2.0)
144+ @CassandraVersion("2.0.0")
145145 public void should_be_able_to_use_state_with_bound_statement() {
146146 PreparedStatement prepared = session().prepare("SELECT v from test where k=?");
147147 BoundStatement bs = prepared.bind(KEY);
@@ -164,7 +164,7 @@
164164 * @expected_result A failure is thrown when setting paging state on a different {@link BoundStatement}.
165165 */
166166 @Test(groups = "short", expectedExceptions = {PagingStateException.class})
167- @CassandraVersion(major = 2.0)
167+ @CassandraVersion("2.0.0")
168168 public void should_not_be_able_to_use_state_with_different_bound_statement() {
169169 PreparedStatement prepared = session().prepare("SELECT v from test where k=?");
170170 BoundStatement bs0 = prepared.bind(KEY);
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +15 −12
@@ -48,7 +48,8 @@
4848 private static final String SIMPLE_TABLE = "test";
4949 private static final String SIMPLE_TABLE2 = "test2";
5050
51- private final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion());
51+ private ProtocolVersion protocolVersion;
52+ private Collection<DataType> primitiveTypes;
5253
5354 private boolean exclude(DataType t) {
5455 return t.getName() == DataType.Name.COUNTER;
@@ -56,6 +57,8 @@
5657
5758 @Override
5859 public void onTestContextInitialized() {
60+ protocolVersion = ccm().getProtocolVersion();
61+ primitiveTypes = DataType.allPrimitiveTypes(protocolVersion);
5962 execute(createTestFixtures());
6063 }
6164
@@ -340,7 +343,7 @@
340343 toPrepare.setConsistencyLevel(ConsistencyLevel.QUORUM);
341344 toPrepare.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);
342345 toPrepare.setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
343- if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0)
346+ if (protocolVersion.compareTo(V4) >= 0)
344347 toPrepare.setOutgoingPayload(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe")));
345348 toPrepare.setIdempotent(true);
346349 toPrepare.enableTracing();
@@ -349,7 +352,7 @@
349352 assertThat(prepared.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM);
350353 assertThat(prepared.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL);
351354 assertThat(prepared.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE);
352- if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0)
355+ if (protocolVersion.compareTo(V4) >= 0)
353356 assertThat(prepared.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe")));
354357 assertThat(prepared.isIdempotent()).isTrue();
355358 assertThat(prepared.isTracing()).isTrue();
@@ -358,7 +361,7 @@
358361 assertThat(bs.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM);
359362 assertThat(bs.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL);
360363 assertThat(bs.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE);
361- if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0)
364+ if (protocolVersion.compareTo(V4) >= 0)
362365 assertThat(bs.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe")));
363366 assertThat(bs.isIdempotent()).isTrue();
364367 assertThat(bs.isTracing()).isTrue();
@@ -460,7 +463,7 @@
460463 Cluster cluster = register(Cluster.builder()
461464 .addContactPoints(getContactPoints())
462465 .withPort(ccm().getBinaryPort())
463- .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3))
466+ .withProtocolVersion(ccm().getProtocolVersion(ProtocolVersion.V3))
464467 .build());
465468 Session session = cluster.connect();
466469 try {
@@ -485,12 +488,12 @@
485488 * @since 2.2.0
486489 */
487490 @Test(groups = "short")
488- @CassandraVersion(major = 2.0)
491+ @CassandraVersion("2.0.0")
489492 public void should_not_allow_unbound_value_on_batch_statement_when_protocol_lesser_than_v4() {
490493 Cluster cluster = register(Cluster.builder()
491494 .addContactPoints(getContactPoints())
492495 .withPort(ccm().getBinaryPort())
493- .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3))
496+ .withProtocolVersion(ccm().getProtocolVersion(ProtocolVersion.V3))
494497 .build());
495498 Session session = cluster.connect();
496499 try {
@@ -515,7 +518,7 @@
515518 * @since 2.2.0
516519 */
517520 @Test(groups = "short")
518- @CassandraVersion(major = 2.2)
521+ @CassandraVersion("2.2.0")
519522 public void should_not_create_tombstone_when_unbound_value_on_bound_statement_and_protocol_v4() {
520523 PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)");
521524 BoundStatement st1 = prepared.bind();
@@ -545,7 +548,7 @@
545548 * @since 2.2.0
546549 */
547550 @Test(groups = "short")
548- @CassandraVersion(major = 2.2)
551+ @CassandraVersion("2.2.0")
549552 public void should_unset_value_by_index() {
550553 PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)");
551554 BoundStatement bound = prepared.bind();
@@ -576,7 +579,7 @@
576579 * @since 2.2.0
577580 */
578581 @Test(groups = "short")
579- @CassandraVersion(major = 2.2)
582+ @CassandraVersion("2.2.0")
580583 public void should_unset_value_by_name() {
581584 PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (:k, :i)");
582585 BoundStatement bound = prepared.bind();
@@ -608,7 +611,7 @@
608611 * @since 2.2.0
609612 */
610613 @Test(groups = "short")
611- @CassandraVersion(major = 2.2)
614+ @CassandraVersion("2.2.0")
612615 public void should_not_create_tombstone_when_unbound_value_on_batch_statement_and_protocol_v4() {
613616 PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)");
614617 BoundStatement st1 = prepared.bind();
@@ -661,7 +664,7 @@
661664 * @since 2.2.0
662665 */
663666 @Test(groups = "short")
664- @CassandraVersion(major = 2.0)
667+ @CassandraVersion("2.0.0")
665668 public void should_create_tombstone_when_null_value_on_batch_statement() {
666669 PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)");
667670 BoundStatement st1 = prepared.bind();
modified driver-core/src/test/java/com/datastax/driver/core/PrimitiveTypeSamples.java +2 −4
@@ -36,11 +36,9 @@
3636 */
3737 public class PrimitiveTypeSamples {
3838
39- public static final Map<DataType, Object> ALL = generateAll();
40-
41- private static Map<DataType, Object> generateAll() {
39+ static Map<DataType, Object> samples(ProtocolVersion protocolVersion) {
4240 try {
43- final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion());
41+ final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(protocolVersion);
4442 ImmutableMap<DataType, Object> data = ImmutableMap.<DataType, Object>builder()
4543 .put(DataType.ascii(), "ascii")
4644 .put(DataType.bigint(), Long.MAX_VALUE)
modified driver-core/src/test/java/com/datastax/driver/core/QueryLoggerTest.java +66 −62
@@ -49,41 +49,9 @@
4949 */
5050 public class QueryLoggerTest extends CCMTestsSupport {
5151
52- private static final List<DataType> dataTypes = new ArrayList<DataType>(
53- Sets.filter(DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion()), new Predicate<DataType>() {
54- @Override
55- public boolean apply(DataType type) {
56- return type != DataType.counter();
57- }
58- }));
59-
60- private static final List<Object> values = Lists.transform(dataTypes, new Function<DataType, Object>() {
61- @Override
62- public Object apply(DataType type) {
63- return getFixedValue(type);
64- }
65- }
66- );
67-
68- private static final String definitions = Joiner.on(", ").join(
69- Lists.transform(dataTypes, new Function<DataType, String>() {
70- @Override
71- public String apply(DataType type) {
72- return "c_" + type + " " + type;
73- }
74- }
75- )
76- );
77-
78- private static final String assignments = Joiner.on(", ").join(
79- Lists.transform(dataTypes, new Function<DataType, String>() {
80- @Override
81- public String apply(DataType type) {
82- return "c_" + type + " = ?";
83- }
84- }
85- )
86- );
52+ private List<DataType> dataTypes;
53+ private List<Object> values;
54+ private String assignments;
8755
8856 private Logger normal = Logger.getLogger(NORMAL_LOGGER.getName());
8957 private Logger slow = Logger.getLogger(SLOW_LOGGER.getName());
@@ -98,6 +66,47 @@
9866 private Level originalSlow;
9967 private Level originalError;
10068
69+ @Override
70+ public void onTestContextInitialized() {
71+ dataTypes = new ArrayList<DataType>(
72+ Sets.filter(DataType.allPrimitiveTypes(ccm().getProtocolVersion()), new Predicate<DataType>() {
73+ @Override
74+ public boolean apply(DataType type) {
75+ return type != DataType.counter();
76+ }
77+ }));
78+
79+ values = Lists.transform(dataTypes, new Function<DataType, Object>() {
80+ @Override
81+ public Object apply(DataType type) {
82+ return getFixedValue(type);
83+ }
84+ }
85+ );
86+
87+ String definitions = Joiner.on(", ").join(
88+ Lists.transform(dataTypes, new Function<DataType, String>() {
89+ @Override
90+ public String apply(DataType type) {
91+ return "c_" + type + " " + type;
92+ }
93+ }
94+ )
95+ );
96+
97+ assignments = Joiner.on(", ").join(
98+ Lists.transform(dataTypes, new Function<DataType, String>() {
99+ @Override
100+ public String apply(DataType type) {
101+ return "c_" + type + " = ?";
102+ }
103+ }
104+ )
105+ );
106+
107+ execute("CREATE TABLE test (pk int PRIMARY KEY, " + definitions + ")");
108+ }
109+
101110 @BeforeMethod(groups = {"short", "unit"})
102111 public void startCapturingLogs() {
103112 originalNormal = normal.getLevel();
@@ -171,7 +180,7 @@
171180 }
172181
173182 @Test(groups = "short")
174- @CassandraVersion(major = 2.0)
183+ @CassandraVersion("2.0.0")
175184 public void should_log_batch_statements() throws Exception {
176185 // given
177186 normal.setLevel(DEBUG);
@@ -202,7 +211,7 @@
202211 }
203212
204213 @Test(groups = "short")
205- @CassandraVersion(major = 2.0)
214+ @CassandraVersion("2.0.0")
206215 public void should_log_unlogged_batch_statements() throws Exception {
207216 // given
208217 normal.setLevel(DEBUG);
@@ -233,7 +242,7 @@
233242 }
234243
235244 @Test(groups = "short")
236- @CassandraVersion(major = 2.0)
245+ @CassandraVersion("2.0.0")
237246 public void should_log_counter_batch_statements() throws Exception {
238247 // Create a special table for testing with counters.
239248 session().execute(
@@ -376,7 +385,7 @@
376385 // Tests with query parameters (log level TRACE)
377386
378387 @Test(groups = "short")
379- @CassandraVersion(major = 2.0)
388+ @CassandraVersion("2.0.0")
380389 public void should_log_non_null_named_parameter_bound_statements() throws Exception {
381390 // given
382391 normal.setLevel(TRACE);
@@ -426,7 +435,7 @@
426435 }
427436
428437 @Test(groups = "short")
429- @CassandraVersion(major = 2.0)
438+ @CassandraVersion("2.0.0")
430439 public void should_log_non_null_positional_parameter_simple_statements() throws Exception {
431440 // given
432441 normal.setLevel(TRACE);
@@ -470,7 +479,7 @@
470479 }
471480
472481 @Test(groups = "short")
473- @CassandraVersion(major = 2.0)
482+ @CassandraVersion("2.0.0")
474483 public void should_log_null_parameter_simple_statements() throws Exception {
475484 // given
476485 normal.setLevel(TRACE);
@@ -491,7 +500,7 @@
491500 }
492501
493502 @Test(groups = "short")
494- @CassandraVersion(major = 3.0)
503+ @CassandraVersion("3.0")
495504 public void should_log_unset_parameter() throws Exception {
496505 // given
497506 normal.setLevel(TRACE);
@@ -514,7 +523,7 @@
514523 }
515524
516525 @Test(groups = "short")
517- @CassandraVersion(major = 2.0)
526+ @CassandraVersion("2.0.0")
518527 public void should_log_bound_statement_parameters_inside_batch_statement() throws Exception {
519528 // given
520529 normal.setLevel(TRACE);
@@ -541,7 +550,7 @@
541550 }
542551
543552 @Test(groups = "short")
544- @CassandraVersion(major = 2.0)
553+ @CassandraVersion("2.0.0")
545554 public void should_log_simple_statement_parameters_inside_batch_statement() throws Exception {
546555 // given
547556 normal.setLevel(TRACE);
@@ -596,7 +605,7 @@
596605 }
597606
598607 @Test(groups = "short")
599- @CassandraVersion(major = 2.0)
608+ @CassandraVersion("2.0.0")
600609 public void should_log_all_parameter_types_simple_statements() throws Exception {
601610 // given
602611 normal.setLevel(TRACE);
@@ -648,7 +657,7 @@
648657 .doesNotContain(query);
649658 }
650659
651- @CassandraVersion(major = 2.0)
660+ @CassandraVersion("2.0.0")
652661 @Test(groups = "short")
653662 public void should_show_total_statements_for_batches_even_if_query_truncated() throws Exception {
654663 // given
@@ -695,7 +704,7 @@
695704 .doesNotContain(TRUNCATED_OUTPUT);
696705 }
697706
698- @CassandraVersion(major = 2.0)
707+ @CassandraVersion("2.0.0")
699708 @Test(groups = "short")
700709 public void should_truncate_parameter_when_max_length_exceeded_bound_statements() throws Exception {
701710 // given
@@ -720,7 +729,7 @@
720729 .doesNotContain("123456");
721730 }
722731
723- @CassandraVersion(major = 2.0)
732+ @CassandraVersion("2.0.0")
724733 @Test(groups = "short")
725734 public void should_truncate_parameter_when_max_length_exceeded_simple_statements() throws Exception {
726735 // given
@@ -767,7 +776,7 @@
767776 }
768777
769778 @Test(groups = "short")
770- @CassandraVersion(major = 2.0)
779+ @CassandraVersion("2.0.0")
771780 public void should_truncate_blob_parameter_when_max_length_exceeded_simple_statements() throws Exception {
772781 // given
773782 normal.setLevel(TRACE);
@@ -813,7 +822,7 @@
813822 }
814823
815824 @Test(groups = "short")
816- @CassandraVersion(major = 2.0)
825+ @CassandraVersion("2.0.0")
817826 public void should_not_truncate_parameter_when_max_length_unlimited_simple_statements() throws Exception {
818827 // given
819828 normal.setLevel(TRACE);
@@ -860,7 +869,7 @@
860869 }
861870
862871 @Test(groups = "short")
863- @CassandraVersion(major = 2.0)
872+ @CassandraVersion("2.0.0")
864873 public void should_not_log_exceeding_number_of_parameters_simple_statements() throws Exception {
865874 // given
866875 normal.setLevel(TRACE);
@@ -883,7 +892,7 @@
883892 }
884893
885894 @Test(groups = "short")
886- @CassandraVersion(major = 2.1)
895+ @CassandraVersion("2.1.0")
887896 public void should_not_log_exceeding_number_of_parameters_simple_statements_with_named_values() throws Exception {
888897 // given
889898 normal.setLevel(TRACE);
@@ -909,7 +918,7 @@
909918 }
910919
911920 @Test(groups = "short")
912- @CassandraVersion(major = 2.0)
921+ @CassandraVersion("2.0.0")
913922 public void should_not_log_exceeding_number_of_parameters_in_batch_statement_bound_statements() throws Exception {
914923 // given
915924 normal.setLevel(TRACE);
@@ -939,7 +948,7 @@
939948 }
940949
941950 @Test(groups = "short")
942- @CassandraVersion(major = 2.0)
951+ @CassandraVersion("2.0.0")
943952 public void should_not_log_exceeding_number_of_parameters_in_batch_statement_simple_statements() throws Exception {
944953 // given
945954 normal.setLevel(TRACE);
@@ -991,7 +1000,7 @@
9911000 }
9921001
9931002 @Test(groups = "short")
994- @CassandraVersion(major = 2.0)
1003+ @CassandraVersion("2.0.0")
9951004 public void should_log_all_parameters_when_max_unlimited_simple_statements() throws Exception {
9961005 // given
9971006 normal.setLevel(TRACE);
@@ -1013,7 +1022,7 @@
10131022 }
10141023
10151024 @Test(groups = "short")
1016- @CassandraVersion(major = 2.1)
1025+ @CassandraVersion("2.1.0")
10171026 public void should_log_all_parameters_when_max_unlimited_simple_statements_with_named_values() throws Exception {
10181027 // given
10191028 normal.setLevel(TRACE);
@@ -1037,7 +1046,7 @@
10371046 .contains("42");
10381047 }
10391048
1040- @CassandraVersion(major = 2.0)
1049+ @CassandraVersion("2.0.0")
10411050 @Test(groups = "short")
10421051 public void should_log_wrapped_bound_statement() throws Exception {
10431052 // given
@@ -1064,9 +1073,4 @@
10641073 .contains("param1:'foo'");
10651074 }
10661075
1067- @Override
1068- public void onTestContextInitialized() {
1069- execute("CREATE TABLE test (pk int PRIMARY KEY, " + definitions + ")");
1070- }
1071-
10721076 }
modified driver-core/src/test/java/com/datastax/driver/core/QueryTimestampTest.java +1 −1
@@ -27,7 +27,7 @@
2727 /**
2828 * Tests the behavior of client-provided timestamps with protocol v3.
2929 */
30-@CassandraVersion(major = 2.1)
30+@CassandraVersion("2.1.0")
3131 public class QueryTimestampTest extends CCMTestsSupport {
3232
3333 private volatile long timestampFromGenerator;
modified driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java +2 −3
@@ -145,7 +145,7 @@
145145 }
146146
147147 @Test(groups = "long")
148- @CassandraVersion(major = 2.0)
148+ @CassandraVersion("2.0.0")
149149 public void should_ignore_node_that_does_not_support_protocol_version_on_session_init() throws Exception {
150150 // Simulate the bug before starting the cluster
151151 mainCcmBuilder = CCMBridge.builder().withNodes(2);
@@ -157,8 +157,7 @@
157157 .withStoragePort(mainCcm.getStoragePort())
158158 .withThriftPort(mainCcm.getThriftPort())
159159 .withBinaryPort(mainCcm.getBinaryPort())
160- .withoutDSE()
161- .withVersion("1.2.19");
160+ .withVersion(VersionNumber.parse("1.2.19"));
162161 otherCcm = CCMCache.get(otherCcmBuilder);
163162 otherCcm.waitForUp(1);
164163
modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +2 −2
@@ -83,7 +83,7 @@
8383 public void should_keep_reconnecting_on_authentication_error() throws InterruptedException {
8484 // For C* 1.2, sleep before attempting to connect as there is a small delay between
8585 // user being created.
86- if (ccm().getVersion().getMajor() < 2) {
86+ if (ccm().getCassandraVersion().getMajor() < 2) {
8787 Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
8888 }
8989 CountingReconnectionPolicy reconnectionPolicy = new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis));
@@ -223,7 +223,7 @@
223223 .withReconnectionPolicy(new ConstantReconnectionPolicy(5000))
224224 .withLoadBalancingPolicy(loadBalancingPolicy)
225225 .withSocketOptions(socketOptions)
226- .withProtocolVersion(TestUtils.getDesiredProtocolVersion())
226+ .withProtocolVersion(ccm().getProtocolVersion())
227227 .build());
228228 // Create two sessions to have multiple pools
229229 cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/SchemaChangesTest.java +12 −12
@@ -209,7 +209,7 @@
209209
210210 @SuppressWarnings("RedundantCast")
211211 @Test(groups = "short", dataProvider = "existingKeyspaceName")
212- @CassandraVersion(major = 2.1)
212+ @CassandraVersion("2.1.0")
213213 public void should_notify_of_udt_creation(String keyspace) {
214214 session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace));
215215 for (SchemaChangeListener listener : listeners) {
@@ -223,7 +223,7 @@
223223 }
224224
225225 @Test(groups = "short", dataProvider = "existingKeyspaceName")
226- @CassandraVersion(major = 2.1)
226+ @CassandraVersion("2.1.0")
227227 public void should_notify_of_udt_update(String keyspace) {
228228 session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace));
229229 session1.execute(String.format("ALTER TYPE %s.type1 ADD j int", keyspace));
@@ -240,7 +240,7 @@
240240
241241 @SuppressWarnings("RedundantCast")
242242 @Test(groups = "short", dataProvider = "existingKeyspaceName")
243- @CassandraVersion(major = 2.1)
243+ @CassandraVersion("2.1.0")
244244 public void should_notify_of_udt_drop(String keyspace) {
245245 session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace));
246246 session1.execute(String.format("DROP TYPE %s.type1", keyspace));
@@ -254,7 +254,7 @@
254254 }
255255
256256 @Test(groups = "short", dataProvider = "existingKeyspaceName")
257- @CassandraVersion(major = 2.2)
257+ @CassandraVersion("2.2.0")
258258 public void should_notify_of_function_creation(String keyspace) {
259259 session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace));
260260 for (SchemaChangeListener listener : listeners) {
@@ -270,7 +270,7 @@
270270 }
271271
272272 @Test(groups = "short", dataProvider = "existingKeyspaceName")
273- @CassandraVersion(major = 2.2)
273+ @CassandraVersion("2.2.0")
274274 public void should_notify_of_function_update(String keyspace) {
275275 session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace));
276276 for (SchemaChangeListener listener : listeners) {
@@ -297,7 +297,7 @@
297297 }
298298
299299 @Test(groups = "short", dataProvider = "existingKeyspaceName")
300- @CassandraVersion(major = 2.2)
300+ @CassandraVersion("2.2.0")
301301 public void should_notify_of_function_drop(String keyspace) {
302302 session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace));
303303 session1.execute(String.format("DROP FUNCTION %s.\"ID\"", keyspace));
@@ -314,7 +314,7 @@
314314 }
315315
316316 @Test(groups = "short", dataProvider = "existingKeyspaceName")
317- @CassandraVersion(major = 2.2)
317+ @CassandraVersion("2.2.0")
318318 public void should_notify_of_aggregate_creation(String keyspace) {
319319 session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java"
320320 + " AS 'return s+v;'", keyspace));
@@ -332,7 +332,7 @@
332332 }
333333
334334 @Test(groups = "short", dataProvider = "existingKeyspaceName")
335- @CassandraVersion(major = 2.2)
335+ @CassandraVersion("2.2.0")
336336 public void should_notify_of_aggregate_update(String keyspace) {
337337 session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java"
338338 + " AS 'return s+v;'", keyspace));
@@ -361,7 +361,7 @@
361361 }
362362
363363 @Test(groups = "short", dataProvider = "existingKeyspaceName")
364- @CassandraVersion(major = 2.2)
364+ @CassandraVersion("2.2.0")
365365 public void should_notify_of_aggregate_drop(String keyspace) {
366366 session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java"
367367 + " AS 'return s+v;'", keyspace));
@@ -380,7 +380,7 @@
380380 }
381381
382382 @Test(groups = "short", dataProvider = "existingKeyspaceName")
383- @CassandraVersion(major = 3.0)
383+ @CassandraVersion("3.0")
384384 public void should_notify_of_view_creation(String keyspace) {
385385 session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace));
386386 session1.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c)", keyspace, keyspace));
@@ -395,7 +395,7 @@
395395 }
396396
397397 @Test(groups = "short", dataProvider = "existingKeyspaceName")
398- @CassandraVersion(major = 3.0)
398+ @CassandraVersion("3.0")
399399 public void should_notify_of_view_update(String keyspace) {
400400 session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace));
401401 session1.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c) WITH compaction = { 'class' : 'SizeTieredCompactionStrategy' }", keyspace, keyspace));
@@ -424,7 +424,7 @@
424424 }
425425
426426 @Test(groups = "short", dataProvider = "existingKeyspaceName")
427- @CassandraVersion(major = 3.0)
427+ @CassandraVersion("3.0")
428428 public void should_notify_of_view_drop(String keyspace) {
429429 session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace));
430430 session1.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c)", keyspace, keyspace));
modified driver-core/src/test/java/com/datastax/driver/core/SchemaRefreshDebouncerTest.java +1 −1
@@ -189,7 +189,7 @@
189189 */
190190 @Test(groups = "short")
191191 public void should_debounce_and_coalesce_multiple_alter_events_on_same_table_into_refresh_table() throws Exception {
192- if (ccm().getVersion().getMajor() > 2 || ccm().getVersion().getMajor() == 2 && ccm().getVersion().getMinor() > 1)
192+ if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.2")) >= 0)
193193 throw new SkipException("Disabled in Cassandra 2.2+ because of CASSANDRA-9996");
194194
195195 String keyspace = TestUtils.generateIdentifier("ks_");
modified driver-core/src/test/java/com/datastax/driver/core/SimpleStatementIntegrationTest.java +7 −7
@@ -35,7 +35,7 @@
3535 }
3636
3737 @Test(groups = "short")
38- @CassandraVersion(major = 2.1)
38+ @CassandraVersion("2.1.0")
3939 public void should_execute_query_with_named_values() {
4040 // Given
4141 SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2",
@@ -50,7 +50,7 @@
5050 }
5151
5252 @Test(groups = "short", expectedExceptions = InvalidQueryException.class)
53- @CassandraVersion(major = 2.1)
53+ @CassandraVersion("2.1.0")
5454 public void should_fail_if_query_with_named_values_but_missing_parameter() {
5555 // Given a Statement missing named parameters.
5656 SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2",
@@ -64,7 +64,7 @@
6464 }
6565
6666 @Test(groups = "short", expectedExceptions = InvalidQueryException.class)
67- @CassandraVersion(major = 2.1)
67+ @CassandraVersion("2.1.0")
6868 public void should_fail_if_query_with_named_values_but_using_wrong_type() {
6969 // Given a Statement using a named parameter with the wrong value for the type (id is of type int, using double)
7070 SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2",
@@ -98,18 +98,18 @@
9898 }
9999
100100 @Test(groups = "short", expectedExceptions = UnsupportedFeatureException.class)
101- @CassandraVersion(major = 2.0)
101+ @CassandraVersion("2.0.0")
102102 public void should_fail_if_query_with_named_values_if_protocol_is_V2() {
103- if (ccm().getVersion().getMajor() >= 3) {
103+ if (ccm().getCassandraVersion().getMajor() >= 3) {
104104 throw new SkipException("Skipping since Cassandra 3.0+ does not support protocol v2");
105105 }
106106 useNamedValuesWithProtocol(ProtocolVersion.V2);
107107 }
108108
109109 @Test(groups = "short", expectedExceptions = UnsupportedFeatureException.class)
110- @CassandraVersion(major = 2.0)
110+ @CassandraVersion("2.0.0")
111111 public void should_fail_if_query_with_named_values_if_protocol_is_V1() {
112- if (ccm().getVersion().getMajor() >= 3) {
112+ if (ccm().getCassandraVersion().getMajor() >= 3) {
113113 throw new SkipException("Skipping since Cassandra 3.0+ does not support protocol v1");
114114 }
115115 useNamedValuesWithProtocol(ProtocolVersion.V1);
modified driver-core/src/test/java/com/datastax/driver/core/SingleConnectionPoolTest.java +1 −1
@@ -25,7 +25,7 @@
2525
2626 import static org.testng.Assert.fail;
2727
28-@CassandraVersion(major = 2.1)
28+@CassandraVersion("2.1.0")
2929 public class SingleConnectionPoolTest extends CCMTestsSupport {
3030
3131 @Test(groups = "short")
modified driver-core/src/test/java/com/datastax/driver/core/StatementIdempotenceTest.java +1 −1
@@ -41,7 +41,7 @@
4141 when(cluster.getConfiguration()).thenReturn(configuration);
4242 when(configuration.getCodecRegistry()).thenReturn(codecRegistry);
4343 when(configuration.getProtocolOptions()).thenReturn(protocolOptions);
44- when(protocolOptions.getProtocolVersion()).thenReturn(TestUtils.getDesiredProtocolVersion());
44+ when(protocolOptions.getProtocolVersion()).thenReturn(ProtocolVersion.NEWEST_SUPPORTED);
4545 }
4646
4747 @Test(groups = "unit")
modified driver-core/src/test/java/com/datastax/driver/core/StatementWrapperTest.java +3 −3
@@ -87,7 +87,7 @@
8787 assertThat(retryPolicy.customStatementsHandled.get()).isEqualTo(1);
8888 }
8989
90- @CassandraVersion(major = 2.0)
90+ @CassandraVersion("2.0.0")
9191 @Test(groups = "short")
9292 public void should_execute_wrapped_simple_statement() {
9393 session().execute(new CustomStatement(new SimpleStatement(INSERT_QUERY, "key_simple", 1)));
@@ -106,7 +106,7 @@
106106 assertThat(rs.one().getInt("v")).isEqualTo(1);
107107 }
108108
109- @CassandraVersion(major = 2.0)
109+ @CassandraVersion("2.0.0")
110110 @Test(groups = "short")
111111 public void should_execute_wrapped_batch_statement() {
112112 BatchStatement batchStatement = new BatchStatement();
@@ -118,7 +118,7 @@
118118 assertThat(rs.one().getInt("v")).isEqualTo(1);
119119 }
120120
121- @CassandraVersion(major = 2.0)
121+ @CassandraVersion("2.0.0")
122122 @Test(groups = "short")
123123 public void should_add_wrapped_batch_statement_to_batch_statement() {
124124 BatchStatement batchStatementForWrapping = new BatchStatement();
modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +2 −2
@@ -407,7 +407,7 @@
407407 * @jira_ticket CASSANDRA-9424
408408 */
409409 @Test(groups = "short")
410- @CassandraVersion(major = 3.0)
410+ @CassandraVersion("3.0")
411411 public void should_parse_new_compression_options() {
412412 // given
413413 String cql = String.format("CREATE TABLE %s.new_compression_options (\n"
@@ -475,7 +475,7 @@
475475 * @test_category metadata
476476 */
477477 @Test(groups = "short")
478- @CassandraVersion(major = 3.0)
478+ @CassandraVersion("3.0")
479479 public void should_parse_extensions_from_table_options() throws Exception {
480480 // given
481481 // create a simple table and retrieve it's metadata from system_schema.tables.
modified driver-core/src/test/java/com/datastax/driver/core/TestListener.java +30 −30
@@ -20,6 +20,7 @@
2020 import org.testng.*;
2121 import org.testng.internal.ConstructorOrMethod;
2222
23+import java.lang.reflect.AnnotatedElement;
2324 import java.lang.reflect.Method;
2425 import java.util.concurrent.TimeUnit;
2526
@@ -87,27 +88,29 @@
8788
8889 Class<?> clazz = testNgMethod.getInstance().getClass();
8990 if (clazz != null) {
90- if (clazz.isAnnotationPresent(CassandraVersion.class)) {
91- CassandraVersion cassandraVersion = clazz.getAnnotation(CassandraVersion.class);
92- cassandraVersionCheck(cassandraVersion);
93- }
94- if (clazz.isAnnotationPresent(DseVersion.class)) {
95- DseVersion dseVersion = clazz.getAnnotation(DseVersion.class);
96- dseVersionCheck(dseVersion);
97- }
91+ do {
92+ if (scanAnnotatedElement(clazz))
93+ break;
94+ } while (!(clazz = clazz.getSuperclass()).equals(Object.class));
9895 }
99-
10096 Method method = constructorOrMethod.getMethod();
10197 if (method != null) {
102- if (method.isAnnotationPresent(CassandraVersion.class)) {
103- CassandraVersion cassandraVersion = method.getAnnotation(CassandraVersion.class);
104- cassandraVersionCheck(cassandraVersion);
105- }
106- if (method.isAnnotationPresent(DseVersion.class)) {
107- DseVersion dseVersion = method.getAnnotation(DseVersion.class);
108- dseVersionCheck(dseVersion);
109- }
98+ scanAnnotatedElement(method);
99+ }
100+ }
101+
102+ private boolean scanAnnotatedElement(AnnotatedElement element) {
103+ if (element.isAnnotationPresent(CassandraVersion.class)) {
104+ CassandraVersion cassandraVersion = element.getAnnotation(CassandraVersion.class);
105+ cassandraVersionCheck(cassandraVersion);
106+ return true;
107+ }
108+ if (element.isAnnotationPresent(DseVersion.class)) {
109+ DseVersion dseVersion = element.getAnnotation(DseVersion.class);
110+ dseVersionCheck(dseVersion);
111+ return true;
110112 }
113+ return false;
111114 }
112115
113116 @Override
@@ -116,29 +119,26 @@
116119 }
117120
118121 private static void cassandraVersionCheck(CassandraVersion version) {
119- versionCheck(CCMBridge.getCassandraVersion(), version.major(), version.minor(), version.description());
122+ versionCheck(CCMBridge.getGlobalCassandraVersion(), VersionNumber.parse(version.value()), version.description());
120123 }
121124
122125 private static void dseVersionCheck(DseVersion version) {
123- if (CCMBridge.isDSE()) {
124- versionCheck(CCMBridge.getDSEVersion(), version.major(), version.minor(), version.description());
126+ VersionNumber dseVersion = CCMBridge.getGlobalDSEVersion();
127+ if (dseVersion != null) {
128+ versionCheck(CCMBridge.getGlobalDSEVersion(), VersionNumber.parse(version.value()), version.description());
125129 } else {
126130 throw new SkipException("Skipping test because not configured for DataStax Enterprise cluster.");
127131 }
128132 }
129133
130- private static void versionCheck(String version, double majorCheck, int minorCheck, String skipString) {
131- if (version == null) {
134+ private static void versionCheck(VersionNumber current, VersionNumber required, String skipString) {
135+ if (current == null) {
132136 throw new SkipException("Skipping test because provided version is null");
133137 } else {
134- String[] versionArray = version.split("\\.|-");
135- double major = Double.parseDouble(versionArray[0] + "." + versionArray[1]);
136- // If there is no minor version, assume latest version of whatever was provided.
137- int minor = versionArray.length >= 3 ? Integer.parseInt(versionArray[2]) : Integer.MAX_VALUE;
138-
139- if (major < majorCheck || (major == majorCheck && minor < minorCheck)) {
140- throw new SkipException("Version >= " + majorCheck + "." + minorCheck + " required. " +
141- "Description: " + skipString);
138+ if (current.compareTo(required) < 0) {
139+ throw new SkipException(
140+ String.format("Version >= %s required, but found %s. Justification: %s",
141+ required, current, skipString));
142142 }
143143 }
144144 }
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +2 −29
@@ -735,33 +735,6 @@
735735 return connectionSuccessful;
736736 }
737737
738- /**
739- * @return The desired target protocol version based on the 'cassandra.version' System property.
740- */
741- public static ProtocolVersion getDesiredProtocolVersion() {
742- String version = CCMBridge.getCassandraVersion();
743- String[] versionArray = version.split("\\.|-");
744- double major = Double.parseDouble(versionArray[0] + "." + versionArray[1]);
745- if (major < 2.0) {
746- return ProtocolVersion.V1;
747- } else if (major < 2.1) {
748- return ProtocolVersion.V2;
749- } else if (major < 2.2) {
750- return ProtocolVersion.V3;
751- } else {
752- return ProtocolVersion.V4;
753- }
754- }
755-
756- /**
757- * @param maximumAllowed The maximum protocol version to use.
758- * @return The desired protocolVersion or maximumAllowed if {@link #getDesiredProtocolVersion} is greater.
759- */
760- public static ProtocolVersion getDesiredProtocolVersion(ProtocolVersion maximumAllowed) {
761- ProtocolVersion versionToUse = getDesiredProtocolVersion();
762- return versionToUse.compareTo(maximumAllowed) > 0 ? maximumAllowed : versionToUse;
763- }
764-
765738 /**
766739 * @return a {@link Cluster} instance that connects only to the control host of the given cluster.
767740 */
@@ -838,7 +811,7 @@
838811
839812 /**
840813 * Helper for generating a DynamicCompositeType {@link ByteBuffer} from the given parameters.
841- *
814+ * <p/>
842815 * Any of params given as an Integer will be considered with a field name of 'i', any as String will
843816 * be considered with a field name of 's'.
844817 *
@@ -881,7 +854,7 @@
881854
882855 /**
883856 * Helper for generating a Composite {@link ByteBuffer} from the given parameters.
884- *
857+ * <p/>
885858 * Expects Integer and String types for parameters.
886859 *
887860 * @param params params to serialize.
modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +1 −1
@@ -191,7 +191,7 @@
191191 * </ol>
192192 */
193193 @Test(groups = "short")
194- @CassandraVersion(major = 2)
194+ @CassandraVersion("2.0")
195195 public void should_get_token_from_row_and_set_token_in_query_with_binding_and_aliasing() {
196196 Row row = session().execute("SELECT token(i) AS t FROM foo WHERE i = 1").one();
197197 Token token = row.getToken("t");
modified driver-core/src/test/java/com/datastax/driver/core/TracingTest.java +1 −1
@@ -26,7 +26,7 @@
2626
2727 import static org.assertj.core.api.Assertions.assertThat;
2828
29-@CassandraVersion(major = 2.0)
29+@CassandraVersion("2.0.0")
3030 public class TracingTest extends CCMTestsSupport {
3131
3232 private static final String KEY = "tracing_test";
modified driver-core/src/test/java/com/datastax/driver/core/TupleTest.java +13 −12
@@ -27,13 +27,16 @@
2727 import static org.testng.Assert.assertEquals;
2828 import static org.testng.Assert.fail;
2929
30-@CassandraVersion(major = 2.1)
30+@CassandraVersion("2.1.0")
3131 public class TupleTest extends CCMTestsSupport {
3232
33- ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion();
33+ private ProtocolVersion protocolVersion;
34+ private Map<DataType, Object> samples;
3435
3536 @Override
3637 public void onTestContextInitialized() {
38+ protocolVersion = ccm().getProtocolVersion();
39+ samples = PrimitiveTypeSamples.samples(protocolVersion);
3740 execute("CREATE TABLE t (k int PRIMARY KEY, v frozen<tuple<int, text, float>>)");
3841 }
3942
@@ -202,8 +205,7 @@
202205 */
203206 @Test(groups = "short")
204207 public void tupleSubtypesTest() throws Exception {
205-
206- List<DataType> DATA_TYPE_PRIMITIVES = Lists.newArrayList(PrimitiveTypeSamples.ALL.keySet());
208+ List<DataType> DATA_TYPE_PRIMITIVES = Lists.newArrayList(samples.keySet());
207209 session().execute("CREATE KEYSPACE test_tuple_subtypes " +
208210 "WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}");
209211 session().execute("USE test_tuple_subtypes");
@@ -226,8 +228,8 @@
226228 for (int j = 0; j < i; ++j) {
227229 dataTypes.add(DATA_TYPE_PRIMITIVES.get(j));
228230 completeDataTypes.add(DATA_TYPE_PRIMITIVES.get(j));
229- createdValues.add(PrimitiveTypeSamples.ALL.get(DATA_TYPE_PRIMITIVES.get(j)));
230- completeValues.add(PrimitiveTypeSamples.ALL.get(DATA_TYPE_PRIMITIVES.get(j)));
231+ createdValues.add(samples.get(DATA_TYPE_PRIMITIVES.get(j)));
232+ completeValues.add(samples.get(DATA_TYPE_PRIMITIVES.get(j)));
231233 }
232234
233235 // complete portion of the arrays needed for trailing nulls
@@ -261,8 +263,7 @@
261263 */
262264 @Test(groups = "short")
263265 public void tupleNonPrimitiveSubTypesTest() throws Exception {
264-
265- List<DataType> DATA_TYPE_PRIMITIVES = Lists.newArrayList(PrimitiveTypeSamples.ALL.keySet());
266+ List<DataType> DATA_TYPE_PRIMITIVES = Lists.newArrayList(samples.keySet());
266267 session().execute("CREATE KEYSPACE test_tuple_non_primitive_subtypes " +
267268 "WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}");
268269 session().execute("USE test_tuple_non_primitive_subtypes");
@@ -296,7 +297,7 @@
296297 ArrayList<Object> createdValues = new ArrayList<Object>();
297298
298299 dataTypes.add(DataType.list(datatype));
299- createdValues.add(Collections.singletonList(PrimitiveTypeSamples.ALL.get(datatype)));
300+ createdValues.add(Collections.singletonList(samples.get(datatype)));
300301
301302 TupleType t = new TupleType(dataTypes, protocolVersion, cluster().getConfiguration().getCodecRegistry());
302303 TupleValue createdTuple = t.newValue(createdValues.toArray());
@@ -319,7 +320,7 @@
319320 ArrayList<Object> createdValues = new ArrayList<Object>();
320321
321322 dataTypes.add(DataType.set(datatype));
322- createdValues.add(new HashSet<Object>(Collections.singletonList(PrimitiveTypeSamples.ALL.get(datatype))));
323+ createdValues.add(new HashSet<Object>(Collections.singletonList(samples.get(datatype))));
323324
324325 TupleType t = new TupleType(dataTypes, protocolVersion, cluster().getConfiguration().getCodecRegistry());
325326 TupleValue createdTuple = t.newValue(createdValues.toArray());
@@ -342,7 +343,7 @@
342343 ArrayList<Object> createdValues = new ArrayList<Object>();
343344
344345 HashMap<Object, Object> hm = new HashMap<Object, Object>();
345- hm.put(PrimitiveTypeSamples.ALL.get(datatype), PrimitiveTypeSamples.ALL.get(datatype));
346+ hm.put(samples.get(datatype), samples.get(datatype));
346347
347348 dataTypes.add(DataType.map(datatype, datatype));
348349 createdValues.add(hm);
@@ -370,7 +371,7 @@
370371 */
371372 @Test(groups = "short")
372373 public void detachedTupleTypeTest() {
373- TupleType detachedType = TupleType.of(TestUtils.getDesiredProtocolVersion(), CodecRegistry.DEFAULT_INSTANCE,
374+ TupleType detachedType = TupleType.of(protocolVersion, CodecRegistry.DEFAULT_INSTANCE,
374375 DataType.cint(), DataType.text(), DataType.cfloat());
375376 TupleValue detachedValue = detachedType.newValue(1, "hello", 2.0f);
376377
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecAssert.java +1 −1
@@ -24,7 +24,7 @@
2424 @SuppressWarnings("unused")
2525 public class TypeCodecAssert<T> extends AbstractAssert<TypeCodecAssert<T>, TypeCodec<T>> {
2626
27- private ProtocolVersion version = TestUtils.getDesiredProtocolVersion();
27+ private ProtocolVersion version = ProtocolVersion.NEWEST_SUPPORTED;
2828
2929 protected TypeCodecAssert(TypeCodec<T> actual) {
3030 super(actual, TypeCodecAssert.class);
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecCollectionsIntegrationTest.java +1 −1
@@ -33,7 +33,7 @@
3333 import static com.google.common.collect.Sets.newHashSet;
3434 import static org.assertj.core.api.Assertions.assertThat;
3535
36-@CassandraVersion(major = 2.0)
36+@CassandraVersion("2.0.0")
3737 public class TypeCodecCollectionsIntegrationTest extends CCMTestsSupport {
3838
3939 private final String insertQuery = "INSERT INTO \"myTable2\" (c_int, l_int, l_bigint, s_float, s_double, m_varint, m_decimal) VALUES (?, ?, ?, ?, ?, ?, ?)";
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecEncapsulationIntegrationTest.java +1 −1
@@ -102,7 +102,7 @@
102102 }
103103
104104 @Test(groups = "short")
105- @CassandraVersion(major = 2.0)
105+ @CassandraVersion("2.0.0")
106106 public void should_use_custom_codecs_with_simple_statements() {
107107 session().execute(insertQuery,
108108 n_int,
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNestedCollectionsIntegrationTest.java +1 −1
@@ -35,7 +35,7 @@
3535 * Validates that nested collections are properly encoded,
3636 * even if some inner type requires a custom codec.
3737 */
38-@CassandraVersion(major = 2.1)
38+@CassandraVersion("2.1.0")
3939 public class TypeCodecNestedCollectionsIntegrationTest extends CCMTestsSupport {
4040
4141 private final String insertQuery = "INSERT INTO \"myTable\" (pk, v) VALUES (?, ?)";
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNestedUDTAndTupleIntegrationTest.java +1 −1
@@ -28,7 +28,7 @@
2828 *
2929 * @jira_ticket JAVA-847
3030 */
31-@CassandraVersion(major = 2.1)
31+@CassandraVersion("2.1.0")
3232 public class TypeCodecNestedUDTAndTupleIntegrationTest extends CCMTestsSupport {
3333
3434 @Override
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNumbersIntegrationTest.java +1 −1
@@ -52,7 +52,7 @@
5252 }
5353
5454 @Test(groups = "short")
55- @CassandraVersion(major = 2.0)
55+ @CassandraVersion("2.0.0")
5656 public void should_use_defaut_codecs_with_simple_statements() {
5757 session().execute(insertQuery, n_int, n_bigint, n_float, n_double, n_varint, n_decimal);
5858 ResultSet rows = session().execute(selectQuery, n_int, n_bigint);
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecTupleIntegrationTest.java +1 −1
@@ -23,7 +23,7 @@
2323 import static com.datastax.driver.core.DataType.cfloat;
2424 import static org.assertj.core.api.Assertions.assertThat;
2525
26-@CassandraVersion(major = 2.1)
26+@CassandraVersion("2.1.0")
2727 public class TypeCodecTupleIntegrationTest extends CCMTestsSupport {
2828
2929 private final String insertQuery = "INSERT INTO users (id, name, location) VALUES (?, ?, ?)";
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecUDTIntegrationTest.java +1 −1
@@ -26,7 +26,7 @@
2626
2727 import static org.assertj.core.api.Assertions.assertThat;
2828
29-@CassandraVersion(major = 2.1)
29+@CassandraVersion("2.1.0")
3030 public class TypeCodecUDTIntegrationTest extends CCMTestsSupport {
3131
3232 private final String insertQuery = "INSERT INTO users (id, name, address) VALUES (?, ?, ?)";
modified driver-core/src/test/java/com/datastax/driver/core/UnresolvedUserTypeTest.java +1 −1
@@ -23,7 +23,7 @@
2323 import static com.datastax.driver.core.Assertions.assertThat;
2424 import static com.datastax.driver.core.DataType.*;
2525
26-@CassandraVersion(major = 3.0)
26+@CassandraVersion("3.0")
2727 public class UnresolvedUserTypeTest extends CCMTestsSupport {
2828
2929 @Override
modified driver-core/src/test/java/com/datastax/driver/core/UserTypesTest.java +10 −8
@@ -36,14 +36,11 @@
3636 import static org.testng.Assert.assertEquals;
3737 import static org.testng.Assert.assertNotEquals;
3838
39-@CassandraVersion(major = 2.1)
39+@CassandraVersion("2.1.0")
4040 public class UserTypesTest extends CCMTestsSupport {
4141
42- private final static List<DataType> DATA_TYPE_PRIMITIVES = new ArrayList<DataType>(DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion()));
43-
44- static {
45- DATA_TYPE_PRIMITIVES.remove(DataType.counter());
46- }
42+ private List<DataType> DATA_TYPE_PRIMITIVES;
43+ private Map<DataType, Object> samples;
4744
4845 private final static List<DataType.Name> DATA_TYPE_NON_PRIMITIVE_NAMES =
4946 new ArrayList<DataType.Name>(EnumSet.of(DataType.Name.LIST, DataType.Name.SET, DataType.Name.MAP, DataType.Name.TUPLE));
@@ -57,6 +54,10 @@
5754
5855 @Override
5956 public void onTestContextInitialized() {
57+ ProtocolVersion protocolVersion = ccm().getProtocolVersion();
58+ DATA_TYPE_PRIMITIVES = new ArrayList<DataType>(DataType.allPrimitiveTypes(protocolVersion));
59+ DATA_TYPE_PRIMITIVES.remove(DataType.counter());
60+ samples = PrimitiveTypeSamples.samples(protocolVersion);
6061 String type1 = "CREATE TYPE phone (alias text, number text)";
6162 String type2 = "CREATE TYPE \"\"\"User Address\"\"\" (street text, \"ZIP\"\"\" int, phones set<frozen<phone>>)";
6263 String table = "CREATE TABLE user (id int PRIMARY KEY, addr frozen<\"\"\"User Address\"\"\">)";
@@ -229,10 +230,11 @@
229230 UserType alldatatypesDef = cluster().getMetadata().getKeyspace("testPrimitiveDatatypes").getUserType("alldatatypes");
230231 UDTValue alldatatypes = alldatatypesDef.newValue();
231232
233+
232234 for (int i = 0; i < DATA_TYPE_PRIMITIVES.size(); i++) {
233235 DataType dataType = DATA_TYPE_PRIMITIVES.get(i);
234236 String index = Character.toString((char) (startIndex + i));
235- Object sampleData = PrimitiveTypeSamples.ALL.get(dataType);
237+ Object sampleData = samples.get(dataType);
236238
237239 switch (dataType.getName()) {
238240 case ASCII:
@@ -360,7 +362,7 @@
360362 DataType dataType = DATA_TYPE_PRIMITIVES.get(j);
361363
362364 String index = Character.toString((char) (startIndex + i)) + "_" + Character.toString((char) (startIndex + j));
363- Object sampleElement = PrimitiveTypeSamples.ALL.get(dataType);
365+ Object sampleElement = samples.get(dataType);
364366 switch (name) {
365367 case LIST:
366368 alldatatypes.setList(index, Lists.newArrayList(sampleElement));
modified driver-core/src/test/java/com/datastax/driver/core/WarningsTest.java +1 −1
@@ -24,7 +24,7 @@
2424 import static org.assertj.core.api.Assertions.assertThat;
2525
2626 @CCMConfig(config = {"batch_size_warn_threshold_in_kb:5"})
27-@CassandraVersion(major = 2.2)
27+@CassandraVersion("2.2.0")
2828 public class WarningsTest extends CCMTestsSupport {
2929
3030 @Override
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/FunctionExecutionExceptionTest.java +1 −1
@@ -20,7 +20,7 @@
2020 import com.datastax.driver.core.utils.CassandraVersion;
2121 import org.testng.annotations.Test;
2222
23-@CassandraVersion(major = 2.2)
23+@CassandraVersion("2.2.0")
2424 @CCMConfig(config = "enable_user_defined_functions:true")
2525 public class FunctionExecutionExceptionTest extends CCMTestsSupport {
2626
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilder21ExecutionTest.java +1 −1
@@ -25,7 +25,7 @@
2525 import static com.datastax.driver.core.Assertions.assertThat;
2626 import static com.datastax.driver.core.querybuilder.QueryBuilder.*;
2727
28-@CassandraVersion(major = 2.1)
28+@CassandraVersion("2.1.0")
2929 public class QueryBuilder21ExecutionTest extends CCMTestsSupport {
3030
3131 @Override
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderExecutionTest.java +3 −3
@@ -205,7 +205,7 @@
205205 * @since 3.0.1
206206 */
207207 @Test(groups = "short")
208- @CassandraVersion(major = 3.2)
208+ @CassandraVersion("3.2")
209209 public void should_support_cast_function_on_column() {
210210 //when
211211 ResultSet r = session().execute(select().cast("f", DataType.cint()).as("fint").column("i").from(TABLE2).where(eq("k", "cast_t")));
@@ -248,7 +248,7 @@
248248 * @since 3.0.1
249249 */
250250 @Test(groups = "short")
251- @CassandraVersion(major = 3.2)
251+ @CassandraVersion("3.2")
252252 public void should_support_fcall_on_cast_column() {
253253 //when
254254 ResultSet ar = session().execute(select().fcall("avg", cast(column("i"), DataType.cfloat())).as("iavg").from(TABLE2).where(eq("k", "cast_t")));
@@ -273,7 +273,7 @@
273273 * @since 3.0.1
274274 */
275275 @Test(groups = "short")
276- @CassandraVersion(major = 3.6)
276+ @CassandraVersion("3.6")
277277 public void should_retrieve_using_like_operator_on_table_with_sasi_index() {
278278 //given
279279 String table = "s_table";
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderITest.java +2 −2
@@ -208,7 +208,7 @@
208208 }
209209
210210 @Test(groups = "short")
211- @CassandraVersion(major = 2.0, minor = 7, description = "DELETE..IF EXISTS only supported in 2.0.7+ (CASSANDRA-5708)")
211+ @CassandraVersion(value = "2.0.7", description = "DELETE..IF EXISTS only supported in 2.0.7+ (CASSANDRA-5708)")
212212 public void conditionalDeletesTest() throws Exception {
213213 session().execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace));
214214
@@ -234,7 +234,7 @@
234234 }
235235
236236 @Test(groups = "short")
237- @CassandraVersion(major = 2.0, minor = 13, description = "Allow IF EXISTS for UPDATE statements (CASSANDRA-8610)")
237+ @CassandraVersion(value = "2.0.13", description = "Allow IF EXISTS for UPDATE statements (CASSANDRA-8610)")
238238 public void conditionalUpdatesTest() throws Exception {
239239 session().execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace));
240240
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTest.java +0 −2
@@ -20,7 +20,6 @@
2020 import com.datastax.driver.core.exceptions.InvalidQueryException;
2121 import com.datastax.driver.core.exceptions.InvalidTypeException;
2222 import com.datastax.driver.core.utils.Bytes;
23-import com.datastax.driver.core.utils.CassandraVersion;
2423 import com.google.common.collect.ImmutableList;
2524 import com.google.common.collect.ImmutableMap;
2625 import com.google.common.collect.Lists;
@@ -861,7 +860,6 @@
861860 }
862861
863862 @Test(groups = "unit")
864- @CassandraVersion(major = 2.1, minor = 3)
865863 public void should_handle_nested_collections() {
866864 String query;
867865 Statement statement;
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTupleExecutionTest.java +1 −1
@@ -29,7 +29,7 @@
2929 import static org.assertj.core.api.Assertions.assertThat;
3030 import static org.testng.Assert.assertEquals;
3131
32-@CassandraVersion(major = 2.1, minor = 3)
32+@CassandraVersion("2.1.3")
3333 public class QueryBuilderTupleExecutionTest extends CCMTestsSupport {
3434
3535 @Test(groups = "short")
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderUDTExecutionTest.java +1 −1
@@ -29,7 +29,7 @@
2929 import static org.assertj.core.api.Assertions.assertThat;
3030 import static org.testng.Assert.assertEquals;
3131
32-@CassandraVersion(major = 2.1, minor = 3)
32+@CassandraVersion("2.1.3")
3333 public class QueryBuilderUDTExecutionTest extends CCMTestsSupport {
3434
3535 @Override
modified driver-core/src/test/java/com/datastax/driver/core/schemabuilder/SchemaBuilderIT.java +2 −2
@@ -32,7 +32,7 @@
3232 public class SchemaBuilderIT extends CCMTestsSupport {
3333
3434 @Test(groups = "short")
35- @CassandraVersion(major = 2.1, minor = 2)
35+ @CassandraVersion("2.1.2")
3636 public void should_modify_table_metadata() {
3737 // Create a table
3838 session().execute(SchemaBuilder.createTable("ks", "TableMetadata")
@@ -128,7 +128,7 @@
128128 }
129129
130130 @Test(groups = "short")
131- @CassandraVersion(major = 2.1)
131+ @CassandraVersion("2.1.0")
132132 public void should_create_a_table_and_a_udt() {
133133 // Create a UDT and a table
134134 session().execute(SchemaBuilder.createType("MyUDT")
modified driver-core/src/test/java/com/datastax/driver/core/utils/CassandraVersion.java +3 −7
@@ -22,19 +22,15 @@
2222 * <p>Annotation for a Class or Method that defines a Cassandra Version requirement. If the cassandra version in use
2323 * does not meet the version requirement, the test is skipped.</p>
2424 *
25- * @see {@link com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)} for usage.
25+ * @see com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)
2626 */
2727 @Retention(RetentionPolicy.RUNTIME)
2828 public @interface CassandraVersion {
29- /**
30- * @return The major version required to execute this test, i.e. "2.0"
31- */
32- double major();
3329
3430 /**
35- * @return The minor version required to execute this test, i.e. "0"
31+ * @return The minimum version required to execute this test, i.e. "2.0.13"
3632 */
37- int minor() default 0;
33+ String value();
3834
3935 /**
4036 * @return The description returned if this version requirement is not met.
modified driver-core/src/test/java/com/datastax/driver/core/utils/DseVersion.java +3 −7
@@ -22,19 +22,15 @@
2222 * <p>Annotation for a Class or Method that defines a DataStax Enterprise Version requirement.
2323 * If the version in use does not meet the version requirement or DSE is not used, the test is skipped.</p>
2424 *
25- * @see {@link com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)} for usage.
25+ * @see com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod, org.testng.ITestResult)
2626 */
2727 @Retention(RetentionPolicy.RUNTIME)
2828 public @interface DseVersion {
29- /**
30- * @return The major version required to execute this test, i.e. "4.8"
31- */
32- double major() default 0.0;
3329
3430 /**
35- * @return The minor version required to execute this test, i.e. "3"
31+ * @return The minimum version required to execute this test, i.e. "2.0.13"
3632 */
37- int minor() default 0;
33+ String value();
3834
3935 /**
4036 * @return The description returned if this version requirement is not met.
modified driver-core/src/test/resources/log4j.properties +1 −0
@@ -20,6 +20,7 @@
2020 # Adjust Scassandra's log level
2121 # (it seems some messages are conditioned by log4j.properties and others by reference.conf, so we need both)
2222 log4j.logger.org.scassandra=ERROR
23+log4j.logger.spray.can=ERROR
2324 # Useful loggers when debugging Scassandra tests
2425 #log4j.logger.org.scassandra.cql=ERROR
2526 #log4j.logger.org.scassandra.server.cqlmessages=ERROR
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/date/SimpleDateCodecsTest.java +1 −1
@@ -33,7 +33,7 @@
3333 import static com.google.common.collect.Lists.newArrayList;
3434 import static org.assertj.core.api.Assertions.assertThat;
3535
36-@CassandraVersion(major = 2.2)
36+@CassandraVersion("2.2.0")
3737 public class SimpleDateCodecsTest extends CCMTestsSupport {
3838
3939 @Override
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/enums/EnumCodecsTest.java +1 −1
@@ -43,7 +43,7 @@
4343 * and ints (with EnumOrdinalCodec).
4444 * It also validates that both codecs may coexist in the same CodecRegistry.
4545 */
46-@CassandraVersion(major = 2.1)
46+@CassandraVersion("2.1.0")
4747 public class EnumCodecsTest extends CCMTestsSupport {
4848
4949 private final String insertQuery = "INSERT INTO t1 (pk, foo, foos, bar, bars, foobars, tup, udt) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/guava/OptionalCodecTest.java +1 −1
@@ -69,7 +69,7 @@
6969 * @since 2.2.0
7070 */
7171 @Test(groups = "short")
72- @CassandraVersion(major = 2.2)
72+ @CassandraVersion("2.2.0")
7373 public void should_map_unset_value_to_absent() {
7474 PreparedStatement insertPrep = session().prepare(this.insertStmt);
7575 PreparedStatement selectPrep = session().prepare(this.selectStmt);
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/jdk8/Jdk8TimeCodecsTest.java +1 −1
@@ -41,7 +41,7 @@
4141 import static com.google.common.collect.Sets.newHashSet;
4242 import static org.assertj.core.api.Assertions.assertThat;
4343
44-@CassandraVersion(major = 2.2)
44+@CassandraVersion("2.2.0")
4545 public class Jdk8TimeCodecsTest extends CCMTestsSupport {
4646
4747 @Override
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/jdk8/OptionalCodecTest.java +1 −1
@@ -69,7 +69,7 @@
6969 * @since 2.2.0
7070 */
7171 @Test(groups = "short")
72- @CassandraVersion(major = 2.2)
72+ @CassandraVersion("2.2.0")
7373 public void should_map_unset_value_to_empty() {
7474 PreparedStatement insertPrep = session().prepare(this.insertStmt);
7575 PreparedStatement selectPrep = session().prepare(this.selectStmt);
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/joda/JodaTimeCodecsTest.java +1 −1
@@ -42,7 +42,7 @@
4242 import static java.util.concurrent.TimeUnit.NANOSECONDS;
4343 import static org.assertj.core.api.Assertions.assertThat;
4444
45-@CassandraVersion(major = 2.2)
45+@CassandraVersion("2.2.0")
4646 public class JodaTimeCodecsTest extends CCMTestsSupport {
4747
4848 @Override
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/json/JacksonJsonCodecTest.java +1 −1
@@ -81,7 +81,7 @@
8181 }
8282
8383 @Test(groups = "short")
84- @CassandraVersion(major = 2.0)
84+ @CassandraVersion("2.0.0")
8585 public void should_use_custom_codec_with_simple_statements() {
8686 session().execute(insertQuery, notAJsonString, alice, bobAndCharlie);
8787 ResultSet rows = session().execute(selectQuery, notAJsonString, alice);
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/json/Jsr353JsonCodecTest.java +5 −5
@@ -82,7 +82,7 @@
8282 }
8383
8484 @Test(groups = "short", dataProvider = "Jsr353JsonCodecTest")
85- @CassandraVersion(major = 2.0)
85+ @CassandraVersion("2.0.0")
8686 public void should_use_custom_codec_with_simple_statements(JsonStructure object) throws IOException {
8787 session().execute(insertQuery, notAJsonString, object);
8888 ResultSet rows = session().execute(selectQuery, notAJsonString, object);
@@ -133,13 +133,13 @@
133133 @Test(groups = "short", dataProvider = "Jsr353JsonCodecTest")
134134 public void should_use_custom_codec_with_prepared_statements_2(JsonStructure object) throws IOException {
135135 session().execute(session().prepare(insertQuery).bind()
136- .setString(0, notAJsonString)
137- .set(1, object, JsonStructure.class)
136+ .setString(0, notAJsonString)
137+ .set(1, object, JsonStructure.class)
138138 );
139139 PreparedStatement ps = session().prepare(selectQuery);
140140 ResultSet rows = session().execute(ps.bind()
141- .setString(0, notAJsonString)
142- .set(1, object, JsonStructure.class)
141+ .setString(0, notAJsonString)
142+ .set(1, object, JsonStructure.class)
143143 );
144144 Row row = rows.one();
145145 assertRow(row, object);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAccessorParamsTest.java +1 −1
@@ -41,7 +41,7 @@
4141 }
4242
4343 @Test(groups = "short")
44- @CassandraVersion(major = 2.0, description = "Uses named parameters")
44+ @CassandraVersion(value = "2.0", description = "Uses named parameters")
4545 public void should_allow_less_parameters_than_bind_markers_if_there_are_repeated_names() {
4646 UserPhoneAccessor accessor = new MappingManager(session())
4747 .createAccessor(UserPhoneAccessor.class);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAccessorTest.java +1 −1
@@ -52,7 +52,7 @@
5252 }
5353
5454 @Test(groups = "short")
55- @CassandraVersion(major = 2.0)
55+ @CassandraVersion("2.0.0")
5656 public void should_allow_null_argument_in_accessor_when_set_by_name() {
5757 FooAccessor accessor = new MappingManager(session())
5858 .createAccessor(FooAccessor.class);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperComputedFieldsTest.java +6 −6
@@ -61,7 +61,7 @@
6161 }
6262
6363 @Test(groups = "short")
64- @CassandraVersion(major = 2.0)
64+ @CassandraVersion("2.0.0")
6565 void should_save_and_get_entity_with_computed_fields() {
6666 long writeTime = System.currentTimeMillis() * 1000;
6767 User newUser = new User("testlogin2", "blah");
@@ -87,7 +87,7 @@
8787 }
8888
8989 @Test(groups = "short")
90- @CassandraVersion(major = 2.0)
90+ @CassandraVersion("2.0.0")
9191 void should_add_aliases_for_fields_in_select_queries() {
9292 BoundStatement bs = (BoundStatement) userMapper.getQuery("test");
9393 assertThat(bs.preparedStatement().getQueryString())
@@ -95,7 +95,7 @@
9595 }
9696
9797 @Test(groups = "short")
98- @CassandraVersion(major = 2.0)
98+ @CassandraVersion("2.0.0")
9999 public void should_map_aliased_resultset_to_objects() {
100100 Statement getQuery = userMapper.getQuery("testlogin");
101101 getQuery.setConsistencyLevel(ConsistencyLevel.QUORUM);
@@ -108,7 +108,7 @@
108108 }
109109
110110 @Test(groups = "short")
111- @CassandraVersion(major = 2.0)
111+ @CassandraVersion("2.0.0")
112112 void should_map_unaliased_resultset_to_objects() {
113113 UserAccessor userAccessor = mappingManager.createAccessor(UserAccessor.class);
114114 ResultSet rs = userAccessor.all();
@@ -120,7 +120,7 @@
120120 }
121121
122122 @Test(groups = "short", expectedExceptions = CodecNotFoundException.class)
123- @CassandraVersion(major = 2.0)
123+ @CassandraVersion("2.0.0")
124124 void should_fail_if_computed_field_is_not_right_type() {
125125 Mapper<User_WrongComputedType> mapper = mappingManager.mapper(User_WrongComputedType.class);
126126
@@ -128,7 +128,7 @@
128128 }
129129
130130 @Test(groups = "short", expectedExceptions = IllegalArgumentException.class)
131- @CassandraVersion(major = 2.0)
131+ @CassandraVersion("2.0.0")
132132 void should_fail_if_computed_field_marked_with_column_annotation() {
133133 mappingManager.mapper(User_WrongAnnotationForComputed.class);
134134 }
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperCustomCodecTest.java +1 −1
@@ -33,7 +33,7 @@
3333 import static org.assertj.core.api.Assertions.assertThat;
3434 import static org.assertj.core.api.Assertions.fail;
3535
36-@CassandraVersion(major = 2.1)
36+@CassandraVersion("2.1.0")
3737 @SuppressWarnings("unused")
3838 public class MapperCustomCodecTest extends CCMTestsSupport {
3939
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperDefaultKeyspaceTest.java +1 −1
@@ -31,7 +31,7 @@
3131 /**
3232 * Tests usage of mapping annotations without specifying a keyspace.
3333 */
34-@CassandraVersion(major = 2.1)
34+@CassandraVersion("2.1.0")
3535 @SuppressWarnings("unused")
3636 public class MapperDefaultKeyspaceTest extends CCMTestsSupport {
3737
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperMaterializedViewTest.java +1 −1
@@ -26,7 +26,7 @@
2626 import static org.assertj.core.api.Assertions.assertThat;
2727
2828 @SuppressWarnings("unused")
29-@CassandraVersion(major = 3.0)
29+@CassandraVersion("3.0")
3030 public class MapperMaterializedViewTest extends CCMTestsSupport {
3131
3232 @Override
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperNestedCollectionsTest.java +1 −1
@@ -31,7 +31,7 @@
3131
3232 import static com.datastax.driver.core.Assertions.assertThat;
3333
34-@CassandraVersion(major = 2.1, minor = 3)
34+@CassandraVersion("2.1.3")
3535 @SuppressWarnings("unused")
3636 public class MapperNestedCollectionsTest extends CCMTestsSupport {
3737
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperOptionTest.java +10 −10
@@ -51,7 +51,7 @@
5151 }
5252
5353 @Test(groups = "short")
54- @CassandraVersion(major = 2.0)
54+ @CassandraVersion("2.0.0")
5555 void should_use_save_options() throws Exception {
5656 Long tsValue = futureTimestamp();
5757 mapper.save(new User(42, "helloworld"), Option.timestamp(tsValue), Option.tracing(true));
@@ -61,7 +61,7 @@
6161 }
6262
6363 @Test(groups = "short")
64- @CassandraVersion(major = 2.0)
64+ @CassandraVersion("2.0.0")
6565 void should_use_delete_options() {
6666 User todelete = new User(45, "todelete");
6767 mapper.save(todelete);
@@ -72,7 +72,7 @@
7272 }
7373
7474 @Test(groups = "short", expectedExceptions = {IllegalArgumentException.class})
75- @CassandraVersion(major = 2.0)
75+ @CassandraVersion("2.0.0")
7676 void should_use_get_options() {
7777 User user = new User(45, "toget");
7878 mapper.save(user);
@@ -90,7 +90,7 @@
9090 }
9191
9292 @Test(groups = "short")
93- @CassandraVersion(major = 2.0)
93+ @CassandraVersion("2.0.0")
9494 void should_use_options_only_once() {
9595 Long tsValue = futureTimestamp();
9696 mapper.save(new User(43, "helloworld"), Option.timestamp(tsValue));
@@ -101,7 +101,7 @@
101101 }
102102
103103 @Test(groups = "short")
104- @CassandraVersion(major = 2.0)
104+ @CassandraVersion("2.0.0")
105105 void should_use_default_options() {
106106 mapper.setDefaultSaveOptions(Option.timestamp(644746L), Option.ttl(76324));
107107 BoundStatement bs = (BoundStatement) mapper.saveQuery(new User(46, "rjhrgce"));
@@ -134,7 +134,7 @@
134134 }
135135
136136 @Test(groups = "short")
137- @CassandraVersion(major = 2.0)
137+ @CassandraVersion("2.0.0")
138138 void should_prioritize_option_over_model_consistency() {
139139 // Generate Write Query and ensure User model writeConsistency is used.
140140 User user = new User(1859, "Steve");
@@ -155,7 +155,7 @@
155155 }
156156
157157 @Test(groups = "short")
158- @CassandraVersion(major = 2.0)
158+ @CassandraVersion("2.0.0")
159159 void should_use_explicit_options_over_default_options() {
160160 long defaultTimestamp = futureTimestamp();
161161 long explicitTimestamp = futureTimestamp();
@@ -171,7 +171,7 @@
171171 * Cover all versions of save() to check that methods that call each other properly propagate the options
172172 */
173173 @Test(groups = "short")
174- @CassandraVersion(major = 2.0)
174+ @CassandraVersion("2.0.0")
175175 void should_use_save_options_for_all_variants() throws ExecutionException, InterruptedException {
176176 Long timestamp = futureTimestamp();
177177 User user = new User(42, "helloworld");
@@ -210,7 +210,7 @@
210210 }
211211
212212 @Test(groups = "short")
213- @CassandraVersion(major = 2.0)
213+ @CassandraVersion("2.0.0")
214214 void should_use_get_options_for_all_variants() throws InterruptedException {
215215 try {
216216 mapper.get(42, Option.consistencyLevel(TWO));
@@ -251,7 +251,7 @@
251251 }
252252
253253 @Test(groups = "short")
254- @CassandraVersion(major = 2.0)
254+ @CassandraVersion("2.0.0")
255255 void should_use_delete_options_for_all_variants() throws InterruptedException {
256256 User user = new User(42, "helloworld");
257257
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperPrimitiveTypes22Test.java +1 −1
@@ -27,7 +27,7 @@
2727
2828 import static org.testng.Assert.assertEquals;
2929
30-@CassandraVersion(major = 2.2)
30+@CassandraVersion("2.2.0")
3131 public class MapperPrimitiveTypes22Test extends CCMTestsSupport {
3232
3333 @Override
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperTest.java +5 −5
@@ -311,7 +311,7 @@
311311 }
312312
313313 @Test(groups = "short")
314- @CassandraVersion(major = 2.0)
314+ @CassandraVersion("2.0.0")
315315 public void testDynamicEntity() throws Exception {
316316 MappingManager manager = new MappingManager(session());
317317
@@ -440,7 +440,7 @@
440440 * @test_category object_mapper
441441 */
442442 @Test(groups = "short")
443- @CassandraVersion(major = 2.0)
443+ @CassandraVersion("2.0.0")
444444 public void should_flag_statement_as_idempotent() {
445445 MappingManager manager = new MappingManager(session());
446446 PostAccessor post = manager.createAccessor(PostAccessor.class);
@@ -457,7 +457,7 @@
457457 * @test_category object_mapper
458458 */
459459 @Test(groups = "short")
460- @CassandraVersion(major = 2.0)
460+ @CassandraVersion("2.0.0")
461461 public void should_flag_statement_as_non_idempotent() {
462462 MappingManager manager = new MappingManager(session());
463463 PostAccessor post = manager.createAccessor(PostAccessor.class);
@@ -474,7 +474,7 @@
474474 * @test_category object_mapper
475475 */
476476 @Test(groups = "short")
477- @CassandraVersion(major = 2.0)
477+ @CassandraVersion("2.0.0")
478478 public void should_flag_statement_with_null_idempotence() {
479479 MappingManager manager = new MappingManager(session());
480480 PostAccessor post = manager.createAccessor(PostAccessor.class);
@@ -490,7 +490,7 @@
490490 * @test_category object_mapper
491491 */
492492 @Test(groups = "short")
493- @CassandraVersion(major = 2.0)
493+ @CassandraVersion("2.0.0")
494494 public void should_flag_all_mapper_generated_statements_as_idempotent() {
495495 MappingManager manager = new MappingManager(session());
496496 Mapper<User> mapper = manager.mapper(User.class);
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperUDTCollectionsTest.java +1 −1
@@ -34,7 +34,7 @@
3434 * Tests mapping of collections of UDTs.
3535 */
3636 @SuppressWarnings("unused")
37-@CassandraVersion(major = 2.1)
37+@CassandraVersion("2.1.0")
3838 public class MapperUDTCollectionsTest extends CCMTestsSupport {
3939
4040 @Override
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperUDTTest.java +1 −1
@@ -38,7 +38,7 @@
3838 import static org.testng.Assert.*;
3939
4040 @SuppressWarnings({"unused", "WeakerAccess"})
41-@CassandraVersion(major = 2.1)
41+@CassandraVersion("2.1.0")
4242 @CreateCCM(PER_METHOD)
4343 public class MapperUDTTest extends CCMTestsSupport {
4444
modified driver-mapping/src/test/java/com/datastax/driver/mapping/UDTFieldMapperTest.java +1 −1
@@ -27,7 +27,7 @@
2727 import java.util.HashMap;
2828 import java.util.Map;
2929
30-@CassandraVersion(major = 2.1)
30+@CassandraVersion("2.1.0")
3131 @CCMConfig(createCluster = false)
3232 @SuppressWarnings("unused")
3333 public class UDTFieldMapperTest extends CCMTestsSupport {
modified driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java +1 −1
@@ -93,7 +93,7 @@
9393 // Delegate javax.security.cert to the parent classloader. javax.security.cert.X509Certificate is used in
9494 // io.netty.util.internal.EmptyArrays, but not directly by the driver.
9595 bootDelegationPackage("javax.security.cert"),
96- systemProperty("cassandra.version").value(CCMBridge.getCassandraVersion()),
96+ systemProperty("cassandra.version").value(CCMBridge.getGlobalCassandraVersion().toString()),
9797 systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1),
9898 systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"),
9999 mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
modified pom.xml +1 −1
@@ -46,7 +46,7 @@
4646
4747 <properties>
4848 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
49- <cassandra.version>3.2.1</cassandra.version>
49+ <cassandra.version>3.10</cassandra.version>
5050 <java.version>1.6</java.version>
5151 <log4j.version>1.2.17</log4j.version>
5252 <slf4j-log4j12.version>1.7.6</slf4j-log4j12.version>