1 package com.thinkaurelius.titan.graphdb;
3 import com.thinkaurelius.titan.CassandraStorageSetup;
4 import com.thinkaurelius.titan.core.TitanFactory;
5 import com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager;
6 import com.thinkaurelius.titan.diskstorage.configuration.ConfigElement;
7 import com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration;
8 import com.thinkaurelius.titan.graphdb.database.StandardTitanGraph;
9 import com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertTrue;
15 import static com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager.*;
18 * @author Joshua Shinavier (http://fortytwo.net)
20 public abstract class CassandraGraphTest extends TitanGraphTest {
23 public static void startCassandra() {
24 CassandraStorageSetup.startCleanEmbedded();
28 protected boolean isLockingOptimistic() {
33 public void testHasTTL() throws Exception {
34 assertTrue(features.hasCellTTL());
38 public void testGraphConfigUsedByThreadBoundTx() {
40 WriteConfiguration wc = getConfiguration();
41 wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
42 wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");
44 graph = (StandardTitanGraph) TitanFactory.open(wc);
46 StandardTitanTx tx = (StandardTitanTx)graph.getCurrentThreadTx();
48 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
49 .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
50 assertEquals("LOCAL_QUORUM",
51 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
52 .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
56 public void testGraphConfigUsedByTx() {
58 WriteConfiguration wc = getConfiguration();
59 wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
60 wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");
62 graph = (StandardTitanGraph) TitanFactory.open(wc);
64 StandardTitanTx tx = (StandardTitanTx)graph.newTransaction();
66 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
67 .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
69 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
70 .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
75 public void testCustomConfigUsedByTx() {
77 WriteConfiguration wc = getConfiguration();
78 wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
79 wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");
81 graph = (StandardTitanGraph) TitanFactory.open(wc);
83 StandardTitanTx tx = (StandardTitanTx)graph.buildTransaction()
84 .customOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE")
85 .customOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();
88 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
89 .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
91 tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
92 .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));