@@ -3611,22 +3611,17 @@ public void testWriterWithKmsKeyName() throws IOException {
3611
3611
// Write an empty object with a kmsKeyName.
3612
3612
String blobName = "test-empty-blob" ;
3613
3613
BlobInfo blobInfo = BlobInfo .newBuilder (BUCKET , blobName ).build ();
3614
- Storage storage =
3615
- StorageOptions .newBuilder ().setHost ("http://localhost:8080" ).build ().getService ();
3616
- storage .create (BucketInfo .of (BUCKET ));
3617
3614
Blob blob =
3618
- storage .create (blobInfo ); // , Storage.BlobTargetOption.kmsKeyName(kmsKeyOneResourcePath));
3615
+ storage .create (blobInfo , Storage .BlobTargetOption .kmsKeyName (kmsKeyOneResourcePath ));
3619
3616
3620
3617
// Create a writer using blob that already has metadata received from Storage API.
3621
- int numberOfBytes = 0 ;
3622
- int iterations = 1024 * 1024 ;
3618
+ int numberOfBytes ;
3623
3619
try (WriteChannel writer = blob .writer ()) {
3624
- for (int i = 0 ; i < iterations ; i ++) {
3625
- byte [] content = BLOB_STRING_CONTENT .getBytes (UTF_8 );
3626
- numberOfBytes += writer .write (ByteBuffer .wrap (content , 0 , content .length ));
3627
- }
3620
+ byte [] content = BLOB_STRING_CONTENT .getBytes (UTF_8 );
3621
+ numberOfBytes = writer .write (ByteBuffer .wrap (content , 0 , content .length ));
3628
3622
}
3629
- assertThat (numberOfBytes ).isEqualTo (27 * iterations );
3623
+ assertThat (numberOfBytes ).isEqualTo (27 );
3624
+ assertThat (blob .getKmsKeyName ()).isNotNull ();
3630
3625
assertThat (storage .delete (BUCKET , blobName )).isTrue ();
3631
3626
}
3632
3627
}
0 commit comments