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