kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 671f4d7f5708ae62f4822f3d7d49e1ab4a3cac57dee3028e3ac1da8da97f3729 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2017-02-17 14:33 -06:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2017-02-17 14:33 -06:00 |
| Parents | 0fc2037f3536, fbbfd98238e6 |
87 files changed
modified driver-core/src/test/java/com/datastax/driver/core/AggregateMetadataTest.java +5 −5
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | import static com.datastax.driver.core.DataType.text; |
| 25 | 25 | import static com.datastax.driver.core.TestUtils.serializeForDynamicCompositeType; |
| 26 | 26 | |
| 27 | -@CassandraVersion(major = 2.2) | |
| 27 | +@CassandraVersion("2.2.0") | |
| 28 | 28 | @CCMConfig(config = "enable_user_defined_functions:true") |
| 29 | 29 | public class AggregateMetadataTest extends CCMTestsSupport { |
| 30 | 30 | |
| @@ -183,9 +183,9 @@ | ||
| 183 | 183 | * @since 3.0.1 |
| 184 | 184 | */ |
| 185 | 185 | @Test(groups = "short") |
| 186 | - @CassandraVersion(major = 2.2) | |
| 186 | + @CassandraVersion("2.2.0") | |
| 187 | 187 | public void should_parse_and_format_aggregate_with_composite_type_literal_initcond() { |
| 188 | - VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion()); | |
| 188 | + VersionNumber ver = ccm().getCassandraVersion(); | |
| 189 | 189 | if (ver.getMajor() == 3) { |
| 190 | 190 | if ((ver.getMinor() >= 1 && ver.getMinor() < 4) || (ver.getMinor() == 0 && ver.getPatch() < 4)) { |
| 191 | 191 | throw new SkipException("Requires C* 2.2.X, 3.0.4+ or 3.4.X+"); |
| @@ -204,9 +204,9 @@ | ||
| 204 | 204 | * @since 3.0.1 |
| 205 | 205 | */ |
| 206 | 206 | @Test(groups = "short") |
| 207 | - @CassandraVersion(major = 3.0, minor = 4) | |
| 207 | + @CassandraVersion("3.4") | |
| 208 | 208 | public void should_parse_and_format_aggregate_with_composite_type_hex_initcond() { |
| 209 | - VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion()); | |
| 209 | + VersionNumber ver = ccm().getCassandraVersion(); | |
| 210 | 210 | if ((ver.getMinor() >= 1 && ver.getMinor() < 4)) { |
| 211 | 211 | throw new SkipException("Requires 3.0.4+ or 3.4.X+"); |
| 212 | 212 | } |
modified driver-core/src/test/java/com/datastax/driver/core/AsyncQueryTest.java +1 −1
| @@ -166,7 +166,7 @@ | ||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | @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") | |
| 170 | 170 | public void should_fail_when_auto_paging_on_io_thread() throws Exception { |
| 171 | 171 | for (int i = 0; i < 1000; i++) { |
| 172 | 172 | 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 @@ | ||
| 27 | 27 | |
| 28 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
| 29 | 29 | |
| 30 | -@CassandraVersion(major = 2.0, description = "uses paging") | |
| 30 | +@CassandraVersion(value = "2.0.0", description = "uses paging") | |
| 31 | 31 | public class AsyncResultSetTest extends CCMTestsSupport { |
| 32 | 32 | |
| 33 | 33 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/AuthenticationTest.java +1 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | public void sleepIf12() { |
| 42 | 42 | // For C* 1.2, sleep before attempting to connect as there is a small delay between |
| 43 | 43 | // user being created. |
| 44 | - if (ccm().getVersion().getMajor() < 2) { | |
| 44 | + if (ccm().getCassandraVersion().getMajor() < 2) { | |
| 45 | 45 | Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); |
| 46 | 46 | } |
| 47 | 47 | } |
modified driver-core/src/test/java/com/datastax/driver/core/BatchStatementTest.java +1 −1
| @@ -71,7 +71,7 @@ | ||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | @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)") | |
| 75 | 75 | public void casBatchTest() { |
| 76 | 76 | PreparedStatement st = session().prepare("INSERT INTO test (k, v) VALUES (?, ?) IF NOT EXISTS"); |
| 77 | 77 |
modified driver-core/src/test/java/com/datastax/driver/core/CCMAccess.java +26 −3
| @@ -32,13 +32,21 @@ | ||
| 32 | 32 | String getClusterName(); |
| 33 | 33 | |
| 34 | 34 | /** |
| 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. | |
| 36 | 37 | * <p/> |
| 37 | - * By default the version is equal to {@link CCMBridge#getCassandraVersion()}. | |
| 38 | 38 | * |
| 39 | 39 | * @return The version of this CCM cluster. |
| 40 | 40 | */ |
| 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(); | |
| 42 | 50 | |
| 43 | 51 | /** |
| 44 | 52 | * @return The config directory for this CCM cluster. |
| @@ -236,4 +244,19 @@ | ||
| 236 | 244 | */ |
| 237 | 245 | void waitForDown(int node); |
| 238 | 246 | |
| 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); | |
| 239 | 262 | } |
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +163 −134
| @@ -40,11 +40,11 @@ | ||
| 40 | 40 | |
| 41 | 41 | private static final Logger logger = LoggerFactory.getLogger(CCMBridge.class); |
| 42 | 42 | |
| 43 | - private static final String CASSANDRA_VERSION; | |
| 43 | + private static final VersionNumber GLOBAL_CASSANDRA_VERSION_NUMBER; | |
| 44 | 44 | |
| 45 | - private static final Set<String> CASSANDRA_INSTALL_ARGS; | |
| 45 | + private static final VersionNumber GLOBAL_DSE_VERSION_NUMBER; | |
| 46 | 46 | |
| 47 | - private static final boolean IS_DSE; | |
| 47 | + private static final Set<String> CASSANDRA_INSTALL_ARGS; | |
| 48 | 48 | |
| 49 | 49 | public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "cassandra1sfun"; |
| 50 | 50 | public static final String DEFAULT_CLIENT_TRUSTSTORE_PATH = "/client.truststore"; |
| @@ -81,8 +81,8 @@ | ||
| 81 | 81 | private static final Map<String, String> ENVIRONMENT_MAP; |
| 82 | 82 | |
| 83 | 83 | /** |
| 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'. | |
| 86 | 86 | */ |
| 87 | 87 | private static final Map<String, String> dseToCassandraVersions = ImmutableMap.<String, String>builder() |
| 88 | 88 | .put("5.0.4", "3.0.10") |
| @@ -144,14 +144,14 @@ | ||
| 144 | 144 | private static final String CCM_COMMAND; |
| 145 | 145 | |
| 146 | 146 | static { |
| 147 | - CASSANDRA_VERSION = System.getProperty("cassandra.version"); | |
| 147 | + String inputCassandraVersion = System.getProperty("cassandra.version"); | |
| 148 | 148 | String installDirectory = System.getProperty("cassandra.directory"); |
| 149 | 149 | String branch = System.getProperty("cassandra.branch"); |
| 150 | 150 | |
| 151 | 151 | String dseProperty = System.getProperty("dse"); |
| 152 | 152 | // If -Ddse, if the value is empty interpret it as enabled, |
| 153 | 153 | // 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)); | |
| 155 | 155 | |
| 156 | 156 | ImmutableSet.Builder<String> installArgs = ImmutableSet.builder(); |
| 157 | 157 | if (installDirectory != null && !installDirectory.trim().isEmpty()) { |
| @@ -159,10 +159,10 @@ | ||
| 159 | 159 | } else if (branch != null && !branch.trim().isEmpty()) { |
| 160 | 160 | installArgs.add("-v git:" + branch.trim().replaceAll("\"", "")); |
| 161 | 161 | } else { |
| 162 | - installArgs.add("-v " + CASSANDRA_VERSION); | |
| 162 | + installArgs.add("-v " + inputCassandraVersion); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (IS_DSE) { | |
| 165 | + if (isDse) { | |
| 166 | 166 | installArgs.add("--dse"); |
| 167 | 167 | } |
| 168 | 168 | |
| @@ -193,12 +193,57 @@ | ||
| 193 | 193 | } |
| 194 | 194 | ENVIRONMENT_MAP = ImmutableMap.copyOf(envMap); |
| 195 | 195 | |
| 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); | |
| 197 | 199 | 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); | |
| 199 | 201 | } else { |
| 202 | + GLOBAL_CASSANDRA_VERSION_NUMBER = VersionNumber.parse(inputCassandraVersion); | |
| 203 | + GLOBAL_DSE_VERSION_NUMBER = null; | |
| 200 | 204 | 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"); | |
| 202 | 247 | } |
| 203 | 248 | } |
| 204 | 249 | |
| @@ -215,7 +260,9 @@ | ||
| 215 | 260 | |
| 216 | 261 | private final String clusterName; |
| 217 | 262 | |
| 218 | - private final VersionNumber version; | |
| 263 | + private final VersionNumber cassandraVersion; | |
| 264 | + | |
| 265 | + private final VersionNumber dseVersion; | |
| 219 | 266 | |
| 220 | 267 | private final int storagePort; |
| 221 | 268 | |
| @@ -237,75 +284,20 @@ | ||
| 237 | 284 | |
| 238 | 285 | private final int[] nodes; |
| 239 | 286 | |
| 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) { | |
| 241 | 289 | this.clusterName = clusterName; |
| 242 | - this.version = version; | |
| 290 | + this.cassandraVersion = cassandraVersion; | |
| 291 | + this.dseVersion = dseVersion; | |
| 243 | 292 | this.storagePort = storagePort; |
| 244 | 293 | this.thriftPort = thriftPort; |
| 245 | 294 | this.binaryPort = binaryPort; |
| 246 | - this.isDSE = isDSE; | |
| 295 | + this.isDSE = dseVersion != null; | |
| 247 | 296 | this.jvmArgs = jvmArgs; |
| 248 | 297 | this.nodes = nodes; |
| 249 | 298 | this.ccmDir = Files.createTempDir(); |
| 250 | 299 | } |
| 251 | 300 | |
| 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 | - | |
| 309 | 301 | public static Builder builder() { |
| 310 | 302 | return new Builder(); |
| 311 | 303 | } |
| @@ -321,8 +313,13 @@ | ||
| 321 | 313 | } |
| 322 | 314 | |
| 323 | 315 | @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; | |
| 326 | 323 | } |
| 327 | 324 | |
| 328 | 325 | @Override |
| @@ -404,7 +401,7 @@ | ||
| 404 | 401 | private String getStartWaitArguments() { |
| 405 | 402 | // make a small exception for C* 1.2 as it has a bug where it starts listening on the binary |
| 406 | 403 | // interface slightly before it joins the cluster. |
| 407 | - if (getCassandraVersion().startsWith("1.")) { | |
| 404 | + if (this.cassandraVersion.getMajor() == 1) { | |
| 408 | 405 | return " --wait-other-notice"; |
| 409 | 406 | } else { |
| 410 | 407 | return " --no-wait"; |
| @@ -419,7 +416,7 @@ | ||
| 419 | 416 | logger.debug("Starting: {} - free memory: {} MB", this, TestUtils.getFreeMemoryMB()); |
| 420 | 417 | try { |
| 421 | 418 | 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) { | |
| 423 | 420 | cmd += " --quiet-windows"; |
| 424 | 421 | } |
| 425 | 422 | execute(cmd); |
| @@ -493,7 +490,7 @@ | ||
| 493 | 490 | logger.debug(String.format("Starting: node %s (%s%s:%s) in %s", n, TestUtils.IP_PREFIX, n, binaryPort, this)); |
| 494 | 491 | try { |
| 495 | 492 | 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) { | |
| 497 | 494 | cmd += " --quiet-windows"; |
| 498 | 495 | } |
| 499 | 496 | execute(cmd, n); |
| @@ -549,7 +546,12 @@ | ||
| 549 | 546 | @Override |
| 550 | 547 | public void decommission(int n) { |
| 551 | 548 | 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); | |
| 553 | 555 | } |
| 554 | 556 | |
| 555 | 557 | @Override |
| @@ -688,6 +690,26 @@ | ||
| 688 | 690 | TestUtils.waitUntilPortIsDown(addressOfNode(node)); |
| 689 | 691 | } |
| 690 | 692 | |
| 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 | + | |
| 691 | 713 | /** |
| 692 | 714 | * <p> |
| 693 | 715 | * Extracts a keystore from the classpath into a temporary file. |
| @@ -746,9 +768,9 @@ | ||
| 746 | 768 | |
| 747 | 769 | int[] nodes = {1}; |
| 748 | 770 | 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>(); | |
| 752 | 774 | private Set<String> jvmArgs = new LinkedHashSet<String>(); |
| 753 | 775 | private final Map<String, Object> cassandraConfiguration = Maps.newLinkedHashMap(); |
| 754 | 776 | private final Map<String, Object> dseConfiguration = Maps.newLinkedHashMap(); |
| @@ -804,41 +826,24 @@ | ||
| 804 | 826 | } |
| 805 | 827 | |
| 806 | 828 | /** |
| 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. | |
| 816 | 830 | */ |
| 817 | - public Builder withoutDSE() { | |
| 818 | - this.isDSE = false; | |
| 831 | + public Builder withVersion(VersionNumber version) { | |
| 832 | + this.version = version; | |
| 819 | 833 | return this; |
| 820 | 834 | } |
| 821 | 835 | |
| 822 | 836 | /** |
| 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. | |
| 824 | 838 | */ |
| 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; | |
| 836 | 841 | return this; |
| 837 | 842 | } |
| 838 | 843 | |
| 839 | 844 | /** |
| 840 | 845 | * 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). | |
| 842 | 847 | */ |
| 843 | 848 | public Builder withCreateOptions(String... createOptions) { |
| 844 | 849 | Collections.addAll(this.createOptions, createOptions); |
| @@ -901,14 +906,36 @@ | ||
| 901 | 906 | public CCMBridge build() { |
| 902 | 907 | // be careful NOT to alter internal state (hashCode/equals) during build! |
| 903 | 908 | 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 | + } | |
| 905 | 927 | |
| 906 | 928 | Map<String, Object> cassandraConfiguration = randomizePorts(this.cassandraConfiguration); |
| 907 | - VersionNumber version = VersionNumber.parse(this.version); | |
| 908 | 929 | int storagePort = Integer.parseInt(cassandraConfiguration.get("storage_port").toString()); |
| 909 | 930 | int thriftPort = Integer.parseInt(cassandraConfiguration.get("rpc_port").toString()); |
| 910 | 931 | 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); | |
| 912 | 939 | |
| 913 | 940 | Runtime.getRuntime().addShutdownHook(new Thread() { |
| 914 | 941 | @Override |
| @@ -916,15 +943,12 @@ | ||
| 916 | 943 | ccm.close(); |
| 917 | 944 | } |
| 918 | 945 | }); |
| 919 | - ccm.execute(buildCreateCommand(clusterName, dse)); | |
| 946 | + ccm.execute(buildCreateCommand(clusterName, versionConfigured, cassandraVersion, dseVersion)); | |
| 920 | 947 | updateNodeConf(ccm); |
| 921 | 948 | ccm.updateConfig(cassandraConfiguration); |
| 922 | - if (dse) { | |
| 949 | + if (dseVersion != null) { | |
| 923 | 950 | 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) { | |
| 928 | 952 | // randomize DSE specific ports if dse present and greater than 5.0 |
| 929 | 953 | dseConfiguration.put("lease_netty_server_port", RANDOM_PORT); |
| 930 | 954 | dseConfiguration.put("internode_messaging_options.port", RANDOM_PORT); |
| @@ -941,6 +965,10 @@ | ||
| 941 | 965 | return ccm; |
| 942 | 966 | } |
| 943 | 967 | |
| 968 | + private static boolean isThriftSupported(VersionNumber cassandraVersion) { | |
| 969 | + return cassandraVersion.compareTo(VersionNumber.parse("4.0")) < 0; | |
| 970 | + } | |
| 971 | + | |
| 944 | 972 | public int weight() { |
| 945 | 973 | // the weight is simply function of the number of nodes |
| 946 | 974 | int totalNodes = 0; |
| @@ -964,7 +992,7 @@ | ||
| 964 | 992 | return allJvmArgs.toString(); |
| 965 | 993 | } |
| 966 | 994 | |
| 967 | - private String buildCreateCommand(String clusterName, boolean dse) { | |
| 995 | + private String buildCreateCommand(String clusterName, boolean versionConfigured, VersionNumber cassandraVersion, VersionNumber dseVersion) { | |
| 968 | 996 | StringBuilder result = new StringBuilder(CCM_COMMAND + " create"); |
| 969 | 997 | result.append(" ").append(clusterName); |
| 970 | 998 | result.append(" -i ").append(TestUtils.IP_PREFIX); |
| @@ -979,16 +1007,18 @@ | ||
| 979 | 1007 | } |
| 980 | 1008 | } |
| 981 | 1009 | |
| 982 | - // If not DSE, remove --dse if in createOptions. | |
| 983 | 1010 | 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()); | |
| 992 | 1022 | } |
| 993 | 1023 | } |
| 994 | 1024 | result.append(" ").append(Joiner.on(" ").join(randomizePorts(lCreateOptions))); |
| @@ -1077,14 +1107,15 @@ | ||
| 1077 | 1107 | @Override |
| 1078 | 1108 | @SuppressWarnings("SimplifiableIfStatement") |
| 1079 | 1109 | 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. | |
| 1082 | 1111 | if (this == o) return true; |
| 1083 | 1112 | if (o == null || getClass() != o.getClass()) return false; |
| 1113 | + | |
| 1084 | 1114 | Builder builder = (Builder) o; |
| 1115 | + | |
| 1116 | + if (dse != builder.dse) return false; | |
| 1085 | 1117 | 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; | |
| 1088 | 1119 | if (!createOptions.equals(builder.createOptions)) return false; |
| 1089 | 1120 | if (!jvmArgs.equals(builder.jvmArgs)) return false; |
| 1090 | 1121 | if (!cassandraConfiguration.equals(builder.cassandraConfiguration)) return false; |
| @@ -1094,19 +1125,17 @@ | ||
| 1094 | 1125 | |
| 1095 | 1126 | @Override |
| 1096 | 1127 | 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. | |
| 1099 | 1129 | 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); | |
| 1101 | 1132 | result = 31 * result + createOptions.hashCode(); |
| 1102 | 1133 | result = 31 * result + jvmArgs.hashCode(); |
| 1103 | 1134 | result = 31 * result + cassandraConfiguration.hashCode(); |
| 1104 | 1135 | result = 31 * result + dseConfiguration.hashCode(); |
| 1105 | 1136 | result = 31 * result + workloads.hashCode(); |
| 1106 | - result = 31 * result + version.hashCode(); | |
| 1107 | 1137 | return result; |
| 1108 | 1138 | } |
| 1109 | - | |
| 1110 | 1139 | } |
| 1111 | 1140 | |
| 1112 | 1141 | } |
modified driver-core/src/test/java/com/datastax/driver/core/CCMCache.java +17 −2
| @@ -49,8 +49,13 @@ | ||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | @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(); | |
| 54 | 59 | } |
| 55 | 60 | |
| 56 | 61 | @Override |
| @@ -215,6 +220,16 @@ | ||
| 215 | 220 | ccm.waitForDown(node); |
| 216 | 221 | } |
| 217 | 222 | |
| 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 | + | |
| 218 | 233 | @Override |
| 219 | 234 | public String toString() { |
| 220 | 235 | return ccm.toString(); |
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +38 −17
| @@ -78,13 +78,18 @@ | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | @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(); | |
| 83 | 88 | } |
| 84 | 89 | |
| 85 | 90 | @Override |
| 86 | - public VersionNumber getVersion() { | |
| 87 | - return delegate.getVersion(); | |
| 91 | + public InetSocketAddress addressOfNode(int n) { | |
| 92 | + return delegate.addressOfNode(n); | |
| 88 | 93 | } |
| 89 | 94 | |
| 90 | 95 | @Override |
| @@ -237,6 +242,16 @@ | ||
| 237 | 242 | throw new UnsupportedOperationException("This CCM cluster is read-only"); |
| 238 | 243 | } |
| 239 | 244 | |
| 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 | + | |
| 240 | 255 | @Override |
| 241 | 256 | public String toString() { |
| 242 | 257 | return delegate.toString(); |
| @@ -318,9 +333,15 @@ | ||
| 318 | 333 | } |
| 319 | 334 | |
| 320 | 335 | 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 | + } | |
| 324 | 345 | for (String aConf : conf) { |
| 325 | 346 | String[] tokens = aConf.split(":"); |
| 326 | 347 | if (tokens.length != 2) |
| @@ -331,7 +352,7 @@ | ||
| 331 | 352 | // cannot be met. |
| 332 | 353 | if (configVersionRequirements.containsKey(key)) { |
| 333 | 354 | VersionNumber requirement = configVersionRequirements.get(key); |
| 334 | - if (version.compareTo(requirement) < 0) { | |
| 355 | + if (version != null && version.compareTo(requirement) < 0) { | |
| 335 | 356 | LOGGER.debug("Skipping inclusion of '{}' in cassandra.yaml since it requires >= C* {} and {} " + |
| 336 | 357 | "was detected.", aConf, requirement, version); |
| 337 | 358 | continue; |
| @@ -428,16 +449,16 @@ | ||
| 428 | 449 | if (ccmBuilder == null) { |
| 429 | 450 | ccmBuilder = CCMBridge.builder().withNodes(numberOfNodes()).notStarted(); |
| 430 | 451 | } |
| 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); | |
| 440 | 457 | } |
| 458 | + | |
| 459 | + Boolean dse = dse(); | |
| 460 | + if (dse != null) | |
| 461 | + ccmBuilder.withDSE(dse); | |
| 441 | 462 | if (ssl()) |
| 442 | 463 | ccmBuilder.withSSL(); |
| 443 | 464 | if (auth()) |
modified driver-core/src/test/java/com/datastax/driver/core/ConditionalUpdateTest.java +1 −1
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | /** |
| 25 | 25 | * Test {@link ResultSet#wasApplied()} for conditional updates. |
| 26 | 26 | */ |
| 27 | -@CassandraVersion(major = 2.0, description = "Conditional Updates requires 2.0+.") | |
| 27 | +@CassandraVersion(value = "2.0.0", description = "Conditional Updates requires 2.0+.") | |
| 28 | 28 | public class ConditionalUpdateTest extends CCMTestsSupport { |
| 29 | 29 | |
| 30 | 30 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +1 −1
| @@ -94,7 +94,7 @@ | ||
| 94 | 94 | * Therefore we use two different driver instances in this test. |
| 95 | 95 | */ |
| 96 | 96 | @Test(groups = "short") |
| 97 | - @CassandraVersion(major = 2.1) | |
| 97 | + @CassandraVersion("2.1.0") | |
| 98 | 98 | public void should_parse_UDT_definitions_when_using_default_protocol_version() { |
| 99 | 99 | // First driver instance: create UDT |
| 100 | 100 | Cluster cluster = register(Cluster.builder() |
modified driver-core/src/test/java/com/datastax/driver/core/CustomPayloadTest.java +1 −11
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | import static org.assertj.core.api.Assertions.assertThat; |
| 34 | 34 | import static org.assertj.core.api.Fail.fail; |
| 35 | 35 | |
| 36 | -@CassandraVersion(major = 2.2) | |
| 36 | +@CassandraVersion("2.2.0") | |
| 37 | 37 | @CCMConfig(jvmArgs = "-Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler") |
| 38 | 38 | public class CustomPayloadTest extends CCMTestsSupport { |
| 39 | 39 | |
| @@ -85,8 +85,6 @@ | ||
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Ensures that an incoming payload is propagated from prepared to bound statements. |
| 88 | - * | |
| 89 | - * @throws Exception | |
| 90 | 88 | */ |
| 91 | 89 | @Test(groups = "short") |
| 92 | 90 | public void should_propagate_incoming_payload_to_bound_statement() throws Exception { |
| @@ -113,8 +111,6 @@ | ||
| 113 | 111 | /** |
| 114 | 112 | * Ensures that an incoming payload is overridden by an explicitly set outgoing payload |
| 115 | 113 | * when propagated to bound statements. |
| 116 | - * | |
| 117 | - * @throws Exception | |
| 118 | 114 | */ |
| 119 | 115 | @Test(groups = "short") |
| 120 | 116 | public void should_override_incoming_payload_when_outgoing_payload_explicitly_set_on_preparing_statement() throws Exception { |
| @@ -141,8 +137,6 @@ | ||
| 141 | 137 | /** |
| 142 | 138 | * Ensures that payloads can still be set individually on bound statements |
| 143 | 139 | * if the prepared statement does not have a default payload. |
| 144 | - * | |
| 145 | - * @throws Exception | |
| 146 | 140 | */ |
| 147 | 141 | @Test(groups = "short") |
| 148 | 142 | public void should_not_set_any_payload_on_bound_statement() throws Exception { |
| @@ -171,8 +165,6 @@ | ||
| 171 | 165 | |
| 172 | 166 | /** |
| 173 | 167 | * Ensures that a custom payload is propagated throughout pages. |
| 174 | - * | |
| 175 | - * @throws Exception | |
| 176 | 168 | */ |
| 177 | 169 | @Test(groups = "short") |
| 178 | 170 | public void should_echo_custom_payload_when_paginating() throws Exception { |
| @@ -253,8 +245,6 @@ | ||
| 253 | 245 | |
| 254 | 246 | /** |
| 255 | 247 | * Ensures that when debugging custom payloads, the driver will print appropriate log messages. |
| 256 | - * | |
| 257 | - * @throws Exception | |
| 258 | 248 | */ |
| 259 | 249 | @Test(groups = "short") |
| 260 | 250 | 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 @@ | ||
| 19 | 19 | import org.testng.annotations.Test; |
| 20 | 20 | |
| 21 | 21 | import java.nio.ByteBuffer; |
| 22 | -import java.util.ArrayList; | |
| 23 | 22 | import java.util.List; |
| 24 | 23 | import java.util.Map; |
| 25 | 24 | |
| @@ -153,7 +152,7 @@ | ||
| 153 | 152 | * @test_category metadata |
| 154 | 153 | */ |
| 155 | 154 | @Test(groups = "short") |
| 156 | - @CassandraVersion(major = 2.1) | |
| 155 | + @CassandraVersion("2.1.0") | |
| 157 | 156 | public void should_handle_udt_with_custom_type() { |
| 158 | 157 | // Given: a UDT with custom types, and a table using it. |
| 159 | 158 | 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 @@ | ||
| 25 | 25 | |
| 26 | 26 | public class DataTypeClassNameParserTest { |
| 27 | 27 | |
| 28 | - private ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion(); | |
| 28 | + private ProtocolVersion protocolVersion = ProtocolVersion.NEWEST_SUPPORTED; | |
| 29 | 29 | private CodecRegistry codecRegistry = new CodecRegistry(); |
| 30 | 30 | |
| 31 | 31 | @Test(groups = "unit") |
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeCqlNameParserTest.java +1 −1
| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | import static com.datastax.driver.core.DataTypeCqlNameParser.parse; |
| 24 | 24 | import static com.datastax.driver.core.Metadata.quote; |
| 25 | 25 | |
| 26 | -@CassandraVersion(major = 3.0) | |
| 26 | +@CassandraVersion("3.0") | |
| 27 | 27 | public class DataTypeCqlNameParserTest extends CCMTestsSupport { |
| 28 | 28 | |
| 29 | 29 | @Test(groups = "short") |
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeIntegrationTest.java +23 −18
| @@ -36,17 +36,22 @@ | ||
| 36 | 36 | * (protocol > v2 only) and a prepared statement. |
| 37 | 37 | * This is repeated with a large number of datatypes. |
| 38 | 38 | */ |
| 39 | -@CCMConfig(clusterProvider = "createClusterBuilderNoDebouncing") | |
| 40 | 39 | public class DataTypeIntegrationTest extends CCMTestsSupport { |
| 41 | 40 | private static final Logger logger = LoggerFactory.getLogger(DataTypeIntegrationTest.class); |
| 42 | 41 | |
| 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; | |
| 45 | 47 | |
| 46 | 48 | enum StatementType {RAW_STRING, SIMPLE_WITH_PARAM, PREPARED} |
| 47 | 49 | |
| 48 | 50 | @Override |
| 49 | 51 | public void onTestContextInitialized() { |
| 52 | + ProtocolVersion protocolVersion = ccm().getProtocolVersion(); | |
| 53 | + samples = PrimitiveTypeSamples.samples(protocolVersion); | |
| 54 | + tables = allTables(); | |
| 50 | 55 | Host host = cluster().getMetadata().getAllHosts().iterator().next(); |
| 51 | 56 | cassandraVersion = host.getCassandraVersion().nextStable(); |
| 52 | 57 | List<String> statements = Lists.newArrayList(); |
| @@ -71,7 +76,7 @@ | ||
| 71 | 76 | } |
| 72 | 77 | |
| 73 | 78 | @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") | |
| 75 | 80 | public void should_insert_and_retrieve_data_with_parameterized_simple_statements() { |
| 76 | 81 | should_insert_and_retrieve_data(StatementType.SIMPLE_WITH_PARAM); |
| 77 | 82 | } |
| @@ -189,7 +194,7 @@ | ||
| 189 | 194 | } |
| 190 | 195 | } |
| 191 | 196 | |
| 192 | - private static List<TestTable> allTables() { | |
| 197 | + private List<TestTable> allTables() { | |
| 193 | 198 | List<TestTable> tables = Lists.newArrayList(); |
| 194 | 199 | |
| 195 | 200 | tables.addAll(tablesWithPrimitives()); |
| @@ -202,18 +207,18 @@ | ||
| 202 | 207 | return ImmutableList.copyOf(tables); |
| 203 | 208 | } |
| 204 | 209 | |
| 205 | - private static List<TestTable> tablesWithPrimitives() { | |
| 210 | + private List<TestTable> tablesWithPrimitives() { | |
| 206 | 211 | List<TestTable> tables = Lists.newArrayList(); |
| 207 | - for (Map.Entry<DataType, Object> entry : PrimitiveTypeSamples.ALL.entrySet()) | |
| 212 | + for (Map.Entry<DataType, Object> entry : samples.entrySet()) | |
| 208 | 213 | tables.add(new TestTable(entry.getKey(), entry.getValue(), "1.2.0")); |
| 209 | 214 | return tables; |
| 210 | 215 | } |
| 211 | 216 | |
| 212 | - private static List<TestTable> tablesWithPrimitivesNull() { | |
| 217 | + private List<TestTable> tablesWithPrimitivesNull() { | |
| 213 | 218 | List<TestTable> tables = Lists.newArrayList(); |
| 214 | 219 | // Create a test table for each primitive type testing with null values. If the |
| 215 | 220 | // 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())) { | |
| 217 | 222 | Object expectedPrimitiveValue = null; |
| 218 | 223 | switch (dataType.getName()) { |
| 219 | 224 | case BIGINT: |
| @@ -248,9 +253,9 @@ | ||
| 248 | 253 | |
| 249 | 254 | } |
| 250 | 255 | |
| 251 | - private static List<TestTable> tablesWithCollectionsOfPrimitives() { | |
| 256 | + private List<TestTable> tablesWithCollectionsOfPrimitives() { | |
| 252 | 257 | List<TestTable> tables = Lists.newArrayList(); |
| 253 | - for (Map.Entry<DataType, Object> entry : PrimitiveTypeSamples.ALL.entrySet()) { | |
| 258 | + for (Map.Entry<DataType, Object> entry : samples.entrySet()) { | |
| 254 | 259 | |
| 255 | 260 | DataType elementType = entry.getKey(); |
| 256 | 261 | Object elementSample = entry.getValue(); |
| @@ -261,12 +266,12 @@ | ||
| 261 | 266 | return tables; |
| 262 | 267 | } |
| 263 | 268 | |
| 264 | - private static List<TestTable> tablesWithMapsOfPrimitives() { | |
| 269 | + private List<TestTable> tablesWithMapsOfPrimitives() { | |
| 265 | 270 | List<TestTable> tables = Lists.newArrayList(); |
| 266 | - for (Map.Entry<DataType, Object> keyEntry : PrimitiveTypeSamples.ALL.entrySet()) { | |
| 271 | + for (Map.Entry<DataType, Object> keyEntry : samples.entrySet()) { | |
| 267 | 272 | DataType keyType = keyEntry.getKey(); |
| 268 | 273 | Object keySample = keyEntry.getValue(); |
| 269 | - for (Map.Entry<DataType, Object> valueEntry : PrimitiveTypeSamples.ALL.entrySet()) { | |
| 274 | + for (Map.Entry<DataType, Object> valueEntry : samples.entrySet()) { | |
| 270 | 275 | DataType valueType = valueEntry.getKey(); |
| 271 | 276 | Object valueSample = valueEntry.getValue(); |
| 272 | 277 | |
| @@ -278,7 +283,7 @@ | ||
| 278 | 283 | return tables; |
| 279 | 284 | } |
| 280 | 285 | |
| 281 | - private static Collection<? extends TestTable> tablesWithNestedCollections() { | |
| 286 | + private Collection<? extends TestTable> tablesWithNestedCollections() { | |
| 282 | 287 | List<TestTable> tables = Lists.newArrayList(); |
| 283 | 288 | |
| 284 | 289 | // To avoid combinatorial explosion, only use int as the primitive type, and two levels of nesting. |
| @@ -309,7 +314,7 @@ | ||
| 309 | 314 | return tables; |
| 310 | 315 | } |
| 311 | 316 | |
| 312 | - private static Collection<? extends TestTable> tablesWithRandomlyGeneratedNestedCollections() { | |
| 317 | + private Collection<? extends TestTable> tablesWithRandomlyGeneratedNestedCollections() { | |
| 313 | 318 | List<TestTable> tables = Lists.newArrayList(); |
| 314 | 319 | |
| 315 | 320 | DataType nestedListType = buildNestedType(DataType.Name.LIST, 5); |
| @@ -325,7 +330,7 @@ | ||
| 325 | 330 | /** |
| 326 | 331 | * Populate a nested collection based on the given type and it's arguments. |
| 327 | 332 | */ |
| 328 | - public static Object nestedObject(DataType type) { | |
| 333 | + public Object nestedObject(DataType type) { | |
| 329 | 334 | |
| 330 | 335 | int typeIdx = type.getTypeArguments().size() > 1 ? 1 : 0; |
| 331 | 336 | DataType argument = type.getTypeArguments().get(typeIdx); |
| @@ -375,7 +380,7 @@ | ||
| 375 | 380 | * @return a DataType that is a nested collection with the given baseType with the |
| 376 | 381 | * given depth. |
| 377 | 382 | */ |
| 378 | - public static DataType buildNestedType(DataType.Name baseType, int depth) { | |
| 383 | + public DataType buildNestedType(DataType.Name baseType, int depth) { | |
| 379 | 384 | Random r = new Random(); |
| 380 | 385 | DataType t = null; |
| 381 | 386 |
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeTest.java +1 −1
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | |
| 38 | 38 | CodecRegistry codecRegistry = new CodecRegistry(); |
| 39 | 39 | |
| 40 | - ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion(); | |
| 40 | + ProtocolVersion protocolVersion = ProtocolVersion.NEWEST_SUPPORTED; | |
| 41 | 41 | |
| 42 | 42 | static boolean exclude(DataType t) { |
| 43 | 43 | return t.getName() == DataType.Name.COUNTER; |
modified driver-core/src/test/java/com/datastax/driver/core/DirectCompressionTest.java +1 −1
| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | * @expected_result session established and queries made successfully using it. |
| 41 | 41 | */ |
| 42 | 42 | @Test(groups = "short") |
| 43 | - @CassandraVersion(major = 2.0) | |
| 43 | + @CassandraVersion("2.0.0") | |
| 44 | 44 | public void should_function_with_lz4_compression() throws Exception { |
| 45 | 45 | compressionTest(ProtocolOptions.Compression.LZ4); |
| 46 | 46 | } |
modified driver-core/src/test/java/com/datastax/driver/core/FunctionMetadataTest.java +3 −2
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | import org.testng.annotations.Test; |
| 20 | 20 | |
| 21 | 21 | 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; | |
| 23 | 24 | import static org.assertj.core.api.Assertions.entry; |
| 24 | 25 | |
| 25 | -@CassandraVersion(major = 2.2) | |
| 26 | +@CassandraVersion("2.2.0") | |
| 26 | 27 | @CCMConfig(config = "enable_user_defined_functions:true") |
| 27 | 28 | public class FunctionMetadataTest extends CCMTestsSupport { |
| 28 | 29 |
modified driver-core/src/test/java/com/datastax/driver/core/GettableDataIntegrationTest.java +1 −1
| @@ -45,7 +45,7 @@ | ||
| 45 | 45 | |
| 46 | 46 | @Override |
| 47 | 47 | 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; | |
| 49 | 49 | // only add tuples / nested collections at > 2.1.3. |
| 50 | 50 | execute("CREATE TABLE codec_mapping (k int PRIMARY KEY, " |
| 51 | 51 | + "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 @@ | ||
| 47 | 47 | * @expected_result session established and queries made successfully using it. |
| 48 | 48 | */ |
| 49 | 49 | @Test(groups = "isolated") |
| 50 | - @CassandraVersion(major = 2.0) | |
| 50 | + @CassandraVersion("2.0.0") | |
| 51 | 51 | public void should_function_with_lz4_compression() throws Exception { |
| 52 | 52 | compressionTest(ProtocolOptions.Compression.LZ4); |
| 53 | 53 | } |
modified driver-core/src/test/java/com/datastax/driver/core/HostMetadataIntegrationTest.java +0 −43
| @@ -15,7 +15,6 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import com.datastax.driver.core.utils.DseVersion; | |
| 19 | 18 | import org.apache.log4j.Level; |
| 20 | 19 | import org.apache.log4j.Logger; |
| 21 | 20 | import org.testng.annotations.Test; |
| @@ -23,52 +22,10 @@ | ||
| 23 | 22 | import java.net.InetAddress; |
| 24 | 23 | |
| 25 | 24 | 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; | |
| 28 | 25 | import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions; |
| 29 | 26 | |
| 30 | 27 | public class HostMetadataIntegrationTest { |
| 31 | 28 | |
| 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 | - | |
| 72 | 29 | /** |
| 73 | 30 | * Validates that {@link Host#getDseVersion()} and {@link Host#getDseWorkload()} return values defined in |
| 74 | 31 | * 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 @@ | ||
| 32 | 32 | import static com.datastax.driver.core.DataType.*; |
| 33 | 33 | import static com.datastax.driver.core.IndexMetadata.Kind.*; |
| 34 | 34 | |
| 35 | -@CassandraVersion(major = 1.2) | |
| 35 | +@CassandraVersion("1.2.0") | |
| 36 | 36 | public class IndexMetadataTest extends CCMTestsSupport { |
| 37 | 37 | |
| 38 | 38 | /** |
| @@ -75,7 +75,7 @@ | ||
| 75 | 75 | + "\"MixedCaseColumn\" list<text>," |
| 76 | 76 | + |
| 77 | 77 | // 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 | |
| 79 | 79 | ? |
| 80 | 80 | ", map_full frozen<map<text, int>>," |
| 81 | 81 | + "set_full frozen<set<text>>," |
| @@ -103,10 +103,10 @@ | ||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | @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") | |
| 107 | 107 | public void should_create_metadata_for_values_index_on_mixed_case_column() { |
| 108 | 108 | // 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 ? | |
| 110 | 110 | String.format("CREATE INDEX \"MixedCaseIndex\" ON %s.indexing (values(\"MixedCaseColumn\"));", keyspace) : |
| 111 | 111 | String.format("CREATE INDEX \"MixedCaseIndex\" ON %s.indexing (\"MixedCaseColumn\");", keyspace); |
| 112 | 112 | session().execute(createValuesIndex); |
| @@ -116,17 +116,17 @@ | ||
| 116 | 116 | .hasName("MixedCaseIndex") |
| 117 | 117 | .hasParent((TableMetadata) column.getParent()) |
| 118 | 118 | .isNotCustomIndex() |
| 119 | - .hasTarget(ccm().getVersion().getMajor() > 2 ? "values(\"MixedCaseColumn\")" : "\"MixedCaseColumn\"") | |
| 119 | + .hasTarget(ccm().getCassandraVersion().getMajor() > 2 ? "values(\"MixedCaseColumn\")" : "\"MixedCaseColumn\"") | |
| 120 | 120 | .hasKind(COMPOSITES) |
| 121 | 121 | .asCqlQuery(createValuesIndex); |
| 122 | 122 | assertThat((TableMetadata) column.getParent()).hasIndex(index); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | @Test(groups = "short") |
| 126 | - @CassandraVersion(major = 2.1) | |
| 126 | + @CassandraVersion("2.1.0") | |
| 127 | 127 | public void should_create_metadata_for_index_on_map_values() { |
| 128 | 128 | // 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 ? | |
| 130 | 130 | String.format("CREATE INDEX map_values_index ON %s.indexing (values(map_values));", keyspace) : |
| 131 | 131 | String.format("CREATE INDEX map_values_index ON %s.indexing (map_values);", keyspace); |
| 132 | 132 | session().execute(createValuesIndex); |
| @@ -136,14 +136,14 @@ | ||
| 136 | 136 | .hasName("map_values_index") |
| 137 | 137 | .hasParent((TableMetadata) column.getParent()) |
| 138 | 138 | .isNotCustomIndex() |
| 139 | - .hasTarget(ccm().getVersion().getMajor() > 2 ? "values(map_values)" : "map_values") | |
| 139 | + .hasTarget(ccm().getCassandraVersion().getMajor() > 2 ? "values(map_values)" : "map_values") | |
| 140 | 140 | .hasKind(COMPOSITES) |
| 141 | 141 | .asCqlQuery(createValuesIndex); |
| 142 | 142 | assertThat((TableMetadata) column.getParent()).hasIndex(index); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | @Test(groups = "short") |
| 146 | - @CassandraVersion(major = 2.1) | |
| 146 | + @CassandraVersion("2.1.0") | |
| 147 | 147 | public void should_create_metadata_for_index_on_map_keys() { |
| 148 | 148 | String createKeysIndex = String.format("CREATE INDEX map_keys_index ON %s.indexing (keys(map_keys));", keyspace); |
| 149 | 149 | session().execute(createKeysIndex); |
| @@ -160,7 +160,7 @@ | ||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | @Test(groups = "short") |
| 163 | - @CassandraVersion(major = 2.1, minor = 3) | |
| 163 | + @CassandraVersion("2.1.3") | |
| 164 | 164 | public void should_create_metadata_for_full_index_on_map() { |
| 165 | 165 | String createFullIndex = String.format("CREATE INDEX map_full_index ON %s.indexing (full(map_full));", keyspace); |
| 166 | 166 | session().execute(createFullIndex); |
| @@ -177,7 +177,7 @@ | ||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | @Test(groups = "short") |
| 180 | - @CassandraVersion(major = 2.1, minor = 3) | |
| 180 | + @CassandraVersion("2.1.3") | |
| 181 | 181 | public void should_create_metadata_for_full_index_on_set() { |
| 182 | 182 | String createFullIndex = String.format("CREATE INDEX set_full_index ON %s.indexing (full(set_full));", keyspace); |
| 183 | 183 | session().execute(createFullIndex); |
| @@ -194,7 +194,7 @@ | ||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | @Test(groups = "short") |
| 197 | - @CassandraVersion(major = 2.1, minor = 3) | |
| 197 | + @CassandraVersion("2.1.3") | |
| 198 | 198 | public void should_create_metadata_for_full_index_on_list() { |
| 199 | 199 | String createFullIndex = String.format("CREATE INDEX list_full_index ON %s.indexing (full(list_full));", keyspace); |
| 200 | 200 | session().execute(createFullIndex); |
| @@ -211,7 +211,7 @@ | ||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | @Test(groups = "short") |
| 214 | - @CassandraVersion(major = 2.2) | |
| 214 | + @CassandraVersion("2.2.0") | |
| 215 | 215 | public void should_create_metadata_for_index_on_map_entries() { |
| 216 | 216 | String createEntriesIndex = String.format("CREATE INDEX map_entries_index ON %s.indexing (entries(map_entries));", keyspace); |
| 217 | 217 | session().execute(createEntriesIndex); |
| @@ -228,7 +228,7 @@ | ||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | @Test(groups = "short") |
| 231 | - @CassandraVersion(major = 3.0) | |
| 231 | + @CassandraVersion("3.0") | |
| 232 | 232 | public void should_allow_multiple_indexes_on_map_column() { |
| 233 | 233 | String createEntriesIndex = String.format("CREATE INDEX map_all_entries_index ON %s.indexing (entries(map_all));", keyspace); |
| 234 | 234 | session().execute(createEntriesIndex); |
modified driver-core/src/test/java/com/datastax/driver/core/LargeDataTest.java +2 −14
| @@ -180,11 +180,9 @@ | ||
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * Test a wide row of size 1,000,000 |
| 183 | - * | |
| 184 | - * @throws Throwable | |
| 185 | 183 | */ |
| 186 | 184 | @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.") | |
| 188 | 186 | public void wideRows() throws Throwable { |
| 189 | 187 | session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "large_data", 1)); |
| 190 | 188 | session().execute("USE large_data"); |
| @@ -194,11 +192,9 @@ | ||
| 194 | 192 | |
| 195 | 193 | /** |
| 196 | 194 | * Test a batch that writes a row of size 4,000 (just below the error threshold for 2.2). |
| 197 | - * | |
| 198 | - * @throws Throwable | |
| 199 | 195 | */ |
| 200 | 196 | @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.") | |
| 202 | 198 | public void wideBatchRows() throws Throwable { |
| 203 | 199 | session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "large_data", 1)); |
| 204 | 200 | session().execute("USE large_data"); |
| @@ -208,8 +204,6 @@ | ||
| 208 | 204 | |
| 209 | 205 | /** |
| 210 | 206 | * Test a wide row of size 1,000,000 consisting of a ByteBuffer |
| 211 | - * | |
| 212 | - * @throws Throwable | |
| 213 | 207 | */ |
| 214 | 208 | @Test(groups = "stress") |
| 215 | 209 | public void wideByteRows() throws Throwable { |
| @@ -221,8 +215,6 @@ | ||
| 221 | 215 | |
| 222 | 216 | /** |
| 223 | 217 | * Test a row with a single extra large text value |
| 224 | - * | |
| 225 | - * @throws Throwable | |
| 226 | 218 | */ |
| 227 | 219 | @Test(groups = "stress") |
| 228 | 220 | public void largeText() throws Throwable { |
| @@ -234,8 +226,6 @@ | ||
| 234 | 226 | |
| 235 | 227 | /** |
| 236 | 228 | * Creates a table with 330 columns |
| 237 | - * | |
| 238 | - * @throws Throwable | |
| 239 | 229 | */ |
| 240 | 230 | @Test(groups = "stress") |
| 241 | 231 | public void wideTable() throws Throwable { |
| @@ -255,8 +245,6 @@ | ||
| 255 | 245 | |
| 256 | 246 | /** |
| 257 | 247 | * Tests 10 random tests consisting of the other methods in this class |
| 258 | - * | |
| 259 | - * @throws Throwable | |
| 260 | 248 | */ |
| 261 | 249 | @Test(groups = "duration") |
| 262 | 250 | @CCMConfig(numberOfNodes = 3) |
modified driver-core/src/test/java/com/datastax/driver/core/MaterializedViewMetadataTest.java +1 −1
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | import static com.datastax.driver.core.ClusteringOrder.DESC; |
| 23 | 23 | import static com.datastax.driver.core.DataType.cint; |
| 24 | 24 | |
| 25 | -@CassandraVersion(major = 3) | |
| 25 | +@CassandraVersion("3.0") | |
| 26 | 26 | public class MaterializedViewMetadataTest extends CCMTestsSupport { |
| 27 | 27 | |
| 28 | 28 | /** |
modified driver-core/src/test/java/com/datastax/driver/core/PagingStateTest.java +3 −3
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | |
| 26 | 26 | import static org.assertj.core.api.Assertions.assertThat; |
| 27 | 27 | |
| 28 | -@CassandraVersion(major = 2.0) | |
| 28 | +@CassandraVersion("2.0.0") | |
| 29 | 29 | public class PagingStateTest extends CCMTestsSupport { |
| 30 | 30 | |
| 31 | 31 | private static final Logger logger = LoggerFactory.getLogger(PagingStateTest.class); |
| @@ -141,7 +141,7 @@ | ||
| 141 | 141 | * from the first query. |
| 142 | 142 | */ |
| 143 | 143 | @Test(groups = "short") |
| 144 | - @CassandraVersion(major = 2.0) | |
| 144 | + @CassandraVersion("2.0.0") | |
| 145 | 145 | public void should_be_able_to_use_state_with_bound_statement() { |
| 146 | 146 | PreparedStatement prepared = session().prepare("SELECT v from test where k=?"); |
| 147 | 147 | BoundStatement bs = prepared.bind(KEY); |
| @@ -164,7 +164,7 @@ | ||
| 164 | 164 | * @expected_result A failure is thrown when setting paging state on a different {@link BoundStatement}. |
| 165 | 165 | */ |
| 166 | 166 | @Test(groups = "short", expectedExceptions = {PagingStateException.class}) |
| 167 | - @CassandraVersion(major = 2.0) | |
| 167 | + @CassandraVersion("2.0.0") | |
| 168 | 168 | public void should_not_be_able_to_use_state_with_different_bound_statement() { |
| 169 | 169 | PreparedStatement prepared = session().prepare("SELECT v from test where k=?"); |
| 170 | 170 | BoundStatement bs0 = prepared.bind(KEY); |
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +15 −12
| @@ -48,7 +48,8 @@ | ||
| 48 | 48 | private static final String SIMPLE_TABLE = "test"; |
| 49 | 49 | private static final String SIMPLE_TABLE2 = "test2"; |
| 50 | 50 | |
| 51 | - private final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion()); | |
| 51 | + private ProtocolVersion protocolVersion; | |
| 52 | + private Collection<DataType> primitiveTypes; | |
| 52 | 53 | |
| 53 | 54 | private boolean exclude(DataType t) { |
| 54 | 55 | return t.getName() == DataType.Name.COUNTER; |
| @@ -56,6 +57,8 @@ | ||
| 56 | 57 | |
| 57 | 58 | @Override |
| 58 | 59 | public void onTestContextInitialized() { |
| 60 | + protocolVersion = ccm().getProtocolVersion(); | |
| 61 | + primitiveTypes = DataType.allPrimitiveTypes(protocolVersion); | |
| 59 | 62 | execute(createTestFixtures()); |
| 60 | 63 | } |
| 61 | 64 | |
| @@ -340,7 +343,7 @@ | ||
| 340 | 343 | toPrepare.setConsistencyLevel(ConsistencyLevel.QUORUM); |
| 341 | 344 | toPrepare.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); |
| 342 | 345 | toPrepare.setRetryPolicy(FallthroughRetryPolicy.INSTANCE); |
| 343 | - if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 346 | + if (protocolVersion.compareTo(V4) >= 0) | |
| 344 | 347 | toPrepare.setOutgoingPayload(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); |
| 345 | 348 | toPrepare.setIdempotent(true); |
| 346 | 349 | toPrepare.enableTracing(); |
| @@ -349,7 +352,7 @@ | ||
| 349 | 352 | assertThat(prepared.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM); |
| 350 | 353 | assertThat(prepared.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL); |
| 351 | 354 | assertThat(prepared.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE); |
| 352 | - if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 355 | + if (protocolVersion.compareTo(V4) >= 0) | |
| 353 | 356 | assertThat(prepared.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); |
| 354 | 357 | assertThat(prepared.isIdempotent()).isTrue(); |
| 355 | 358 | assertThat(prepared.isTracing()).isTrue(); |
| @@ -358,7 +361,7 @@ | ||
| 358 | 361 | assertThat(bs.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM); |
| 359 | 362 | assertThat(bs.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL); |
| 360 | 363 | assertThat(bs.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE); |
| 361 | - if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 364 | + if (protocolVersion.compareTo(V4) >= 0) | |
| 362 | 365 | assertThat(bs.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); |
| 363 | 366 | assertThat(bs.isIdempotent()).isTrue(); |
| 364 | 367 | assertThat(bs.isTracing()).isTrue(); |
| @@ -460,7 +463,7 @@ | ||
| 460 | 463 | Cluster cluster = register(Cluster.builder() |
| 461 | 464 | .addContactPoints(getContactPoints()) |
| 462 | 465 | .withPort(ccm().getBinaryPort()) |
| 463 | - .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3)) | |
| 466 | + .withProtocolVersion(ccm().getProtocolVersion(ProtocolVersion.V3)) | |
| 464 | 467 | .build()); |
| 465 | 468 | Session session = cluster.connect(); |
| 466 | 469 | try { |
| @@ -485,12 +488,12 @@ | ||
| 485 | 488 | * @since 2.2.0 |
| 486 | 489 | */ |
| 487 | 490 | @Test(groups = "short") |
| 488 | - @CassandraVersion(major = 2.0) | |
| 491 | + @CassandraVersion("2.0.0") | |
| 489 | 492 | public void should_not_allow_unbound_value_on_batch_statement_when_protocol_lesser_than_v4() { |
| 490 | 493 | Cluster cluster = register(Cluster.builder() |
| 491 | 494 | .addContactPoints(getContactPoints()) |
| 492 | 495 | .withPort(ccm().getBinaryPort()) |
| 493 | - .withProtocolVersion(TestUtils.getDesiredProtocolVersion(ProtocolVersion.V3)) | |
| 496 | + .withProtocolVersion(ccm().getProtocolVersion(ProtocolVersion.V3)) | |
| 494 | 497 | .build()); |
| 495 | 498 | Session session = cluster.connect(); |
| 496 | 499 | try { |
| @@ -515,7 +518,7 @@ | ||
| 515 | 518 | * @since 2.2.0 |
| 516 | 519 | */ |
| 517 | 520 | @Test(groups = "short") |
| 518 | - @CassandraVersion(major = 2.2) | |
| 521 | + @CassandraVersion("2.2.0") | |
| 519 | 522 | public void should_not_create_tombstone_when_unbound_value_on_bound_statement_and_protocol_v4() { |
| 520 | 523 | PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); |
| 521 | 524 | BoundStatement st1 = prepared.bind(); |
| @@ -545,7 +548,7 @@ | ||
| 545 | 548 | * @since 2.2.0 |
| 546 | 549 | */ |
| 547 | 550 | @Test(groups = "short") |
| 548 | - @CassandraVersion(major = 2.2) | |
| 551 | + @CassandraVersion("2.2.0") | |
| 549 | 552 | public void should_unset_value_by_index() { |
| 550 | 553 | PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); |
| 551 | 554 | BoundStatement bound = prepared.bind(); |
| @@ -576,7 +579,7 @@ | ||
| 576 | 579 | * @since 2.2.0 |
| 577 | 580 | */ |
| 578 | 581 | @Test(groups = "short") |
| 579 | - @CassandraVersion(major = 2.2) | |
| 582 | + @CassandraVersion("2.2.0") | |
| 580 | 583 | public void should_unset_value_by_name() { |
| 581 | 584 | PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (:k, :i)"); |
| 582 | 585 | BoundStatement bound = prepared.bind(); |
| @@ -608,7 +611,7 @@ | ||
| 608 | 611 | * @since 2.2.0 |
| 609 | 612 | */ |
| 610 | 613 | @Test(groups = "short") |
| 611 | - @CassandraVersion(major = 2.2) | |
| 614 | + @CassandraVersion("2.2.0") | |
| 612 | 615 | public void should_not_create_tombstone_when_unbound_value_on_batch_statement_and_protocol_v4() { |
| 613 | 616 | PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); |
| 614 | 617 | BoundStatement st1 = prepared.bind(); |
| @@ -661,7 +664,7 @@ | ||
| 661 | 664 | * @since 2.2.0 |
| 662 | 665 | */ |
| 663 | 666 | @Test(groups = "short") |
| 664 | - @CassandraVersion(major = 2.0) | |
| 667 | + @CassandraVersion("2.0.0") | |
| 665 | 668 | public void should_create_tombstone_when_null_value_on_batch_statement() { |
| 666 | 669 | PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); |
| 667 | 670 | BoundStatement st1 = prepared.bind(); |
modified driver-core/src/test/java/com/datastax/driver/core/PrimitiveTypeSamples.java +2 −4
| @@ -36,11 +36,9 @@ | ||
| 36 | 36 | */ |
| 37 | 37 | public class PrimitiveTypeSamples { |
| 38 | 38 | |
| 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) { | |
| 42 | 40 | try { |
| 43 | - final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(TestUtils.getDesiredProtocolVersion()); | |
| 41 | + final Collection<DataType> primitiveTypes = DataType.allPrimitiveTypes(protocolVersion); | |
| 44 | 42 | ImmutableMap<DataType, Object> data = ImmutableMap.<DataType, Object>builder() |
| 45 | 43 | .put(DataType.ascii(), "ascii") |
| 46 | 44 | .put(DataType.bigint(), Long.MAX_VALUE) |
modified driver-core/src/test/java/com/datastax/driver/core/QueryLoggerTest.java +66 −62
| @@ -49,41 +49,9 @@ | ||
| 49 | 49 | */ |
| 50 | 50 | public class QueryLoggerTest extends CCMTestsSupport { |
| 51 | 51 | |
| 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; | |
| 87 | 55 | |
| 88 | 56 | private Logger normal = Logger.getLogger(NORMAL_LOGGER.getName()); |
| 89 | 57 | private Logger slow = Logger.getLogger(SLOW_LOGGER.getName()); |
| @@ -98,6 +66,47 @@ | ||
| 98 | 66 | private Level originalSlow; |
| 99 | 67 | private Level originalError; |
| 100 | 68 | |
| 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 | + | |
| 101 | 110 | @BeforeMethod(groups = {"short", "unit"}) |
| 102 | 111 | public void startCapturingLogs() { |
| 103 | 112 | originalNormal = normal.getLevel(); |
| @@ -171,7 +180,7 @@ | ||
| 171 | 180 | } |
| 172 | 181 | |
| 173 | 182 | @Test(groups = "short") |
| 174 | - @CassandraVersion(major = 2.0) | |
| 183 | + @CassandraVersion("2.0.0") | |
| 175 | 184 | public void should_log_batch_statements() throws Exception { |
| 176 | 185 | // given |
| 177 | 186 | normal.setLevel(DEBUG); |
| @@ -202,7 +211,7 @@ | ||
| 202 | 211 | } |
| 203 | 212 | |
| 204 | 213 | @Test(groups = "short") |
| 205 | - @CassandraVersion(major = 2.0) | |
| 214 | + @CassandraVersion("2.0.0") | |
| 206 | 215 | public void should_log_unlogged_batch_statements() throws Exception { |
| 207 | 216 | // given |
| 208 | 217 | normal.setLevel(DEBUG); |
| @@ -233,7 +242,7 @@ | ||
| 233 | 242 | } |
| 234 | 243 | |
| 235 | 244 | @Test(groups = "short") |
| 236 | - @CassandraVersion(major = 2.0) | |
| 245 | + @CassandraVersion("2.0.0") | |
| 237 | 246 | public void should_log_counter_batch_statements() throws Exception { |
| 238 | 247 | // Create a special table for testing with counters. |
| 239 | 248 | session().execute( |
| @@ -376,7 +385,7 @@ | ||
| 376 | 385 | // Tests with query parameters (log level TRACE) |
| 377 | 386 | |
| 378 | 387 | @Test(groups = "short") |
| 379 | - @CassandraVersion(major = 2.0) | |
| 388 | + @CassandraVersion("2.0.0") | |
| 380 | 389 | public void should_log_non_null_named_parameter_bound_statements() throws Exception { |
| 381 | 390 | // given |
| 382 | 391 | normal.setLevel(TRACE); |
| @@ -426,7 +435,7 @@ | ||
| 426 | 435 | } |
| 427 | 436 | |
| 428 | 437 | @Test(groups = "short") |
| 429 | - @CassandraVersion(major = 2.0) | |
| 438 | + @CassandraVersion("2.0.0") | |
| 430 | 439 | public void should_log_non_null_positional_parameter_simple_statements() throws Exception { |
| 431 | 440 | // given |
| 432 | 441 | normal.setLevel(TRACE); |
| @@ -470,7 +479,7 @@ | ||
| 470 | 479 | } |
| 471 | 480 | |
| 472 | 481 | @Test(groups = "short") |
| 473 | - @CassandraVersion(major = 2.0) | |
| 482 | + @CassandraVersion("2.0.0") | |
| 474 | 483 | public void should_log_null_parameter_simple_statements() throws Exception { |
| 475 | 484 | // given |
| 476 | 485 | normal.setLevel(TRACE); |
| @@ -491,7 +500,7 @@ | ||
| 491 | 500 | } |
| 492 | 501 | |
| 493 | 502 | @Test(groups = "short") |
| 494 | - @CassandraVersion(major = 3.0) | |
| 503 | + @CassandraVersion("3.0") | |
| 495 | 504 | public void should_log_unset_parameter() throws Exception { |
| 496 | 505 | // given |
| 497 | 506 | normal.setLevel(TRACE); |
| @@ -514,7 +523,7 @@ | ||
| 514 | 523 | } |
| 515 | 524 | |
| 516 | 525 | @Test(groups = "short") |
| 517 | - @CassandraVersion(major = 2.0) | |
| 526 | + @CassandraVersion("2.0.0") | |
| 518 | 527 | public void should_log_bound_statement_parameters_inside_batch_statement() throws Exception { |
| 519 | 528 | // given |
| 520 | 529 | normal.setLevel(TRACE); |
| @@ -541,7 +550,7 @@ | ||
| 541 | 550 | } |
| 542 | 551 | |
| 543 | 552 | @Test(groups = "short") |
| 544 | - @CassandraVersion(major = 2.0) | |
| 553 | + @CassandraVersion("2.0.0") | |
| 545 | 554 | public void should_log_simple_statement_parameters_inside_batch_statement() throws Exception { |
| 546 | 555 | // given |
| 547 | 556 | normal.setLevel(TRACE); |
| @@ -596,7 +605,7 @@ | ||
| 596 | 605 | } |
| 597 | 606 | |
| 598 | 607 | @Test(groups = "short") |
| 599 | - @CassandraVersion(major = 2.0) | |
| 608 | + @CassandraVersion("2.0.0") | |
| 600 | 609 | public void should_log_all_parameter_types_simple_statements() throws Exception { |
| 601 | 610 | // given |
| 602 | 611 | normal.setLevel(TRACE); |
| @@ -648,7 +657,7 @@ | ||
| 648 | 657 | .doesNotContain(query); |
| 649 | 658 | } |
| 650 | 659 | |
| 651 | - @CassandraVersion(major = 2.0) | |
| 660 | + @CassandraVersion("2.0.0") | |
| 652 | 661 | @Test(groups = "short") |
| 653 | 662 | public void should_show_total_statements_for_batches_even_if_query_truncated() throws Exception { |
| 654 | 663 | // given |
| @@ -695,7 +704,7 @@ | ||
| 695 | 704 | .doesNotContain(TRUNCATED_OUTPUT); |
| 696 | 705 | } |
| 697 | 706 | |
| 698 | - @CassandraVersion(major = 2.0) | |
| 707 | + @CassandraVersion("2.0.0") | |
| 699 | 708 | @Test(groups = "short") |
| 700 | 709 | public void should_truncate_parameter_when_max_length_exceeded_bound_statements() throws Exception { |
| 701 | 710 | // given |
| @@ -720,7 +729,7 @@ | ||
| 720 | 729 | .doesNotContain("123456"); |
| 721 | 730 | } |
| 722 | 731 | |
| 723 | - @CassandraVersion(major = 2.0) | |
| 732 | + @CassandraVersion("2.0.0") | |
| 724 | 733 | @Test(groups = "short") |
| 725 | 734 | public void should_truncate_parameter_when_max_length_exceeded_simple_statements() throws Exception { |
| 726 | 735 | // given |
| @@ -767,7 +776,7 @@ | ||
| 767 | 776 | } |
| 768 | 777 | |
| 769 | 778 | @Test(groups = "short") |
| 770 | - @CassandraVersion(major = 2.0) | |
| 779 | + @CassandraVersion("2.0.0") | |
| 771 | 780 | public void should_truncate_blob_parameter_when_max_length_exceeded_simple_statements() throws Exception { |
| 772 | 781 | // given |
| 773 | 782 | normal.setLevel(TRACE); |
| @@ -813,7 +822,7 @@ | ||
| 813 | 822 | } |
| 814 | 823 | |
| 815 | 824 | @Test(groups = "short") |
| 816 | - @CassandraVersion(major = 2.0) | |
| 825 | + @CassandraVersion("2.0.0") | |
| 817 | 826 | public void should_not_truncate_parameter_when_max_length_unlimited_simple_statements() throws Exception { |
| 818 | 827 | // given |
| 819 | 828 | normal.setLevel(TRACE); |
| @@ -860,7 +869,7 @@ | ||
| 860 | 869 | } |
| 861 | 870 | |
| 862 | 871 | @Test(groups = "short") |
| 863 | - @CassandraVersion(major = 2.0) | |
| 872 | + @CassandraVersion("2.0.0") | |
| 864 | 873 | public void should_not_log_exceeding_number_of_parameters_simple_statements() throws Exception { |
| 865 | 874 | // given |
| 866 | 875 | normal.setLevel(TRACE); |
| @@ -883,7 +892,7 @@ | ||
| 883 | 892 | } |
| 884 | 893 | |
| 885 | 894 | @Test(groups = "short") |
| 886 | - @CassandraVersion(major = 2.1) | |
| 895 | + @CassandraVersion("2.1.0") | |
| 887 | 896 | public void should_not_log_exceeding_number_of_parameters_simple_statements_with_named_values() throws Exception { |
| 888 | 897 | // given |
| 889 | 898 | normal.setLevel(TRACE); |
| @@ -909,7 +918,7 @@ | ||
| 909 | 918 | } |
| 910 | 919 | |
| 911 | 920 | @Test(groups = "short") |
| 912 | - @CassandraVersion(major = 2.0) | |
| 921 | + @CassandraVersion("2.0.0") | |
| 913 | 922 | public void should_not_log_exceeding_number_of_parameters_in_batch_statement_bound_statements() throws Exception { |
| 914 | 923 | // given |
| 915 | 924 | normal.setLevel(TRACE); |
| @@ -939,7 +948,7 @@ | ||
| 939 | 948 | } |
| 940 | 949 | |
| 941 | 950 | @Test(groups = "short") |
| 942 | - @CassandraVersion(major = 2.0) | |
| 951 | + @CassandraVersion("2.0.0") | |
| 943 | 952 | public void should_not_log_exceeding_number_of_parameters_in_batch_statement_simple_statements() throws Exception { |
| 944 | 953 | // given |
| 945 | 954 | normal.setLevel(TRACE); |
| @@ -991,7 +1000,7 @@ | ||
| 991 | 1000 | } |
| 992 | 1001 | |
| 993 | 1002 | @Test(groups = "short") |
| 994 | - @CassandraVersion(major = 2.0) | |
| 1003 | + @CassandraVersion("2.0.0") | |
| 995 | 1004 | public void should_log_all_parameters_when_max_unlimited_simple_statements() throws Exception { |
| 996 | 1005 | // given |
| 997 | 1006 | normal.setLevel(TRACE); |
| @@ -1013,7 +1022,7 @@ | ||
| 1013 | 1022 | } |
| 1014 | 1023 | |
| 1015 | 1024 | @Test(groups = "short") |
| 1016 | - @CassandraVersion(major = 2.1) | |
| 1025 | + @CassandraVersion("2.1.0") | |
| 1017 | 1026 | public void should_log_all_parameters_when_max_unlimited_simple_statements_with_named_values() throws Exception { |
| 1018 | 1027 | // given |
| 1019 | 1028 | normal.setLevel(TRACE); |
| @@ -1037,7 +1046,7 @@ | ||
| 1037 | 1046 | .contains("42"); |
| 1038 | 1047 | } |
| 1039 | 1048 | |
| 1040 | - @CassandraVersion(major = 2.0) | |
| 1049 | + @CassandraVersion("2.0.0") | |
| 1041 | 1050 | @Test(groups = "short") |
| 1042 | 1051 | public void should_log_wrapped_bound_statement() throws Exception { |
| 1043 | 1052 | // given |
| @@ -1064,9 +1073,4 @@ | ||
| 1064 | 1073 | .contains("param1:'foo'"); |
| 1065 | 1074 | } |
| 1066 | 1075 | |
| 1067 | - @Override | |
| 1068 | - public void onTestContextInitialized() { | |
| 1069 | - execute("CREATE TABLE test (pk int PRIMARY KEY, " + definitions + ")"); | |
| 1070 | - } | |
| 1071 | - | |
| 1072 | 1076 | } |
modified driver-core/src/test/java/com/datastax/driver/core/QueryTimestampTest.java +1 −1
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | /** |
| 28 | 28 | * Tests the behavior of client-provided timestamps with protocol v3. |
| 29 | 29 | */ |
| 30 | -@CassandraVersion(major = 2.1) | |
| 30 | +@CassandraVersion("2.1.0") | |
| 31 | 31 | public class QueryTimestampTest extends CCMTestsSupport { |
| 32 | 32 | |
| 33 | 33 | private volatile long timestampFromGenerator; |
modified driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java +2 −3
| @@ -145,7 +145,7 @@ | ||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | @Test(groups = "long") |
| 148 | - @CassandraVersion(major = 2.0) | |
| 148 | + @CassandraVersion("2.0.0") | |
| 149 | 149 | public void should_ignore_node_that_does_not_support_protocol_version_on_session_init() throws Exception { |
| 150 | 150 | // Simulate the bug before starting the cluster |
| 151 | 151 | mainCcmBuilder = CCMBridge.builder().withNodes(2); |
| @@ -157,8 +157,7 @@ | ||
| 157 | 157 | .withStoragePort(mainCcm.getStoragePort()) |
| 158 | 158 | .withThriftPort(mainCcm.getThriftPort()) |
| 159 | 159 | .withBinaryPort(mainCcm.getBinaryPort()) |
| 160 | - .withoutDSE() | |
| 161 | - .withVersion("1.2.19"); | |
| 160 | + .withVersion(VersionNumber.parse("1.2.19")); | |
| 162 | 161 | otherCcm = CCMCache.get(otherCcmBuilder); |
| 163 | 162 | otherCcm.waitForUp(1); |
| 164 | 163 |
modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +2 −2
| @@ -83,7 +83,7 @@ | ||
| 83 | 83 | public void should_keep_reconnecting_on_authentication_error() throws InterruptedException { |
| 84 | 84 | // For C* 1.2, sleep before attempting to connect as there is a small delay between |
| 85 | 85 | // user being created. |
| 86 | - if (ccm().getVersion().getMajor() < 2) { | |
| 86 | + if (ccm().getCassandraVersion().getMajor() < 2) { | |
| 87 | 87 | Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); |
| 88 | 88 | } |
| 89 | 89 | CountingReconnectionPolicy reconnectionPolicy = new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)); |
| @@ -223,7 +223,7 @@ | ||
| 223 | 223 | .withReconnectionPolicy(new ConstantReconnectionPolicy(5000)) |
| 224 | 224 | .withLoadBalancingPolicy(loadBalancingPolicy) |
| 225 | 225 | .withSocketOptions(socketOptions) |
| 226 | - .withProtocolVersion(TestUtils.getDesiredProtocolVersion()) | |
| 226 | + .withProtocolVersion(ccm().getProtocolVersion()) | |
| 227 | 227 | .build()); |
| 228 | 228 | // Create two sessions to have multiple pools |
| 229 | 229 | cluster.connect(); |
modified driver-core/src/test/java/com/datastax/driver/core/SchemaChangesTest.java +12 −12
| @@ -209,7 +209,7 @@ | ||
| 209 | 209 | |
| 210 | 210 | @SuppressWarnings("RedundantCast") |
| 211 | 211 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 212 | - @CassandraVersion(major = 2.1) | |
| 212 | + @CassandraVersion("2.1.0") | |
| 213 | 213 | public void should_notify_of_udt_creation(String keyspace) { |
| 214 | 214 | session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace)); |
| 215 | 215 | for (SchemaChangeListener listener : listeners) { |
| @@ -223,7 +223,7 @@ | ||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 226 | - @CassandraVersion(major = 2.1) | |
| 226 | + @CassandraVersion("2.1.0") | |
| 227 | 227 | public void should_notify_of_udt_update(String keyspace) { |
| 228 | 228 | session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace)); |
| 229 | 229 | session1.execute(String.format("ALTER TYPE %s.type1 ADD j int", keyspace)); |
| @@ -240,7 +240,7 @@ | ||
| 240 | 240 | |
| 241 | 241 | @SuppressWarnings("RedundantCast") |
| 242 | 242 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 243 | - @CassandraVersion(major = 2.1) | |
| 243 | + @CassandraVersion("2.1.0") | |
| 244 | 244 | public void should_notify_of_udt_drop(String keyspace) { |
| 245 | 245 | session1.execute(String.format("CREATE TYPE %s.type1(i int)", keyspace)); |
| 246 | 246 | session1.execute(String.format("DROP TYPE %s.type1", keyspace)); |
| @@ -254,7 +254,7 @@ | ||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 257 | - @CassandraVersion(major = 2.2) | |
| 257 | + @CassandraVersion("2.2.0") | |
| 258 | 258 | public void should_notify_of_function_creation(String keyspace) { |
| 259 | 259 | session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); |
| 260 | 260 | for (SchemaChangeListener listener : listeners) { |
| @@ -270,7 +270,7 @@ | ||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 273 | - @CassandraVersion(major = 2.2) | |
| 273 | + @CassandraVersion("2.2.0") | |
| 274 | 274 | public void should_notify_of_function_update(String keyspace) { |
| 275 | 275 | session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); |
| 276 | 276 | for (SchemaChangeListener listener : listeners) { |
| @@ -297,7 +297,7 @@ | ||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 300 | - @CassandraVersion(major = 2.2) | |
| 300 | + @CassandraVersion("2.2.0") | |
| 301 | 301 | public void should_notify_of_function_drop(String keyspace) { |
| 302 | 302 | session1.execute(String.format("CREATE FUNCTION %s.\"ID\"(i int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java AS 'return i;'", keyspace)); |
| 303 | 303 | session1.execute(String.format("DROP FUNCTION %s.\"ID\"", keyspace)); |
| @@ -314,7 +314,7 @@ | ||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 317 | - @CassandraVersion(major = 2.2) | |
| 317 | + @CassandraVersion("2.2.0") | |
| 318 | 318 | public void should_notify_of_aggregate_creation(String keyspace) { |
| 319 | 319 | session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" |
| 320 | 320 | + " AS 'return s+v;'", keyspace)); |
| @@ -332,7 +332,7 @@ | ||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 335 | - @CassandraVersion(major = 2.2) | |
| 335 | + @CassandraVersion("2.2.0") | |
| 336 | 336 | public void should_notify_of_aggregate_update(String keyspace) { |
| 337 | 337 | session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" |
| 338 | 338 | + " AS 'return s+v;'", keyspace)); |
| @@ -361,7 +361,7 @@ | ||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 364 | - @CassandraVersion(major = 2.2) | |
| 364 | + @CassandraVersion("2.2.0") | |
| 365 | 365 | public void should_notify_of_aggregate_drop(String keyspace) { |
| 366 | 366 | session1.execute(String.format("CREATE FUNCTION %s.\"PLUS\"(s int, v int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE java" |
| 367 | 367 | + " AS 'return s+v;'", keyspace)); |
| @@ -380,7 +380,7 @@ | ||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 383 | - @CassandraVersion(major = 3.0) | |
| 383 | + @CassandraVersion("3.0") | |
| 384 | 384 | public void should_notify_of_view_creation(String keyspace) { |
| 385 | 385 | session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); |
| 386 | 386 | 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 @@ | ||
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 398 | - @CassandraVersion(major = 3.0) | |
| 398 | + @CassandraVersion("3.0") | |
| 399 | 399 | public void should_notify_of_view_update(String keyspace) { |
| 400 | 400 | session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); |
| 401 | 401 | 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 @@ | ||
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | @Test(groups = "short", dataProvider = "existingKeyspaceName") |
| 427 | - @CassandraVersion(major = 3.0) | |
| 427 | + @CassandraVersion("3.0") | |
| 428 | 428 | public void should_notify_of_view_drop(String keyspace) { |
| 429 | 429 | session1.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); |
| 430 | 430 | 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 @@ | ||
| 189 | 189 | */ |
| 190 | 190 | @Test(groups = "short") |
| 191 | 191 | 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) | |
| 193 | 193 | throw new SkipException("Disabled in Cassandra 2.2+ because of CASSANDRA-9996"); |
| 194 | 194 | |
| 195 | 195 | String keyspace = TestUtils.generateIdentifier("ks_"); |
modified driver-core/src/test/java/com/datastax/driver/core/SimpleStatementIntegrationTest.java +7 −7
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | @Test(groups = "short") |
| 38 | - @CassandraVersion(major = 2.1) | |
| 38 | + @CassandraVersion("2.1.0") | |
| 39 | 39 | public void should_execute_query_with_named_values() { |
| 40 | 40 | // Given |
| 41 | 41 | SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2", |
| @@ -50,7 +50,7 @@ | ||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | @Test(groups = "short", expectedExceptions = InvalidQueryException.class) |
| 53 | - @CassandraVersion(major = 2.1) | |
| 53 | + @CassandraVersion("2.1.0") | |
| 54 | 54 | public void should_fail_if_query_with_named_values_but_missing_parameter() { |
| 55 | 55 | // Given a Statement missing named parameters. |
| 56 | 56 | SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2", |
| @@ -64,7 +64,7 @@ | ||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | @Test(groups = "short", expectedExceptions = InvalidQueryException.class) |
| 67 | - @CassandraVersion(major = 2.1) | |
| 67 | + @CassandraVersion("2.1.0") | |
| 68 | 68 | public void should_fail_if_query_with_named_values_but_using_wrong_type() { |
| 69 | 69 | // Given a Statement using a named parameter with the wrong value for the type (id is of type int, using double) |
| 70 | 70 | SimpleStatement statement = new SimpleStatement("SELECT * FROM users WHERE id = :id and id2 = :id2", |
| @@ -98,18 +98,18 @@ | ||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | @Test(groups = "short", expectedExceptions = UnsupportedFeatureException.class) |
| 101 | - @CassandraVersion(major = 2.0) | |
| 101 | + @CassandraVersion("2.0.0") | |
| 102 | 102 | 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) { | |
| 104 | 104 | throw new SkipException("Skipping since Cassandra 3.0+ does not support protocol v2"); |
| 105 | 105 | } |
| 106 | 106 | useNamedValuesWithProtocol(ProtocolVersion.V2); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | @Test(groups = "short", expectedExceptions = UnsupportedFeatureException.class) |
| 110 | - @CassandraVersion(major = 2.0) | |
| 110 | + @CassandraVersion("2.0.0") | |
| 111 | 111 | 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) { | |
| 113 | 113 | throw new SkipException("Skipping since Cassandra 3.0+ does not support protocol v1"); |
| 114 | 114 | } |
| 115 | 115 | useNamedValuesWithProtocol(ProtocolVersion.V1); |
modified driver-core/src/test/java/com/datastax/driver/core/SingleConnectionPoolTest.java +1 −1
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | |
| 26 | 26 | import static org.testng.Assert.fail; |
| 27 | 27 | |
| 28 | -@CassandraVersion(major = 2.1) | |
| 28 | +@CassandraVersion("2.1.0") | |
| 29 | 29 | public class SingleConnectionPoolTest extends CCMTestsSupport { |
| 30 | 30 | |
| 31 | 31 | @Test(groups = "short") |
modified driver-core/src/test/java/com/datastax/driver/core/StatementIdempotenceTest.java +1 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | when(cluster.getConfiguration()).thenReturn(configuration); |
| 42 | 42 | when(configuration.getCodecRegistry()).thenReturn(codecRegistry); |
| 43 | 43 | when(configuration.getProtocolOptions()).thenReturn(protocolOptions); |
| 44 | - when(protocolOptions.getProtocolVersion()).thenReturn(TestUtils.getDesiredProtocolVersion()); | |
| 44 | + when(protocolOptions.getProtocolVersion()).thenReturn(ProtocolVersion.NEWEST_SUPPORTED); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | @Test(groups = "unit") |
modified driver-core/src/test/java/com/datastax/driver/core/StatementWrapperTest.java +3 −3
| @@ -87,7 +87,7 @@ | ||
| 87 | 87 | assertThat(retryPolicy.customStatementsHandled.get()).isEqualTo(1); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - @CassandraVersion(major = 2.0) | |
| 90 | + @CassandraVersion("2.0.0") | |
| 91 | 91 | @Test(groups = "short") |
| 92 | 92 | public void should_execute_wrapped_simple_statement() { |
| 93 | 93 | session().execute(new CustomStatement(new SimpleStatement(INSERT_QUERY, "key_simple", 1))); |
| @@ -106,7 +106,7 @@ | ||
| 106 | 106 | assertThat(rs.one().getInt("v")).isEqualTo(1); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - @CassandraVersion(major = 2.0) | |
| 109 | + @CassandraVersion("2.0.0") | |
| 110 | 110 | @Test(groups = "short") |
| 111 | 111 | public void should_execute_wrapped_batch_statement() { |
| 112 | 112 | BatchStatement batchStatement = new BatchStatement(); |
| @@ -118,7 +118,7 @@ | ||
| 118 | 118 | assertThat(rs.one().getInt("v")).isEqualTo(1); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - @CassandraVersion(major = 2.0) | |
| 121 | + @CassandraVersion("2.0.0") | |
| 122 | 122 | @Test(groups = "short") |
| 123 | 123 | public void should_add_wrapped_batch_statement_to_batch_statement() { |
| 124 | 124 | BatchStatement batchStatementForWrapping = new BatchStatement(); |
modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +2 −2
| @@ -407,7 +407,7 @@ | ||
| 407 | 407 | * @jira_ticket CASSANDRA-9424 |
| 408 | 408 | */ |
| 409 | 409 | @Test(groups = "short") |
| 410 | - @CassandraVersion(major = 3.0) | |
| 410 | + @CassandraVersion("3.0") | |
| 411 | 411 | public void should_parse_new_compression_options() { |
| 412 | 412 | // given |
| 413 | 413 | String cql = String.format("CREATE TABLE %s.new_compression_options (\n" |
| @@ -475,7 +475,7 @@ | ||
| 475 | 475 | * @test_category metadata |
| 476 | 476 | */ |
| 477 | 477 | @Test(groups = "short") |
| 478 | - @CassandraVersion(major = 3.0) | |
| 478 | + @CassandraVersion("3.0") | |
| 479 | 479 | public void should_parse_extensions_from_table_options() throws Exception { |
| 480 | 480 | // given |
| 481 | 481 | // 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 @@ | ||
| 20 | 20 | import org.testng.*; |
| 21 | 21 | import org.testng.internal.ConstructorOrMethod; |
| 22 | 22 | |
| 23 | +import java.lang.reflect.AnnotatedElement; | |
| 23 | 24 | import java.lang.reflect.Method; |
| 24 | 25 | import java.util.concurrent.TimeUnit; |
| 25 | 26 | |
| @@ -87,27 +88,29 @@ | ||
| 87 | 88 | |
| 88 | 89 | Class<?> clazz = testNgMethod.getInstance().getClass(); |
| 89 | 90 | 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)); | |
| 98 | 95 | } |
| 99 | - | |
| 100 | 96 | Method method = constructorOrMethod.getMethod(); |
| 101 | 97 | 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; | |
| 110 | 112 | } |
| 113 | + return false; | |
| 111 | 114 | } |
| 112 | 115 | |
| 113 | 116 | @Override |
| @@ -116,29 +119,26 @@ | ||
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | 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()); | |
| 120 | 123 | } |
| 121 | 124 | |
| 122 | 125 | 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()); | |
| 125 | 129 | } else { |
| 126 | 130 | throw new SkipException("Skipping test because not configured for DataStax Enterprise cluster."); |
| 127 | 131 | } |
| 128 | 132 | } |
| 129 | 133 | |
| 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) { | |
| 132 | 136 | throw new SkipException("Skipping test because provided version is null"); |
| 133 | 137 | } 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)); | |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +2 −29
| @@ -735,33 +735,6 @@ | ||
| 735 | 735 | return connectionSuccessful; |
| 736 | 736 | } |
| 737 | 737 | |
| 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 | - | |
| 765 | 738 | /** |
| 766 | 739 | * @return a {@link Cluster} instance that connects only to the control host of the given cluster. |
| 767 | 740 | */ |
| @@ -838,7 +811,7 @@ | ||
| 838 | 811 | |
| 839 | 812 | /** |
| 840 | 813 | * Helper for generating a DynamicCompositeType {@link ByteBuffer} from the given parameters. |
| 841 | - * | |
| 814 | + * <p/> | |
| 842 | 815 | * Any of params given as an Integer will be considered with a field name of 'i', any as String will |
| 843 | 816 | * be considered with a field name of 's'. |
| 844 | 817 | * |
| @@ -881,7 +854,7 @@ | ||
| 881 | 854 | |
| 882 | 855 | /** |
| 883 | 856 | * Helper for generating a Composite {@link ByteBuffer} from the given parameters. |
| 884 | - * | |
| 857 | + * <p/> | |
| 885 | 858 | * Expects Integer and String types for parameters. |
| 886 | 859 | * |
| 887 | 860 | * @param params params to serialize. |
modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +1 −1
| @@ -191,7 +191,7 @@ | ||
| 191 | 191 | * </ol> |
| 192 | 192 | */ |
| 193 | 193 | @Test(groups = "short") |
| 194 | - @CassandraVersion(major = 2) | |
| 194 | + @CassandraVersion("2.0") | |
| 195 | 195 | public void should_get_token_from_row_and_set_token_in_query_with_binding_and_aliasing() { |
| 196 | 196 | Row row = session().execute("SELECT token(i) AS t FROM foo WHERE i = 1").one(); |
| 197 | 197 | Token token = row.getToken("t"); |
modified driver-core/src/test/java/com/datastax/driver/core/TracingTest.java +1 −1
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | |
| 27 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 28 | 28 | |
| 29 | -@CassandraVersion(major = 2.0) | |
| 29 | +@CassandraVersion("2.0.0") | |
| 30 | 30 | public class TracingTest extends CCMTestsSupport { |
| 31 | 31 | |
| 32 | 32 | 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 @@ | ||
| 27 | 27 | import static org.testng.Assert.assertEquals; |
| 28 | 28 | import static org.testng.Assert.fail; |
| 29 | 29 | |
| 30 | -@CassandraVersion(major = 2.1) | |
| 30 | +@CassandraVersion("2.1.0") | |
| 31 | 31 | public class TupleTest extends CCMTestsSupport { |
| 32 | 32 | |
| 33 | - ProtocolVersion protocolVersion = TestUtils.getDesiredProtocolVersion(); | |
| 33 | + private ProtocolVersion protocolVersion; | |
| 34 | + private Map<DataType, Object> samples; | |
| 34 | 35 | |
| 35 | 36 | @Override |
| 36 | 37 | public void onTestContextInitialized() { |
| 38 | + protocolVersion = ccm().getProtocolVersion(); | |
| 39 | + samples = PrimitiveTypeSamples.samples(protocolVersion); | |
| 37 | 40 | execute("CREATE TABLE t (k int PRIMARY KEY, v frozen<tuple<int, text, float>>)"); |
| 38 | 41 | } |
| 39 | 42 | |
| @@ -202,8 +205,7 @@ | ||
| 202 | 205 | */ |
| 203 | 206 | @Test(groups = "short") |
| 204 | 207 | 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()); | |
| 207 | 209 | session().execute("CREATE KEYSPACE test_tuple_subtypes " + |
| 208 | 210 | "WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}"); |
| 209 | 211 | session().execute("USE test_tuple_subtypes"); |
| @@ -226,8 +228,8 @@ | ||
| 226 | 228 | for (int j = 0; j < i; ++j) { |
| 227 | 229 | dataTypes.add(DATA_TYPE_PRIMITIVES.get(j)); |
| 228 | 230 | 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))); | |
| 231 | 233 | } |
| 232 | 234 | |
| 233 | 235 | // complete portion of the arrays needed for trailing nulls |
| @@ -261,8 +263,7 @@ | ||
| 261 | 263 | */ |
| 262 | 264 | @Test(groups = "short") |
| 263 | 265 | 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()); | |
| 266 | 267 | session().execute("CREATE KEYSPACE test_tuple_non_primitive_subtypes " + |
| 267 | 268 | "WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}"); |
| 268 | 269 | session().execute("USE test_tuple_non_primitive_subtypes"); |
| @@ -296,7 +297,7 @@ | ||
| 296 | 297 | ArrayList<Object> createdValues = new ArrayList<Object>(); |
| 297 | 298 | |
| 298 | 299 | dataTypes.add(DataType.list(datatype)); |
| 299 | - createdValues.add(Collections.singletonList(PrimitiveTypeSamples.ALL.get(datatype))); | |
| 300 | + createdValues.add(Collections.singletonList(samples.get(datatype))); | |
| 300 | 301 | |
| 301 | 302 | TupleType t = new TupleType(dataTypes, protocolVersion, cluster().getConfiguration().getCodecRegistry()); |
| 302 | 303 | TupleValue createdTuple = t.newValue(createdValues.toArray()); |
| @@ -319,7 +320,7 @@ | ||
| 319 | 320 | ArrayList<Object> createdValues = new ArrayList<Object>(); |
| 320 | 321 | |
| 321 | 322 | 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)))); | |
| 323 | 324 | |
| 324 | 325 | TupleType t = new TupleType(dataTypes, protocolVersion, cluster().getConfiguration().getCodecRegistry()); |
| 325 | 326 | TupleValue createdTuple = t.newValue(createdValues.toArray()); |
| @@ -342,7 +343,7 @@ | ||
| 342 | 343 | ArrayList<Object> createdValues = new ArrayList<Object>(); |
| 343 | 344 | |
| 344 | 345 | 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)); | |
| 346 | 347 | |
| 347 | 348 | dataTypes.add(DataType.map(datatype, datatype)); |
| 348 | 349 | createdValues.add(hm); |
| @@ -370,7 +371,7 @@ | ||
| 370 | 371 | */ |
| 371 | 372 | @Test(groups = "short") |
| 372 | 373 | public void detachedTupleTypeTest() { |
| 373 | - TupleType detachedType = TupleType.of(TestUtils.getDesiredProtocolVersion(), CodecRegistry.DEFAULT_INSTANCE, | |
| 374 | + TupleType detachedType = TupleType.of(protocolVersion, CodecRegistry.DEFAULT_INSTANCE, | |
| 374 | 375 | DataType.cint(), DataType.text(), DataType.cfloat()); |
| 375 | 376 | TupleValue detachedValue = detachedType.newValue(1, "hello", 2.0f); |
| 376 | 377 |
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecAssert.java +1 −1
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | @SuppressWarnings("unused") |
| 25 | 25 | public class TypeCodecAssert<T> extends AbstractAssert<TypeCodecAssert<T>, TypeCodec<T>> { |
| 26 | 26 | |
| 27 | - private ProtocolVersion version = TestUtils.getDesiredProtocolVersion(); | |
| 27 | + private ProtocolVersion version = ProtocolVersion.NEWEST_SUPPORTED; | |
| 28 | 28 | |
| 29 | 29 | protected TypeCodecAssert(TypeCodec<T> actual) { |
| 30 | 30 | super(actual, TypeCodecAssert.class); |
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecCollectionsIntegrationTest.java +1 −1
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | import static com.google.common.collect.Sets.newHashSet; |
| 34 | 34 | import static org.assertj.core.api.Assertions.assertThat; |
| 35 | 35 | |
| 36 | -@CassandraVersion(major = 2.0) | |
| 36 | +@CassandraVersion("2.0.0") | |
| 37 | 37 | public class TypeCodecCollectionsIntegrationTest extends CCMTestsSupport { |
| 38 | 38 | |
| 39 | 39 | 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 @@ | ||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | @Test(groups = "short") |
| 105 | - @CassandraVersion(major = 2.0) | |
| 105 | + @CassandraVersion("2.0.0") | |
| 106 | 106 | public void should_use_custom_codecs_with_simple_statements() { |
| 107 | 107 | session().execute(insertQuery, |
| 108 | 108 | n_int, |
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNestedCollectionsIntegrationTest.java +1 −1
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | * Validates that nested collections are properly encoded, |
| 36 | 36 | * even if some inner type requires a custom codec. |
| 37 | 37 | */ |
| 38 | -@CassandraVersion(major = 2.1) | |
| 38 | +@CassandraVersion("2.1.0") | |
| 39 | 39 | public class TypeCodecNestedCollectionsIntegrationTest extends CCMTestsSupport { |
| 40 | 40 | |
| 41 | 41 | 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 @@ | ||
| 28 | 28 | * |
| 29 | 29 | * @jira_ticket JAVA-847 |
| 30 | 30 | */ |
| 31 | -@CassandraVersion(major = 2.1) | |
| 31 | +@CassandraVersion("2.1.0") | |
| 32 | 32 | public class TypeCodecNestedUDTAndTupleIntegrationTest extends CCMTestsSupport { |
| 33 | 33 | |
| 34 | 34 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/TypeCodecNumbersIntegrationTest.java +1 −1
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | @Test(groups = "short") |
| 55 | - @CassandraVersion(major = 2.0) | |
| 55 | + @CassandraVersion("2.0.0") | |
| 56 | 56 | public void should_use_defaut_codecs_with_simple_statements() { |
| 57 | 57 | session().execute(insertQuery, n_int, n_bigint, n_float, n_double, n_varint, n_decimal); |
| 58 | 58 | 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 @@ | ||
| 23 | 23 | import static com.datastax.driver.core.DataType.cfloat; |
| 24 | 24 | import static org.assertj.core.api.Assertions.assertThat; |
| 25 | 25 | |
| 26 | -@CassandraVersion(major = 2.1) | |
| 26 | +@CassandraVersion("2.1.0") | |
| 27 | 27 | public class TypeCodecTupleIntegrationTest extends CCMTestsSupport { |
| 28 | 28 | |
| 29 | 29 | 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 @@ | ||
| 26 | 26 | |
| 27 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 28 | 28 | |
| 29 | -@CassandraVersion(major = 2.1) | |
| 29 | +@CassandraVersion("2.1.0") | |
| 30 | 30 | public class TypeCodecUDTIntegrationTest extends CCMTestsSupport { |
| 31 | 31 | |
| 32 | 32 | 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 @@ | ||
| 23 | 23 | import static com.datastax.driver.core.Assertions.assertThat; |
| 24 | 24 | import static com.datastax.driver.core.DataType.*; |
| 25 | 25 | |
| 26 | -@CassandraVersion(major = 3.0) | |
| 26 | +@CassandraVersion("3.0") | |
| 27 | 27 | public class UnresolvedUserTypeTest extends CCMTestsSupport { |
| 28 | 28 | |
| 29 | 29 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/UserTypesTest.java +10 −8
| @@ -36,14 +36,11 @@ | ||
| 36 | 36 | import static org.testng.Assert.assertEquals; |
| 37 | 37 | import static org.testng.Assert.assertNotEquals; |
| 38 | 38 | |
| 39 | -@CassandraVersion(major = 2.1) | |
| 39 | +@CassandraVersion("2.1.0") | |
| 40 | 40 | public class UserTypesTest extends CCMTestsSupport { |
| 41 | 41 | |
| 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; | |
| 47 | 44 | |
| 48 | 45 | private final static List<DataType.Name> DATA_TYPE_NON_PRIMITIVE_NAMES = |
| 49 | 46 | new ArrayList<DataType.Name>(EnumSet.of(DataType.Name.LIST, DataType.Name.SET, DataType.Name.MAP, DataType.Name.TUPLE)); |
| @@ -57,6 +54,10 @@ | ||
| 57 | 54 | |
| 58 | 55 | @Override |
| 59 | 56 | 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); | |
| 60 | 61 | String type1 = "CREATE TYPE phone (alias text, number text)"; |
| 61 | 62 | String type2 = "CREATE TYPE \"\"\"User Address\"\"\" (street text, \"ZIP\"\"\" int, phones set<frozen<phone>>)"; |
| 62 | 63 | String table = "CREATE TABLE user (id int PRIMARY KEY, addr frozen<\"\"\"User Address\"\"\">)"; |
| @@ -229,10 +230,11 @@ | ||
| 229 | 230 | UserType alldatatypesDef = cluster().getMetadata().getKeyspace("testPrimitiveDatatypes").getUserType("alldatatypes"); |
| 230 | 231 | UDTValue alldatatypes = alldatatypesDef.newValue(); |
| 231 | 232 | |
| 233 | + | |
| 232 | 234 | for (int i = 0; i < DATA_TYPE_PRIMITIVES.size(); i++) { |
| 233 | 235 | DataType dataType = DATA_TYPE_PRIMITIVES.get(i); |
| 234 | 236 | String index = Character.toString((char) (startIndex + i)); |
| 235 | - Object sampleData = PrimitiveTypeSamples.ALL.get(dataType); | |
| 237 | + Object sampleData = samples.get(dataType); | |
| 236 | 238 | |
| 237 | 239 | switch (dataType.getName()) { |
| 238 | 240 | case ASCII: |
| @@ -360,7 +362,7 @@ | ||
| 360 | 362 | DataType dataType = DATA_TYPE_PRIMITIVES.get(j); |
| 361 | 363 | |
| 362 | 364 | 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); | |
| 364 | 366 | switch (name) { |
| 365 | 367 | case LIST: |
| 366 | 368 | alldatatypes.setList(index, Lists.newArrayList(sampleElement)); |
modified driver-core/src/test/java/com/datastax/driver/core/WarningsTest.java +1 −1
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | import static org.assertj.core.api.Assertions.assertThat; |
| 25 | 25 | |
| 26 | 26 | @CCMConfig(config = {"batch_size_warn_threshold_in_kb:5"}) |
| 27 | -@CassandraVersion(major = 2.2) | |
| 27 | +@CassandraVersion("2.2.0") | |
| 28 | 28 | public class WarningsTest extends CCMTestsSupport { |
| 29 | 29 | |
| 30 | 30 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/FunctionExecutionExceptionTest.java +1 −1
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | import com.datastax.driver.core.utils.CassandraVersion; |
| 21 | 21 | import org.testng.annotations.Test; |
| 22 | 22 | |
| 23 | -@CassandraVersion(major = 2.2) | |
| 23 | +@CassandraVersion("2.2.0") | |
| 24 | 24 | @CCMConfig(config = "enable_user_defined_functions:true") |
| 25 | 25 | public class FunctionExecutionExceptionTest extends CCMTestsSupport { |
| 26 | 26 |
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilder21ExecutionTest.java +1 −1
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | import static com.datastax.driver.core.Assertions.assertThat; |
| 26 | 26 | import static com.datastax.driver.core.querybuilder.QueryBuilder.*; |
| 27 | 27 | |
| 28 | -@CassandraVersion(major = 2.1) | |
| 28 | +@CassandraVersion("2.1.0") | |
| 29 | 29 | public class QueryBuilder21ExecutionTest extends CCMTestsSupport { |
| 30 | 30 | |
| 31 | 31 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderExecutionTest.java +3 −3
| @@ -213,7 +213,7 @@ | ||
| 213 | 213 | * @since 3.0.1 |
| 214 | 214 | */ |
| 215 | 215 | @Test(groups = "short") |
| 216 | - @CassandraVersion(major = 3.2) | |
| 216 | + @CassandraVersion("3.2") | |
| 217 | 217 | public void should_support_cast_function_on_column() { |
| 218 | 218 | //when |
| 219 | 219 | ResultSet r = session().execute(select().cast("f", DataType.cint()).as("fint").column("i").from(TABLE2).where(eq("k", "cast_t"))); |
| @@ -256,7 +256,7 @@ | ||
| 256 | 256 | * @since 3.0.1 |
| 257 | 257 | */ |
| 258 | 258 | @Test(groups = "short") |
| 259 | - @CassandraVersion(major = 3.2) | |
| 259 | + @CassandraVersion("3.2") | |
| 260 | 260 | public void should_support_fcall_on_cast_column() { |
| 261 | 261 | //when |
| 262 | 262 | ResultSet ar = session().execute(select().fcall("avg", cast(column("i"), DataType.cfloat())).as("iavg").from(TABLE2).where(eq("k", "cast_t"))); |
| @@ -281,7 +281,7 @@ | ||
| 281 | 281 | * @since 3.0.1 |
| 282 | 282 | */ |
| 283 | 283 | @Test(groups = "short") |
| 284 | - @CassandraVersion(major = 3.6) | |
| 284 | + @CassandraVersion("3.6") | |
| 285 | 285 | public void should_retrieve_using_like_operator_on_table_with_sasi_index() { |
| 286 | 286 | //given |
| 287 | 287 | String table = "s_table"; |
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderITest.java +2 −2
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | @Test(groups = "short") |
| 75 | - @CassandraVersion(major = 2.0, minor = 7, description = "DELETE..IF EXISTS only supported in 2.0.7+ (CASSANDRA-5708)") | |
| 75 | + @CassandraVersion(value = "2.0.7", description = "DELETE..IF EXISTS only supported in 2.0.7+ (CASSANDRA-5708)") | |
| 76 | 76 | public void conditionalDeletesTest() throws Exception { |
| 77 | 77 | session().execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace)); |
| 78 | 78 | |
| @@ -98,7 +98,7 @@ | ||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | @Test(groups = "short") |
| 101 | - @CassandraVersion(major = 2.0, minor = 13, description = "Allow IF EXISTS for UPDATE statements (CASSANDRA-8610)") | |
| 101 | + @CassandraVersion(value = "2.0.13", description = "Allow IF EXISTS for UPDATE statements (CASSANDRA-8610)") | |
| 102 | 102 | public void conditionalUpdatesTest() throws Exception { |
| 103 | 103 | session().execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace)); |
| 104 | 104 |
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTupleExecutionTest.java +1 −1
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | import static org.assertj.core.api.Assertions.assertThat; |
| 30 | 30 | import static org.testng.Assert.assertEquals; |
| 31 | 31 | |
| 32 | -@CassandraVersion(major = 2.1, minor = 3) | |
| 32 | +@CassandraVersion("2.1.3") | |
| 33 | 33 | public class QueryBuilderTupleExecutionTest extends CCMTestsSupport { |
| 34 | 34 | |
| 35 | 35 | @Test(groups = "short") |
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderUDTExecutionTest.java +1 −1
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | import static org.assertj.core.api.Assertions.assertThat; |
| 30 | 30 | import static org.testng.Assert.assertEquals; |
| 31 | 31 | |
| 32 | -@CassandraVersion(major = 2.1, minor = 3) | |
| 32 | +@CassandraVersion("2.1.3") | |
| 33 | 33 | public class QueryBuilderUDTExecutionTest extends CCMTestsSupport { |
| 34 | 34 | |
| 35 | 35 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/schemabuilder/SchemaBuilderIT.java +2 −2
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | public class SchemaBuilderIT extends CCMTestsSupport { |
| 33 | 33 | |
| 34 | 34 | @Test(groups = "short") |
| 35 | - @CassandraVersion(major = 2.1, minor = 2) | |
| 35 | + @CassandraVersion("2.1.2") | |
| 36 | 36 | public void should_modify_table_metadata() { |
| 37 | 37 | // Create a table |
| 38 | 38 | session().execute(SchemaBuilder.createTable("ks", "TableMetadata") |
| @@ -128,7 +128,7 @@ | ||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | @Test(groups = "short") |
| 131 | - @CassandraVersion(major = 2.1) | |
| 131 | + @CassandraVersion("2.1.0") | |
| 132 | 132 | public void should_create_a_table_and_a_udt() { |
| 133 | 133 | // Create a UDT and a table |
| 134 | 134 | session().execute(SchemaBuilder.createType("MyUDT") |
modified driver-core/src/test/java/com/datastax/driver/core/utils/CassandraVersion.java +3 −7
| @@ -22,19 +22,15 @@ | ||
| 22 | 22 | * <p>Annotation for a Class or Method that defines a Cassandra Version requirement. If the cassandra version in use |
| 23 | 23 | * does not meet the version requirement, the test is skipped.</p> |
| 24 | 24 | * |
| 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) | |
| 26 | 26 | */ |
| 27 | 27 | @Retention(RetentionPolicy.RUNTIME) |
| 28 | 28 | public @interface CassandraVersion { |
| 29 | - /** | |
| 30 | - * @return The major version required to execute this test, i.e. "2.0" | |
| 31 | - */ | |
| 32 | - double major(); | |
| 33 | 29 | |
| 34 | 30 | /** |
| 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" | |
| 36 | 32 | */ |
| 37 | - int minor() default 0; | |
| 33 | + String value(); | |
| 38 | 34 | |
| 39 | 35 | /** |
| 40 | 36 | * @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 @@ | ||
| 22 | 22 | * <p>Annotation for a Class or Method that defines a DataStax Enterprise Version requirement. |
| 23 | 23 | * If the version in use does not meet the version requirement or DSE is not used, the test is skipped.</p> |
| 24 | 24 | * |
| 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) | |
| 26 | 26 | */ |
| 27 | 27 | @Retention(RetentionPolicy.RUNTIME) |
| 28 | 28 | 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; | |
| 33 | 29 | |
| 34 | 30 | /** |
| 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" | |
| 36 | 32 | */ |
| 37 | - int minor() default 0; | |
| 33 | + String value(); | |
| 38 | 34 | |
| 39 | 35 | /** |
| 40 | 36 | * @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 @@ | ||
| 20 | 20 | # Adjust Scassandra's log level |
| 21 | 21 | # (it seems some messages are conditioned by log4j.properties and others by reference.conf, so we need both) |
| 22 | 22 | log4j.logger.org.scassandra=ERROR |
| 23 | +log4j.logger.spray.can=ERROR | |
| 23 | 24 | # Useful loggers when debugging Scassandra tests |
| 24 | 25 | #log4j.logger.org.scassandra.cql=ERROR |
| 25 | 26 | #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 @@ | ||
| 33 | 33 | import static com.google.common.collect.Lists.newArrayList; |
| 34 | 34 | import static org.assertj.core.api.Assertions.assertThat; |
| 35 | 35 | |
| 36 | -@CassandraVersion(major = 2.2) | |
| 36 | +@CassandraVersion("2.2.0") | |
| 37 | 37 | public class SimpleDateCodecsTest extends CCMTestsSupport { |
| 38 | 38 | |
| 39 | 39 | @Override |
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/enums/EnumCodecsTest.java +1 −1
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | * and ints (with EnumOrdinalCodec). |
| 44 | 44 | * It also validates that both codecs may coexist in the same CodecRegistry. |
| 45 | 45 | */ |
| 46 | -@CassandraVersion(major = 2.1) | |
| 46 | +@CassandraVersion("2.1.0") | |
| 47 | 47 | public class EnumCodecsTest extends CCMTestsSupport { |
| 48 | 48 | |
| 49 | 49 | 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 @@ | ||
| 69 | 69 | * @since 2.2.0 |
| 70 | 70 | */ |
| 71 | 71 | @Test(groups = "short") |
| 72 | - @CassandraVersion(major = 2.2) | |
| 72 | + @CassandraVersion("2.2.0") | |
| 73 | 73 | public void should_map_unset_value_to_absent() { |
| 74 | 74 | PreparedStatement insertPrep = session().prepare(this.insertStmt); |
| 75 | 75 | 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 @@ | ||
| 41 | 41 | import static com.google.common.collect.Sets.newHashSet; |
| 42 | 42 | import static org.assertj.core.api.Assertions.assertThat; |
| 43 | 43 | |
| 44 | -@CassandraVersion(major = 2.2) | |
| 44 | +@CassandraVersion("2.2.0") | |
| 45 | 45 | public class Jdk8TimeCodecsTest extends CCMTestsSupport { |
| 46 | 46 | |
| 47 | 47 | @Override |
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/jdk8/OptionalCodecTest.java +1 −1
| @@ -69,7 +69,7 @@ | ||
| 69 | 69 | * @since 2.2.0 |
| 70 | 70 | */ |
| 71 | 71 | @Test(groups = "short") |
| 72 | - @CassandraVersion(major = 2.2) | |
| 72 | + @CassandraVersion("2.2.0") | |
| 73 | 73 | public void should_map_unset_value_to_empty() { |
| 74 | 74 | PreparedStatement insertPrep = session().prepare(this.insertStmt); |
| 75 | 75 | 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 @@ | ||
| 42 | 42 | import static java.util.concurrent.TimeUnit.NANOSECONDS; |
| 43 | 43 | import static org.assertj.core.api.Assertions.assertThat; |
| 44 | 44 | |
| 45 | -@CassandraVersion(major = 2.2) | |
| 45 | +@CassandraVersion("2.2.0") | |
| 46 | 46 | public class JodaTimeCodecsTest extends CCMTestsSupport { |
| 47 | 47 | |
| 48 | 48 | @Override |
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/json/JacksonJsonCodecTest.java +1 −1
| @@ -81,7 +81,7 @@ | ||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | @Test(groups = "short") |
| 84 | - @CassandraVersion(major = 2.0) | |
| 84 | + @CassandraVersion("2.0.0") | |
| 85 | 85 | public void should_use_custom_codec_with_simple_statements() { |
| 86 | 86 | session().execute(insertQuery, notAJsonString, alice, bobAndCharlie); |
| 87 | 87 | ResultSet rows = session().execute(selectQuery, notAJsonString, alice); |
modified driver-extras/src/test/java/com/datastax/driver/extras/codecs/json/Jsr353JsonCodecTest.java +1 −1
| @@ -99,7 +99,7 @@ | ||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | @Test(groups = "short", dataProvider = "Jsr353JsonCodecTest") |
| 102 | - @CassandraVersion(major = 2.0) | |
| 102 | + @CassandraVersion("2.0.0") | |
| 103 | 103 | public void should_use_custom_codec_with_simple_statements(JsonStructure object) throws IOException { |
| 104 | 104 | session().execute(insertQuery, notAJsonString, object); |
| 105 | 105 | ResultSet rows = session().execute(selectQuery, notAJsonString, object); |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAccessorParamsTest.java +1 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | @Test(groups = "short") |
| 44 | - @CassandraVersion(major = 2.0, description = "Uses named parameters") | |
| 44 | + @CassandraVersion(value = "2.0", description = "Uses named parameters") | |
| 45 | 45 | public void should_allow_less_parameters_than_bind_markers_if_there_are_repeated_names() { |
| 46 | 46 | UserPhoneAccessor accessor = new MappingManager(session()) |
| 47 | 47 | .createAccessor(UserPhoneAccessor.class); |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAccessorTest.java +1 −1
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | @Test(groups = "short") |
| 55 | - @CassandraVersion(major = 2.0) | |
| 55 | + @CassandraVersion("2.0.0") | |
| 56 | 56 | public void should_allow_null_argument_in_accessor_when_set_by_name() { |
| 57 | 57 | FooAccessor accessor = new MappingManager(session()) |
| 58 | 58 | .createAccessor(FooAccessor.class); |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperComputedFieldsTest.java +6 −6
| @@ -61,7 +61,7 @@ | ||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | @Test(groups = "short") |
| 64 | - @CassandraVersion(major = 2.0) | |
| 64 | + @CassandraVersion("2.0.0") | |
| 65 | 65 | void should_save_and_get_entity_with_computed_fields() { |
| 66 | 66 | long writeTime = System.currentTimeMillis() * 1000; |
| 67 | 67 | User newUser = new User("testlogin2", "blah"); |
| @@ -87,7 +87,7 @@ | ||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | @Test(groups = "short") |
| 90 | - @CassandraVersion(major = 2.0) | |
| 90 | + @CassandraVersion("2.0.0") | |
| 91 | 91 | void should_add_aliases_for_fields_in_select_queries() { |
| 92 | 92 | BoundStatement bs = (BoundStatement) userMapper.getQuery("test"); |
| 93 | 93 | assertThat(bs.preparedStatement().getQueryString()) |
| @@ -95,7 +95,7 @@ | ||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | @Test(groups = "short") |
| 98 | - @CassandraVersion(major = 2.0) | |
| 98 | + @CassandraVersion("2.0.0") | |
| 99 | 99 | public void should_map_aliased_resultset_to_objects() { |
| 100 | 100 | Statement getQuery = userMapper.getQuery("testlogin"); |
| 101 | 101 | getQuery.setConsistencyLevel(ConsistencyLevel.QUORUM); |
| @@ -108,7 +108,7 @@ | ||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | @Test(groups = "short") |
| 111 | - @CassandraVersion(major = 2.0) | |
| 111 | + @CassandraVersion("2.0.0") | |
| 112 | 112 | void should_map_unaliased_resultset_to_objects() { |
| 113 | 113 | UserAccessor userAccessor = mappingManager.createAccessor(UserAccessor.class); |
| 114 | 114 | ResultSet rs = userAccessor.all(); |
| @@ -120,7 +120,7 @@ | ||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | @Test(groups = "short", expectedExceptions = CodecNotFoundException.class) |
| 123 | - @CassandraVersion(major = 2.0) | |
| 123 | + @CassandraVersion("2.0.0") | |
| 124 | 124 | void should_fail_if_computed_field_is_not_right_type() { |
| 125 | 125 | Mapper<User_WrongComputedType> mapper = mappingManager.mapper(User_WrongComputedType.class); |
| 126 | 126 | |
| @@ -128,7 +128,7 @@ | ||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | @Test(groups = "short", expectedExceptions = IllegalArgumentException.class) |
| 131 | - @CassandraVersion(major = 2.0) | |
| 131 | + @CassandraVersion("2.0.0") | |
| 132 | 132 | void should_fail_if_computed_field_marked_with_column_annotation() { |
| 133 | 133 | mappingManager.mapper(User_WrongAnnotationForComputed.class); |
| 134 | 134 | } |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperCustomCodecTest.java +1 −1
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | import static org.assertj.core.api.Assertions.assertThat; |
| 34 | 34 | import static org.assertj.core.api.Assertions.fail; |
| 35 | 35 | |
| 36 | -@CassandraVersion(major = 2.1) | |
| 36 | +@CassandraVersion("2.1.0") | |
| 37 | 37 | @SuppressWarnings("unused") |
| 38 | 38 | public class MapperCustomCodecTest extends CCMTestsSupport { |
| 39 | 39 |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperDefaultKeyspaceTest.java +1 −1
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | /** |
| 32 | 32 | * Tests usage of mapping annotations without specifying a keyspace. |
| 33 | 33 | */ |
| 34 | -@CassandraVersion(major = 2.1) | |
| 34 | +@CassandraVersion("2.1.0") | |
| 35 | 35 | @SuppressWarnings("unused") |
| 36 | 36 | public class MapperDefaultKeyspaceTest extends CCMTestsSupport { |
| 37 | 37 |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperMaterializedViewTest.java +1 −1
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | import static org.assertj.core.api.Assertions.assertThat; |
| 27 | 27 | |
| 28 | 28 | @SuppressWarnings("unused") |
| 29 | -@CassandraVersion(major = 3.0) | |
| 29 | +@CassandraVersion("3.0") | |
| 30 | 30 | public class MapperMaterializedViewTest extends CCMTestsSupport { |
| 31 | 31 | |
| 32 | 32 | @Override |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperNestedCollectionsTest.java +1 −1
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | |
| 32 | 32 | import static com.datastax.driver.core.Assertions.assertThat; |
| 33 | 33 | |
| 34 | -@CassandraVersion(major = 2.1, minor = 3) | |
| 34 | +@CassandraVersion("2.1.3") | |
| 35 | 35 | @SuppressWarnings("unused") |
| 36 | 36 | public class MapperNestedCollectionsTest extends CCMTestsSupport { |
| 37 | 37 |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperOptionTest.java +10 −10
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | @Test(groups = "short") |
| 54 | - @CassandraVersion(major = 2.0) | |
| 54 | + @CassandraVersion("2.0.0") | |
| 55 | 55 | void should_use_save_options() throws Exception { |
| 56 | 56 | Long tsValue = futureTimestamp(); |
| 57 | 57 | mapper.save(new User(42, "helloworld"), Option.timestamp(tsValue), Option.tracing(true)); |
| @@ -61,7 +61,7 @@ | ||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | @Test(groups = "short") |
| 64 | - @CassandraVersion(major = 2.0) | |
| 64 | + @CassandraVersion("2.0.0") | |
| 65 | 65 | void should_use_delete_options() { |
| 66 | 66 | User todelete = new User(45, "todelete"); |
| 67 | 67 | mapper.save(todelete); |
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | @Test(groups = "short", expectedExceptions = {IllegalArgumentException.class}) |
| 75 | - @CassandraVersion(major = 2.0) | |
| 75 | + @CassandraVersion("2.0.0") | |
| 76 | 76 | void should_use_get_options() { |
| 77 | 77 | User user = new User(45, "toget"); |
| 78 | 78 | mapper.save(user); |
| @@ -90,7 +90,7 @@ | ||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | @Test(groups = "short") |
| 93 | - @CassandraVersion(major = 2.0) | |
| 93 | + @CassandraVersion("2.0.0") | |
| 94 | 94 | void should_use_options_only_once() { |
| 95 | 95 | Long tsValue = futureTimestamp(); |
| 96 | 96 | mapper.save(new User(43, "helloworld"), Option.timestamp(tsValue)); |
| @@ -101,7 +101,7 @@ | ||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | @Test(groups = "short") |
| 104 | - @CassandraVersion(major = 2.0) | |
| 104 | + @CassandraVersion("2.0.0") | |
| 105 | 105 | void should_use_default_options() { |
| 106 | 106 | mapper.setDefaultSaveOptions(Option.timestamp(644746L), Option.ttl(76324)); |
| 107 | 107 | BoundStatement bs = (BoundStatement) mapper.saveQuery(new User(46, "rjhrgce")); |
| @@ -134,7 +134,7 @@ | ||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | @Test(groups = "short") |
| 137 | - @CassandraVersion(major = 2.0) | |
| 137 | + @CassandraVersion("2.0.0") | |
| 138 | 138 | void should_prioritize_option_over_model_consistency() { |
| 139 | 139 | // Generate Write Query and ensure User model writeConsistency is used. |
| 140 | 140 | User user = new User(1859, "Steve"); |
| @@ -155,7 +155,7 @@ | ||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | @Test(groups = "short") |
| 158 | - @CassandraVersion(major = 2.0) | |
| 158 | + @CassandraVersion("2.0.0") | |
| 159 | 159 | void should_use_explicit_options_over_default_options() { |
| 160 | 160 | long defaultTimestamp = futureTimestamp(); |
| 161 | 161 | long explicitTimestamp = futureTimestamp(); |
| @@ -171,7 +171,7 @@ | ||
| 171 | 171 | * Cover all versions of save() to check that methods that call each other properly propagate the options |
| 172 | 172 | */ |
| 173 | 173 | @Test(groups = "short") |
| 174 | - @CassandraVersion(major = 2.0) | |
| 174 | + @CassandraVersion("2.0.0") | |
| 175 | 175 | void should_use_save_options_for_all_variants() throws ExecutionException, InterruptedException { |
| 176 | 176 | Long timestamp = futureTimestamp(); |
| 177 | 177 | User user = new User(42, "helloworld"); |
| @@ -210,7 +210,7 @@ | ||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | @Test(groups = "short") |
| 213 | - @CassandraVersion(major = 2.0) | |
| 213 | + @CassandraVersion("2.0.0") | |
| 214 | 214 | void should_use_get_options_for_all_variants() throws InterruptedException { |
| 215 | 215 | try { |
| 216 | 216 | mapper.get(42, Option.consistencyLevel(TWO)); |
| @@ -251,7 +251,7 @@ | ||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | @Test(groups = "short") |
| 254 | - @CassandraVersion(major = 2.0) | |
| 254 | + @CassandraVersion("2.0.0") | |
| 255 | 255 | void should_use_delete_options_for_all_variants() throws InterruptedException { |
| 256 | 256 | User user = new User(42, "helloworld"); |
| 257 | 257 |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperPrimitiveTypes22Test.java +1 −1
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | |
| 28 | 28 | import static org.testng.Assert.assertEquals; |
| 29 | 29 | |
| 30 | -@CassandraVersion(major = 2.2) | |
| 30 | +@CassandraVersion("2.2.0") | |
| 31 | 31 | public class MapperPrimitiveTypes22Test extends CCMTestsSupport { |
| 32 | 32 | |
| 33 | 33 | @Override |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperTest.java +5 −5
| @@ -310,7 +310,7 @@ | ||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | @Test(groups = "short") |
| 313 | - @CassandraVersion(major = 2.0) | |
| 313 | + @CassandraVersion("2.0.0") | |
| 314 | 314 | public void testDynamicEntity() throws Exception { |
| 315 | 315 | MappingManager manager = new MappingManager(session()); |
| 316 | 316 | |
| @@ -439,7 +439,7 @@ | ||
| 439 | 439 | * @test_category object_mapper |
| 440 | 440 | */ |
| 441 | 441 | @Test(groups = "short") |
| 442 | - @CassandraVersion(major = 2.0) | |
| 442 | + @CassandraVersion("2.0.0") | |
| 443 | 443 | public void should_flag_statement_as_idempotent() { |
| 444 | 444 | MappingManager manager = new MappingManager(session()); |
| 445 | 445 | PostAccessor post = manager.createAccessor(PostAccessor.class); |
| @@ -456,7 +456,7 @@ | ||
| 456 | 456 | * @test_category object_mapper |
| 457 | 457 | */ |
| 458 | 458 | @Test(groups = "short") |
| 459 | - @CassandraVersion(major = 2.0) | |
| 459 | + @CassandraVersion("2.0.0") | |
| 460 | 460 | public void should_flag_statement_as_non_idempotent() { |
| 461 | 461 | MappingManager manager = new MappingManager(session()); |
| 462 | 462 | PostAccessor post = manager.createAccessor(PostAccessor.class); |
| @@ -473,7 +473,7 @@ | ||
| 473 | 473 | * @test_category object_mapper |
| 474 | 474 | */ |
| 475 | 475 | @Test(groups = "short") |
| 476 | - @CassandraVersion(major = 2.0) | |
| 476 | + @CassandraVersion("2.0.0") | |
| 477 | 477 | public void should_flag_statement_with_null_idempotence() { |
| 478 | 478 | MappingManager manager = new MappingManager(session()); |
| 479 | 479 | PostAccessor post = manager.createAccessor(PostAccessor.class); |
| @@ -489,7 +489,7 @@ | ||
| 489 | 489 | * @test_category object_mapper |
| 490 | 490 | */ |
| 491 | 491 | @Test(groups = "short") |
| 492 | - @CassandraVersion(major = 2.0) | |
| 492 | + @CassandraVersion("2.0.0") | |
| 493 | 493 | public void should_flag_all_mapper_generated_statements_as_idempotent() { |
| 494 | 494 | MappingManager manager = new MappingManager(session()); |
| 495 | 495 | 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 @@ | ||
| 34 | 34 | * Tests mapping of collections of UDTs. |
| 35 | 35 | */ |
| 36 | 36 | @SuppressWarnings("unused") |
| 37 | -@CassandraVersion(major = 2.1) | |
| 37 | +@CassandraVersion("2.1.0") | |
| 38 | 38 | public class MapperUDTCollectionsTest extends CCMTestsSupport { |
| 39 | 39 | |
| 40 | 40 | @Override |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperUDTTest.java +1 −1
| @@ -38,7 +38,7 @@ | ||
| 38 | 38 | import static org.testng.Assert.*; |
| 39 | 39 | |
| 40 | 40 | @SuppressWarnings({"unused", "WeakerAccess"}) |
| 41 | -@CassandraVersion(major = 2.1) | |
| 41 | +@CassandraVersion("2.1.0") | |
| 42 | 42 | @CreateCCM(PER_METHOD) |
| 43 | 43 | public class MapperUDTTest extends CCMTestsSupport { |
| 44 | 44 |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/UDTFieldMapperTest.java +1 −1
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | import java.util.HashMap; |
| 28 | 28 | import java.util.Map; |
| 29 | 29 | |
| 30 | -@CassandraVersion(major = 2.1) | |
| 30 | +@CassandraVersion("2.1.0") | |
| 31 | 31 | @CCMConfig(createCluster = false) |
| 32 | 32 | @SuppressWarnings("unused") |
| 33 | 33 | public class UDTFieldMapperTest extends CCMTestsSupport { |
modified driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java +1 −1
| @@ -122,7 +122,7 @@ | ||
| 122 | 122 | // Delegate javax.security.cert to the parent classloader. javax.security.cert.X509Certificate is used in |
| 123 | 123 | // io.netty.util.internal.EmptyArrays, but not directly by the driver. |
| 124 | 124 | bootDelegationPackage("javax.security.cert"), |
| 125 | - systemProperty("cassandra.version").value(CCMBridge.getCassandraVersion()), | |
| 125 | + systemProperty("cassandra.version").value(CCMBridge.getGlobalCassandraVersion().toString()), | |
| 126 | 126 | systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1), |
| 127 | 127 | systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"), |
| 128 | 128 | mavenBundle("org.slf4j", "slf4j-api", "1.7.5"), |