Elffuss BraidHub

kikocis/java-driver public

Add LZ4 test to SessionTest.
Changesetec70fbe19981b515eb49e8989dac1e58e011efbf32b1b7ddd5666ed1b4779538
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-03-26 12:31 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2015-03-31 15:12 +02:00
Parents06a7241b7aba

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/SessionTest.java +26 −6
@@ -21,6 +21,7 @@
2121 import java.util.concurrent.Executors;
2222 import java.util.concurrent.TimeUnit;
2323
24+import com.datastax.driver.core.utils.CassandraVersion;
2425 import org.testng.annotations.Test;
2526
2627 import static org.testng.Assert.assertEquals;
@@ -106,19 +107,38 @@
106107 assertEquals(rows.get(0).getLong("c"), 2L);
107108 }
108109
110+ /**
111+ * Validates that a session can be established using snappy compression and executes some queries that inserts and
112+ * retrieves data using that session.
113+ *
114+ * @test_category connection:compression
115+ * @expected_result session established and queries made successfully using it.
116+ */
109117 @Test(groups = "short")
110- public void compressionTest() throws Exception {
111-
112- // Same as executeTest, but with compression enabled
118+ public void session_should_function_with_snappy_compression() throws Exception {
119+ compressionTest(ProtocolOptions.Compression.SNAPPY);
120+ }
113121
114- cluster.getConfiguration().getProtocolOptions().setCompression(ProtocolOptions.Compression.SNAPPY);
122+ /**
123+ * Validates that a session can be established using lz4 compression and executes some queries that inserts and
124+ * retrieves data using that session.
125+ *
126+ * @test_category connection:compression
127+ * @expected_result session established and queries made successfully using it.
128+ */
129+ @Test(groups = "short")
130+ @CassandraVersion(major=2.0)
131+ public void session_should_function_with_lz4_compression() throws Exception {
132+ compressionTest(ProtocolOptions.Compression.LZ4);
133+ }
115134
135+ public void compressionTest(ProtocolOptions.Compression compression) {
136+ cluster.getConfiguration().getProtocolOptions().setCompression(compression);
116137 try {
117-
118138 Session compressedSession = cluster.connect(keyspace);
119139
120140 // Simple calls to all versions of the execute/executeAsync methods
121- String key = "execute_compressed_test";
141+ String key = "execute_compressed_test_" + compression;
122142 ResultSet rs = compressedSession.execute(String.format(Locale.US, TestUtils.INSERT_FORMAT, TABLE3, key, "foo", 42, 24.03f));
123143 assertTrue(rs.isExhausted());
124144