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/22 22:35:34 UTC

cvs commit: jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft SoftRefCacheTest.java

hchar       2005/01/22 13:35:34

  Added:       sandbox/yajcache/test/org/apache/jcs/yajcache/soft
                        SoftRefCacheTest.java
  Log:
  move yajcache to sandbox
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-jcs/sandbox/yajcache/test/org/apache/jcs/yajcache/soft/SoftRefCacheTest.java
  
  Index: SoftRefCacheTest.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.annotate.*;
  
  /**
   *
   * @author Hanson Char
   */
  @CopyRightApache
  @TestOnly
  public class SoftRefCacheTest extends TestCase {
      private Log log = LogFactory.getLog(this.getClass());
      
      public void testSoftRefCache() throws Exception {
          ICacheSafe<byte[]> c = SafeCacheManager.inst.getCache("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());
          SoftRefCache sc = (SoftRefCache)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());
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org