public void testContainer() throws IOException, InterruptedException { storageHandler.copyImage(currentProjectName, testImage.getAbsolutePath(), null); String checksumImage = Utils.md5Checksum(testImage); FileChecksumContainer fileChecksumContainer = projectManager.getFileChecksumContainer(); assertTrue( "Checksum isn't in container", fileChecksumContainer.containsChecksum(checksumImage)); // wait to get a different timestamp on next file Thread.sleep(2000); File newTestImage = storageHandler.copyImage(currentProjectName, testImage.getAbsolutePath(), null); File imageDirectory = new File( Constants.DEFAULT_ROOT + "/" + currentProjectName + "/" + Constants.IMAGE_DIRECTORY + "/"); File[] filesImage = imageDirectory.listFiles(); // nomedia file is also in images folder assertEquals("Wrong amount of files in folder", 2, filesImage.length); File newTestSound = storageHandler.copySoundFile(testSound.getAbsolutePath()); String checksumSound = Utils.md5Checksum(testSound); assertTrue( "Checksum isn't in container", fileChecksumContainer.containsChecksum(checksumSound)); File soundDirectory = new File( Constants.DEFAULT_ROOT + "/" + currentProjectName + "/" + Constants.SOUND_DIRECTORY); File[] filesSound = soundDirectory.listFiles(); // nomedia file is also in sounds folder assertEquals("Wrong amount of files in folder", 2, filesSound.length); fileChecksumContainer.decrementUsage(newTestImage.getAbsolutePath()); assertTrue("Checksum was deleted", fileChecksumContainer.containsChecksum(checksumImage)); fileChecksumContainer.decrementUsage(newTestImage.getAbsolutePath()); assertFalse("Checksum wasn't deleted", fileChecksumContainer.containsChecksum(checksumImage)); fileChecksumContainer.decrementUsage(newTestSound.getAbsolutePath()); assertFalse("Checksum wasn't deleted", fileChecksumContainer.containsChecksum(checksumSound)); }
public void testDeleteFile() throws IOException, InterruptedException { File newTestImage1 = storageHandler.copyImage(currentProjectName, testImage.getAbsolutePath(), null); // wait to get a different timestamp on next file Thread.sleep(2000); storageHandler.deleteFile(newTestImage1.getAbsolutePath()); File imageDirectory = new File( Constants.DEFAULT_ROOT + "/" + currentProjectName + "/" + Constants.IMAGE_DIRECTORY); File[] filesImage = imageDirectory.listFiles(); assertEquals("Wrong amount of files in folder", 1, filesImage.length); File newTestSound = storageHandler.copySoundFile(testSound.getAbsolutePath()); storageHandler.deleteFile(newTestSound.getAbsolutePath()); File soundDirectory = new File( Constants.DEFAULT_ROOT + "/" + currentProjectName + "/" + Constants.SOUND_DIRECTORY); File[] filesSound = soundDirectory.listFiles(); assertEquals("Wrong amount of files in folder", 1, filesSound.length); }