@Test public void testStoreStreamUpdatesExistingDocumentAndDoesNotTryToCreateNewOne() throws Exception { final ByteArrayInputStream input = new ByteArrayInputStream("hello".getBytes()); makeConfigurationExisting("huch".getBytes()); storage.save(input); final File configFile = new File(tempDir.getRoot(), "configuration.zip"); assertTrue(configFile.exists()); assertArrayEquals("hello".getBytes(), FileUtils.readFileToByteArray(configFile)); }
@Override public void save(final InputStream stream) { FileOutputStream fileOutput; try { fileOutput = new FileOutputStream(configFile); try { IOUtils.copy(stream, fileOutput); } finally { fileOutput.close(); } } catch (final IOException e) { throw new RuntimeException(e); } }
FileStorage implements Storage { @Override public void save(final InputStream stream) { FileOutputStream fileOutput; try { fileOutput = new FileOutputStream(configFile); try { IOUtils.copy(stream, fileOutput); } finally { fileOutput.close(); } } catch (final IOException e) { throw new RuntimeException(e); } } }
FileStorage implements Storage { @Override public void save(final InputStream stream) { FileOutputStream fileOutput; try { fileOutput = new FileOutputStream(configFile); try { IOUtils.copy(stream, fileOutput); } finally { fileOutput.close(); } } catch (final IOException e) { throw new RuntimeException(e); } } FileStorage();   FileStorage(final File localStorageDirectory); }
FileStorage implements Storage { @Override public void save(final InputStream stream) { FileOutputStream fileOutput; try { fileOutput = new FileOutputStream(configFile); try { IOUtils.copy(stream, fileOutput); } finally { fileOutput.close(); } } catch (final IOException e) { throw new RuntimeException(e); } } FileStorage();   FileStorage(final File localStorageDirectory); @Override void save(final InputStream stream); @Override InputStream load(); }
FileStorage implements Storage { @Override public void save(final InputStream stream) { FileOutputStream fileOutput; try { fileOutput = new FileOutputStream(configFile); try { IOUtils.copy(stream, fileOutput); } finally { fileOutput.close(); } } catch (final IOException e) { throw new RuntimeException(e); } } FileStorage();   FileStorage(final File localStorageDirectory); @Override void save(final InputStream stream); @Override InputStream load();  }