Author: markt Date: Wed Apr 1 10:23:42 2015 New Revision: 1670600 URL: http://svn.apache.org/r1670600 Log: Update unit tests to account for file modification resolution changes in HostConfig. Generally: - make sure modification times change by more than FILE_MODIFICATION_RESOLUTION_MS - make sure file modification times are always in the past
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Modified: tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java?rev=1670600&r1=1670599&r2=1670600&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java (original) +++ tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Wed Apr 1 10:23:42 2015 @@ -1120,35 +1120,39 @@ public class TestHostConfigAutomaticDepl tomcat.start(); host.backgroundProcess(); - // Update the last modified time. Add a few seconds to make sure that - // the OS reports a change in modification time. + // Update the last modified time. Make sure that the OS reports a change + // in modification time that HostConfig can detect. switch (toModify) { case XML: if (xml == null) { Assert.fail(); } else { - xml.setLastModified(System.currentTimeMillis() + 5000); + xml.setLastModified(System.currentTimeMillis() - + 10 * HostConfig.FILE_MODIFICATION_RESOLUTION_MS); } break; case EXT: if (ext == null) { Assert.fail(); } else { - ext.setLastModified(System.currentTimeMillis() + 5000); + ext.setLastModified(System.currentTimeMillis() - + 10 * HostConfig.FILE_MODIFICATION_RESOLUTION_MS); } break; case WAR: if (war == null) { Assert.fail(); } else { - war.setLastModified(System.currentTimeMillis() + 5000); + war.setLastModified(System.currentTimeMillis() - + 10 * HostConfig.FILE_MODIFICATION_RESOLUTION_MS); } break; case DIR: if (dir == null) { Assert.fail(); } else { - dir.setLastModified(System.currentTimeMillis() + 5000); + dir.setLastModified(System.currentTimeMillis() - + 10 * HostConfig.FILE_MODIFICATION_RESOLUTION_MS); } break; default: @@ -1696,6 +1700,9 @@ public class TestHostConfigAutomaticDepl dest = new File(external, "external" + ".war"); } Files.copy(src.toPath(), dest.toPath()); + // Make sure that HostConfig thinks the WAR has been modified. + dest.setLastModified( + System.currentTimeMillis() - HostConfig.FILE_MODIFICATION_RESOLUTION_MS); return dest; } @@ -1706,6 +1713,9 @@ public class TestHostConfigAutomaticDepl Assert.assertTrue(parent.mkdirs()); } Files.copy(XML_SOURCE.toPath(), xml.toPath()); + // Make sure that HostConfig thinks the xml has been modified. + xml.setLastModified( + System.currentTimeMillis() - HostConfig.FILE_MODIFICATION_RESOLUTION_MS); return xml; } @@ -1739,6 +1749,9 @@ public class TestHostConfigAutomaticDepl context.append("\" />"); fos.write(context.toString().getBytes(StandardCharsets.ISO_8859_1)); } + // Make sure that HostConfig thinks the xml has been modified. + xml.setLastModified( + System.currentTimeMillis() - HostConfig.FILE_MODIFICATION_RESOLUTION_MS); return xml; } @@ -1756,7 +1769,12 @@ public class TestHostConfigAutomaticDepl @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.copy(file, dest.resolve(src.relativize(file))); + Path destPath = dest.resolve(src.relativize(file)); + Files.copy(file, destPath); + // Make sure that HostConfig thinks all newly copied files have + // been modified. + destPath.toFile().setLastModified( + System.currentTimeMillis() - HostConfig.FILE_MODIFICATION_RESOLUTION_MS); return FileVisitResult.CONTINUE; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org