コード例 #1
0
  @Test
  public void shouldFindRemovedFiles() throws Exception {
    File newFile = createFileForClass(TestFakeProduct.class);
    assertThat(detector.findChangedFiles(), hasItem(newFile));

    FileUtils.forceDelete(newFile);

    assertTrue(detector.filesWereRemoved());
    assertThat(detector.findChangedFiles(), not(hasItem(newFile)));
  }
コード例 #2
0
  @Before
  public void inContext() throws IOException {
    changeDetector = mock(ChangeDetector.class);
    when(changeDetector.findChangedFiles()).thenThrow(new IOException());

    changeDetector.clear();

    testDetector = new StubTestDetector();
    core = createCore(changeDetector, testDetector);
  }
コード例 #3
0
 @Test
 public void shouldBeTolerantOfDissapearingDirectories() throws Exception {
   detector =
       new FileChangeDetector() {
         @Override
         protected File[] childrenOf(File directory) {
           return null;
         }
       };
   detector.setClasspathProvider(classpath);
   assertEquals(emptySet(), detector.findChangedFiles());
 }
コード例 #4
0
 @Test
 public void shouldFindChangedFiles() throws IOException {
   Set<File> files = detector.findChangedFiles();
   assertTrue("Should have found changed files on first run", files.size() > 0);
   assertThat(
       "TestFakeProduct should be in changed list",
       files,
       hasItem(getFileForClass(TestFakeProduct.class)));
   assertTrue(
       "FakeProduct should be in changed list",
       files.contains(getFileForClass(FakeProduct.class)));
   assertTrue("Should have no changed files now", detector.findChangedFiles().isEmpty());
 }
コード例 #5
0
 @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());
 }
コード例 #6
0
 @Test
 public void canLookInMultipleClassDirectories() throws Exception {
   File newFile = createFileForClass(TestFakeProduct.class);
   File thisFile = InfinitestTestUtils.getFileForClass(getClass());
   Set<File> changedFiles = detector.findChangedFiles();
   assertThat(changedFiles, hasItem(newFile));
   assertThat(changedFiles, hasItem(thisFile));
 }
コード例 #7
0
 @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);
 }
コード例 #8
0
 @Test
 public void shouldHandleStrangeClasspaths() throws Exception {
   ChangeDetector changeDetector = new FileChangeDetector();
   changeDetector.setClasspathProvider(new StandaloneClasspath(new ArrayList<File>(), ""));
   assertTrue(changeDetector.findChangedFiles().isEmpty());
 }