@Before public void inContext() throws Exception { altClassDir = new File("altClasses"); FileUtils.forceMkdir(altClassDir); List<File> buildPaths = new ArrayList<File>(); buildPaths.addAll(fakeBuildPaths()); buildPaths.add(altClassDir); classpath = new StandaloneClasspath(buildPaths); detector = new FileChangeDetector(); detector.setClasspathProvider(classpath); }
@Test public void shouldBeTolerantOfDissapearingDirectories() throws Exception { detector = new FileChangeDetector() { @Override protected File[] childrenOf(File directory) { return null; } }; detector.setClasspathProvider(classpath); assertEquals(emptySet(), detector.findChangedFiles()); }
@Test public void shouldDetectChangedFilesByTimeStamp() throws Exception { detector = new FileChangeDetector() { @Override protected long getModificationTimestamp(File classFile) { return timestamp; } }; detector.setClasspathProvider(classpath); assertFalse( "Should have found changed files on first run", detector.findChangedFiles().isEmpty()); assertTrue("Timestamp is unchanged", detector.findChangedFiles().isEmpty()); timestamp += 100; assertFalse("Timestamp changed", detector.findChangedFiles().isEmpty()); }
@Test public void shouldHandleStrangeClasspaths() throws Exception { ChangeDetector changeDetector = new FileChangeDetector(); changeDetector.setClasspathProvider(new StandaloneClasspath(new ArrayList<File>(), "")); assertTrue(changeDetector.findChangedFiles().isEmpty()); }