kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | d4baa70f2ddd473af860ff593030ea7a7adea4d08a5b2748ebbb111dd8c952b6 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-09-10 20:57 -05:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-09-29 16:16 -07:00 |
| Parents | 33346b808ffb |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/SchemaTest.java +22 −1
| @@ -17,6 +17,8 @@ | ||
| 17 | 17 | |
| 18 | 18 | import java.util.*; |
| 19 | 19 | |
| 20 | +import org.slf4j.Logger; | |
| 21 | +import org.slf4j.LoggerFactory; | |
| 20 | 22 | import org.testng.annotations.Test; |
| 21 | 23 | import static org.testng.Assert.assertEquals; |
| 22 | 24 | |
| @@ -24,6 +26,7 @@ | ||
| 24 | 26 | * Test we correctly process and print schema. |
| 25 | 27 | */ |
| 26 | 28 | public class SchemaTest extends CCMBridge.PerClassSingleNodeCluster { |
| 29 | + static final Logger logger = LoggerFactory.getLogger(SchemaTest.class); | |
| 27 | 30 | |
| 28 | 31 | private static final Map<String, String> cql3 = new HashMap<String, String>(); |
| 29 | 32 | private static final Map<String, String> compact = new HashMap<String, String>(); |
| @@ -96,6 +99,24 @@ | ||
| 96 | 99 | compact.put("compact_dynamic", compactDynamic); |
| 97 | 100 | compact.put("compact_composite", compactComposite); |
| 98 | 101 | |
| 102 | + Properties properties = System.getProperties(); | |
| 103 | + String vmVersion = properties.getProperty("java.vm.specification.version"); | |
| 104 | + double javaVersion = 1.6; | |
| 105 | + if(vmVersion != null) { | |
| 106 | + try { | |
| 107 | + javaVersion = Double.parseDouble(vmVersion); | |
| 108 | + } catch (NumberFormatException e) { | |
| 109 | + logger.warn("Could not parse java version from {}. Assuming {}.", vmVersion, javaVersion); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + // Ordering of compaction options will be dependent on JDK. See schemaOptionsTest comments for explanation of why this is needed. | |
| 114 | + String compactionOptions; | |
| 115 | + if(javaVersion >= 1.8) | |
| 116 | + compactionOptions = " AND compaction = { 'sstable_size_in_mb' : 15, 'class' : 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy' }\n"; | |
| 117 | + else | |
| 118 | + compactionOptions = " AND compaction = { 'class' : 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy', 'sstable_size_in_mb' : 15 }\n"; | |
| 119 | + | |
| 99 | 120 | withOptions = String.format("CREATE TABLE %s.with_options (\n" |
| 100 | 121 | + " k text,\n" |
| 101 | 122 | + " v1 int,\n" |
| @@ -110,7 +131,7 @@ | ||
| 110 | 131 | + " AND bloom_filter_fp_chance = 0.01\n" |
| 111 | 132 | + " AND caching = 'ALL'\n" |
| 112 | 133 | + " AND comment = 'My awesome table'\n" |
| 113 | - + " AND compaction = { 'class' : 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy', 'sstable_size_in_mb' : 15 }\n" | |
| 134 | + + compactionOptions | |
| 114 | 135 | + " AND compression = { 'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor', 'chunk_length_kb' : 128 };", keyspace); |
| 115 | 136 | |
| 116 | 137 | List<String> allDefs = new ArrayList<String>(); |