3434import java .util .Arrays ;
3535import java .util .Map ;
3636import java .util .Random ;
37+ import static org .easymock .EasyMock .verify ;
38+ import org .junit .After ;
3739
3840public class BlobReadChannelTest {
3941
@@ -55,28 +57,19 @@ public void setUp() throws IOException, InterruptedException {
5557 storageRpcMock = EasyMock .createMock (StorageRpc .class );
5658 }
5759
58- @ Test
59- public void testCreate () {
60- EasyMock .expect (optionsMock .storageRpc ()).andReturn (storageRpcMock );
61- EasyMock .replay (optionsMock );
62- reader = new BlobReadChannelImpl (optionsMock , BLOB_INFO , EMPTY_RPC_OPTIONS );
63- assertTrue (reader .isOpen ());
60+ @ After
61+ public void tearDown () throws Exception {
62+ verify (optionsMock );
63+ verify (storageRpcMock );
6464 }
6565
6666 @ Test
67- public void testReadSmall () throws IOException {
67+ public void testCreate () {
6868 EasyMock .expect (optionsMock .storageRpc ()).andReturn (storageRpcMock );
69- EasyMock .expect (optionsMock .retryParams ()).andReturn (RetryParams .noRetries ());
7069 EasyMock .replay (optionsMock );
71- reader = new BlobReadChannelImpl (optionsMock , BLOB_INFO , EMPTY_RPC_OPTIONS );
72- byte [] result = randomByteArray (DEFAULT_CHUNK_SIZE );
73- ByteBuffer readBuffer = ByteBuffer .allocate (42 );
74- EasyMock
75- .expect (storageRpcMock .read (BLOB_INFO .toPb (), EMPTY_RPC_OPTIONS , 0 , DEFAULT_CHUNK_SIZE ))
76- .andReturn (result );
7770 EasyMock .replay (storageRpcMock );
78- reader . read ( readBuffer );
79- assertArrayEquals ( Arrays . copyOf ( result , readBuffer . capacity ()), readBuffer . array ());
71+ reader = new BlobReadChannelImpl ( optionsMock , BLOB_INFO , EMPTY_RPC_OPTIONS );
72+ assertTrue ( reader . isOpen ());
8073 }
8174
8275 @ Test
@@ -120,7 +113,6 @@ public void testReadBig() throws IOException {
120113 storageRpcMock .read (BLOB_INFO .toPb (), EMPTY_RPC_OPTIONS , DEFAULT_CHUNK_SIZE ,
121114 CUSTOM_CHUNK_SIZE ))
122115 .andReturn (secondResult );
123- EasyMock .expectLastCall ();
124116 EasyMock .replay (storageRpcMock );
125117 reader .read (firstReadBuffer );
126118 reader .read (secondReadBuffer );
@@ -165,6 +157,7 @@ public void testSeek() throws IOException {
165157 public void testClose () throws IOException {
166158 EasyMock .expect (optionsMock .storageRpc ()).andReturn (storageRpcMock );
167159 EasyMock .replay (optionsMock );
160+ EasyMock .replay (storageRpcMock );
168161 reader = new BlobReadChannelImpl (optionsMock , BLOB_INFO , EMPTY_RPC_OPTIONS );
169162 assertTrue (reader .isOpen ());
170163 reader .close ();
@@ -175,6 +168,7 @@ public void testClose() throws IOException {
175168 public void testReadClosed () {
176169 EasyMock .expect (optionsMock .storageRpc ()).andReturn (storageRpcMock );
177170 EasyMock .replay (optionsMock );
171+ EasyMock .replay (storageRpcMock );
178172 reader = new BlobReadChannelImpl (optionsMock , BLOB_INFO , EMPTY_RPC_OPTIONS );
179173 reader .close ();
180174 try {
0 commit comments