[Design the new POJO MicroContainer] - Re: File last modified diff behavior
by jaikiran
"alesj" wrote :
|
| | long tempTimestamp = testJsp.getLastModified();
| | // Platform dependent precision for last modified. Let's wait a minimum of 1 sec
| | Thread.sleep(1500);
| | assertFalse(checker.hasStructureBeenModified(originalRoot));
| | long lastModified = testJsp.getLastModified();
|
| Does this work for you?
|
Yes, it does:
-------------------------------------------------------------------------------
| Test set: org.jboss.test.deployers.vfs.structure.modified.test.SynchModificationTestCase
| -------------------------------------------------------------------------------
| Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.816 sec
|
"alesj" wrote :
| Checker then deletes and re-creates the temp file,
| resulting in new last modified.
|
Right, it's the checker which sets the last modified on the new temp to the current system time and should be atleast 1 second diff from the old temp file's last modified time. That delay, with Thread.sleep achieves this.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225342#4225342
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225342
16 years, 12 months
[Design the new POJO MicroContainer] - Re: File last modified diff behavior
by jaikiran
Yep, i have Kubuntu system where this still fails:
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.425 sec <<< FAILURE!
| testWAR(org.jboss.test.deployers.vfs.structure.modified.test.SynchModificationTestCase) Time elapsed: 0.121 sec <<< FAILURE!
| junit.framework.AssertionFailedError: Last modified diff is not bigger then 0, diff: 0
| at junit.framework.Assert.fail(Assert.java:47)
| at junit.framework.Assert.assertTrue(Assert.java:20)
| at org.jboss.test.deployers.vfs.structure.modified.test.SynchModificationTestCase.testWAR(SynchModificationTestCase.java:122)
|
I see that the testcase was changed to:
assertTrue(updateFile.setLastModified(System.currentTimeMillis() + 1500l));
|
This probably won't introduce the "delay" that we are expecting.
Looking at this:
| long tempTimestamp = testJsp.getLastModified();
| assertFalse(checker.hasStructureBeenModified(originalRoot));
| long lastModified = testJsp.getLastModified();
I guess, internally its a file "copy" (original deployment to temp deployment) if the original file has changed. I am not really sure whether the "copy" copies over the last modified timestamp from the source. Maybe the copy just copies the file and updates the last modified time to current system timestamp?
The delay that we need, should be between the change of the original file and copying to temp file. Something like:
| long tempTimestamp = testJsp.getLastModified();
| // Platform dependent precision for last modified. Let's wait a minimum of 1 sec
| Thread.sleep(1500);
| assertFalse(checker.hasStructureBeenModified(originalRoot));
| long lastModified = testJsp.getLastModified();
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225335#4225335
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225335
16 years, 12 months
[Design the new POJO MicroContainer] - Re: File last modified diff behavior
by jaikiran
anonymous wrote :
| File updateFile = new File(rootFile, "test.jsp");
| assertTrue(updateFile.setLastModified(System.currentTimeMillis()));
As per the javadoc of java.io.File.setLastModified:
anonymous wrote : All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified() method will return the (possibly truncated) time argument that was passed to this method.
|
|
So unless there is a difference of 1 second, there's no guarantee of that test case passing on all platforms. I guess the test case could be changed to add some delay before updating the last modified timestamp on the original file.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225317#4225317
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225317
16 years, 12 months