### Question:
ClientBlob extends AbstractBlob { @Override public InputStream openInputStream() throws IOException { ensureOpen(); return streamMgr.manageInputStream(getConnection(), new ClientInputStream(remote.openInputStream())); } ClientBlob(BlobStoreConnection con, StreamManager streamMgr,
                    RemoteBlob remote); @Override URI getCanonicalId(); @Override InputStream openInputStream(); @Override OutputStream openOutputStream(long estSize, boolean overwrite); @Override long getSize(); @Override boolean exists(); @Override void delete(); @Override Blob moveTo(URI blobId, Map<String, String> hints);  }### Answer:
@Test public void testOpenInputStream() throws IOException { URI id = URI.create("foo:bar"); InputStream in = createMock(InputStream.class); makeThreadSafe(in, true); reset(blob); makeThreadSafe(blob, true); expect(blob.openInputStream()).andReturn(in); expect(blob.openInputStream()).andThrow(new MissingBlobException(id)); expect(in.read()).andReturn(42); in.close(); expectLastCall().atLeastOnce(); replay(blob); replay(in); InputStream ci = cb.openInputStream(); assertNotNull(ci); assertEquals(42, ci.read()); ci.close(); try { cb.openInputStream(); fail("Failed to rcv expected exception"); } catch (MissingBlobException e) { assertEquals(id, e.getBlobId()); } verify(blob); verify(in); }