@Override protected boolean match(PreparedStatementExecution actualPreparedStatementExecution) { List<CqlType> variableTypes = actualPreparedStatementExecution.getVariableTypes(); List<Object> actualVariables = actualPreparedStatementExecution.getVariables(); if (!actualPreparedStatementExecution.getConsistency().equals(expectedPreparedStatementExecution.getConsistency())) return false; if (!actualPreparedStatementExecution.getPreparedStatementText().equals(expectedPreparedStatementExecution.getPreparedStatementText())) return false; List<Object> expectedVariables = expectedPreparedStatementExecution.getVariables(); return checkVariables(expectedVariables, variableTypes, actualVariables); } }
public PreparedStatementExecution build() { if (preparedStatementText == null) { throw new IllegalStateException("Must set preparedStatementText in PreparedStatementExecutionBuilder"); } return new PreparedStatementExecution(this.preparedStatementText, this.consistency, this.serialConsistency, this.variables, this.variableTypes, this.timestamp); } }
assertTrue(pse.getConsistency().equals(cl.toString()));
public PreparedStatementExecution executePrepared( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { PreparedStatement ps = session.prepare(statement); BoundStatement bound = ps.bind(); if (level != null) { bound.setConsistencyLevel(level); } if (serialLevel != null) { bound.setSerialConsistencyLevel(serialLevel); } session.execute(bound); List<PreparedStatementExecution> pses = sCluster.node(1).activityClient().retrievePreparedStatementExecutions(); PreparedStatementExecution pse = pses.get(0); assertTrue(pse.getPreparedStatementText().equals(statement)); return pse; }
checkSerialCLMatch(cl, pse.getSerialConsistency());
/** * 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(); } }
public PreparedStatementExecution executePrepared( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { PreparedStatement ps = session.prepare(statement); BoundStatement bound = ps.bind(); if (level != null) { bound.setConsistencyLevel(level); } if (serialLevel != null) { bound.setSerialConsistencyLevel(serialLevel); } session.execute(bound); List<PreparedStatementExecution> pses = sCluster.node(1).activityClient().retrievePreparedStatementExecutions(); PreparedStatementExecution pse = pses.get(0); assertTrue(pse.getPreparedStatementText().equals(statement)); return pse; }
checkSerialCLMatch(cl, pse.getSerialConsistency());
assertTrue(pse.getConsistency().equals(cl.toString()));
checkSerialCLMatch(cl, pse.getSerialConsistency());
assertTrue(pse.getConsistency().equals(cl_one.toString())); clearActivityLog(); assertTrue(pse.getConsistency().equals(cl_all.toString()));
checkSerialCLMatch(cl, pse.getSerialConsistency());
/** * 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(); } }
assertTrue(pse.getConsistency().equals(cl.toString()));
assertTrue(pse.getConsistency().equals(cl.toString()));
assertTrue(pse.getConsistency().equals(cl_one.toString())); clearActivityLog(); assertTrue(pse.getConsistency().equals(cl_all.toString()));