Elffuss BraidHub

kikocis/java-driver public

Add should_parse_new_compression_options() test for CASSANDRA-9424.
Changeset9fd6b8ac2d4c1cd11aa8724005fae576f30fd222fba337423356099692efe45c
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-09-17 13:17 -05:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-09-17 13:17 -05:00
Parents4d62c19c02ff

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +33 −0
@@ -22,6 +22,8 @@
2222
2323 import static org.assertj.core.api.Assertions.entry;
2424
25+import com.datastax.driver.core.utils.CassandraVersion;
26+
2527 import static com.datastax.driver.core.Assertions.assertThat;
2628 import static com.datastax.driver.core.DataType.*;
2729 import static com.datastax.driver.core.TableOrView.Order.ASC;
@@ -391,6 +393,37 @@
391393
392394 }
393395
396+ /**
397+ * Validates that metadata is appropriately parsed when using the new compression options format introduced
398+ * in 3.0.0-alpha1. Since compression options are parsed as a String map, this should behave exactly as
399+ * the old style compression options used in {@link #should_parse_table_options}.
400+ *
401+ * @jira_ticket CASSANDRA-9424
402+ */
403+ @Test(groups="short")
404+ @CassandraVersion(major=3.0)
405+ public void should_parse_new_compression_options() {
406+ // given
407+ String cql = String.format("CREATE TABLE %s.new_compression_options (\n"
408+ + " k text,\n"
409+ + " c1 int,\n"
410+ + " c2 int,\n"
411+ + " i int,\n"
412+ + " PRIMARY KEY (k, c1, c2)\n"
413+ + ") WITH CLUSTERING ORDER BY (c1 DESC, c2 ASC)\n"
414+ + " AND compression = { 'class' : 'DeflateCompressor', 'chunk_length_in_kb' : 128 };",
415+ keyspace);
416+
417+ // when
418+ session.execute(cql);
419+ TableMetadata table = cluster.getMetadata().getKeyspace(keyspace).getTable("new_compression_options");
420+
421+ // then
422+ assertThat(table.getOptions().getCompression())
423+ .contains(entry("class", "org.apache.cassandra.io.compress.DeflateCompressor"))
424+ .contains(entry("chunk_length_in_kb", "128"));
425+ }
426+
394427 @Test(groups = "short")
395428 public void should_escape_single_quote_table_comment() {
396429 // given