[jboss-cvs] JBossAS SVN: r82702 - in projects/vfs/trunk/src: test/java/org/jboss/test/virtual/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 8 09:48:37 EST 2009
Author: alesj
Date: 2009-01-08 09:48:36 -0500 (Thu, 08 Jan 2009)
New Revision: 82702
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CombinedVFSCache.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CombinedVFSCacheTestCase.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
Log:
Test fixes - so we really hit cache.
Last insert fix.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CombinedVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CombinedVFSCache.java 2009-01-08 14:44:38 UTC (rev 82701)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CombinedVFSCache.java 2009-01-08 14:48:36 UTC (rev 82702)
@@ -105,15 +105,6 @@
realCache = new NoopVFSCache();
}
- public long lastInsert()
- {
- if (realCache instanceof CacheStatistics)
- {
- return CacheStatistics.class.cast(realCache).lastInsert();
- }
- return -1l;
- }
-
public VirtualFile getFile(URI uri) throws IOException
{
VirtualFile file = permanentCache.getFile(uri);
@@ -201,6 +192,17 @@
return size;
}
+ public long lastInsert()
+ {
+ long permanentHit = permanentCache.lastInsert();
+ long realHit = -1;
+ if (realCache instanceof CacheStatistics)
+ {
+ realHit = CacheStatistics.class.cast(realCache).lastInsert();
+ }
+ return permanentHit > realHit ? permanentHit : realHit;
+ }
+
@Override
public String toString()
{
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CombinedVFSCacheTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CombinedVFSCacheTestCase.java 2009-01-08 14:44:38 UTC (rev 82701)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CombinedVFSCacheTestCase.java 2009-01-08 14:48:36 UTC (rev 82702)
@@ -28,8 +28,8 @@
import junit.framework.Test;
import org.jboss.virtual.plugins.cache.CombinedVFSCache;
import org.jboss.virtual.plugins.cache.IterableTimedVFSCache;
+import org.jboss.virtual.spi.ExceptionHandler;
import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.spi.ExceptionHandler;
import org.jboss.virtual.spi.cache.VFSCache;
/**
@@ -50,6 +50,25 @@
}
@Override
+ protected void configureCache(VFSCache cache) throws Exception
+ {
+ if (cache instanceof CombinedVFSCache)
+ {
+ CombinedVFSCache cvc = CombinedVFSCache.class.cast(cache);
+
+ URL url = getResource("/vfs/test/nested");
+ Map<URL, ExceptionHandler> map = Collections.singletonMap(url, null);
+ cvc.setPermanentRoots(map);
+
+ IterableTimedVFSCache realCache = new IterableTimedVFSCache(5);
+ realCache.start();
+ cvc.setRealCache(realCache);
+
+ cvc.create();
+ }
+ }
+
+ @Override
protected void stopCache(VFSCache cache)
{
if (cache != null)
@@ -71,25 +90,7 @@
protected CombinedVFSCache createCache()
{
- try
- {
- CombinedWrapperVFSCache cache = new CombinedWrapperVFSCache();
- URL url = getResource("/vfs/test/nested");
- Map<URL, ExceptionHandler> map = Collections.singletonMap(url, null);
- cache.setPermanentRoots(map);
-
- IterableTimedVFSCache realCache = new IterableTimedVFSCache(5);
- realCache.start();
- cache.setRealCache(realCache);
-
- cache.create();
-
- return cache;
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e);
- }
+ return new CombinedWrapperVFSCache();
}
protected Map<Object, Object> getMap()
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2009-01-08 14:44:38 UTC (rev 82701)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2009-01-08 14:48:36 UTC (rev 82702)
@@ -49,6 +49,10 @@
protected abstract VFSCache createCache();
+ protected void configureCache(VFSCache cache) throws Exception
+ {
+ }
+
protected void stopCache(VFSCache cache)
{
if (cache != null)
@@ -67,8 +71,10 @@
VFSCacheFactory.setInstance(cache);
try
{
- VirtualFile root = VFS.getRoot(url);
+ configureCache(cache);
+ VirtualFile root = VFS.getCachedFile(url);
+
VirtualFile file = root.findChild("/nested.jar/META-INF/empty.txt");
URL fileURL = file.toURL();
VirtualFile nested = root.findChild("/nested.jar/complex.jar/subfolder/subsubfolder/subsubchild");
@@ -111,7 +117,9 @@
VFSCacheFactory.setInstance(cache);
try
{
- VirtualFile root = VFS.getRoot(url);
+ configureCache(cache);
+
+ VirtualFile root = VFS.getCachedFile(url);
assertNotNull(root);
Iterable<VFSContext> iter = statistics.getCachedContexts();
More information about the jboss-cvs-commits
mailing list