SVN implements SourceControl { public static DateFormat getOutDateFormatter() { DateFormat f = new SimpleDateFormat(SVN_DATE_FORMAT_OUT); f.setTimeZone(TimeZone.getTimeZone("GMT")); return f; }  Map<String, String> getProperties(); void setProperty(String property); void setPropertyOnDelete(String propertyOnDelete); void setConfigDir(String configDir); void setCheckExternals(boolean value); void setRepositoryLocation(String repositoryLocation); void setLocalWorkingCopy(String localWorkingCopy); void setUsername(String userName); void setPassword(String password); void validate(); List<Modification> getModifications(final Date lastBuild, final Date now); static DateFormat getOutDateFormatter(); void setUseLocalRevision(boolean useLocalRevision);  }
@Test public void testParseModifications() throws JDOMException, ParseException, IOException { String svnLog = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<log>\n" + " <logentry revision=\"663\">\n" + " <author>lee</author>\n" + " <date>2003-04-30T10:01:42.349105Z</date>\n" + " <paths>\n" + " <path action=\"A\">/trunk/playground/aaa/ccc</path>\n" + " <path action=\"M\">/trunk/playground/aaa/ccc/d.txt</path>\n" + " <path action=\"A\">/trunk/playground/bbb</path>\n" + " </paths>\n" + " <msg>bli</msg>\n" + " </logentry>\n" + " <logentry revision=\"664\">\n" + " <author>etienne</author>\n" + " <date>2003-04-30T10:03:14.100900Z</date>\n" + " <paths>\n" + " <path action=\"A\">/trunk/playground/aaa/f.txt</path>\n" + " </paths>\n" + " <msg>bla</msg>\n" + " </logentry>\n" + " <logentry revision=\"665\">\n" + " <author>martin</author>\n" + " <date>2003-04-30T10:04:48.050619Z</date>\n" + " <paths>\n" + " <path action=\"D\">/trunk/playground/bbb</path>\n" + " </paths>\n" + " <msg>blo</msg>\n" + " </logentry>\n" + "</log>"; Modification[] modifications = SVN.SVNLogXMLParser.parse(new StringReader(svnLog)); assertEquals(5, modifications.length); Modification modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:01:42.349"), "lee", "bli", "663", "", "/trunk/playground/aaa/ccc", "added"); assertThat(modifications[0], equalTo(modification)); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:01:42.349"), "lee", "bli", "663", "", "/trunk/playground/aaa/ccc/d.txt", "modified"); assertThat(modifications[1], equalTo(modification)); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:01:42.349"), "lee", "bli", "663", "", "/trunk/playground/bbb", "added"); assertThat(modifications[2], equalTo(modification)); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:03:14.100"), "etienne", "bla", "664", "", "/trunk/playground/aaa/f.txt", "added"); assertThat(modifications[3], equalTo(modification)); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:04:48.050"), "martin", "blo", "665", "", "/trunk/playground/bbb", "deleted"); assertThat(modifications[4], equalTo(modification)); modifications = SVN.SVNLogXMLParser.parse(new StringReader(svnLog), "external/path"); assertEquals(5, modifications.length); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:01:42.349"), "lee", "bli", "663", "", "/external/path:/trunk/playground/aaa/ccc", "added"); assertThat(modifications[0], equalTo(modification)); modifications = SVN.SVNLogXMLParser.parse(new StringReader(svnLog), null); assertEquals(5, modifications.length); modification = createModification(SVN.getOutDateFormatter().parse("2003-04-30T10:01:42.349"), "lee", "bli", "663", "", "/trunk/playground/aaa/ccc/d.txt", "modified"); assertThat(modifications[1], equalTo(modification)); }
@Test public void testParseAndFilter() throws ParseException, JDOMException, IOException { String svnLog = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<log>\n" + " <logentry revision=\"663\">\n" + " <author>lee</author>\n" + " <date>2003-08-02T10:01:13.349105Z</date>\n" + " <paths>\n" + " <path action=\"A\">/trunk/playground/bbb</path>\n" + " </paths>\n" + " <msg>bli</msg>\n" + " </logentry>\n" + " <logentry revision=\"664\">\n" + " <author>etienne</author>\n" + " <date>2003-07-29T17:45:12.100900Z</date>\n" + " <paths>\n" + " <path action=\"A\">/trunk/playground/aaa/f.txt</path>\n" + " </paths>\n" + " <msg>bla</msg>\n" + " </logentry>\n" + " <logentry revision=\"665\">\n" + " <author>martin</author>\n" + " <date>2003-07-29T18:15:11.100900Z</date>\n" + " <paths>\n" + " <path action=\"D\">/trunk/playground/ccc</path>\n" + " </paths>\n" + " <msg>blo</msg>\n" + " </logentry>\n" + "</log>"; TimeZone.setDefault(TimeZone.getTimeZone("GMT+0:00")); Date julyTwentynineSixPM2003 = new GregorianCalendar(2003, Calendar.JULY, 29, 18, 0, 0).getTime(); List modifications = SVN.SVNLogXMLParser.parseAndFilter(new StringReader(svnLog), julyTwentynineSixPM2003); assertEquals(2, modifications.size()); Modification modification = createModification(SVN.getOutDateFormatter().parse("2003-08-02T10:01:13.349"), "lee", "bli", "663", "", "/trunk/playground/bbb", "added"); assertThat((Modification) modifications.get(0), equalTo(modification)); modification = createModification(SVN.getOutDateFormatter().parse("2003-07-29T18:15:11.100"), "martin", "blo", "665", "", "/trunk/playground/ccc", "deleted"); assertThat((Modification) modifications.get(1), equalTo(modification)); Date julyTwentyeightZeroPM2003 = new GregorianCalendar(2003, Calendar.JULY, 28, 0, 0, 0).getTime(); modifications = SVN.SVNLogXMLParser.parseAndFilter(new StringReader(svnLog), julyTwentyeightZeroPM2003); assertEquals(3, modifications.size()); modifications = SVN.SVNLogXMLParser.parseAndFilter(new StringReader(svnLog), julyTwentynineSixPM2003, "external/path"); assertEquals(2, modifications.size()); modification = createModification(SVN.getOutDateFormatter().parse("2003-08-02T10:01:13.349"), "lee", "bli", "663", "", "/external/path:/trunk/playground/bbb", "added"); assertThat((Modification) modifications.get(0), equalTo(modification)); }