Ejemplo n.º 1
0
 private String runCreateFileAndGetContent(String[] args) throws Exception {
   updater.parseCommandLine(args);
   File resultFile = updater.createUpdateList();
   String content = FileUtil.getFileContent(resultFile);
   FileUtil.deleteFile(resultFile);
   return content;
 }
Ejemplo n.º 2
0
 @Test
 public void shouldKnowIfAGivenDirectoryExists() throws Exception {
   File testFolder = new File("TestFolder");
   testFolder.mkdir();
   updater.parseCommandLine(new String[] {"TestFolder"});
   assertTrue(updater.directoriesAreValid());
   FileUtil.deleteFileSystemDirectory(testFolder);
   assertFalse(updater.directoriesAreValid());
 }
Ejemplo n.º 3
0
 @Test
 public void testMainUnhappyPath() throws Exception {
   String args[] = {"foo", "bar"};
   UpdateFileList updaterMock = mock(UpdateFileList.class);
   UpdateFileList.testUpdater = updaterMock;
   when(updaterMock.directoriesAreValid()).thenReturn(false);
   UpdateFileList.main(args);
   verify(updaterMock).printMessage("Some directories are invalid.");
   verify(updaterMock).exit();
 }
Ejemplo n.º 4
0
 @Test
 public void testMainHappyPath() throws Exception {
   String args[] = {"foo", "bar"};
   UpdateFileList updaterMock = mock(UpdateFileList.class);
   UpdateFileList.testUpdater = updaterMock;
   when(updaterMock.directoriesAreValid()).thenReturn(true);
   UpdateFileList.main(args);
   verify(updaterMock).parseCommandLine(args);
   verify(updaterMock).createUpdateList();
   verify(updaterMock).createDoNotUpdateList();
 }
Ejemplo n.º 5
0
 @Test
 public void shouldPutSpecialFilesInDifferentList() throws Exception {
   String arg1 = "-doNotReplace:MasterFolder/TestFolder/fitnesse.css";
   String arg2 = "-doNotReplace:MasterFolder/TestFolder/fitnesse_print.css";
   updater.parseCommandLine(new String[] {arg1, arg2, "MasterFolder/TestFolder"});
   File doNotUpdateFile = updater.createDoNotUpdateList();
   String doNotUpdateContent = FileUtil.getFileContent(doNotUpdateFile);
   FileUtil.deleteFile(doNotUpdateFile);
   assertSubString("TestFolder/fitnesse.css", doNotUpdateContent);
   assertSubString("TestFolder/fitnesse_print.css", doNotUpdateContent);
   assertDoesntHaveRegexp("TestFolder/TestFile", doNotUpdateContent);
 }
Ejemplo n.º 6
0
  public static void main(String[] args) {
    UpdateFileList updater = testUpdater != null ? testUpdater : new UpdateFileList();

    updater.parseCommandLine(args);
    if (updater.directoriesAreValid()) {
      updater.createUpdateList();
      updater.createDoNotUpdateList();
    } else {
      LOG.severe("Some directories are invalid. Aborting.");
      updater.exit();
    }
  }
Ejemplo n.º 7
0
 @Test
 public void shouldHandleInvalidCommandLine() throws Exception {
   boolean validCommandLine = updater.parseCommandLine(new String[0]);
   assertFalse(validCommandLine);
 }
Ejemplo n.º 8
0
 @Test
 public void canParseTheCommandLine() throws Exception {
   updater.parseCommandLine(new String[] {"testDir"});
   assertEquals(1, updater.getDirectories().size());
   assertEquals("testDir", updater.getDirectories().get(0));
 }
Ejemplo n.º 9
0
 @Test
 public void makeAnUpdateFileList() throws Exception {
   assertTrue(updater.getClass() == UpdateFileList.class);
 }
Ejemplo n.º 10
0
 @Test
 public void shouldSplitUpWindowsLikePathNames() throws Exception {
   String args[] = {"-baseDirectory:C:\\FitNesse/Resources", "MasterFolder"};
   updater.parseCommandLine(args);
   assertEquals(asList("C:\\FitNesse/Resources/MasterFolder"), updater.getDirectories());
 }