Search in sources :

Example 11 with AdminResult

use of com.datastax.oss.driver.internal.core.adminrequest.AdminResult in project java-driver by datastax.

the class ReprepareOnUpTest method should_not_reprepare_already_known_statements.

@Test
public void should_not_reprepare_already_known_statements() {
    MockReprepareOnUp reprepareOnUp = new MockReprepareOnUp("test", pool, ImmediateEventExecutor.INSTANCE, getMockPayloads('a', 'b', 'c', 'd', 'e', 'f'), context, whenPrepared);
    reprepareOnUp.start();
    MockAdminQuery adminQuery = reprepareOnUp.queries.poll();
    assertThat(adminQuery).isNotNull();
    assertThat(adminQuery.request).isInstanceOf(Query.class);
    assertThat(((Query) adminQuery.request).query).isEqualTo("SELECT prepared_id FROM system.prepared_statements");
    // server knows d, e and f already:
    adminQuery.resultFuture.complete(new AdminResult(preparedIdRows('d', 'e', 'f'), null, DefaultProtocolVersion.DEFAULT));
    for (char c = 'a'; c <= 'c'; c++) {
        adminQuery = reprepareOnUp.queries.poll();
        assertThat(adminQuery).isNotNull();
        assertThat(adminQuery.request).isInstanceOf(Prepare.class);
        assertThat(((Prepare) adminQuery.request).cqlQuery).isEqualTo("mock query " + c);
        adminQuery.resultFuture.complete(null);
    }
    assertThatStage(done).isSuccess(v -> assertThat(reprepareOnUp.queries).isEmpty());
}
Also used : Query(com.datastax.oss.protocol.internal.request.Query) Prepare(com.datastax.oss.protocol.internal.request.Prepare) AdminResult(com.datastax.oss.driver.internal.core.adminrequest.AdminResult) Test(org.junit.Test)

Aggregations

AdminResult (com.datastax.oss.driver.internal.core.adminrequest.AdminResult)11 Test (org.junit.Test)6 Prepare (com.datastax.oss.protocol.internal.request.Prepare)4 Query (com.datastax.oss.protocol.internal.request.Query)4 DriverChannel (com.datastax.oss.driver.internal.core.channel.DriverChannel)3 Version (com.datastax.oss.driver.api.core.Version)2 DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)2 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)2 EndPoint (com.datastax.oss.driver.api.core.metadata.EndPoint)2 Node (com.datastax.oss.driver.api.core.metadata.Node)2 AdminRow (com.datastax.oss.driver.internal.core.adminrequest.AdminRow)2 UnexpectedResponseException (com.datastax.oss.driver.internal.core.adminrequest.UnexpectedResponseException)2 Error (com.datastax.oss.protocol.internal.response.Error)2 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 CompletionStage (java.util.concurrent.CompletionStage)2 DseNodeProperties (com.datastax.dse.driver.api.core.metadata.DseNodeProperties)1 Assertions.assertThat (com.datastax.oss.driver.Assertions.assertThat)1 Assertions.assertThatStage (com.datastax.oss.driver.Assertions.assertThatStage)1