01: package org.shiftone.cache.test;
02:
03: import junit.framework.TestCase;
04:
05: import org.shiftone.cache.Cache;
06: import org.shiftone.cache.CacheFactory;
07: import org.shiftone.cache.policy.fifo.FifoCacheFactory;
08: import org.shiftone.cache.util.Log;
09:
10: import java.util.ArrayList;
11: import java.util.List;
12:
13: /**
14: * @version $Revision: 1.3 $
15: * @author $Author: jeffdrost $
16: */
17: public class ReaperTestCase extends TestCase {
18:
19: private static final Log LOG = new Log(ReaperTestCase.class);
20:
21: public void testSoft() throws Exception {
22:
23: CacheFactory factory = new FifoCacheFactory();
24: Cache cache = factory.newInstance("test", 10000, 10000);
25:
26: LOG.info("cache = " + cache);
27: cache.addObject("test", "test");
28: Thread.sleep(5000);
29:
30: cache = null;
31:
32: Thread.sleep(5000);
33:
34: Object o = createBigObject();
35:
36: Runtime.getRuntime().gc();
37: Runtime.getRuntime().runFinalization();
38: Thread.sleep(5000);
39: }
40:
41: Object createBigObject() {
42:
43: List list = new ArrayList();
44:
45: for (int i = 0; i < 10000; i++) {
46: list.add(new byte[1024]);
47: }
48:
49: return list;
50: }
51: }
|