kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 44457cdc3b144f2fad8934ebba385b65790ad1ae3fa526287a4a9f4873782c37 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-07-03 15:16 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-07-03 19:21 +02:00 |
| Parents | 1c8ac384bf5a |
24 files changed
modified driver-core/src/test/java/com/datastax/driver/core/AuthenticationTest.java +14 −25
| @@ -15,9 +15,6 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import java.net.InetAddress; | |
| 19 | -import java.net.InetSocketAddress; | |
| 20 | -import java.util.Map; | |
| 21 | 18 | import java.util.concurrent.TimeUnit; |
| 22 | 19 | |
| 23 | 20 | import org.slf4j.Logger; |
| @@ -36,17 +33,18 @@ | ||
| 36 | 33 | |
| 37 | 34 | private static final Logger logger = LoggerFactory.getLogger(AuthenticationTest.class); |
| 38 | 35 | |
| 39 | - private CCMBridge cassandraCluster; | |
| 36 | + private CCMBridge ccm; | |
| 40 | 37 | |
| 41 | 38 | /** |
| 42 | 39 | * creates a cluster and turns on password authentication before starting it. |
| 43 | 40 | */ |
| 44 | 41 | @BeforeClass (groups = "short") |
| 45 | 42 | public void setupClusterWithAuthentication() throws InterruptedException { |
| 46 | - cassandraCluster = CCMBridge.create("test"); | |
| 47 | - cassandraCluster.populate(1); | |
| 48 | - cassandraCluster.updateConfig("authenticator", "PasswordAuthenticator"); | |
| 49 | - cassandraCluster.start(1, "-Dcassandra.superuser_setup_delay_ms=0"); | |
| 43 | + ccm = CCMBridge.builder("test") | |
| 44 | + .withCassandraConfiguration("authenticator", "PasswordAuthenticator") | |
| 45 | + .notStarted() | |
| 46 | + .build(); | |
| 47 | + ccm.start(1, "-Dcassandra.superuser_setup_delay_ms=0"); | |
| 50 | 48 | |
| 51 | 49 | // Even though we've override the default user setup delay, still wait |
| 52 | 50 | // one second to make sure we don't race |
| @@ -55,51 +53,42 @@ | ||
| 55 | 53 | |
| 56 | 54 | @AfterClass (groups = "short") |
| 57 | 55 | public void shutdownCluster() { |
| 58 | - if (null != cassandraCluster) | |
| 59 | - cassandraCluster.stop(); | |
| 56 | + if (ccm != null) | |
| 57 | + ccm.stop(); | |
| 60 | 58 | } |
| 61 | 59 | |
| 62 | 60 | @Test(groups = "short") |
| 63 | - public void testAuthenticatedConnection() throws InterruptedException { | |
| 61 | + public void should_connect_with_credentials() throws InterruptedException { | |
| 64 | 62 | try { |
| 65 | 63 | Cluster.builder().addContactPoint(CCMBridge.IP_PREFIX + '1') |
| 66 | 64 | .withCredentials("cassandra", "cassandra") |
| 67 | 65 | .build() |
| 68 | 66 | .connect(); |
| 69 | 67 | } catch (NoHostAvailableException e) { |
| 70 | - | |
| 71 | - for (Map.Entry<InetSocketAddress, Throwable> entry : e.getErrors().entrySet()) | |
| 72 | - logger.error("Error connecting to " + entry.getKey(), entry.getValue()); | |
| 73 | - throw new RuntimeException(e); | |
| 68 | + logger.error(e.getCustomMessage(1, true, true)); | |
| 74 | 69 | } |
| 75 | 70 | } |
| 76 | 71 | |
| 77 | 72 | @Test(groups = "short", expectedExceptions = AuthenticationException.class) |
| 78 | - public void testConnectionAttemptWithIncorrectCredentialsIsRefused() throws InterruptedException { | |
| 73 | + public void should_fail_to_connect_with_wrong_credentials() throws InterruptedException { | |
| 79 | 74 | try { |
| 80 | 75 | Cluster.builder().addContactPoint(CCMBridge.IP_PREFIX + '1') |
| 81 | 76 | .withCredentials("bogus", "bogus") |
| 82 | 77 | .build() |
| 83 | 78 | .connect(); |
| 84 | 79 | } catch (NoHostAvailableException e) { |
| 85 | - | |
| 86 | - for (Map.Entry<InetSocketAddress, Throwable> entry : e.getErrors().entrySet()) | |
| 87 | - logger.info("Error connecting to " + entry.getKey() + ": " + entry.getValue()); | |
| 88 | - throw new RuntimeException(e); | |
| 80 | + logger.error(e.getCustomMessage(1, true, true)); | |
| 89 | 81 | } |
| 90 | 82 | } |
| 91 | 83 | |
| 92 | 84 | @Test(groups = "short", expectedExceptions = AuthenticationException.class) |
| 93 | - public void testConnectionAttemptWithoutCredentialsIsRefused() throws InterruptedException { | |
| 85 | + public void should_fail_to_connect_without_credentials() throws InterruptedException { | |
| 94 | 86 | try { |
| 95 | 87 | Cluster.builder().addContactPoint(CCMBridge.IP_PREFIX + '1') |
| 96 | 88 | .build() |
| 97 | 89 | .connect(); |
| 98 | 90 | } catch (NoHostAvailableException e) { |
| 99 | - | |
| 100 | - for (Map.Entry<InetSocketAddress, Throwable> entry : e.getErrors().entrySet()) | |
| 101 | - logger.info("Error connecting to " + entry.getKey() + ": " + entry.getValue()); | |
| 102 | - throw new RuntimeException(e); | |
| 91 | + logger.error(e.getCustomMessage(1, true, true)); | |
| 103 | 92 | } |
| 104 | 93 | } |
| 105 | 94 | } |
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +116 −93
| @@ -38,10 +38,8 @@ | ||
| 38 | 38 | import org.testng.annotations.AfterClass; |
| 39 | 39 | import org.testng.annotations.BeforeClass; |
| 40 | 40 | |
| 41 | -import static com.google.common.base.Preconditions.checkArgument; | |
| 42 | 41 | import static org.testng.Assert.fail; |
| 43 | 42 | |
| 44 | -import com.datastax.driver.core.Cluster.Builder; | |
| 45 | 43 | import com.datastax.driver.core.exceptions.AlreadyExistsException; |
| 46 | 44 | import com.datastax.driver.core.exceptions.DriverException; |
| 47 | 45 | import com.datastax.driver.core.exceptions.NoHostAvailableException; |
| @@ -56,6 +54,8 @@ | ||
| 56 | 54 | public static final String IP_PREFIX; |
| 57 | 55 | |
| 58 | 56 | private static final String CASSANDRA_VERSION_REGEXP = "\\d\\.\\d\\.\\d+(-\\w+)?"; |
| 57 | + static final File CASSANDRA_DIR; | |
| 58 | + static final String CASSANDRA_VERSION; | |
| 59 | 59 | |
| 60 | 60 | public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "cassandra1sfun"; |
| 61 | 61 | public static final String DEFAULT_CLIENT_TRUSTSTORE_PATH = "/client.truststore"; |
| @@ -89,6 +89,21 @@ | ||
| 89 | 89 | private static final String CCM_COMMAND; |
| 90 | 90 | |
| 91 | 91 | static { |
| 92 | + String version = System.getProperty("cassandra.version"); | |
| 93 | + if (version.matches(CASSANDRA_VERSION_REGEXP)) { | |
| 94 | + CASSANDRA_DIR = null; | |
| 95 | + CASSANDRA_VERSION = "-v " + version; | |
| 96 | + } else { | |
| 97 | + CASSANDRA_DIR = new File(version); | |
| 98 | + CASSANDRA_VERSION = ""; | |
| 99 | + } | |
| 100 | + | |
| 101 | + String ip_prefix = System.getProperty("ipprefix"); | |
| 102 | + if (ip_prefix == null || ip_prefix.isEmpty()) { | |
| 103 | + ip_prefix = "127.0.1."; | |
| 104 | + } | |
| 105 | + IP_PREFIX = ip_prefix; | |
| 106 | + | |
| 92 | 107 | // Inherit the current environment. |
| 93 | 108 | Map<String,String> envMap = Maps.newHashMap(new ProcessBuilder().environment()); |
| 94 | 109 | // If ccm.path is set, override the PATH variable with it. |
| @@ -122,33 +137,9 @@ | ||
| 122 | 137 | private static boolean isWindows() { |
| 123 | 138 | |
| 124 | 139 | String osName = System.getProperty("os.name"); |
| 125 | - if (osName == null) { | |
| 126 | - return false; | |
| 127 | - } | |
| 128 | - return osName.startsWith("Windows"); | |
| 129 | - } | |
| 130 | - | |
| 131 | - static final File CASSANDRA_DIR; | |
| 132 | - static final String CASSANDRA_VERSION; | |
| 133 | - | |
| 134 | - static { | |
| 135 | - String version = System.getProperty("cassandra.version"); | |
| 136 | - if (version.matches(CASSANDRA_VERSION_REGEXP)) { | |
| 137 | - CASSANDRA_DIR = null; | |
| 138 | - CASSANDRA_VERSION = "-v " + version; | |
| 139 | - } else { | |
| 140 | - CASSANDRA_DIR = new File(version); | |
| 141 | - CASSANDRA_VERSION = ""; | |
| 142 | - } | |
| 143 | - | |
| 144 | - String ip_prefix = System.getProperty("ipprefix"); | |
| 145 | - if (ip_prefix == null || ip_prefix.isEmpty()) { | |
| 146 | - ip_prefix = "127.0.1."; | |
| 147 | - } | |
| 148 | - IP_PREFIX = ip_prefix; | |
| 140 | + return osName != null && osName.startsWith("Windows"); | |
| 149 | 141 | } |
| 150 | 142 | |
| 151 | - private final Runtime runtime = Runtime.getRuntime(); | |
| 152 | 143 | private final File ccmDir; |
| 153 | 144 | |
| 154 | 145 | private CCMBridge() { |
| @@ -190,28 +181,8 @@ | ||
| 190 | 181 | return f; |
| 191 | 182 | } |
| 192 | 183 | |
| 193 | - public static CCMBridge create(String name, String... options) { | |
| 194 | - CCMBridge bridge = new CCMBridge(); | |
| 195 | - bridge.execute(CCM_COMMAND + " create %s -b -i %s %s " + Joiner.on(" ").join(options), name, IP_PREFIX, CASSANDRA_VERSION); | |
| 196 | - return bridge; | |
| 197 | - } | |
| 198 | - | |
| 199 | - public static CCMBridge create(String name, int nbNodes, String... options) { | |
| 200 | - CCMBridge bridge = new CCMBridge(); | |
| 201 | - bridge.execute(CCM_COMMAND + " create %s -n %d -s -i %s -b %s " + Joiner.on(" ").join(options), name, nbNodes, IP_PREFIX, CASSANDRA_VERSION); | |
| 202 | - return bridge; | |
| 203 | - } | |
| 204 | - | |
| 205 | - public static CCMBridge createWithCustomVersion(String name, int nbNodes, String cassandraVersion) { | |
| 206 | - CCMBridge bridge = new CCMBridge(); | |
| 207 | - bridge.execute(CCM_COMMAND + " create %s -n %d -s -i %s -b -v %s ", name, nbNodes, IP_PREFIX, cassandraVersion); | |
| 208 | - return bridge; | |
| 209 | - } | |
| 210 | - | |
| 211 | - public static CCMBridge create(String name, int nbNodesDC1, int nbNodesDC2) { | |
| 212 | - CCMBridge bridge = new CCMBridge(); | |
| 213 | - bridge.execute(CCM_COMMAND + " create %s -n %d:%d -s -i %s -b %s", name, nbNodesDC1, nbNodesDC2, IP_PREFIX, CASSANDRA_VERSION); | |
| 214 | - return bridge; | |
| 184 | + public static Builder builder(String clusterName) { | |
| 185 | + return new Builder(clusterName); | |
| 215 | 186 | } |
| 216 | 187 | |
| 217 | 188 | public static CCMBridge.CCMCluster buildCluster(int nbNodes, Cluster.Builder builder) { |
| @@ -239,9 +210,9 @@ | ||
| 239 | 210 | execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto", n); |
| 240 | 211 | } |
| 241 | 212 | |
| 242 | - public void start(int n, String option) { | |
| 243 | - logger.info("Starting: " + IP_PREFIX + n + " with " + option); | |
| 244 | - execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto --jvm_arg=%s", n, option); | |
| 213 | + public void start(int n, String jvmArg) { | |
| 214 | + logger.info("Starting: " + IP_PREFIX + n + " with " + jvmArg); | |
| 215 | + execute(CCM_COMMAND + " node%d start --wait-other-notice --wait-for-binary-proto --jvm_arg=%s", n, jvmArg); | |
| 245 | 216 | } |
| 246 | 217 | |
| 247 | 218 | public void stop(int n) { |
| @@ -250,7 +221,7 @@ | ||
| 250 | 221 | } |
| 251 | 222 | |
| 252 | 223 | public void stop(String clusterName) { |
| 253 | - logger.info("Stopping Cluster : "+clusterName); | |
| 224 | + logger.info("Stopping Cluster : " + clusterName); | |
| 254 | 225 | execute(CCM_COMMAND + " stop "+clusterName); |
| 255 | 226 | } |
| 256 | 227 | |
| @@ -300,10 +271,6 @@ | ||
| 300 | 271 | execute(CCM_COMMAND + " node%d decommission", n); |
| 301 | 272 | } |
| 302 | 273 | |
| 303 | - public void updateConfig(String name, String value) { | |
| 304 | - updateConfig(ImmutableMap.of(name, value)); | |
| 305 | - } | |
| 306 | - | |
| 307 | 274 | public void updateConfig(Map<String, String> configs) { |
| 308 | 275 | StringBuilder confStr = new StringBuilder(); |
| 309 | 276 | for (Map.Entry<String, String> entry : configs.entrySet()) { |
| @@ -312,10 +279,6 @@ | ||
| 312 | 279 | execute(CCM_COMMAND + " updateconf " + confStr); |
| 313 | 280 | } |
| 314 | 281 | |
| 315 | - public void populate(int n) { | |
| 316 | - execute(CCM_COMMAND + " populate -n %d -i %s", n, IP_PREFIX); | |
| 317 | - } | |
| 318 | - | |
| 319 | 282 | private void execute(String command, Object... args) { |
| 320 | 283 | |
| 321 | 284 | String fullCommand = String.format(command, args) + " --config-dir=" + ccmDir; |
| @@ -323,6 +286,7 @@ | ||
| 323 | 286 | logger.debug("Executing: " + fullCommand); |
| 324 | 287 | CommandLine cli = CommandLine.parse(fullCommand); |
| 325 | 288 | Executor executor = new DefaultExecutor(); |
| 289 | + executor.setWorkingDirectory(CASSANDRA_DIR); | |
| 326 | 290 | |
| 327 | 291 | LogOutputStream outStream = new LogOutputStream() { |
| 328 | 292 | @Override protected void processLine(String line, int logLevel) { |
| @@ -372,33 +336,6 @@ | ||
| 372 | 336 | } |
| 373 | 337 | } |
| 374 | 338 | |
| 375 | - /** | |
| 376 | - * Enables SSL without client authentication. Does not apply to already started nodes. | |
| 377 | - */ | |
| 378 | - public void enableSSL() { | |
| 379 | - enableSSL(false); | |
| 380 | - } | |
| 381 | - | |
| 382 | - /** | |
| 383 | - * Enables SSL. Does not apply to already started nodes. | |
| 384 | - * @param requireClientAuth Whether or not to require Clients used authentication. | |
| 385 | - */ | |
| 386 | - public void enableSSL(boolean requireClientAuth) { | |
| 387 | - ImmutableMap.Builder<String, String> configs = ImmutableMap.builder(); | |
| 388 | - | |
| 389 | - configs.put("client_encryption_options.enabled", "true"); | |
| 390 | - configs.put("client_encryption_options.keystore", DEFAULT_SERVER_KEYSTORE_FILE.getAbsolutePath()); | |
| 391 | - configs.put("client_encryption_options.keystore_password", DEFAULT_SERVER_KEYSTORE_PASSWORD); | |
| 392 | - | |
| 393 | - if (requireClientAuth) { | |
| 394 | - configs.put("client_encryption_options.require_client_auth", "true"); | |
| 395 | - configs.put("client_encryption_options.truststore", DEFAULT_SERVER_TRUSTSTORE_FILE.getAbsolutePath()); | |
| 396 | - configs.put("client_encryption_options.truststore_password", DEFAULT_SERVER_TRUSTSTORE_PASSWORD); | |
| 397 | - } | |
| 398 | - | |
| 399 | - updateConfig(configs.build()); | |
| 400 | - } | |
| 401 | - | |
| 402 | 339 | private static void busyWaitForPort(InetAddress address, int port, boolean expectedConnectionState) { |
| 403 | 340 | long maxAcceptableWaitTime = TimeUnit.SECONDS.toMillis(10); |
| 404 | 341 | long waitQuantum = TimeUnit.MILLISECONDS.toMillis(500); |
| @@ -508,7 +445,7 @@ | ||
| 508 | 445 | if (!clusterInitialized){ |
| 509 | 446 | try { |
| 510 | 447 | //launch ccm cluster |
| 511 | - ccmBridge = CCMBridge.create("test-class"); | |
| 448 | + ccmBridge = CCMBridge.builder("test-class").withoutNodes().notStarted().build(); | |
| 512 | 449 | |
| 513 | 450 | ports = new int[5]; |
| 514 | 451 | for (int i = 0; i < 5; i++) { |
| @@ -534,7 +471,7 @@ | ||
| 534 | 471 | |
| 535 | 472 | private void initKeyspace() { |
| 536 | 473 | try { |
| 537 | - Builder builder = Cluster.builder(); | |
| 474 | + Cluster.Builder builder = Cluster.builder(); | |
| 538 | 475 | |
| 539 | 476 | builder = configure(builder); |
| 540 | 477 | |
| @@ -594,14 +531,16 @@ | ||
| 594 | 531 | if (nbNodes == 0) |
| 595 | 532 | throw new IllegalArgumentException(); |
| 596 | 533 | |
| 597 | - return new CCMCluster(CCMBridge.create("test", nbNodes), builder, nbNodes); | |
| 534 | + CCMBridge ccm = CCMBridge.builder("test").withNodes(nbNodes).build(); | |
| 535 | + return new CCMCluster(ccm, builder, nbNodes); | |
| 598 | 536 | } |
| 599 | 537 | |
| 600 | 538 | public static CCMCluster create(int nbNodesDC1, int nbNodesDC2, Cluster.Builder builder) { |
| 601 | 539 | if (nbNodesDC1 == 0) |
| 602 | 540 | throw new IllegalArgumentException(); |
| 603 | 541 | |
| 604 | - return new CCMCluster(CCMBridge.create("test", nbNodesDC1, nbNodesDC2), builder, nbNodesDC1 + nbNodesDC2); | |
| 542 | + CCMBridge ccm = CCMBridge.builder("test").withNodes(nbNodesDC1, nbNodesDC2).build(); | |
| 543 | + return new CCMCluster(ccm, builder, nbNodesDC1 + nbNodesDC2); | |
| 605 | 544 | } |
| 606 | 545 | |
| 607 | 546 | public static CCMCluster create(CCMBridge cassandraCluster, Cluster.Builder builder, int totalNodes) { |
| @@ -617,7 +556,8 @@ | ||
| 617 | 556 | |
| 618 | 557 | try { |
| 619 | 558 | Thread.sleep(1000); |
| 620 | - } catch (Exception e) { | |
| 559 | + } catch (InterruptedException e) { | |
| 560 | + fail("Unexpected interruption"); | |
| 621 | 561 | } |
| 622 | 562 | this.cluster = builder.addContactPoints(contactPoints).build(); |
| 623 | 563 | this.session = cluster.connect(); |
| @@ -648,4 +588,87 @@ | ||
| 648 | 588 | } |
| 649 | 589 | } |
| 650 | 590 | } |
| 591 | + | |
| 592 | + /** use {@link #builder(String)} to get an instance */ | |
| 593 | + public static class Builder { | |
| 594 | + private final String clusterName; | |
| 595 | + private Integer[] nodes = { 1 }; | |
| 596 | + private boolean start = true; | |
| 597 | + private String cassandraVersion = CASSANDRA_VERSION; | |
| 598 | + private String[] startOptions = new String[0]; | |
| 599 | + private Map<String, String> cassandraConfiguration = Maps.newHashMap(); | |
| 600 | + | |
| 601 | + | |
| 602 | + Builder(String clusterName) { | |
| 603 | + this.clusterName = clusterName; | |
| 604 | + } | |
| 605 | + | |
| 606 | + /** Number of nodes for each DC. Defaults to [1] (1 DC with 1 node) */ | |
| 607 | + public Builder withNodes(Integer... nodes) { | |
| 608 | + this.nodes = nodes; | |
| 609 | + return this; | |
| 610 | + } | |
| 611 | + | |
| 612 | + public Builder withoutNodes() { | |
| 613 | + return withNodes(); | |
| 614 | + } | |
| 615 | + | |
| 616 | + public Builder withSSL(boolean requireClientAuth) { | |
| 617 | + cassandraConfiguration.put("client_encryption_options.enabled", "true"); | |
| 618 | + cassandraConfiguration.put("client_encryption_options.keystore", DEFAULT_SERVER_KEYSTORE_FILE.getAbsolutePath()); | |
| 619 | + cassandraConfiguration.put("client_encryption_options.keystore_password", DEFAULT_SERVER_KEYSTORE_PASSWORD); | |
| 620 | + | |
| 621 | + if (requireClientAuth) { | |
| 622 | + cassandraConfiguration.put("client_encryption_options.require_client_auth", "true"); | |
| 623 | + cassandraConfiguration.put("client_encryption_options.truststore", DEFAULT_SERVER_TRUSTSTORE_FILE.getAbsolutePath()); | |
| 624 | + cassandraConfiguration.put("client_encryption_options.truststore_password", DEFAULT_SERVER_TRUSTSTORE_PASSWORD); | |
| 625 | + } | |
| 626 | + return this; | |
| 627 | + } | |
| 628 | + | |
| 629 | + /** Whether to start the cluster immediately (defaults to true if this is never called) */ | |
| 630 | + public Builder notStarted() { | |
| 631 | + this.start = false; | |
| 632 | + return this; | |
| 633 | + } | |
| 634 | + | |
| 635 | + /** Defaults to system property cassandra.version */ | |
| 636 | + public Builder withCassandraVersion(String cassandraVersion) { | |
| 637 | + this.cassandraVersion = "-v " + cassandraVersion; | |
| 638 | + return this; | |
| 639 | + } | |
| 640 | + | |
| 641 | + /** Free-form options that will be added at the end of the start command */ | |
| 642 | + public Builder withStartOptions(String... options) { | |
| 643 | + this.startOptions = options; | |
| 644 | + return this; | |
| 645 | + } | |
| 646 | + | |
| 647 | + /** Customizes entries in cassandra.yaml (can be called multiple times) */ | |
| 648 | + public Builder withCassandraConfiguration(String key, String value) { | |
| 649 | + this.cassandraConfiguration.put(key, value); | |
| 650 | + return this; | |
| 651 | + } | |
| 652 | + | |
| 653 | + public CCMBridge build() { | |
| 654 | + CCMBridge ccm = new CCMBridge(); | |
| 655 | + ccm.execute(buildCreateCommand()); | |
| 656 | + ccm.updateConfig(cassandraConfiguration); | |
| 657 | + if (start) | |
| 658 | + ccm.start(); | |
| 659 | + return ccm; | |
| 660 | + } | |
| 661 | + | |
| 662 | + private String buildCreateCommand() { | |
| 663 | + StringBuilder result = new StringBuilder(CCM_COMMAND + " create"); | |
| 664 | + result.append(" " + clusterName); | |
| 665 | + result.append(" -i" + IP_PREFIX); | |
| 666 | + result.append(" " + cassandraVersion); | |
| 667 | + if (nodes.length > 0) | |
| 668 | + result.append(" -n " + Joiner.on(":").join(nodes)); | |
| 669 | + if (startOptions.length > 0) | |
| 670 | + result.append(" " + Joiner.on(" ").join(startOptions)); | |
| 671 | + return result.toString(); | |
| 672 | + } | |
| 673 | + } | |
| 651 | 674 | } |
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +16 −13
| @@ -15,15 +15,6 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 19 | -import com.datastax.driver.core.policies.ConstantReconnectionPolicy; | |
| 20 | -import com.datastax.driver.core.querybuilder.Insert; | |
| 21 | -import com.datastax.driver.core.utils.UUIDs; | |
| 22 | -import com.google.common.collect.Lists; | |
| 23 | -import org.slf4j.Logger; | |
| 24 | -import org.slf4j.LoggerFactory; | |
| 25 | -import org.testng.annotations.Test; | |
| 26 | - | |
| 27 | 18 | import java.net.InetAddress; |
| 28 | 19 | import java.net.InetSocketAddress; |
| 29 | 20 | import java.util.Collections; |
| @@ -31,10 +22,23 @@ | ||
| 31 | 22 | import java.util.concurrent.TimeUnit; |
| 32 | 23 | import java.util.concurrent.TimeoutException; |
| 33 | 24 | |
| 25 | +import com.google.common.collect.Lists; | |
| 26 | +import org.slf4j.Logger; | |
| 27 | +import org.slf4j.LoggerFactory; | |
| 28 | +import org.testng.annotations.Test; | |
| 29 | + | |
| 30 | +import static org.assertj.core.api.Assertions.fail; | |
| 31 | +import static org.mockito.Mockito.spy; | |
| 32 | +import static org.mockito.Mockito.times; | |
| 33 | +import static org.mockito.Mockito.verify; | |
| 34 | + | |
| 35 | +import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 36 | +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; | |
| 37 | +import com.datastax.driver.core.querybuilder.Insert; | |
| 38 | +import com.datastax.driver.core.utils.UUIDs; | |
| 39 | + | |
| 34 | 40 | import static com.datastax.driver.core.FakeHost.Behavior.THROWING_CONNECT_TIMEOUTS; |
| 35 | 41 | import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto; |
| 36 | -import static org.assertj.core.api.Assertions.fail; | |
| 37 | -import static org.mockito.Mockito.*; | |
| 38 | 42 | |
| 39 | 43 | public class ClusterInitTest { |
| 40 | 44 | private static final Logger logger = LoggerFactory.getLogger(ClusterInitTest.class); |
| @@ -52,8 +56,7 @@ | ||
| 52 | 56 | try { |
| 53 | 57 | // Obtaining connect timeouts is not trivial: we create a 6-host cluster but only start one of them, |
| 54 | 58 | // then simulate the other 5. |
| 55 | - ccm = CCMBridge.create("test"); | |
| 56 | - ccm.populate(6); | |
| 59 | + ccm = CCMBridge.builder("test").withNodes(6).notStarted().build(); | |
| 57 | 60 | ccm.start(1); |
| 58 | 61 | |
| 59 | 62 | for (int i = 0; i < 5; i++) { |
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +2 −2
| @@ -55,7 +55,7 @@ | ||
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | 57 | try { |
| 58 | - ccm = CCMBridge.create("test", 2); | |
| 58 | + ccm = CCMBridge.builder("test").withNodes(2).build(); | |
| 59 | 59 | // We pass only the first host as contact point, so we know the control connection will be on this host |
| 60 | 60 | cluster = Cluster.builder() |
| 61 | 61 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| @@ -96,7 +96,7 @@ | ||
| 96 | 96 | Cluster cluster = null; |
| 97 | 97 | |
| 98 | 98 | try { |
| 99 | - ccm = CCMBridge.create("test", 3); | |
| 99 | + ccm = CCMBridge.builder("test").withNodes(3).build(); | |
| 100 | 100 | |
| 101 | 101 | cluster = Cluster.builder() |
| 102 | 102 | .addContactPoint(CCMBridge.ipOfNode(1)) |
modified driver-core/src/test/java/com/datastax/driver/core/HeartbeatTest.java +2 −2
| @@ -57,7 +57,7 @@ | ||
| 57 | 57 | CCMBridge ccm = null; |
| 58 | 58 | Cluster cluster = null; |
| 59 | 59 | try { |
| 60 | - ccm = CCMBridge.create("test", 1); | |
| 60 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 61 | 61 | cluster = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)) |
| 62 | 62 | .withPoolingOptions(new PoolingOptions() |
| 63 | 63 | .setHeartbeatIntervalSeconds(3)) |
| @@ -121,7 +121,7 @@ | ||
| 121 | 121 | CCMBridge ccm = null; |
| 122 | 122 | Cluster cluster = null; |
| 123 | 123 | try { |
| 124 | - ccm = CCMBridge.create("test", 1); | |
| 124 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 125 | 125 | cluster = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)) |
| 126 | 126 | .withPoolingOptions(new PoolingOptions() |
| 127 | 127 | .setHeartbeatIntervalSeconds(0)) |
modified driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java +2 −2
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | CCMBridge ccm = null; |
| 52 | 52 | Cluster cluster = null; |
| 53 | 53 | try { |
| 54 | - ccm = CCMBridge.create("test", 2); | |
| 54 | + ccm = CCMBridge.builder("test").withNodes(2).build(); | |
| 55 | 55 | cluster = Cluster.builder() |
| 56 | 56 | .addContactPoints(CCMBridge.ipOfNode(1), CCMBridge.ipOfNode(2)) |
| 57 | 57 | .withLoadBalancingPolicy(policy) |
| @@ -86,7 +86,7 @@ | ||
| 86 | 86 | CCMBridge ccm = null; |
| 87 | 87 | Cluster cluster = null; |
| 88 | 88 | try { |
| 89 | - ccm = CCMBridge.create("test", 2); | |
| 89 | + ccm = CCMBridge.builder("test").withNodes(2).build(); | |
| 90 | 90 | |
| 91 | 91 | // In order to validate this behavior, we need to stop the first node that would be attempted to be |
| 92 | 92 | // established as the control connection. |
modified driver-core/src/test/java/com/datastax/driver/core/MetadataTest.java +1 −1
| @@ -54,7 +54,7 @@ | ||
| 54 | 54 | Cluster cluster = null; |
| 55 | 55 | |
| 56 | 56 | try { |
| 57 | - ccm = CCMBridge.create("test", 3); | |
| 57 | + ccm = CCMBridge.builder("test").withNodes(3).build(); | |
| 58 | 58 | |
| 59 | 59 | cluster = Cluster.builder() |
| 60 | 60 | .addContactPoint(CCMBridge.ipOfNode(1)) |
modified driver-core/src/test/java/com/datastax/driver/core/MissingRpcAddressTest.java +1 −1
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | |
| 37 | 37 | @Test(groups = "short") |
| 38 | 38 | public void testMissingRpcAddressAtStartup() throws Exception { |
| 39 | - CCMBridge ccm = CCMBridge.create("ccm", 2); | |
| 39 | + CCMBridge ccm = CCMBridge.builder("ccm").withNodes(2).build(); | |
| 40 | 40 | |
| 41 | 41 | Cluster cluster = null; |
| 42 | 42 | try { |
modified driver-core/src/test/java/com/datastax/driver/core/NettyOptionsTest.java +1 −1
| @@ -48,7 +48,7 @@ | ||
| 48 | 48 | public void should_invoke_netty_options_hooks(int hosts, int coreConnections) throws Exception { |
| 49 | 49 | //given |
| 50 | 50 | int expectedNumberOfCalls = coreConnections * hosts + 1; |
| 51 | - CCMBridge ccm = CCMBridge.createWithCustomVersion("test", hosts, "2.0.10"); | |
| 51 | + CCMBridge ccm = CCMBridge.builder("test").withNodes(hosts).withCassandraVersion("2.0.10").build(); | |
| 52 | 52 | Cluster cluster = null; |
| 53 | 53 | try { |
| 54 | 54 | NettyOptions nettyOptions = mock(NettyOptions.class, CALLS_REAL_METHODS.get()); |
modified driver-core/src/test/java/com/datastax/driver/core/RecommissionedNodeTest.java +8 −8
| @@ -44,7 +44,7 @@ | ||
| 44 | 44 | |
| 45 | 45 | @Test(groups = "long") |
| 46 | 46 | public void should_ignore_recommissioned_node_on_reconnection_attempt() throws Exception { |
| 47 | - mainCcm = CCMBridge.create("main", 3); | |
| 47 | + mainCcm = CCMBridge.builder("main").withNodes(3).build(); | |
| 48 | 48 | // node1 will be our "recommissioned" node, for now we just stop it so that it stays in the peers table. |
| 49 | 49 | mainCcm.stop(1); |
| 50 | 50 | mainCcm.waitForDown(1); |
| @@ -56,7 +56,7 @@ | ||
| 56 | 56 | // From that point, reconnections to node1 have been scheduled. |
| 57 | 57 | |
| 58 | 58 | // Start another ccm that will reuse node1's address |
| 59 | - otherCcm = CCMBridge.create("other", 1); | |
| 59 | + otherCcm = CCMBridge.builder("other").withNodes(1).build(); | |
| 60 | 60 | otherCcm.waitForUp(1); |
| 61 | 61 | |
| 62 | 62 | // Give the driver the time to notice the node is back up and try to connect to it. |
| @@ -67,7 +67,7 @@ | ||
| 67 | 67 | |
| 68 | 68 | @Test(groups = "long") |
| 69 | 69 | public void should_ignore_recommissioned_node_on_control_connection_reconnect() throws Exception { |
| 70 | - mainCcm = CCMBridge.create("main", 2); | |
| 70 | + mainCcm = CCMBridge.builder("main").withNodes(2).build(); | |
| 71 | 71 | mainCcm.stop(1); |
| 72 | 72 | mainCcm.waitForDown(1); |
| 73 | 73 | |
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | waitForCountUpHosts(mainCluster, 1); |
| 78 | 78 | |
| 79 | 79 | // Start another ccm that will reuse node1's address |
| 80 | - otherCcm = CCMBridge.create("other", 1); | |
| 80 | + otherCcm = CCMBridge.builder("other").withNodes(1).build(); | |
| 81 | 81 | otherCcm.waitForUp(1); |
| 82 | 82 | |
| 83 | 83 | // Stop node2, the control connection gets defunct |
| @@ -91,11 +91,11 @@ | ||
| 91 | 91 | @Test(groups = "long") |
| 92 | 92 | public void should_ignore_recommissioned_node_on_session_init() throws Exception { |
| 93 | 93 | // Simulate the bug before starting the cluster |
| 94 | - mainCcm = CCMBridge.create("main", 2); | |
| 94 | + mainCcm = CCMBridge.builder("main").withNodes(2).build(); | |
| 95 | 95 | mainCcm.stop(1); |
| 96 | 96 | mainCcm.waitForDown(1); |
| 97 | 97 | |
| 98 | - otherCcm = CCMBridge.create("other", 1); | |
| 98 | + otherCcm = CCMBridge.builder("other").withNodes(1).build(); | |
| 99 | 99 | otherCcm.waitForUp(1); |
| 100 | 100 | |
| 101 | 101 | // Start the driver, it should only connect to node 2 |
| @@ -119,11 +119,11 @@ | ||
| 119 | 119 | @CassandraVersion(major=2.0) |
| 120 | 120 | public void should_ignore_node_that_does_not_support_protocol_version_on_session_init() throws Exception { |
| 121 | 121 | // Simulate the bug before starting the cluster |
| 122 | - mainCcm = CCMBridge.create("main", 2); | |
| 122 | + mainCcm = CCMBridge.builder("main").withNodes(2).build(); | |
| 123 | 123 | mainCcm.stop(1); |
| 124 | 124 | mainCcm.waitForDown(1); |
| 125 | 125 | |
| 126 | - otherCcm = CCMBridge.createWithCustomVersion("main", 1, "1.2.19"); | |
| 126 | + otherCcm = CCMBridge.builder("main").withNodes(1).withCassandraVersion("1.2.19").build(); | |
| 127 | 127 | otherCcm.waitForUp(1); |
| 128 | 128 | |
| 129 | 129 | // Start the driver, it should only connect to node 2 |
modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +8 −8
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | CCMBridge ccm = null; |
| 54 | 54 | Cluster cluster = null; |
| 55 | 55 | try { |
| 56 | - ccm = CCMBridge.create("test", 2); | |
| 56 | + ccm = CCMBridge.builder("test").withNodes(2).build(); | |
| 57 | 57 | int reconnectionDelay = 1000; |
| 58 | 58 | cluster = Cluster.builder() |
| 59 | 59 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| @@ -90,10 +90,10 @@ | ||
| 90 | 90 | CCMBridge ccm = null; |
| 91 | 91 | Cluster cluster = null; |
| 92 | 92 | try { |
| 93 | - ccm = CCMBridge.create("test"); | |
| 94 | - ccm.populate(1); | |
| 95 | - // Configure password authentication on the server (default: cassandra / cassandra) | |
| 96 | - ccm.updateConfig("authenticator", "PasswordAuthenticator"); | |
| 93 | + ccm = CCMBridge.builder("test") | |
| 94 | + .withCassandraConfiguration("authenticator", "PasswordAuthenticator") // default credentials: cassandra / cassandra | |
| 95 | + .notStarted() | |
| 96 | + .build(); | |
| 97 | 97 | ccm.start(1, "-Dcassandra.superuser_setup_delay_ms=0"); |
| 98 | 98 | |
| 99 | 99 | DynamicPlainTextAuthProvider authProvider = new DynamicPlainTextAuthProvider("cassandra", "cassandra"); |
| @@ -149,7 +149,7 @@ | ||
| 149 | 149 | CountingReconnectionPolicy reconnectionPolicy = new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)); |
| 150 | 150 | |
| 151 | 151 | try { |
| 152 | - ccm = CCMBridge.create("test", 2); | |
| 152 | + ccm = CCMBridge.builder("test").withNodes(2).build(); | |
| 153 | 153 | cluster = Cluster.builder() |
| 154 | 154 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 155 | 155 | .withReconnectionPolicy(reconnectionPolicy) |
| @@ -190,7 +190,7 @@ | ||
| 190 | 190 | TogglabePolicy loadBalancingPolicy = new TogglabePolicy(new RoundRobinPolicy()); |
| 191 | 191 | |
| 192 | 192 | try { |
| 193 | - ccm = CCMBridge.create("test", 1); | |
| 193 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 194 | 194 | cluster = Cluster.builder() |
| 195 | 195 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 196 | 196 | .withLoadBalancingPolicy(loadBalancingPolicy) |
| @@ -256,7 +256,7 @@ | ||
| 256 | 256 | SocketOptions socketOptions = spy(new SocketOptions()); |
| 257 | 257 | |
| 258 | 258 | try { |
| 259 | - ccm = CCMBridge.create("test", 1); | |
| 259 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 260 | 260 | cluster = Cluster.builder() |
| 261 | 261 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 262 | 262 | .withReconnectionPolicy(new ConstantReconnectionPolicy(5000)) |
modified driver-core/src/test/java/com/datastax/driver/core/RefreshConnectedHostTest.java +1 −2
| @@ -41,8 +41,7 @@ | ||
| 41 | 41 | LimitingLoadBalancingPolicy loadBalancingPolicy = new LimitingLoadBalancingPolicy(new RoundRobinPolicy(), 2, 1); |
| 42 | 42 | |
| 43 | 43 | // Setup a 3-host cluster, start only two hosts so that we know in advance which ones the policy will use |
| 44 | - ccm = CCMBridge.create("test"); | |
| 45 | - ccm.populate(3); | |
| 44 | + ccm = CCMBridge.builder("test").withNodes(3).notStarted().build(); | |
| 46 | 45 | ccm.start(1); |
| 47 | 46 | ccm.start(2); |
| 48 | 47 | ccm.waitForUp(1); |
modified driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java +3 −10
| @@ -17,7 +17,6 @@ | ||
| 17 | 17 | |
| 18 | 18 | import java.security.KeyStore; |
| 19 | 19 | import java.security.SecureRandom; |
| 20 | -import java.util.concurrent.TimeUnit; | |
| 21 | 20 | |
| 22 | 21 | import com.google.common.base.Optional; |
| 23 | 22 | import javax.net.ssl.KeyManagerFactory; |
| @@ -25,15 +24,9 @@ | ||
| 25 | 24 | import javax.net.ssl.TrustManagerFactory; |
| 26 | 25 | import org.testng.annotations.AfterClass; |
| 27 | 26 | import org.testng.annotations.BeforeClass; |
| 28 | -import org.testng.annotations.Test; | |
| 29 | 27 | |
| 30 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 31 | - | |
| 32 | -import static com.datastax.driver.core.Assertions.assertThat; | |
| 33 | 28 | import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_KEYSTORE_PASSWORD; |
| 34 | -import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_KEYSTORE_PATH; | |
| 35 | 29 | import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_TRUSTSTORE_PASSWORD; |
| 36 | -import static com.datastax.driver.core.CCMBridge.DEFAULT_CLIENT_TRUSTSTORE_PATH; | |
| 37 | 30 | public abstract class SSLTestBase { |
| 38 | 31 | |
| 39 | 32 | private final boolean requireClientAuth; |
| @@ -46,9 +39,9 @@ | ||
| 46 | 39 | |
| 47 | 40 | @BeforeClass(groups={"short", "long"}) |
| 48 | 41 | public void beforeClass() { |
| 49 | - ccm = CCMBridge.create("test"); | |
| 50 | - ccm.enableSSL(requireClientAuth); | |
| 51 | - ccm.bootstrapNode(1); | |
| 42 | + ccm = CCMBridge.builder("test") | |
| 43 | + .withSSL(requireClientAuth) | |
| 44 | + .build(); | |
| 52 | 45 | } |
| 53 | 46 | |
| 54 | 47 | @AfterClass(groups={"short", "long"}) |
modified driver-core/src/test/java/com/datastax/driver/core/SchemaAgreementTest.java +1 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | |
| 42 | 42 | @BeforeClass(groups = "short") |
| 43 | 43 | public void setup() { |
| 44 | - ccm = CCMBridge.create("schema_agreement", 2); | |
| 44 | + ccm = CCMBridge.builder("schema_agreement").withNodes(2).build(); | |
| 45 | 45 | cluster = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)).build(); |
| 46 | 46 | session = cluster.connect(); |
| 47 | 47 | session.execute("create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); |
modified driver-core/src/test/java/com/datastax/driver/core/SchemaChangesTest.java +1 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | |
| 42 | 42 | @BeforeClass(groups = "short") |
| 43 | 43 | public void setup() { |
| 44 | - ccm = CCMBridge.create("schemaChangesTest", 1); | |
| 44 | + ccm = CCMBridge.builder("schemaChangesTest").withNodes(1).build(); | |
| 45 | 45 | |
| 46 | 46 | cluster = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)).build(); |
| 47 | 47 | cluster2 = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)).build(); |
modified driver-core/src/test/java/com/datastax/driver/core/SessionLeakTest.java +2 −6
| @@ -27,13 +27,9 @@ | ||
| 27 | 27 | import static org.testng.Assert.assertEquals; |
| 28 | 28 | import static java.util.concurrent.TimeUnit.MINUTES; |
| 29 | 29 | |
| 30 | -import com.google.common.collect.Lists; | |
| 31 | -import org.testng.annotations.Test; | |
| 32 | - | |
| 33 | 30 | import static org.assertj.core.api.Assertions.fail; |
| 34 | 31 | |
| 35 | 32 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 36 | -import com.datastax.driver.core.utils.SocketChannelMonitor; | |
| 37 | 33 | |
| 38 | 34 | import static com.datastax.driver.core.Assertions.assertThat; |
| 39 | 35 | |
| @@ -50,7 +46,7 @@ | ||
| 50 | 46 | public void connectionLeakTest() throws Exception { |
| 51 | 47 | // Checking for JAVA-342 |
| 52 | 48 | CCMBridge ccmBridge; |
| 53 | - ccmBridge = CCMBridge.create("test", 1); | |
| 49 | + ccmBridge = CCMBridge.builder("test").withNodes(1).build(); | |
| 54 | 50 | channelMonitor = new SocketChannelMonitor(); |
| 55 | 51 | channelMonitor.reportAtFixedInterval(1, TimeUnit.SECONDS); |
| 56 | 52 | try { |
| @@ -113,7 +109,7 @@ | ||
| 113 | 109 | public void should_not_leak_session_when_wrong_keyspace() throws Exception { |
| 114 | 110 | // Checking for JAVA-806 |
| 115 | 111 | CCMBridge ccmBridge; |
| 116 | - ccmBridge = CCMBridge.create("test", 1); | |
| 112 | + ccmBridge = CCMBridge.builder("test").withNodes(1).build(); | |
| 117 | 113 | channelMonitor = new SocketChannelMonitor(); |
| 118 | 114 | channelMonitor.reportAtFixedInterval(1, TimeUnit.SECONDS); |
| 119 | 115 | try { |
modified driver-core/src/test/java/com/datastax/driver/core/SingleTokenIntegrationTest.java +4 −5
| @@ -34,11 +34,10 @@ | ||
| 34 | 34 | Cluster cluster = null; |
| 35 | 35 | |
| 36 | 36 | try { |
| 37 | - ccm = CCMBridge.create("test"); | |
| 38 | - // force the initial token to a non-min value to validate that the single range will always be ]minToken, minToken] | |
| 39 | - ccm.updateConfig("initial_token", "1"); | |
| 40 | - ccm.bootstrapNode(1); | |
| 41 | - ccm.start(); | |
| 37 | + ccm = CCMBridge.builder("test") | |
| 38 | + // force the initial token to a non-min value to validate that the single range will always be ]minToken, minToken] | |
| 39 | + .withCassandraConfiguration("initial_token", "1") | |
| 40 | + .build(); | |
| 42 | 41 | |
| 43 | 42 | cluster = Cluster.builder().addContactPoint(CCMBridge.ipOfNode(1)).build(); |
| 44 | 43 |
modified driver-core/src/test/java/com/datastax/driver/core/TimeoutStressTest.java +1 −1
| @@ -70,7 +70,7 @@ | ||
| 70 | 70 | |
| 71 | 71 | @BeforeClass(groups = "long") |
| 72 | 72 | public void beforeClass() throws Exception { |
| 73 | - ccmBridge = CCMBridge.create("test", 3); | |
| 73 | + ccmBridge = CCMBridge.builder("test").withNodes(3).build(); | |
| 74 | 74 | channelMonitor = new SocketChannelMonitor(); |
| 75 | 75 | nodes = Lists.newArrayList( |
| 76 | 76 | new InetSocketAddress(CCMBridge.IP_PREFIX + '1', 9042), |
modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +1 −1
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | |
| 73 | 73 | @BeforeClass(groups = "short") |
| 74 | 74 | public void setup() { |
| 75 | - ccm = CCMBridge.create("test", 3, ccmOptions); | |
| 75 | + ccm = CCMBridge.builder("test").withNodes(3).withStartOptions(ccmOptions).build(); | |
| 76 | 76 | |
| 77 | 77 | // Only connect to node 1, which makes it easier to query system tables in should_expose_tokens_per_host() |
| 78 | 78 | LoadBalancingPolicy lbp = new WhiteListPolicy(new RoundRobinPolicy(), |
modified driver-core/src/test/java/com/datastax/driver/core/policies/CloseableLoadBalancingPolicyTest.java +1 −1
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | CCMBridge ccm = null; |
| 30 | 30 | Cluster cluster = null; |
| 31 | 31 | try { |
| 32 | - ccm = CCMBridge.create("test", 1); | |
| 32 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 33 | 33 | cluster = Cluster.builder() |
| 34 | 34 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 35 | 35 | .withLoadBalancingPolicy(policy) |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DCAwareRoundRobinPolicyTest.java +1 −1
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | @BeforeClass(groups = "short") |
| 37 | 37 | public void createCcm() { |
| 38 | 38 | // Two-DC cluster with one host in each DC |
| 39 | - ccm = CCMBridge.create("test", 1, 1); | |
| 39 | + ccm = CCMBridge.builder("test").withNodes(1, 1).build(); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | @AfterClass(groups = "short") |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DowngradingConsistencyRetryPolicyIntegrationTest.java +1 −1
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | Cluster cluster = null; |
| 47 | 47 | try { |
| 48 | 48 | // 3-node cluster, keyspace with RF = 3 |
| 49 | - ccm = CCMBridge.create(this.getClass().getName(), 3); | |
| 49 | + ccm = CCMBridge.builder(this.getClass().getName()).withNodes(3).build(); | |
| 50 | 50 | cluster = Cluster.builder() |
| 51 | 51 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 52 | 52 | .withRetryPolicy(Mockito.spy(DowngradingConsistencyRetryPolicy.INSTANCE)) |
modified driver-core/src/test/java/com/datastax/driver/core/policies/TokenAwarePolicyTest.java +1 −3
| @@ -16,9 +16,7 @@ | ||
| 16 | 16 | package com.datastax.driver.core.policies; |
| 17 | 17 | |
| 18 | 18 | import java.nio.ByteBuffer; |
| 19 | -import java.util.ArrayList; | |
| 20 | 19 | import java.util.List; |
| 21 | -import java.util.Set; | |
| 22 | 20 | |
| 23 | 21 | import static org.assertj.core.api.Assertions.assertThat; |
| 24 | 22 | import com.google.common.collect.Lists; |
| @@ -44,7 +42,7 @@ | ||
| 44 | 42 | CCMBridge ccm = null; |
| 45 | 43 | Cluster cluster = null; |
| 46 | 44 | try { |
| 47 | - ccm = CCMBridge.create("test", 3); | |
| 45 | + ccm = CCMBridge.builder("test").withNodes(3).build(); | |
| 48 | 46 | cluster = Cluster.builder() |
| 49 | 47 | .addContactPoint(CCMBridge.ipOfNode(1)) |
| 50 | 48 | .withLoadBalancingPolicy(loadBalancingPolicy) |
modified driver-examples/osgi/src/test/java/com/datastax/driver/osgi/CCMBridgeListener.java +1 −1
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | private CCMBridge ccm; |
| 34 | 34 | |
| 35 | 35 | @Override public void onStart(ITestContext context) { |
| 36 | - ccm = CCMBridge.create("test", 1); | |
| 36 | + ccm = CCMBridge.builder("test").withNodes(1).build(); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | @Override public void onFinish(ITestContext context) { |