PathResourceTests defensively compares last-modified timestamps at seconds precision

Issue: SPR-13542
(cherry picked from commit 9cf2895)
This commit is contained in:
Juergen Hoeller
2015-10-06 13:25:27 +02:00
parent 315a848e6e
commit be90f7ddd4

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,17 +40,18 @@ import static org.mockito.BDDMockito.*;
* @author Philippe Marschall
* @author Phillip Webb
* @author Nicholas Williams
* @author Juergen Hoeller
*/
public class PathResourceTests {
private static final String TEST_DIR = platformPath("src/test/java/org/"
+ "springframework/core/io");
private static final String TEST_DIR =
platformPath("src/test/java/org/springframework/core/io");
private static final String TEST_FILE = platformPath("src/test/java/org/"
+ "springframework/core/io/example.properties");
private static final String TEST_FILE =
platformPath("src/test/java/org/springframework/core/io/example.properties");
private static final String NON_EXISTING_FILE = platformPath("src/test/java/org/"
+ "springframework/core/io/doesnotexist.properties");
private static final String NON_EXISTING_FILE =
platformPath("src/test/java/org/springframework/core/io/doesnotexist.properties");
private static String platformPath(String string) {
@@ -222,7 +223,7 @@ public class PathResourceTests {
public void lastModified() throws Exception {
PathResource resource = new PathResource(TEST_FILE);
File file = new File(TEST_FILE);
assertThat(resource.lastModified(), equalTo(file.lastModified()));
assertThat(resource.lastModified() / 1000, equalTo(file.lastModified() / 1000));
}
@Test