summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java')
-rw-r--r--src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java b/src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java
new file mode 100644
index 0000000..0aab994
--- /dev/null
+++ b/src/test/java/com/thinkaurelius/titan/graphdb/CassandraGraphTest.java
@@ -0,0 +1,95 @@
+package com.thinkaurelius.titan.graphdb;
+
+import com.thinkaurelius.titan.CassandraStorageSetup;
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager;
+import com.thinkaurelius.titan.diskstorage.configuration.ConfigElement;
+import com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration;
+import com.thinkaurelius.titan.graphdb.database.StandardTitanGraph;
+import com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager.*;
+
+/**
+ * @author Joshua Shinavier (http://fortytwo.net)
+ */
+public abstract class CassandraGraphTest extends TitanGraphTest {
+
+ @BeforeClass
+ public static void startCassandra() {
+ CassandraStorageSetup.startCleanEmbedded();
+ }
+
+ @Override
+ protected boolean isLockingOptimistic() {
+ return true;
+ }
+
+ @Test
+ public void testHasTTL() throws Exception {
+ assertTrue(features.hasCellTTL());
+ }
+
+ @Test
+ public void testGraphConfigUsedByThreadBoundTx() {
+ close();
+ WriteConfiguration wc = getConfiguration();
+ wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
+ wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");
+
+ graph = (StandardTitanGraph) TitanFactory.open(wc);
+
+ StandardTitanTx tx = (StandardTitanTx)graph.getCurrentThreadTx();
+ assertEquals("ALL",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
+ assertEquals("LOCAL_QUORUM",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
+ }
+
+ @Test
+ public void testGraphConfigUsedByTx() {
+ close();
+ WriteConfiguration wc = getConfiguration();
+ wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
+ wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");
+
+ graph = (StandardTitanGraph) TitanFactory.open(wc);
+
+ StandardTitanTx tx = (StandardTitanTx)graph.newTransaction();
+ assertEquals("TWO",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
+ assertEquals("THREE",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
+ tx.rollback();
+ }
+
+ @Test
+ public void testCustomConfigUsedByTx() {
+ close();
+ WriteConfiguration wc = getConfiguration();
+ wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
+ wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");
+
+ graph = (StandardTitanGraph) TitanFactory.open(wc);
+
+ StandardTitanTx tx = (StandardTitanTx)graph.buildTransaction()
+ .customOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE")
+ .customOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();
+
+ assertEquals("ONE",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
+ assertEquals("TWO",
+ tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
+ .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
+ tx.rollback();
+ }
+}