Exemplo n.º 1
0
 @Test
 public void testWriteChannelFail() throws IOException {
   String blobName = "test-write-channel-blob-fail";
   BlobInfo blob = BlobInfo.builder(BUCKET, blobName).generation(-1L).build();
   try {
     try (BlobWriteChannel writer =
         storage.writer(blob, Storage.BlobWriteOption.generationMatch())) {
       writer.write(ByteBuffer.allocate(42));
     }
     fail("StorageException was expected");
   } catch (StorageException ex) {
     // expected
   }
 }
Exemplo n.º 2
0
 @Test
 public void testCreateBlobMd5Fail() throws UnsupportedEncodingException {
   String blobName = "test-create-blob-md5-fail";
   BlobInfo blob =
       BlobInfo.builder(BUCKET, blobName)
           .contentType(CONTENT_TYPE)
           .md5("O1R4G1HJSDUISJjoIYmVhQ==")
           .build();
   ByteArrayInputStream stream = new ByteArrayInputStream(BLOB_STRING_CONTENT.getBytes(UTF_8));
   try {
     storage.create(blob, stream, Storage.BlobWriteOption.md5Match());
     fail("StorageException was expected");
   } catch (StorageException ex) {
     // expected
   }
 }