Skip to content

Commit

Permalink
Make ThriftCompatibilityTest use an actual Thrift CF
Browse files Browse the repository at this point in the history
  • Loading branch information
iamaleksey committed Jul 15, 2015
1 parent bfd0104 commit 376e552
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions test/unit/org/apache/cassandra/cql3/ThriftCompatibilityTest.java
Expand Up @@ -17,26 +17,48 @@
*/
package org.apache.cassandra.cql3;

import java.util.Collections;

import org.junit.BeforeClass;
import org.junit.Test;

import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.db.marshal.BytesType;
import org.apache.cassandra.db.marshal.Int32Type;
import org.apache.cassandra.db.marshal.UTF8Type;
import org.apache.cassandra.schema.KeyspaceParams;
import org.apache.cassandra.thrift.CfDef;
import org.apache.cassandra.thrift.ColumnDef;
import org.apache.cassandra.thrift.ThriftConversion;
import org.apache.cassandra.utils.ByteBufferUtil;

import static org.junit.Assert.assertEquals;
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;

public class ThriftCompatibilityTest extends SchemaLoader
{
@BeforeClass
public static void defineSchema() throws Exception
{
// The before class annotation of SchemaLoader will prepare the service so no need to do it here
SchemaLoader.createKeyspace("thriftcompat",
KeyspaceParams.simple(1),
SchemaLoader.jdbcCFMD("thriftcompat", "JdbcInteger", Int32Type.instance)
.addColumnDefinition(integerColumn("thriftcompat", "JdbcInteger")));
SchemaLoader.createKeyspace("thriftcompat", KeyspaceParams.simple(1), thriftCFM("thriftcompat", "JdbcInteger"));
}

public static CFMetaData thriftCFM(String keyspace, String table)
{
ColumnDef column = new ColumnDef();
column.setName(bytes(42))
.setValidation_class(UTF8Type.instance.toString());

CfDef cf = new CfDef(keyspace, table);
cf.setColumn_type("Standard")
.setComparator_type(Int32Type.instance.toString())
.setDefault_validation_class(UTF8Type.instance.toString())
.setKey_validation_class(BytesType.instance.toString())
.setColumn_metadata(Collections.singletonList(column));

return ThriftConversion.fromThrift(cf);
}

private static UntypedResultSet execute(String query)
Expand Down

0 comments on commit 376e552

Please sign in to comment.