FilesystemInstallation implements Installation { @Override public synchronized void addContent(DataInVersion dataInVersion) { if (this.running) { dataInVersion.storeIn(versionFolder); } } private  FilesystemInstallation(File versionFolder); static Installation create(File versionFolder, ProgressReport report); @Override synchronized void addContent(DataInVersion dataInVersion); @Override synchronized void abort(); @Override synchronized void finish(); @Override boolean isRunning();  }
@Test(expected = UpdateFailedException.class) public void throwsUpdateFailedExceptionOnError() throws Exception { File versionFolder = folder.getRoot(); File contentFile = new File(versionFolder, "ContentFile"); versionFolder.mkdir(); contentFile.createNewFile(); contentFile.setReadOnly(); File newFile = new File(folder.newFolder("sourceFolder"), "ContentFile"); installation.addContent(new FileDataInVersion(newFile)); }
@Test(expected = UpdateFailedException.class) public void throwsUpdateFailedExceptionWhenURLCannotBeResolved() throws Exception { File contentFile = folder.newFile("ContentFile"); contentFile.delete(); installation.addContent(new UrlDataInVersion(contentFile.toURI().toURL(), "TheContent")); }
@Test public void addsContentToVersionFolderFromURL() throws Exception { File contentFile = folder.newFile("ContentFile"); FileUtils.writeStringToFile(contentFile, "XXX"); installation.addContent(new UrlDataInVersion(contentFile.toURI().toURL(), "TheContent")); File versionFolder = folder.getRoot(); File versionContentFile = new File(versionFolder, "TheContent"); assertThat(FileUtils.readFileToString(versionContentFile), is("XXX")); }