### Question:
ClientBlob extends AbstractBlob { @Override public OutputStream openOutputStream(long estSize, boolean overwrite) throws IOException { ensureOpen(); return streamMgr.manageOutputStream(getConnection(), new ClientOutputStream(remote.openOutputStream(estSize, overwrite))); } 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 testOpenOutputStream() throws IOException { URI id = URI.create("foo:bar"); OutputStream out = createMock(OutputStream.class); makeThreadSafe(out, true); reset(blob); makeThreadSafe(blob, true); expect(blob.openOutputStream(42L, true)).andReturn(out); expect(blob.openOutputStream(-1L, true)).andThrow(new MissingBlobException(id)); out.write(42); out.close(); expectLastCall().atLeastOnce(); replay(blob); replay(out); OutputStream co = cb.openOutputStream(42L, true); assertNotNull(co); co.write(42); co.close(); try { cb.openOutputStream(-1L, true); fail("Failed to rcv expected exception"); } catch (MissingBlobException e) { assertEquals(id, e.getBlobId()); } verify(blob); verify(out); }