You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by hc...@apache.org on 2005/01/29 11:19:59 UTC
cvs commit: jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft SoftRefFileCacheSafeTest.java SoftRefCacheTest.java
hchar 2005/01/29 02:19:59
Modified: sandbox/yajcache/test/org/apache/jcs/yajcache/soft
SoftRefCacheTest.java
Added: sandbox/yajcache/test/org/apache/jcs/yajcache/soft
SoftRefFileCacheSafeTest.java
Log:
unit test for SoftRefCache vs SoftRefFileCacheSafe
Revision Changes Path
1.3 +8 -6 jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft/SoftRefCacheTest.java
Index: SoftRefCacheTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft/SoftRefCacheTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SoftRefCacheTest.java 27 Jan 2005 11:09:44 -0000 1.2
+++ SoftRefCacheTest.java 29 Jan 2005 10:19:59 -0000 1.3
@@ -17,11 +17,12 @@
package org.apache.jcs.yajcache.soft;
import junit.framework.*;
-import org.apache.jcs.yajcache.core.ICacheSafe;
-import org.apache.jcs.yajcache.core.SafeCacheManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.yajcache.core.CacheManager;
+import org.apache.jcs.yajcache.core.CacheType;
+import org.apache.jcs.yajcache.core.ICache;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
@@ -34,8 +35,8 @@
private Log log = LogFactory.getLog(this.getClass());
public void testSoftRefCache() throws Exception {
- ICacheSafe<byte[]> c = SafeCacheManager.inst.getCache("bytesCache", byte[].class);
-
+ ICache<byte[]> c = CacheManager.inst.getCache(
+ CacheType.SOFT_REFERENCE, "bytesCache", byte[].class);
for (int h=0; h < 10; h++) {
for (int i=h*10, max=i+10; i < max; i++) {
log.debug("put i="+i);
@@ -53,7 +54,7 @@
log.debug("size: " + c.size());
// SoftRefFileCache sc = (SoftRefFileCache)c;
// log.debug("count: " + sc.getCollectorCount());
- log.debug(SoftRefCacheCleaner.inst.toString());
+// log.debug(SoftRefCacheCleaner.inst.toString());
// for (int i=0; i < 100; i++) {
// log.debug("get i="+i +":"+ c.get(String.valueOf(i)));
@@ -66,6 +67,7 @@
}
log.debug("size: " + c.size());
// log.debug("count: " + sc.getCollectorCount());
- log.debug(SoftRefCacheCleaner.inst.toString());
+// log.debug(SoftRefCacheCleaner.inst.toString());
+ log.debug(c);
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft/SoftRefFileCacheSafeTest.java
Index: SoftRefFileCacheSafeTest.java
===================================================================
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jcs.yajcache.soft;
import junit.framework.*;
import org.apache.jcs.yajcache.core.ICacheSafe;
import org.apache.jcs.yajcache.core.SafeCacheManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jcs.yajcache.core.CacheType;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
*
* @author Hanson Char
*/
@CopyRightApache
@TestOnly
public class SoftRefFileCacheSafeTest extends TestCase {
private Log log = LogFactory.getLog(this.getClass());
public void testSoftRefCache() throws Exception {
ICacheSafe<byte[]> c = SafeCacheManager.inst.getCache(
CacheType.SOFT_REFERENCE_FILE_SAFE, "bytesCache", byte[].class);
for (int h=0; h < 10; h++) {
for (int i=h*10, max=i+10; i < max; i++) {
log.debug("put i="+i);
c.put(String.valueOf(i), new byte[100*1024]);
// c.put("0", new byte[100*1024]);
c.get("0");
}
for (int i=0; i < 10; i++) {
log.debug("get i="+i +":"+ c.get(String.valueOf(i)));
}
// for (int i=0; i < h*10+10; i++) {
// log.debug("get i="+i +":"+ c.get(String.valueOf(i)));
// }
}
log.debug("size: " + c.size());
// SoftRefFileCache sc = (SoftRefFileCache)c;
// log.debug("count: " + sc.getCollectorCount());
// log.debug(SoftRefCacheCleaner.inst.toString());
// for (int i=0; i < 100; i++) {
// log.debug("get i="+i +":"+ c.get(String.valueOf(i)));
// }
// log.debug("sleeping for 5 secs");
// Thread.sleep(5*1000);
for (int i=0; i < 100; i++) {
log.debug("get i="+i +":"+ c.get(String.valueOf(i)));
}
log.debug("size: " + c.size());
// log.debug("count: " + sc.getCollectorCount());
// log.debug(SoftRefCacheCleaner.inst.toString());
log.debug(c);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org