diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2009-04-09 17:52:32 +0000 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2009-04-09 17:52:32 +0000 |
commit | 9ea45de2be0334513ff4230dcd842a06936bd7ad (patch) | |
tree | 98bc485a03bb4e1405c403d9f19d7eabd89e4182 /src/clojure/contrib/test_contrib | |
parent | 19641235676df4355ada6dfd2acb8ce2190642de (diff) |
added Perry Trolard's properties helpers
added tests that use a fixture dir (we should standardize on something here)
Diffstat (limited to 'src/clojure/contrib/test_contrib')
-rw-r--r-- | src/clojure/contrib/test_contrib/test_java_utils.clj | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/clojure/contrib/test_contrib/test_java_utils.clj b/src/clojure/contrib/test_contrib/test_java_utils.clj index 21a4addc..5c2588a3 100644 --- a/src/clojure/contrib/test_contrib/test_java_utils.clj +++ b/src/clojure/contrib/test_contrib/test_java_utils.clj @@ -1,7 +1,8 @@ (ns clojure.contrib.test-contrib.test-java-utils (:use clojure.contrib.test-is clojure.contrib.java-utils) - (:import [java.io File])) + (:import [java.io File] + [java.util Properties])) (deftest test-relative-path-string (testing "strings" @@ -75,8 +76,25 @@ (is (= propcount (count (System/getProperties)))))) ) +(deftest test-as-properties + (let [expected (doto (Properties.) + (.setProperty "a" "b") + (.setProperty "c" "d"))] + (testing "with a map" + (is (= expected + (as-properties {:a "b" :c "d"})))) + (testing "with a sequence of pairs" + (is (= expected + (as-properties [[:a :b] [:c :d]])))))) + +(deftest test-read-properties + (is (= {"a" "b" "c" "d"} + (read-properties (file "test/fixtures/test_java_utils.properties"))))) - +(deftest test-write-properties + (write-properties [['a 'b] ['c 'd]] (file "test/tmp/test_java_utils_write_properties.properties")) + (is (= {"a" "b" "c" "d"} + (read-properties (file "test/tmp/test_java_utils_write_properties.properties"))))) |