|
28 | 28 |
|
29 | 29 | import com.google.common.collect.ImmutableList; |
30 | 30 | import com.google.gcloud.storage.BatchResponse.Result; |
| 31 | +import java.io.ByteArrayInputStream; |
| 32 | +import java.io.InputStream; |
31 | 33 | import java.util.Collections; |
32 | 34 | import java.util.Iterator; |
33 | 35 | import java.util.LinkedList; |
@@ -180,6 +182,28 @@ public void testCreateNullContentType() throws Exception { |
180 | 182 | assertEquals(info, blob.info()); |
181 | 183 | } |
182 | 184 |
|
| 185 | + @Test |
| 186 | + public void testCreateFromStream() throws Exception { |
| 187 | + BlobInfo info = BlobInfo.builder("b", "n").contentType(CONTENT_TYPE).build(); |
| 188 | + byte[] content = {0xD, 0xE, 0xA, 0xD}; |
| 189 | + InputStream streamContent = new ByteArrayInputStream(content); |
| 190 | + expect(storage.create(info, streamContent)).andReturn(info); |
| 191 | + replay(storage); |
| 192 | + Blob blob = bucket.create("n", streamContent, CONTENT_TYPE); |
| 193 | + assertEquals(info, blob.info()); |
| 194 | + } |
| 195 | + |
| 196 | + @Test |
| 197 | + public void testCreateFromStreamNullContentType() throws Exception { |
| 198 | + BlobInfo info = BlobInfo.builder("b", "n").contentType(Storage.DEFAULT_CONTENT_TYPE).build(); |
| 199 | + byte[] content = {0xD, 0xE, 0xA, 0xD}; |
| 200 | + InputStream streamContent = new ByteArrayInputStream(content); |
| 201 | + expect(storage.create(info, streamContent)).andReturn(info); |
| 202 | + replay(storage); |
| 203 | + Blob blob = bucket.create("n", streamContent, null); |
| 204 | + assertEquals(info, blob.info()); |
| 205 | + } |
| 206 | + |
183 | 207 | @Test |
184 | 208 | public void testLoad() throws Exception { |
185 | 209 | expect(storage.get(BUCKET_INFO.name())).andReturn(BUCKET_INFO); |
|
0 commit comments