You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/04/04 01:28:36 UTC
svn commit: r1584468 -
/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java
Author: sebb
Date: Thu Apr 3 23:28:36 2014
New Revision: 1584468
URL: http://svn.apache.org/r1584468
Log:
Fix up test; ensure first file really is oldest
Modified:
commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java
Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java?rev=1584468&r1=1584467&r2=1584468&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java Thu Apr 3 23:28:36 2014
@@ -256,10 +256,19 @@ public class FileDiskCacheUnitTest
SleepUtil.sleepAtLeast( 100 );
// DO WORK
- ICacheElement<String, String> result = diskCache.get( "key0" );
+ int stillCached = 0;
+ for ( int i = 0; i < maxNumberOfFiles; i++ )
+ {
+ final String key = "key" + i;
+ ICacheElement<String, String> result = diskCache.get( key );
+// System.out.println("Entry "+ key+ " null? " + (result==null));
+ if (result != null) {
+ stillCached++;
+ }
+ }
// VERIFY
- assertNotNull( "Should NOT be null.", result );
+ assertEquals("All files should still be cached", maxNumberOfFiles, stillCached);
}
/**
@@ -285,6 +294,7 @@ public class FileDiskCacheUnitTest
}
SleepUtil.sleepAtLeast( 500 );
+ // DO WORK
int stillCached = 0;
for ( int i = 0; i <= maxNumberOfFiles; i++ )
{
@@ -295,12 +305,9 @@ public class FileDiskCacheUnitTest
stillCached++;
}
}
+
+ // VERIFY
assertEquals(maxNumberOfFiles, stillCached);
-// // DO WORK
-// ICacheElement<String, String> result = diskCache.get( "key0" );
-//
-// // VERIFY
-// assertNull( "Should be null.", result );
}
/**
@@ -374,6 +381,9 @@ public class FileDiskCacheUnitTest
for ( int i = 0; i < maxNumberOfFiles; i++ )
{
diskCache.update( new CacheElement<String, String>( cacheName, "key" + i, "Data" ) );
+ if (i == 0 ){
+ SleepUtil.sleepAtLeast( 1001 ); // ensure the first file is seen as older
+ }
}
SleepUtil.sleepAtLeast( 500 );
@@ -388,24 +398,13 @@ public class FileDiskCacheUnitTest
diskCache.update( new CacheElement<String, String>( cacheName, "key" + maxNumberOfFiles, "Data" ) );
SleepUtil.sleepAtLeast( 100 );
-// // DO WORK
-// ICacheElement<String, String> result = diskCache.get( "key0" );
-//
- int stillCached = 0;
- for ( int i = 0; i <= maxNumberOfFiles; i++ )
- {
- final String key = "key" + i;
- ICacheElement<String, String> result = diskCache.get( key );
- System.out.println("Entry "+ key+ " null? " + (result==null));
- if (result != null) {
- stillCached++;
- }
- }
- assertEquals(maxNumberOfFiles, stillCached);
+ // DO WORK
+ ICacheElement<String, String> result = diskCache.get( "key0" );
// VERIFY
-// assertNull( "Should be null.", result );
+ assertNull( "Should be null.", result );
}
+
/**
* Verify file.
* <p>