@Test @PrepareForTest(KodoOutputStream.class) public void testConstructor() throws Exception { PowerMockito.whenNew(File.class).withArguments(Mockito.anyString()).thenReturn(mFile); String errorMessage = "protocol doesn't support output"; PowerMockito.whenNew(FileOutputStream.class).withArguments(mFile) .thenThrow(new IOException(errorMessage)); mThrown.expect(IOException.class); mThrown.expectMessage(errorMessage); new KodoOutputStream("testKey", mKodoClient, sTmpDirs).close(); }
@Override public void close() { if (mClosed.getAndSet(true)) { return; } try { mLocalOutputStream.close(); mKodoClient.uploadFile(mKey, mFile); } catch (Exception e) { LOG.error("Failed to upload {}.", mKey, e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } } }
KodoOutputStream extends OutputStream { @Override public void close() { if (mClosed.getAndSet(true)) { return; } try { mLocalOutputStream.close(); mKodoClient.uploadFile(mKey, mFile); } catch (Exception e) { LOG.error("Failed to upload {}.", mKey, e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } } } }
KodoOutputStream extends OutputStream { @Override public void close() { if (mClosed.getAndSet(true)) { return; } try { mLocalOutputStream.close(); mKodoClient.uploadFile(mKey, mFile); } catch (Exception e) { LOG.error("Failed to upload {}.", mKey, e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } } } KodoOutputStream(String key, KodoClient kodoClient, List<String> tmpDirs); }
KodoOutputStream extends OutputStream { @Override public void close() { if (mClosed.getAndSet(true)) { return; } try { mLocalOutputStream.close(); mKodoClient.uploadFile(mKey, mFile); } catch (Exception e) { LOG.error("Failed to upload {}.", mKey, e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } } } KodoOutputStream(String key, KodoClient kodoClient, List<String> tmpDirs); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close(); }
KodoOutputStream extends OutputStream { @Override public void close() { if (mClosed.getAndSet(true)) { return; } try { mLocalOutputStream.close(); mKodoClient.uploadFile(mKey, mFile); } catch (Exception e) { LOG.error("Failed to upload {}.", mKey, e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } } } KodoOutputStream(String key, KodoClient kodoClient, List<String> tmpDirs); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close();  }