@@ -0,0 +1,3649 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.cassandra;%0A%0Aimport com.datastax.driver.core.Cluster;%0Aimport com.facebook.presto.cassandra.CassandraTokenSplitManager.TokenSplit;%0Aimport com.google.common.collect.ImmutableList;%0Aimport io.airlift.json.JsonCodec;%0Aimport org.testng.annotations.BeforeMethod;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.util.List;%0A%0Aimport static com.facebook.presto.cassandra.CassandraTestingUtils.HOSTNAME;%0Aimport static com.facebook.presto.cassandra.CassandraTestingUtils.PORT;%0Aimport static com.facebook.presto.cassandra.CassandraTestingUtils.createOrReplaceKeyspace;%0Aimport static java.lang.String.format;%0Aimport static org.testng.Assert.assertEquals;%0A%0Apublic class TestCassandraTokenSplitManager%0A%7B%0A    private static final int DOES_NOT_MATTER = 1;%0A    private static final String CONNECTOR_ID = %22integration_test%22;%0A    private static final int SPLIT_SIZE = 100;%0A    private static final String KEYSPACE = %22test_cassandra_token_split_manager_keyspace%22;%0A    private static final String TABLE = %22test_cassandra_token_split_manager_table%22;%0A    private static final int PARTITION_COUNT = 1000;%0A%0A    private CassandraSession session;%0A    private CassandraTokenSplitManager splitManager;%0A%0A    @BeforeMethod%0A    public void setUp()%0A            throws Exception%0A    %7B%0A        EmbeddedCassandra.start();%0A        Cluster.Builder cluster = Cluster.builder()%0A                .withPort(PORT);%0A        session = new CassandraSession(%0A                CONNECTOR_ID,%0A                ImmutableList.of(HOSTNAME),%0A                cluster,%0A                DOES_NOT_MATTER,%0A                DOES_NOT_MATTER,%0A                JsonCodec.listJsonCodec(ExtraColumnMetadata.class),%0A                DOES_NOT_MATTER);%0A        splitManager = new CassandraTokenSplitManager(session, SPLIT_SIZE);%0A    %7D%0A%0A    @Test%0A    public void testCassandraTokenSplitManager()%0A            throws Exception%0A    %7B%0A        session.executeWithSession(session -%3E %7B%0A            createOrReplaceKeyspace(session, KEYSPACE);%0A            return null;%0A        %7D);%0A%0A        session.executeWithSession(KEYSPACE, session -%3E %7B%0A            String createTable = format(%22CREATE TABLE %25s.%25s (key text PRIMARY KEY)%22, KEYSPACE, TABLE);%0A            session.execute(createTable);%0A            return null;%0A        %7D);%0A        EmbeddedCassandra.flush(KEYSPACE, TABLE);%0A        EmbeddedCassandra.refreshSizeEstimates();%0A%0A        List%3CTokenSplit%3E splits = splitManager.getSplits(KEYSPACE, TABLE);%0A        // even for the empty table at least one split must be produced, in case the statistics are inaccurate%0A        assertEquals(splits.size(), 1);%0A%0A        for (int i = 0; i %3C PARTITION_COUNT; i++) %7B%0A            String insertInto = format(%22INSERT INTO %25s.%25s (key) VALUES ('%25s')%22, KEYSPACE, TABLE, %22value%22 + i);%0A            session.executeWithSession(KEYSPACE, session -%3E session.execute(insertInto));%0A        %7D%0A        EmbeddedCassandra.flush(KEYSPACE, TABLE);%0A        EmbeddedCassandra.refreshSizeEstimates();%0A%0A        splits = splitManager.getSplits(KEYSPACE, TABLE);%0A        assertEquals(splits.size(), PARTITION_COUNT / SPLIT_SIZE);%0A    %7D%0A%7D%0A

Add CassandraTokenSplitManager integration test