|
31 | 31 | * |
32 | 32 | * @author Peter Donald |
33 | 33 | * @author Matthew Hawthorne |
34 | | - * @version $Id: FileUtilsTestCase.java,v 1.12 2004/03/12 21:44:47 jeremias Exp $ |
| 34 | + * @version $Id: FileUtilsTestCase.java,v 1.13 2004/03/12 22:22:25 jeremias Exp $ |
35 | 35 | * @see FileUtils |
36 | 36 | */ |
37 | 37 | public class FileUtilsTestCase extends FileBasedTestCase { |
@@ -249,16 +249,41 @@ private void log(Object obj) { |
249 | 249 |
|
250 | 250 | public void testCopyFile1() throws Exception { |
251 | 251 | File destination = new File(getTestDirectory(), "copy1.txt"); |
| 252 | + |
| 253 | + Thread.sleep(200); //This is to slow things down so we can catch if |
| 254 | + //the lastModified date is not ok |
| 255 | + |
252 | 256 | FileUtils.copyFile(testFile1, destination); |
253 | 257 | assertTrue("Check Exist", destination.exists()); |
254 | 258 | assertTrue("Check Full copy", destination.length() == testFile1Size); |
| 259 | + assertTrue("Check last modified date preserved", |
| 260 | + testFile1.lastModified() == destination.lastModified()); |
255 | 261 | } |
256 | 262 |
|
257 | 263 | public void testCopyFile2() throws Exception { |
258 | 264 | File destination = new File(getTestDirectory(), "copy2.txt"); |
| 265 | + |
| 266 | + Thread.sleep(200); //This is to slow things down so we can catch if |
| 267 | + //the lastModified date is not ok |
| 268 | + |
259 | 269 | FileUtils.copyFile(testFile1, destination); |
260 | 270 | assertTrue("Check Exist", destination.exists()); |
261 | 271 | assertTrue("Check Full copy", destination.length() == testFile2Size); |
| 272 | + assertTrue("Check last modified date preserved", |
| 273 | + testFile1.lastModified() == destination.lastModified()); |
| 274 | + } |
| 275 | + |
| 276 | + public void testCopyFile2WithoutFileDatePreservation() throws Exception { |
| 277 | + File destination = new File(getTestDirectory(), "copy2.txt"); |
| 278 | + |
| 279 | + Thread.sleep(200); //This is to slow things down so we can catch if |
| 280 | + //the lastModified date is not ok |
| 281 | + |
| 282 | + FileUtils.copyFile(testFile1, destination, false); |
| 283 | + assertTrue("Check Exist", destination.exists()); |
| 284 | + assertTrue("Check Full copy", destination.length() == testFile2Size); |
| 285 | + assertTrue("Check last modified date modified", |
| 286 | + testFile1.lastModified() != destination.lastModified()); |
262 | 287 | } |
263 | 288 |
|
264 | 289 | // forceDelete |
@@ -286,19 +311,31 @@ public void testCopyFile1ToDir() throws Exception { |
286 | 311 | if (!directory.exists()) |
287 | 312 | directory.mkdirs(); |
288 | 313 | File destination = new File(directory, testFile1.getName()); |
| 314 | + |
| 315 | + Thread.sleep(200); //This is to slow things down so we can catch if |
| 316 | + //the lastModified date is not ok |
| 317 | + |
289 | 318 | FileUtils.copyFileToDirectory(testFile1, directory); |
290 | 319 | assertTrue("Check Exist", destination.exists()); |
291 | 320 | assertTrue("Check Full copy", destination.length() == testFile1Size); |
| 321 | + assertTrue("Check last modified date preserved", |
| 322 | + testFile1.lastModified() == destination.lastModified()); |
292 | 323 | } |
293 | 324 |
|
294 | 325 | public void testCopyFile2ToDir() throws Exception { |
295 | 326 | File directory = new File(getTestDirectory(), "subdir"); |
296 | 327 | if (!directory.exists()) |
297 | 328 | directory.mkdirs(); |
298 | 329 | File destination = new File(directory, testFile1.getName()); |
| 330 | + |
| 331 | + Thread.sleep(200); //This is to slow things down so we can catch if |
| 332 | + //the lastModified date is not ok |
| 333 | + |
299 | 334 | FileUtils.copyFileToDirectory(testFile1, directory); |
300 | 335 | assertTrue("Check Exist", destination.exists()); |
301 | 336 | assertTrue("Check Full copy", destination.length() == testFile2Size); |
| 337 | + assertTrue("Check last modified date preserved", |
| 338 | + testFile1.lastModified() == destination.lastModified()); |
302 | 339 | } |
303 | 340 |
|
304 | 341 | // forceDelete |
|
0 commit comments