Index: TestFileCache.java =================================================================== RCS file: /home/cvspublic/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/cache/file/TestFileCache.java,v retrieving revision 1.5 diff -u -r1.5 TestFileCache.java --- TestFileCache.java 6 Apr 2004 16:47:15 -0000 1.5 +++ TestFileCache.java 22 Apr 2004 16:31:26 -0000 @@ -77,6 +77,15 @@ cache = (FileCache) container.getComponentInstance(FileCache.class); } + /** + * @see junit.framework.TestCase#tearDown() + */ + public void tearDown() throws Exception + { + super.tearDown(); + removeTestFiles(); + } + public void testComponent() throws Exception { @@ -129,6 +138,22 @@ dumpCache(cache.getIterator()); + // Reload files array to get the files back in the correct order + // because the cache CAN have reordered them while evicting. + // This can happen if test files where left over from a previous + // test which then will have an older timestamp. + // In that case it is NOT garanteed that files[18] below will still + // be in the cache! + // Note: this is only an issue for the test itself and not for the + // cache as such. + + Iterator it = cache.getIterator(); + for ( int ix = 0; it.hasNext(); ix++ ) + { + FileCacheEntry entry = (FileCacheEntry) it.next(); + files[ix] = entry.getFile(); + } + String stuff = (String) cache.getDocument(files[18].getCanonicalPath()); assertNotNull(stuff); @@ -169,7 +194,8 @@ { String testFile = "./test/testdata/psml/user/cachetest/testFile-" + ix + ".psml"; File file = new File(testFile); - file.delete(); + if ( file.exists() ) + file.delete(); } }