Search in sources :

Example 1 with BatchExecution

use of org.scassandra.http.client.BatchExecution in project java-driver by datastax.

the class ConsistencyTest method should_use_query_option_serial_cl.

/**
 * Exhaustively tests all serial consistency levels when they are set via QueryOptions.
 *
 * @test_category consistency
 */
@Test(groups = "short", dataProvider = "serialConsistencyLevels", dataProviderClass = DataProviders.class)
public void should_use_query_option_serial_cl(ConsistencyLevel cl) throws Throwable {
    // Build a cluster with a CL level set in the query options.
    Cluster cluster = builder().withQueryOptions(new QueryOptions().setSerialConsistencyLevel(cl)).build();
    try {
        Session session = cluster.connect();
        // Construct unique query, with no CL defined.
        String queryString = "serial_query_cl";
        Query clQuery = executeSimple(session, queryString, null, cl);
        checkSerialCLMatch(cl, clQuery.getSerialConsistency());
        // Check prepared statement CL
        String prepareString = "preapred_statement_serial_cl";
        PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
        checkSerialCLMatch(cl, pse.getSerialConsistency());
        // Check batch statement CL
        String batchStateString = "batch_statement_serial_cl";
        BatchExecution batch = executeBatch(session, batchStateString, null, null);
        checkSerialCLMatch(cl, batch.getSerialConsistency());
    } finally {
        cluster.close();
    }
}
Also used : Query(org.scassandra.http.client.Query) BatchExecution(org.scassandra.http.client.BatchExecution) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) Test(org.testng.annotations.Test)

Example 2 with BatchExecution

use of org.scassandra.http.client.BatchExecution in project java-driver by datastax.

the class ConsistencyTest method should_use_global_default_cl_when_none_specified.

/**
 * When no consistency level is defined the default of LOCAL_ONE should be used.
 *
 * @test_category consistency
 */
@Test(groups = "short")
public void should_use_global_default_cl_when_none_specified() throws Throwable {
    // Build a cluster with no CL level set in the query options.
    Cluster cluster = builder().build();
    try {
        Session session = cluster.connect();
        // Construct unique simple statement query, with no CL defined.
        // Check to ensure
        String queryString = "default_cl";
        Query clQuery = executeSimple(session, queryString, null, null);
        assertTrue(clQuery.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
        // Check prepared statement default CL
        String prepareString = "prepared_default_cl";
        PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
        assertTrue(pse.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
        // Check batch statement default CL
        String batchStateString = "batch_default_cl";
        BatchExecution batch = executeBatch(session, batchStateString, null, null);
        assertTrue(batch.getConsistency().equals(ConsistencyLevel.LOCAL_ONE.toString()));
    } finally {
        cluster.close();
    }
}
Also used : Query(org.scassandra.http.client.Query) BatchExecution(org.scassandra.http.client.BatchExecution) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) Test(org.testng.annotations.Test)

Example 3 with BatchExecution

use of org.scassandra.http.client.BatchExecution in project java-driver by datastax.

the class ConsistencyTest method should_use_statement_cl.

/**
 * Exhaustively tests all consistency levels when they are set at the statement level.
 *
 * @test_category consistency
 */
@Test(groups = "short", dataProvider = "consistencyLevels", dataProviderClass = DataProviders.class)
public void should_use_statement_cl(ConsistencyLevel cl) throws Throwable {
    // Build a cluster with no CL set in the query options.
    // Note: nonQuietClusterCloseOptions is used to speed up tests
    Cluster cluster = builder().build();
    try {
        Session session = cluster.connect();
        // Construct unique query statement with a CL defined.
        String queryString = "statement_cl";
        Query clQuery = executeSimple(session, queryString, cl, null);
        assertTrue(clQuery.getConsistency().equals(cl.toString()));
        // Check prepared statement CL
        String prepareString = "preapred_statement_cl";
        PreparedStatementExecution pse = executePrepared(session, prepareString, cl, null);
        assertTrue(pse.getConsistency().equals(cl.toString()));
        // Check batch statement CL
        String batchStateString = "batch_statement_cl";
        BatchExecution batch = executeBatch(session, batchStateString, cl, null);
        assertTrue(batch.getConsistency().equals(cl.toString()));
    } finally {
        cluster.close();
    }
}
Also used : Query(org.scassandra.http.client.Query) BatchExecution(org.scassandra.http.client.BatchExecution) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) Test(org.testng.annotations.Test)

Example 4 with BatchExecution

use of org.scassandra.http.client.BatchExecution in project java-driver by datastax.

the class ConsistencyTest method should_use_query_option_cl.

/**
 * Exhaustively tests all consistency levels when they are set via QueryOptions.
 *
 * @test_category consistency
 */
@Test(groups = "short", dataProvider = "consistencyLevels", dataProviderClass = DataProviders.class)
public void should_use_query_option_cl(ConsistencyLevel cl) throws Throwable {
    // Build a cluster with a CL level set in the query options.
    Cluster cluster = builder().withQueryOptions(new QueryOptions().setConsistencyLevel(cl)).build();
    try {
        Session session = cluster.connect();
        // Construct unique query, with no CL defined.
        String queryString = "query_cl";
        Query clQuery = executeSimple(session, queryString, null, null);
        assertTrue(clQuery.getConsistency().equals(cl.toString()));
        // Check prepared statement CL
        String prepareString = "preapred_query_cl";
        PreparedStatementExecution pse = executePrepared(session, prepareString, null, null);
        assertTrue(pse.getConsistency().equals(cl.toString()));
        // Check batch statement CL
        String batchStateString = "batch_query_cl";
        BatchExecution batch = executeBatch(session, batchStateString, null, null);
        assertTrue(batch.getConsistency().equals(cl.toString()));
    } finally {
        cluster.close();
    }
}
Also used : Query(org.scassandra.http.client.Query) BatchExecution(org.scassandra.http.client.BatchExecution) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) Test(org.testng.annotations.Test)

Example 5 with BatchExecution

use of org.scassandra.http.client.BatchExecution in project java-driver by datastax.

the class ConsistencyTest method should_use_statement_serial_cl.

/**
 * Exhaustively tests all serial consistency levels when they are set at the statement level.
 *
 * @test_category consistency
 */
@Test(groups = "short", dataProvider = "serialConsistencyLevels", dataProviderClass = DataProviders.class)
public void should_use_statement_serial_cl(ConsistencyLevel cl) throws Throwable {
    // Build a cluster with no CL set in the query options.
    Cluster cluster = builder().build();
    try {
        Session session = cluster.connect();
        // Construct unique query statement with a CL defined.
        String queryString = "statement_serial_cl";
        Query clQuery = executeSimple(session, queryString, null, cl);
        checkSerialCLMatch(cl, clQuery.getSerialConsistency());
        // Check prepared statement CL
        String prepareString = "preapred_statement_serial_cl";
        PreparedStatementExecution pse = executePrepared(session, prepareString, null, cl);
        checkSerialCLMatch(cl, pse.getSerialConsistency());
        // Check batch statement CL
        String batchStateString = "batch_statement_serial_cl";
        BatchExecution batch = executeBatch(session, batchStateString, null, cl);
        checkSerialCLMatch(cl, batch.getSerialConsistency());
    } finally {
        cluster.close();
    }
}
Also used : Query(org.scassandra.http.client.Query) BatchExecution(org.scassandra.http.client.BatchExecution) PreparedStatementExecution(org.scassandra.http.client.PreparedStatementExecution) Test(org.testng.annotations.Test)

Aggregations

BatchExecution (org.scassandra.http.client.BatchExecution)6 PreparedStatementExecution (org.scassandra.http.client.PreparedStatementExecution)6 Query (org.scassandra.http.client.Query)6 Test (org.testng.annotations.Test)6