Search in sources :

Example 6 with CassandraVersion

use of com.datastax.driver.core.utils.CassandraVersion in project java-driver by datastax.

the class IndexMetadataTest method should_create_metadata_for_index_on_map_values.

@Test(groups = "short")
@CassandraVersion("2.1.0")
public void should_create_metadata_for_index_on_map_values() {
    // 3.0 assumes the 'values' keyword if index on a collection
    String createValuesIndex = ccm().getCassandraVersion().getMajor() > 2 ? String.format("CREATE INDEX map_values_index ON %s.indexing (values(map_values));", keyspace) : String.format("CREATE INDEX map_values_index ON %s.indexing (map_values);", keyspace);
    session().execute(createValuesIndex);
    ColumnMetadata column = getColumn("map_values");
    IndexMetadata index = getIndex("map_values_index");
    assertThat(index).hasName("map_values_index").hasParent((TableMetadata) column.getParent()).isNotCustomIndex().hasTarget(ccm().getCassandraVersion().getMajor() > 2 ? "values(map_values)" : "map_values").hasKind(COMPOSITES).asCqlQuery(createValuesIndex);
    assertThat((TableMetadata) column.getParent()).hasIndex(index);
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Example 7 with CassandraVersion

use of com.datastax.driver.core.utils.CassandraVersion in project java-driver by datastax.

the class IndexMetadataTest method should_create_metadata_for_full_index_on_list.

@Test(groups = "short")
@CassandraVersion("2.1.3")
public void should_create_metadata_for_full_index_on_list() {
    String createFullIndex = String.format("CREATE INDEX list_full_index ON %s.indexing (full(list_full));", keyspace);
    session().execute(createFullIndex);
    ColumnMetadata column = getColumn("list_full");
    IndexMetadata index = getIndex("list_full_index");
    assertThat(index).hasName("list_full_index").hasParent((TableMetadata) column.getParent()).isNotCustomIndex().hasTarget("full(list_full)").hasKind(COMPOSITES).asCqlQuery(createFullIndex);
    assertThat((TableMetadata) column.getParent()).hasIndex(index);
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Example 8 with CassandraVersion

use of com.datastax.driver.core.utils.CassandraVersion in project java-driver by datastax.

the class IndexMetadataTest method should_create_metadata_for_full_index_on_set.

@Test(groups = "short")
@CassandraVersion("2.1.3")
public void should_create_metadata_for_full_index_on_set() {
    String createFullIndex = String.format("CREATE INDEX set_full_index ON %s.indexing (full(set_full));", keyspace);
    session().execute(createFullIndex);
    ColumnMetadata column = getColumn("set_full");
    IndexMetadata index = getIndex("set_full_index");
    assertThat(index).hasName("set_full_index").hasParent((TableMetadata) column.getParent()).isNotCustomIndex().hasTarget("full(set_full)").hasKind(COMPOSITES).asCqlQuery(createFullIndex);
    assertThat((TableMetadata) column.getParent()).hasIndex(index);
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Example 9 with CassandraVersion

use of com.datastax.driver.core.utils.CassandraVersion in project java-driver by datastax.

the class QueryLoggerTest method should_log_wrapped_bound_statement.

@CassandraVersion("2.0.0")
@Test(groups = "short")
public void should_log_wrapped_bound_statement() throws Exception {
    // given
    normal.setLevel(TRACE);
    queryLogger = QueryLogger.builder().withConstantThreshold(Long.MAX_VALUE).withMaxQueryStringLength(Integer.MAX_VALUE).build();
    cluster().register(queryLogger);
    // when
    String query = "UPDATE test SET c_text = :param1 WHERE pk = :param2";
    PreparedStatement ps = session().prepare(query);
    BoundStatement bs = ps.bind();
    bs.setString("param1", "foo");
    bs.setInt("param2", 42);
    session().execute(new CustomStatement(bs));
    // then
    String line = normalAppender.waitAndGet(10000);
    assertThat(line).contains("Query completed normally").contains(ipOfNode(1)).contains(query).contains("param2:42").contains("param1:'foo'");
}
Also used : CustomStatement(com.datastax.driver.core.StatementWrapperTest.CustomStatement) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Example 10 with CassandraVersion

use of com.datastax.driver.core.utils.CassandraVersion in project java-driver by datastax.

the class ProtocolVersionRenegotiationTest method should_fail_when_version_provided_and_too_low_3_8_plus.

/**
 * @jira_ticket JAVA-1367
 */
@Test(groups = "short")
@CassandraVersion("3.8")
public void should_fail_when_version_provided_and_too_low_3_8_plus() throws Exception {
    UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V1);
    assertThat(e.getUnsupportedVersion()).isEqualTo(V1);
    // post-CASSANDRA-11464: server replies with client's version
    assertThat(e.getServerVersion()).isEqualTo(V1);
}
Also used : UnsupportedProtocolVersionException(com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Aggregations

CassandraVersion (com.datastax.driver.core.utils.CassandraVersion)16 Test (org.testng.annotations.Test)15 ColumnMetadata (com.datastax.driver.core.ColumnMetadata)8 Row (com.datastax.driver.core.Row)3 ResultSet (com.datastax.driver.core.ResultSet)2 CustomStatement (com.datastax.driver.core.StatementWrapperTest.CustomStatement)1 UnsupportedProtocolVersionException (com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException)1 DseVersion (com.datastax.driver.core.utils.DseVersion)1 Option (com.datastax.driver.mapping.Mapper.Option)1 Pattern (java.util.regex.Pattern)1