39
39
import com .google .cloud .storage .Bucket ;
40
40
import com .google .cloud .storage .BucketInfo ;
41
41
import com .google .cloud .storage .CopyWriter ;
42
+ import com .google .cloud .storage .DataGenerator ;
42
43
import com .google .cloud .storage .PackagePrivateMethodWorkarounds ;
43
44
import com .google .cloud .storage .Storage ;
44
45
import com .google .cloud .storage .Storage .BlobField ;
@@ -562,7 +563,6 @@ public void testListBlobsCurrentDirectoryIncludesBothObjectsAndSyntheticDirector
562
563
}
563
564
564
565
@ Test
565
- // When gRPC support is added for matchGlob, enable this test for gRPC.
566
566
public void testListBlobsWithMatchGlob () throws Exception {
567
567
BucketInfo bucketInfo = BucketInfo .newBuilder (generator .randomBucketName ()).build ();
568
568
try (TemporaryBucket tempBucket =
@@ -848,8 +848,6 @@ public void testComposeBlobFail() {
848
848
}
849
849
850
850
@ Test
851
- // Bucket attribute extration on allowlist bug b/246634709
852
- @ Exclude (transports = Transport .GRPC )
853
851
public void testCopyBlob () {
854
852
855
853
String sourceBlobName = generator .randomObjectName () + "-source" ;
@@ -872,8 +870,35 @@ public void testCopyBlob() {
872
870
}
873
871
874
872
@ Test
875
- // Bucket attribute extration on allowlist bug b/246634709
876
- @ Exclude (transports = Transport .GRPC )
873
+ public void copyBlob_classChange_multipleChunks () {
874
+
875
+ String sourceBlobName = generator .randomObjectName () + "-source" ;
876
+ BlobId source = BlobId .of (bucket .getName (), sourceBlobName );
877
+ ImmutableMap <String , String > metadata = ImmutableMap .of ("k" , "v" );
878
+ BlobInfo blob = BlobInfo .newBuilder (source ).setMetadata (metadata ).build ();
879
+ int _5MiB = 5 * 1024 * 1024 ;
880
+ byte [] bytes = DataGenerator .base64Characters ().genBytes (_5MiB );
881
+ Blob remoteBlob = storage .create (blob , bytes );
882
+ assertThat (remoteBlob ).isNotNull ();
883
+ String targetBlobName = generator .randomObjectName () + "-target" ;
884
+ CopyRequest req =
885
+ CopyRequest .newBuilder ()
886
+ .setSource (source )
887
+ .setTarget (
888
+ BlobInfo .newBuilder (bucket , targetBlobName )
889
+ // change the storage class to force GCS to copy bytes
890
+ .setStorageClass (StorageClass .NEARLINE )
891
+ .build (),
892
+ BlobTargetOption .doesNotExist ())
893
+ .setMegabytesCopiedPerChunk (2L )
894
+ .build ();
895
+ CopyWriter copyWriter = storage .copy (req );
896
+ BlobInfo remoteBlob2 = copyWriter .getResult ();
897
+ assertThat (copyWriter .isDone ()).isTrue ();
898
+ assertThat (remoteBlob2 ).isNotNull ();
899
+ }
900
+
901
+ @ Test
877
902
public void testCopyBlobWithPredefinedAcl () {
878
903
879
904
String sourceBlobName = generator .randomObjectName () + "-source" ;
@@ -903,8 +928,6 @@ public void testCopyBlobWithPredefinedAcl() {
903
928
}
904
929
905
930
@ Test
906
- // Bucket attribute extration on allowlist bug b/246634709
907
- @ Exclude (transports = Transport .GRPC )
908
931
public void testCopyBlobWithEncryptionKeys () {
909
932
910
933
String sourceBlobName = generator .randomObjectName () + "-source" ;
@@ -955,8 +978,6 @@ public void testCopyBlobWithEncryptionKeys() {
955
978
}
956
979
957
980
@ Test
958
- // Bucket attribute extration on allowlist bug b/246634709
959
- @ Exclude (transports = Transport .GRPC )
960
981
public void testCopyBlobUpdateMetadata () {
961
982
962
983
String sourceBlobName = generator .randomObjectName () + "-source" ;
@@ -981,9 +1002,7 @@ public void testCopyBlobUpdateMetadata() {
981
1002
assertTrue (storage .delete (bucket .getName (), targetBlobName ));
982
1003
}
983
1004
984
- // Re-enable this test when it stops failing
985
- // @Test
986
- @ Exclude (transports = Transport .GRPC )
1005
+ @ Test
987
1006
public void testCopyBlobUpdateStorageClass () {
988
1007
String sourceBlobName = generator .randomObjectName () + "-source" ;
989
1008
BlobId source = BlobId .of (bucket .getName (), sourceBlobName );
@@ -1007,8 +1026,6 @@ public void testCopyBlobUpdateStorageClass() {
1007
1026
}
1008
1027
1009
1028
@ Test
1010
- // Bucket attribute extration on allowlist bug b/246634709
1011
- @ Exclude (transports = Transport .GRPC )
1012
1029
public void testCopyBlobNoContentType () {
1013
1030
1014
1031
String sourceBlobName = generator .randomObjectName () + "-source" ;
@@ -1022,17 +1039,16 @@ public void testCopyBlobNoContentType() {
1022
1039
CopyWriter copyWriter = storage .copy (req );
1023
1040
assertEquals (bucket .getName (), copyWriter .getResult ().getBucket ());
1024
1041
assertEquals (targetBlobName , copyWriter .getResult ().getName ());
1025
- assertNull (copyWriter .getResult ().getContentType ());
1042
+ assertTrue (
1043
+ copyWriter .getResult ().getContentType () == null
1044
+ || copyWriter .getResult ().getContentType ().isEmpty ());
1026
1045
assertEquals (metadata , copyWriter .getResult ().getMetadata ());
1027
1046
assertTrue (copyWriter .isDone ());
1028
1047
assertTrue (remoteSourceBlob .delete ());
1029
1048
assertTrue (storage .delete (bucket .getName (), targetBlobName ));
1030
1049
}
1031
1050
1032
1051
@ Test
1033
- // Verified against testbench
1034
- // Bucket attribute extration on allowlist bug b/246634709
1035
- @ Exclude (transports = Transport .GRPC )
1036
1052
public void testCopyBlobFail () {
1037
1053
1038
1054
String sourceBlobName = "test-copy-blob-source-fail" ;
0 commit comments