/*
 * 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());
    }
}

@@ -901,16 +901,23 @@
 che.
+lang.
 annotat
-e
+ion
 .*;%0A
@@ -1824,32 +1824,34 @@
  %22 + c.size());%0A
+//
         SoftRefC
@@ -1845,24 +1845,28 @@
      SoftRef
+File
 Cache sc = (
@@ -1868,24 +1868,28 @@
 c = (SoftRef
+File
 Cache)c;%0A   
@@ -1885,16 +1885,18 @@
 ache)c;%0A
+//
         
@@ -2354,24 +2354,26 @@
  c.size());%0A
+//
         log.

make compile