diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2009-08-15 13:26:49 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2009-08-15 13:26:49 -0400 |
commit | cb35f77f5b5bea740120bc649ae82c8015c7ca4c (patch) | |
tree | a5a95fa69aa668f153f618986a0592b5d5080105 | |
parent | d596fee7fbe2f428a34ebecbaaf9451e215d5bdf (diff) |
as-url addition from James Reeves
-rw-r--r-- | src/clojure/contrib/java_utils.clj | 1 | ||||
-rw-r--r-- | src/clojure/contrib/test_contrib/test_java_utils.clj | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/clojure/contrib/java_utils.clj b/src/clojure/contrib/java_utils.clj index ea6ab90a..0f030c55 100644 --- a/src/clojure/contrib/java_utils.clj +++ b/src/clojure/contrib/java_utils.clj @@ -168,3 +168,4 @@ (defmethod as-url String [#^String x] (URL. x)) +(defmethod as-url File [#^File x] (.toURL x)) diff --git a/src/clojure/contrib/test_contrib/test_java_utils.clj b/src/clojure/contrib/test_contrib/test_java_utils.clj index 8a56b197..abf1b9a6 100644 --- a/src/clojure/contrib/test_contrib/test_java_utils.clj +++ b/src/clojure/contrib/test_contrib/test_java_utils.clj @@ -3,6 +3,7 @@ [clojure.contrib.duck-streams :only (spit)] clojure.contrib.java-utils) (:import [java.io File] + [java.net URL URI] [java.util Properties])) (deftest test-relative-path-string @@ -23,6 +24,13 @@ (is (= (File. "bar") (as-file (File. "bar"))))) ) +(deftest test-as-url + (are [result expr] (= result expr) + (URL. "http://foo") (as-url (URL. "http://foo")) + (URL. "http://foo") (as-url "http://foo") + (URL. "http://foo") (as-url (URI. "http://foo")) + (URL. "file:/foo") (as-url (File. "/foo")))) + (deftest test-file (testing "single argument" (is (= (File. "foo") (file "foo")))) |