Skip to content

Instantly share code, notes, and snippets.

@tolbertam
Created November 19, 2015 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolbertam/26c0c4f28f782ef61d1a to your computer and use it in GitHub Desktop.
Save tolbertam/26c0c4f28f782ef61d1a to your computer and use it in GitHub Desktop.
1.2 tweak
diff --git a/driver-core/src/test/java/com/datastax/driver/core/CustomTypeTest.java b/driver-core/src/test/java/com/datastax/driver/core/CustomTypeTest.java
index c53f848..cd29a60 100644
--- a/driver-core/src/test/java/com/datastax/driver/core/CustomTypeTest.java
+++ b/driver-core/src/test/java/com/datastax/driver/core/CustomTypeTest.java
@@ -47,6 +47,9 @@ public class CustomTypeTest extends CCMBridge.PerClassSingleNodeCluster {
public static final DataType LIST_OF_INTS = list(cint());
+ // As ListType(Int32Type) is broken in C* 1.2, do not test using it.
+ public static final boolean isNot12 = TestUtils.getDesiredProtocolVersion().compareTo(ProtocolVersion.V1) > 0;
+
@Override
protected Collection<String> getTableDefinitions() {
return Collections.singleton(
@@ -54,7 +57,8 @@ public class CustomTypeTest extends CCMBridge.PerClassSingleNodeCluster {
+ " k int,"
+ " c1 'DynamicCompositeType(s => UTF8Type, i => Int32Type)',"
+ " c2 'ReversedType(CompositeType(UTF8Type, Int32Type))'," // reversed translates to CLUSTERING ORDER BY DESC
- + " c3 'ListType(Int32Type)'," // translates to list<int>
+ + (isNot12 ?
+ " c3 'ListType(Int32Type)'," : "c3 'UTF8Type',") // translates to list<int> for > 1.2, text otherwise.
+ " PRIMARY KEY (k, c1, c2)"
+ ")"
);
@@ -67,11 +71,11 @@ public class CustomTypeTest extends CCMBridge.PerClassSingleNodeCluster {
assertThat(table.getColumn("c1")).isClusteringColumn().hasType(CUSTOM_DYNAMIC_COMPOSITE);
assertThat(table.getColumn("c2")).isClusteringColumn().hasType(CUSTOM_COMPOSITE).hasClusteringOrder(ClusteringOrder.DESC);
- assertThat(table.getColumn("c3")).hasType(LIST_OF_INTS);
+ assertThat(table.getColumn("c3")).hasType(isNot12 ? LIST_OF_INTS: DataType.text());
- session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 's@foo:i@32', 'foo:32', [1,2,3])");
- session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 'i@42', ':42', [2,3,4])");
- session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 'i@12:i@3', 'foo', [3,4,5])");
+ session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 's@foo:i@32', 'foo:32', " + (isNot12 ? "[1,2,3]" : "'[1,2,3]'") + ")");
+ session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 'i@42', ':42', " + (isNot12 ? "[2,3,4]" : "'[2,3,4]'") + ")");
+ session.execute("INSERT INTO test(k, c1, c2, c3) VALUES (0, 'i@12:i@3', 'foo', " + (isNot12 ? "[3,4,5]" : "'[3,4,5]'") + ")");
ResultSet rs = session.execute("SELECT * FROM test");
@@ -79,24 +83,34 @@ public class CustomTypeTest extends CCMBridge.PerClassSingleNodeCluster {
assertThat(r.getColumnDefinitions().getType("c1")).isEqualTo(CUSTOM_DYNAMIC_COMPOSITE);
assertThat(r.getColumnDefinitions().getType("c2")).isEqualTo(CUSTOM_COMPOSITE);
- assertThat(r.getColumnDefinitions().getType("c3")).isEqualTo(LIST_OF_INTS);
+ if(isNot12)
+ assertThat(r.getColumnDefinitions().getType("c3")).isEqualTo(LIST_OF_INTS);
assertThat(r.getInt("k")).isEqualTo(0);
assertThat(r.getBytesUnsafe("c1")).isEqualTo(serializeForDynamicCompositeType(12, 3));
assertThat(r.getBytesUnsafe("c2")).isEqualTo(serializeForCompositeType("foo"));
- assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(3,4,5));
+ if(isNot12)
+ assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(3,4,5));
+ else
+ assertThat(r.getString("c3")).isEqualTo("[3,4,5]");
r = rs.one();
assertThat(r.getInt("k")).isEqualTo(0);
assertThat(r.getBytesUnsafe("c1")).isEqualTo(serializeForDynamicCompositeType(42));
assertThat(r.getBytesUnsafe("c2")).isEqualTo(serializeForCompositeType("", 42));
- assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(2,3,4));
+ if(isNot12)
+ assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(2,3,4));
+ else
+ assertThat(r.getString("c3")).isEqualTo("[2,3,4]");
r = rs.one();
assertThat(r.getInt("k")).isEqualTo(0);
assertThat(r.getBytesUnsafe("c1")).isEqualTo(serializeForDynamicCompositeType("foo", 32));
assertThat(r.getBytesUnsafe("c2")).isEqualTo(serializeForCompositeType("foo", 32));
- assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(1,2,3));
+ if(isNot12)
+ assertThat(r.getList("c3", Integer.class)).isEqualTo(newArrayList(1,2,3));
+ else
+ assertThat(r.getString("c3")).isEqualTo("[1,2,3]");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment