mirror of https://github.com/apache/jclouds.git
Add ByteSource Payload support for Clojure
This commit is contained in:
parent
c035bcd6b2
commit
f5c9a72243
|
@ -52,7 +52,8 @@ See http://code.google.com/p/jclouds for details."
|
||||||
[org.jclouds.io Payload Payloads payloads.StreamingPayload]
|
[org.jclouds.io Payload Payloads payloads.StreamingPayload]
|
||||||
java.util.Arrays
|
java.util.Arrays
|
||||||
[java.security DigestOutputStream MessageDigest]
|
[java.security DigestOutputStream MessageDigest]
|
||||||
com.google.common.collect.ImmutableSet))
|
com.google.common.collect.ImmutableSet
|
||||||
|
com.google.common.io.ByteSource))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Payload support for creating Blobs.
|
;; Payload support for creating Blobs.
|
||||||
|
@ -72,6 +73,8 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(payload [s] (Payloads/newStringPayload s))
|
(payload [s] (Payloads/newStringPayload s))
|
||||||
java.io.File
|
java.io.File
|
||||||
(payload [f] (Payloads/newFilePayload f))
|
(payload [f] (Payloads/newFilePayload f))
|
||||||
|
ByteSource
|
||||||
|
(payload [bs] (Payloads/newByteSourcePayload bs))
|
||||||
clojure.lang.IFn
|
clojure.lang.IFn
|
||||||
;; This will let you pass a closure to payload that takes an OutputStream
|
;; This will let you pass a closure to payload that takes an OutputStream
|
||||||
;; as argument and writes to it when called from a StreamingPayload.
|
;; as argument and writes to it when called from a StreamingPayload.
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
(:use [clojure.test])
|
(:use [clojure.test])
|
||||||
(:import [java.io ByteArrayInputStream ByteArrayOutputStream
|
(:import [java.io ByteArrayInputStream ByteArrayOutputStream
|
||||||
StringBufferInputStream]
|
StringBufferInputStream]
|
||||||
[org.jclouds.util Strings2]))
|
[org.jclouds.util Strings2]
|
||||||
|
com.google.common.io.ByteSource))
|
||||||
|
|
||||||
(defn clean-stub-fixture
|
(defn clean-stub-fixture
|
||||||
"This should allow basic tests to easily be run with another service."
|
"This should allow basic tests to easily be run with another service."
|
||||||
|
@ -180,12 +181,21 @@
|
||||||
:payload (.getBytes "blob3")))
|
:payload (.getBytes "blob3")))
|
||||||
(Strings2/toStringAndClose (get-blob-stream blobstore-stub
|
(Strings2/toStringAndClose (get-blob-stream blobstore-stub
|
||||||
"container" "blob3")))))
|
"container" "blob3")))))
|
||||||
|
|
||||||
(is (= "blob4"
|
(is (= "blob4"
|
||||||
(do
|
(do
|
||||||
(put-blob blobstore-stub "container"
|
(put-blob blobstore-stub "container"
|
||||||
(blob "blob4"
|
(blob "blob4"
|
||||||
:payload #(.write % (.getBytes "blob4"))))
|
:payload #(.write % (.getBytes "blob4"))))
|
||||||
(Strings2/toStringAndClose (get-blob-stream blobstore-stub
|
(Strings2/toStringAndClose (get-blob-stream blobstore-stub
|
||||||
"container" "blob4"))))))
|
"container" "blob4")))))
|
||||||
|
|
||||||
|
(is (= "blob5"
|
||||||
|
(do
|
||||||
|
(put-blob blobstore-stub "container"
|
||||||
|
(blob "blob5"
|
||||||
|
:payload (ByteSource/wrap (.getBytes "blob5"))))
|
||||||
|
(Strings2/toStringAndClose (get-blob-stream blobstore-stub
|
||||||
|
"container" "blob5"))))))
|
||||||
|
|
||||||
;; TODO: more tests involving blob-specific functions
|
;; TODO: more tests involving blob-specific functions
|
||||||
|
|
Loading…
Reference in New Issue