Skip to content

Commit

Permalink
Fixed test.
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed May 6, 2017
1 parent 3f5c636 commit b977dfc
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,41 +86,41 @@ public void testScan() throws IOException {
public void testClean() throws IOException {
final String repoDir = getCurrentTestDir().getCanonicalPath() + File.separator + "repo2";

StroomZipRepository StroomZipRepository = new StroomZipRepository(repoDir, false, 10000, ZIP_FILENAME_DELIMITER);
StroomZipRepository stroomZipRepository = new StroomZipRepository(repoDir, false, 10000, ZIP_FILENAME_DELIMITER);

final StroomZipOutputStream out1 = StroomZipRepository.getStroomZipOutputStream();
final StroomZipOutputStream out1 = stroomZipRepository.getStroomZipOutputStream();
StroomZipOutputStreamUtil.addSimpleEntry(out1, new StroomZipEntry(null, "file", StroomZipFileType.Data),
"SOME_DATA".getBytes(StreamUtil.DEFAULT_CHARSET));
Assert.assertFalse(out1.getFinalFile().isFile());
out1.close();
Assert.assertTrue(out1.getFinalFile().isFile());

final StroomZipOutputStream out2 = StroomZipRepository.getStroomZipOutputStream();
final StroomZipOutputStream out2 = stroomZipRepository.getStroomZipOutputStream();
StroomZipOutputStreamUtil.addSimpleEntry(out2, new StroomZipEntry(null, "file", StroomZipFileType.Data),
"SOME_DATA".getBytes(StreamUtil.DEFAULT_CHARSET));
Assert.assertFalse(out2.getFinalFile().isFile());
Assert.assertTrue(new File(out2.getFinalFile().getAbsolutePath() + StroomZipRepository.LOCK_EXTENSION).isFile());

// Leave open

StroomZipRepository = new StroomZipRepository(repoDir, false, 1000, ZIP_FILENAME_DELIMITER);
stroomZipRepository = new StroomZipRepository(repoDir, false, 10000, ZIP_FILENAME_DELIMITER);
Assert.assertTrue("Expecting pucker file to be left", out1.getFinalFile().isFile());
Assert.assertTrue("Expecting lock file to not be deleted",
new File(out2.getFinalFile().getAbsolutePath() + StroomZipRepository.LOCK_EXTENSION).isFile());

final StroomZipOutputStream out3 = StroomZipRepository.getStroomZipOutputStream();
final StroomZipOutputStream out3 = stroomZipRepository.getStroomZipOutputStream();
StroomZipOutputStreamUtil.addSimpleEntry(out3, new StroomZipEntry(null, "file", StroomZipFileType.Data),
"SOME_DATA".getBytes(StreamUtil.DEFAULT_CHARSET));
final File lockFile3 = new File(out3.getFinalFile().getAbsolutePath() + StroomZipRepository.LOCK_EXTENSION);
Assert.assertTrue(lockFile3.isFile());

StroomZipRepository.clean();
stroomZipRepository.clean();
Assert.assertTrue(lockFile3.isFile());

if (!lockFile3.setLastModified(System.currentTimeMillis() - (48 * 60 * 60 * 1000))) {
Assert.fail("Unable to set LastModified");
}
StroomZipRepository.clean();
stroomZipRepository.clean();
Assert.assertFalse("Expecting old lock file to be deleted", lockFile3.isFile());
}

Expand Down

0 comments on commit b977dfc

Please sign in to comment.