From 9ba88797a048cd5857ce70de058e675b0a629a09 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 9 Mar 2010 17:01:24 -0800 Subject: [PATCH] Fix File method of download-blob multimethod. --- .../src/main/clojure/org/jclouds/blobstore.clj | 2 +- .../src/test/clojure/org/jclouds/blobstore_test.clj | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore.clj b/blobstore/src/main/clojure/org/jclouds/blobstore.clj index 81a225fa6d..8e85b32e41 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore.clj @@ -258,7 +258,7 @@ container, name, string -> etag (copy (.getContent blob) target))) (defmethod download-blob File [blobstore container-name name target] - (download-blob (FileOutputStream. target))) + (download-blob blobstore container-name name (FileOutputStream. target))) (define-accessors StorageMetadata "blob" type id name location-id uri last-modfied) diff --git a/blobstore/src/test/clojure/org/jclouds/blobstore_test.clj b/blobstore/src/test/clojure/org/jclouds/blobstore_test.clj index 7d3cada272..77f0ab1ec7 100644 --- a/blobstore/src/test/clojure/org/jclouds/blobstore_test.clj +++ b/blobstore/src/test/clojure/org/jclouds/blobstore_test.clj @@ -1,6 +1,6 @@ (ns org.jclouds.blobstore-test (:use [org.jclouds.blobstore] :reload-all) - (:use clojure.test) + (:use [clojure.test]) (:import [org.jclouds.blobstore BlobStoreContextFactory] [java.io ByteArrayOutputStream])) @@ -65,11 +65,12 @@ (let [name "test" container-name "test-container" data "test content" - baos (ByteArrayOutputStream.)] - (create-container container-name) - (create-blob container-name name data) - (download-blob container-name name baos) - (is (= data (.toString baos))))) + data-file (java.io.File/createTempFile "jclouds" "data")] + (try (create-container container-name) + (create-blob container-name name data) + (download-blob container-name name data-file) + (is (= data (slurp (.getAbsolutePath data-file)))) + (finally (.delete data-file))))) ;; TODO: more tests involving blob-specific functions