Search in sources :

Example 16 with CassandraRequirement

use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.

the class PerRequestKeyspaceIT method should_reject_batch_statement_with_explicit_keyspace_in_protocol_v4.

@Test
@CassandraRequirement(min = "2.2")
public void should_reject_batch_statement_with_explicit_keyspace_in_protocol_v4() {
    SimpleStatement statementWithoutKeyspace = SimpleStatement.newInstance("INSERT INTO foo (k, cc, v) VALUES (?, ?, ?)", nameRule.getMethodName(), 1, 1);
    should_reject_statement_with_keyspace_in_protocol_v4(BatchStatement.builder(DefaultBatchType.LOGGED).setKeyspace(sessionRule.keyspace()).addStatement(statementWithoutKeyspace).build());
}
Also used : SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) Test(org.junit.Test) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement)

Example 17 with CassandraRequirement

use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.

the class PerRequestKeyspaceIT method should_reject_batch_statement_with_inferred_keyspace_in_protocol_v4.

@Test
@CassandraRequirement(min = "2.2")
public void should_reject_batch_statement_with_inferred_keyspace_in_protocol_v4() {
    SimpleStatement statementWithKeyspace = SimpleStatement.newInstance("INSERT INTO foo (k, cc, v) VALUES (?, ?, ?)", nameRule.getMethodName(), 1, 1).setKeyspace(sessionRule.keyspace());
    should_reject_statement_with_keyspace_in_protocol_v4(BatchStatement.builder(DefaultBatchType.LOGGED).addStatement(statementWithKeyspace).build());
}
Also used : SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) Test(org.junit.Test) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement)

Example 18 with CassandraRequirement

use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.

the class PerRequestKeyspaceIT method should_execute_batch_with_inferred_keyspace.

@Test
@CassandraRequirement(min = "4.0")
public void should_execute_batch_with_inferred_keyspace() {
    CqlSession session = sessionRule.session();
    session.execute(BatchStatement.builder(DefaultBatchType.LOGGED).setKeyspace(sessionRule.keyspace()).addStatements(SimpleStatement.newInstance("INSERT INTO foo (k, cc, v) VALUES (?, ?, ?)", nameRule.getMethodName(), 1, 1).setKeyspace(sessionRule.keyspace()), SimpleStatement.newInstance("INSERT INTO foo (k, cc, v) VALUES (?, ?, ?)", nameRule.getMethodName(), 2, 2).setKeyspace(sessionRule.keyspace())).build());
    Row row = session.execute(SimpleStatement.newInstance("SELECT v FROM foo WHERE k = ? AND cc = 1", nameRule.getMethodName()).setKeyspace(sessionRule.keyspace())).one();
    assertThat(row.getInt(0)).isEqualTo(1);
}
Also used : Row(com.datastax.oss.driver.api.core.cql.Row) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.Test) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement)

Example 19 with CassandraRequirement

use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.

the class ProtocolVersionInitialNegotiationIT method should_downgrade_to_v5_oss.

@CassandraRequirement(min = "4.0-rc1", description = "Only C* in [4.0-rc1,*[ has V5 as its highest version")
@Test
public void should_downgrade_to_v5_oss() {
    Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
    try (CqlSession session = SessionUtils.newSession(ccm)) {
        assertThat(session.getContext().getProtocolVersion().getCode()).isEqualTo(5);
        session.execute("select * from system.local");
    }
}
Also used : CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.Test) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement)

Example 20 with CassandraRequirement

use of com.datastax.oss.driver.api.testinfra.CassandraRequirement in project java-driver by datastax.

the class ProtocolVersionInitialNegotiationIT method should_not_downgrade_if_server_supports_latest_version_oss.

/**
 * Note that this test will need to be updated as new protocol versions are introduced.
 */
@CassandraRequirement(min = "4.0", description = "Only C* in [4.0,*[ has V5 supported")
@Test
public void should_not_downgrade_if_server_supports_latest_version_oss() {
    Assume.assumeFalse("This test is only for OSS C*", ccm.getDseVersion().isPresent());
    try (CqlSession session = SessionUtils.newSession(ccm)) {
        assertThat(session.getContext().getProtocolVersion()).isEqualTo(ProtocolVersion.V5);
        session.execute("select * from system.local");
    }
}
Also used : CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.Test) CassandraRequirement(com.datastax.oss.driver.api.testinfra.CassandraRequirement)

Aggregations

CassandraRequirement (com.datastax.oss.driver.api.testinfra.CassandraRequirement)29 Test (org.junit.Test)27 CqlSession (com.datastax.oss.driver.api.core.CqlSession)21 PreparedStatement (com.datastax.oss.driver.api.core.cql.PreparedStatement)8 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)7 ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)6 Row (com.datastax.oss.driver.api.core.cql.Row)6 ByteBuffer (java.nio.ByteBuffer)5 AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)3 BoundStatement (com.datastax.oss.driver.api.core.cql.BoundStatement)3 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)3 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)3 AllNodesFailedException (com.datastax.oss.driver.api.core.AllNodesFailedException)2 UnsupportedProtocolVersionException (com.datastax.oss.driver.api.core.UnsupportedProtocolVersionException)2 Version (com.datastax.oss.driver.api.core.Version)2 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)2 ColumnMetadata (com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata)2 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)2 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)2 DseRequirement (com.datastax.oss.driver.api.testinfra.DseRequirement)2