1 package org.apache.commons.jcs3;
2
3 import org.apache.commons.jcs3.access.CacheAccess;
4 import org.apache.commons.jcs3.engine.behavior.ICacheElement;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import junit.framework.TestCase;
26
27
28
29 public class JCSCacheElementRetrievalUnitTest
30 extends TestCase
31 {
32
33
34
35
36 public void testSimpleElementRetrieval()
37 throws Exception
38 {
39 final CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" );
40
41 jcs.put( "test_key", "test_data" );
42
43 final long now = System.currentTimeMillis();
44 final ICacheElement<String, String> elem = jcs.getCacheElement( "test_key" );
45 assertEquals( "Name wasn't right", "testCache1", elem.getCacheName() );
46
47 final long diff = now - elem.getElementAttributes().getCreateTime();
48 assertTrue( "Create time should have been at or after the call", diff >= 0 );
49
50 }
51 }