@Test public void testDateFormats() { DateTimeTestData[] dates = new DateTimeTestData[]{ new DateTimeTestData("2020-03-24T17:11:35.545818Z", LocalDateTime.of(2020, 3, 24, 17, 11, 35, 545000000)), new DateTimeTestData("2007-09-11T11:48:56.123456Z", LocalDateTime.of(2007, 9, 11, 11, 48, 56, 123000000)), new DateTimeTestData("2007-09-11T11:48:56.000000Z", LocalDateTime.of(2007, 9, 11, 11, 48, 56)), new DateTimeTestData("2007-09-11T11:48:56.Z", LocalDateTime.of(2007, 9, 11, 11, 48, 56)), new DateTimeTestData("2007-09-11 11:48:56Z"), new DateTimeTestData("2007-09-11T11:48:56"), new DateTimeTestData("2007-09-11T11:48:56.123456"), new DateTimeTestData("2007-09-11T11:48:56.000000"), }; for (int i = 0; i < dates.length; i++) { String revId = "12345"; String author = "username1"; String file = "trunk/project/filename.ext"; try { String output = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + " revision=\"" + revId + "\">\n" + "<author>" + author + "</author>\n" + "<date>" + dates[i].dateTimeString + "</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">" + file + "</path>\n" + "</paths>\n" + "<msg>* " + file + "\n" + " Description.\n" + "</msg>\n" + "</logentry>\n" + "</log>"; History result = instance.parse(output); assertNotNull(result); assertNotNull(result.getHistoryEntries()); assertEquals(1, result.getHistoryEntries().size()); HistoryEntry e = result.getHistoryEntries().get(0); assertEquals(revId, e.getRevision()); assertEquals(author, e.getAuthor()); Date actualDateTime = Date.from(dates[i].actualDateTime.atZone(ZoneOffset.systemDefault()).toInstant()); assertEquals(dates[i].dateTimeString, actualDateTime, e.getDate()); assertEquals(1, e.getFiles().size()); assertEquals(Paths.get(Paths.get("/"+file).toUri()).toFile().toString(), e.getFiles().first()); if (dates[i].expectedException) { fail("Should throw an IO exception for " + dates[i].dateTimeString); } } catch (IOException ex) { if (!dates[i].expectedException) { fail("Should not throw an IO exception for " + dates[i].dateTimeString); } } } }
History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); } }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  @Override void processStream(InputStream input); }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  @Override void processStream(InputStream input);  }