Permalink
Browse files

use clear-db instead of remove-db to see if errors about missing data…

…files would be solved
  • Loading branch information...
1 parent abf6972 commit cabe63f0b9d430d2cb38ce369b465105828a1bff @freakinruben freakinruben committed Apr 14, 2014
@@ -24,19 +24,6 @@
TypeMaker$UniquenessConsistency/LOCK
TypeMaker$UniquenessConsistency/NO_LOCK))
-
-(defn unique-direction-converter
- [type-maker unique-direction unique-locked]
- (when unique-direction
- (when (#{:both :in} unique-direction)
- (.unique type-maker
- Direction/IN
- (convert-bool-to-lock unique-locked)))
- (when (#{:both :out} unique-direction)
- (.unique type-maker
- Direction/OUT
- (convert-bool-to-lock unique-locked)))))
-
(defn deflabel
"Creates a edge label with the given properties."
([tname] (deflabel tname {}))
@@ -1,5 +1,8 @@
(ns clojurewerkz.titanium.conf
- (:import (org.apache.commons.io FileUtils)))
+ (:import (org.apache.commons.io FileUtils))
+ (:require [clojurewerkz.titanium.edges :as te]
+ [clojurewerkz.titanium.vertices :as tv]
+ [clojurewerkz.titanium.graph :as tg]))
(def cs-dir (str (clojure.java.io/as-url
@@ -12,11 +15,18 @@
"storage.cassandra-config-dir" cs-dir
;; Embedded elasticsearch settings
"storage.index.search.backend" "elasticsearch"
- "storage.index.search.directory" "/tmp/titanium-test/elasticsearch"
+ "storage.index.search.directory" "/tmp/cassandra/elasticsearch"
"storage.index.search.client-only" false
"storage.index.search.local-mode" true
"storage.compression.enabled" false
"storage.cassandra.db.compression.enabled" false})
(defn clear-db []
+ (tg/transact!
+ (doseq [e (te/get-all-edges)]
+ (te/remove! e))
+ (doseq [v (tv/get-all-vertices)]
+ (tv/remove! v))))
+
+(defn remove-db []
(FileUtils/deleteDirectory (java.io.File. "/tmp/titanium-test")))
@@ -8,8 +8,8 @@
(deftest test-edges
- (clear-db)
(tg/open conf)
+ (clear-db)
(testing "creating and immediately finding a relationship without properties"
(tg/transact!
@@ -240,7 +240,7 @@
(is (thrown-with-msg? Throwable #"There were 2 vertices returned."
(ted/unique-upconnect! v1 :connexion v2))))))
(tg/shutdown)
- (clear-db)))
+ ))
@@ -1,14 +1,14 @@
(ns clojurewerkz.titanium.element-test
(:use [clojure.test]
- [clojurewerkz.titanium.conf :only (conf clear-db)])
+ [clojurewerkz.titanium.conf :only (conf remove-db)])
(:import [com.thinkaurelius.titan.graphdb.relations RelationIdentifier])
(:require [clojurewerkz.titanium.graph :as g]
[clojurewerkz.titanium.vertices :as v]
[clojurewerkz.titanium.edges :as e]))
(deftest element-test
- (clear-db)
- (g/open conf)
+ (remove-db)
+ (g/open conf)
(testing "Get keys."
(g/transact! (let [a (v/create! {:name "v1" :a 1 :b 1})
b (v/create! {:name "v2" :a 1 :b 1})
@@ -34,8 +34,8 @@
(deftest test-conf-graph
- (clear-db)
(tg/open conf)
+ (clear-db)
(testing "Is the graph open?"
(is (tg/open?)))
@@ -95,5 +95,4 @@
(is (= 1 (count
(tg/transact! (tv/find-by-kv :vertex-id random-long))))
"*graph* has only one vertex with the specified vertex-id")))
- (tg/shutdown)
- (clear-db))
+ (tg/shutdown))
@@ -9,8 +9,8 @@
;; The Graph of the Gods example from the Titan wiki
(deftest test-integration-example1
- (clear-db)
(tg/open conf)
+ (clear-db)
(tg/transact!
(let [saturn (tv/create! {:name "Saturn" :type "titan"})
jupiter (tv/create! {:name "Jupiter" :type "god"})
@@ -7,8 +7,8 @@
[clojurewerkz.titanium.graph :as tg]))
(deftest test-types
- (clear-db)
(tg/open conf)
+ (clear-db)
(testing "Create property key."
(testing "With no parameters."
@@ -24,7 +24,7 @@
(is (not (.isUnique k Direction/IN))))))
(testing "With indexed vertex."
- (tg/transact!
+ (tg/transact!
(tt/defkey :second-key Integer
{:indexed-vertex? true})
(let [k (tt/get-type :second-key)]
@@ -37,7 +37,7 @@
(is (not (.isUnique k Direction/IN))))))
(testing "With indexed vertex."
- (tg/transact!
+ (tg/transact!
(tt/defkey :third-key Integer
{:indexed-vertex? true
:unique-direction :out})
@@ -51,7 +51,7 @@
(is (not (.isUnique k Direction/IN))))))
(testing "With indexed edge."
- (tg/transact!
+ (tg/transact!
(tt/defkey :fourth-key Integer
{:indexed-edge? true
:unique-direction :out})
@@ -65,7 +65,7 @@
(is (not (.isUnique k Direction/IN))))))
(testing "With searchable vertex."
- (tg/transact!
+ (tg/transact!
(tt/defkey :fifth-key Integer
{:indexed-vertex? true
:searchable? true
@@ -80,9 +80,9 @@
(is (not (.hasIndex k "search" Edge)))
(is (.isUnique k Direction/OUT))
(is (not (.isUnique k Direction/IN))))))
-
+
(testing "With searchable edge."
- (tg/transact!
+ (tg/transact!
(tt/defkey :sixth-key Integer
{:indexed-edge? true
:searchable? true
@@ -99,7 +99,7 @@
(is (not (.isUnique k Direction/IN))))))
(testing "Unique property in both directions."
- (tg/transact!
+ (tg/transact!
(tt/defkey :seventh-key Long
{:indexed-vertex? true
:indexed-edge? true
@@ -119,7 +119,7 @@
(tv/create! {:seventh-key 1}))))))
(testing "Search all the things."
- (tg/transact!
+ (tg/transact!
(tt/defkey :eighth-key Integer
{:indexed-edge? true
:indexed-vertex? true
@@ -1,18 +1,18 @@
(ns clojurewerkz.titanium.vertices-test
(:require [clojurewerkz.titanium.graph :as tg]
[clojurewerkz.titanium.vertices :as tv]
- [clojurewerkz.titanium.edges :as ted]
+ [clojurewerkz.titanium.edges :as ted]
[clojurewerkz.titanium.indexing :as ti]
[clojurewerkz.titanium.types :as tt])
(:use clojure.test
[clojurewerkz.titanium.conf :only (clear-db conf)])
(:import (com.thinkaurelius.titan.graphdb.vertices StandardVertex)))
(deftest vertex-test
- (clear-db)
(tg/open conf)
+ (clear-db)
- (tg/transact!
+ (tg/transact!
(tt/defkey-once :vname String {:indexed-vertex? true
:unique-direction :out})
(tt/defkey-once :age Long {:indexed-vertex? true
@@ -21,14 +21,14 @@
:unique-direction :out})
(tt/defkey-once :last-name String {:indexed-vertex? true
:unique-direction :out}))
-
+
(testing "Adding a vertex."
(tg/transact!
(let [v (tv/create! {:name "Titanium" :language "Clojure"})]
(is (.getId v))
(is (= "Titanium" (.getProperty v "name"))))))
- (testing "Deletion of vertices."
+ (testing "Deletion of vertices."
(tg/transact!
(let [u (tv/create! {:vname "uniquename"})
u-id (tv/id-of u)]
@@ -43,15 +43,15 @@
(tv/remove! v)
(is (nil? (tv/find-by-id id))))))
- (testing "Simple property mutation."
+ (testing "Simple property mutation."
(tg/transact!
(let [u (tv/create! {:a 1 :b 1})]
(tv/assoc! u :b 2)
(tv/dissoc! u :a)
(is (= 2 (tv/get u :b)))
(is (= nil (tv/get u :a))))))
- (testing "Multiple property mutation."
+ (testing "Multiple property mutation."
(tg/transact!
(let [u (tv/create! {:a 1 :b 1 :d 1})]
(tv/assoc! u :b 2 :c 3)
@@ -75,7 +75,7 @@
v (tv/create! data)
v' (tv/merge! v {:age 31} {:position "Industrial Designer"})]
(is (= v v'))
- (is (= {:name "Gerard" :age 31 :position "Industrial Designer"}
+ (is (= {:name "Gerard" :age 31 :position "Industrial Designer"}
(dissoc (tv/to-map v) :__id__)))
(are [k val] (is (= val (tv/get v k)))
:name "Gerard" :age 31))))
@@ -97,7 +97,7 @@
v' (tv/clear! v)]
(is (= v v'))
(is (= {} (dissoc (tv/to-map v) :__id__))))))
-
+
(testing "Property map."
(tg/transact!
(let [v1 (tv/create! {:a 1 :b 2 :c 3})
@@ -117,10 +117,10 @@
(dissoc (tv/to-map v) :__id__))))))
(testing "Dissocing property map."
- (tg/transact!
+ (tg/transact!
(let [m {:station "Boston Manor" :lines #{"Piccadilly"}}
v (tv/create! m)]
- (ted/dissoc! v "lines")
+ (ted/dissoc! v "lines")
(is (= {:station "Boston Manor"} (dissoc (tv/to-map v) :__id__))))))
(testing "Accessing a non existent node."
@@ -156,7 +156,7 @@
(testing "Get all vertices."
(tg/transact!
(let [v1 (tv/create! {:age 28 :name "Michael"})
- v2 (tv/create! {:age 26 :name "Alex"})
+ v2 (tv/create! {:age 26 :name "Alex"})
xs (set (tv/get-all-vertices))]
;; TODO CacheVertex's are hanging around
(is (= #{v1 v2} (set (filter #(= (type %) StandardVertex) xs)))))))
@@ -174,7 +174,7 @@
fetched (tv/find-by-id (tv/id-of created))]
(is (= (tv/id-of created) (tv/id-of fetched)))
(is (= (tv/to-map created) (tv/to-map fetched))))))
-
+
(testing "Upsert!"
(tg/transact!
(let [v1-a (tv/upsert! :first-name
@@ -203,9 +203,8 @@
{:first-name "Brooke" :last-name "Maril" :age 19})]
(is (= 22
(tv/get (tv/refresh v1-a) :age)
- (tv/get (tv/refresh v1-b) :age)))
+ (tv/get (tv/refresh v1-b) :age)))
(is (thrown-with-msg? Throwable #"There were 2 vertices returned."
(tv/unique-upsert! :last-name {:last-name "Maril"}))))))
-
- (tg/shutdown)
- (clear-db))
+
+ (tg/shutdown))

0 comments on commit cabe63f

Please sign in to comment.