4444import java .io .FileInputStream ;
4545import java .io .FileOutputStream ;
4646import java .io .IOException ;
47+ import java .io .InputStream ;
4748import java .net .HttpURLConnection ;
4849import java .net .URI ;
4950import java .net .URISyntaxException ;
@@ -657,6 +658,10 @@ public void testBlobSnapshotValidationTest() throws StorageException, URISyntaxE
657658 byte [] retrievedBuff = outStream .toByteArray ();
658659 assertEquals (length , retrievedBuff .length );
659660
661+ InputStream inputStream = blobSnapshot .openInputStream ();
662+ retrievedBuff = inputStream .readAllBytes ();
663+ assertEquals (length , retrievedBuff .length );
664+
660665 // Read operation should work fine.
661666 blobSnapshot .downloadAttributes ();
662667
@@ -667,6 +672,11 @@ public void testBlobSnapshotValidationTest() throws StorageException, URISyntaxE
667672 blobSnapshotUsingRootUri .download (outStream );
668673 retrievedBuff = outStream .toByteArray ();
669674 assertEquals (length , retrievedBuff .length );
675+
676+ inputStream = blobSnapshotUsingRootUri .openInputStream ();
677+ retrievedBuff = inputStream .readAllBytes ();
678+ assertEquals (length , retrievedBuff .length );
679+
670680 assertEquals (blobSnapshot .getSnapshotID (), blobSnapshotUsingRootUri .getSnapshotID ());
671681
672682 // Expect an IllegalArgumentException from upload.
@@ -707,6 +717,33 @@ public void testBlobSnapshotValidationTest() throws StorageException, URISyntaxE
707717 catch (IllegalArgumentException e ) {
708718 assertEquals ("Cannot perform this operation on a blob representing a snapshot." , e .getMessage ());
709719 }
720+
721+ // Expect an IllegalArgumentException from openOutputStream.
722+ try {
723+ blobSnapshotUsingRootUri .openOutputStream ();
724+ fail ("Expect an IllegalArgumentException from openOutputStream" );
725+ }
726+ catch (IllegalArgumentException e ) {
727+ assertEquals ("Cannot perform this operation on a blob representing a snapshot." , e .getMessage ());
728+ }
729+
730+ // Expect an IllegalArgumentException from uploadBlock.
731+ try {
732+ blobSnapshotUsingRootUri .uploadBlock ("foo" , new ByteArrayInputStream (new byte [0 ]), 0 );
733+ fail ("Expect an IllegalArgumentException from uploadBlock" );
734+ }
735+ catch (IllegalArgumentException e ) {
736+ assertEquals ("Cannot perform this operation on a blob representing a snapshot." , e .getMessage ());
737+ }
738+
739+ // Expect an IllegalArgumentException from commitBlockList.
740+ try {
741+ blobSnapshotUsingRootUri .commitBlockList (new ArrayList <BlockEntry >());
742+ fail ("Expect an IllegalArgumentException from commitBlockList" );
743+ }
744+ catch (IllegalArgumentException e ) {
745+ assertEquals ("Cannot perform this operation on a blob representing a snapshot." , e .getMessage ());
746+ }
710747 }
711748
712749 /**
0 commit comments