public void testGetModifications() throws Exception { final long timestamp = 100; HttpFile httpFile = new HttpFile() { protected long getURLLastModified(URL url) { return timestamp; } }; httpFile.setURL("http://dummy.domain.net/my/path?que=ry"); List modifications = httpFile.getModifications(new Date(1), new Date()); assertEquals(1, modifications.size()); Modification modif = (Modification) modifications.get(0); assertEquals("my/path?que=ry", modif.getFileName()); assertEquals("dummy.domain.net", modif.getFolderName()); assertEquals("dummy.domain.net/my/path?que=ry", modif.getFullPath()); assertEquals("", modif.comment); assertEquals(timestamp, modif.modifiedTime.getTime()); assertEquals("User", modif.userName); }
/** * Transforms a set of version properties into a CruiseControl Modification object. * * @param versionList a set of version information properties * @param n the index of the property information to use * @return a Modification object representing the change */ protected Modification transformJCaVersionContainerToModification( JCaContainer versionList, int n, boolean promote) { Modification mod = new Modification("harvest"); mod.revision = versionList.getString(JCaAttrKey.CA_ATTRKEY_MAPPED_VERSION_NAME, n); Modification.ModifiedFile modfile = mod.createModifiedFile( versionList.getString(JCaAttrKey.CA_ATTRKEY_NAME, n), versionList.getString(JCaAttrKey.CA_ATTRKEY_FULL_PATH_NAME, n)); modfile.revision = mod.revision; JCaTimeStamp created = versionList.getTimeStamp(JCaAttrKey.CA_ATTRKEY_MODIFIED_TIME, n); mod.modifiedTime = created.toDate(); mod.userName = versionList.getString(JCaAttrKey.CA_ATTRKEY_MODIFIER_NAME, n); mod.emailAddress = getEmailAddress(mod.userName); mod.comment = versionList.getString(JCaAttrKey.CA_ATTRKEY_DESCRIPTION, n); String status = versionList.getString(JCaAttrKey.CA_ATTRKEY_VERSION_STATUS, n); if (promote) { if (status.equals("N")) { // If this is the first revision, then the file has been newly added if (mod.revision.equals("0")) { modfile.action = "added"; } else { modfile.action = "modified"; } } else if (status.equals("D")) { modfile.action = "deleted"; if (propertyOnDelete != null) { properties.put(propertyOnDelete, "true"); } } else if (status.equals("R")) { modfile.action = "reserved"; } else if (status.equals("M")) { modfile.action = "merge_tagged"; } } else { // Any versions which have been demoted are effectively deleted from the state modfile.action = "deleted"; if (propertyOnDelete != null) { properties.put(propertyOnDelete, "true"); } } if (property != null) { properties.put(property, "true"); } return mod; }