/** * Verifies that the cluster builder fails when beta flag is set and user attempts to pass a * version explicitly. * * @jira_ticket JAVA-1248 */ @Test(groups = "short") public void should_not_initialize_when_beta_flag_is_set_and_version_explicitly_required() throws Exception { try { Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .withProtocolVersion(V4) .build(); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { assertThat(e.getMessage()) .isEqualTo("Can not set the version explicitly if `allowBetaProtocolVersion` was used."); } }
/** * Verifies that the cluster builder fails when version is explicitly set and user attempts to set * beta flag. * * @jira_ticket JAVA-1248 */ @Test(groups = "short") public void should_not_initialize_when_version_explicitly_required_and_beta_flag_is_set() throws Exception { try { Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withProtocolVersion(V4) .allowBetaProtocolVersion() .build(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()) .isEqualTo("Can't use beta flag with initial protocol version of V4"); } }
/** * Verifies that the driver can connect to 3.10 with the following combination of options: Version * UNSET Flag SET Expected version: V5 * * @jira_ticket JAVA-1248 */ @Test(groups = "short") public void should_connect_with_beta_when_no_version_explicitly_required_and_flag_set() throws Exception { // Note: when the driver's ProtocolVersion.NEWEST_SUPPORTED will be incremented to V6 or higher // a renegotiation will start taking place here and will downgrade the version from V6 to V5, // but the test should remain valid since it's executed against 3.10 exclusively Cluster cluster = Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .build(); cluster.connect(); assertThat(cluster.getConfiguration().getProtocolOptions().getProtocolVersion()).isEqualTo(V5); }
/** * Verifies that the cluster builder fails when version is explicitly set and user attempts to set * beta flag. * * @jira_ticket JAVA-1248 */ @Test(groups = "short", enabled = false) public void should_not_initialize_when_version_explicitly_required_and_beta_flag_is_set() throws Exception { try { Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withProtocolVersion(V4) .allowBetaProtocolVersion() .build(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()) .isEqualTo("Can't use beta flag with initial protocol version of V4"); } }
/** * Verifies that the driver can connect to 3.10 with the following combination of options: Version * UNSET Flag SET Expected version: V5 * * @jira_ticket JAVA-1248 */ @Test(groups = "short", enabled = false) public void should_connect_with_beta_when_no_version_explicitly_required_and_flag_set() throws Exception { // Note: when the driver's ProtocolVersion.NEWEST_SUPPORTED will be incremented to V6 or higher // a renegotiation will start taking place here and will downgrade the version from V6 to V5, // but the test should remain valid since it's executed against 3.10 exclusively Cluster cluster = Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .build(); cluster.connect(); assertThat(cluster.getConfiguration().getProtocolOptions().getProtocolVersion()).isEqualTo(V5); }
/** * Verifies that the cluster builder fails when beta flag is set and user attempts to pass a * version explicitly. * * @jira_ticket JAVA-1248 */ @Test(groups = "short", enabled = false) public void should_not_initialize_when_beta_flag_is_set_and_version_explicitly_required() throws Exception { try { Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .withProtocolVersion(V4) .build(); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { assertThat(e.getMessage()) .isEqualTo("Can not set the version explicitly if `allowBetaProtocolVersion` was used."); } }
private UnsupportedProtocolVersionException connectWithUnsupportedBetaVersion() { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .build()); return initWithUnsupportedVersion(cluster); }
@Override public Cluster.Builder createClusterBuilder() { // TODO remove when protocol v5 is stable in C* 4 return super.createClusterBuilderNoDebouncing().allowBetaProtocolVersion(); }
private UnsupportedProtocolVersionException connectWithUnsupportedBetaVersion() { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .allowBetaProtocolVersion() .build()); return initWithUnsupportedVersion(cluster); }