1 package org.apache.jcs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.jcs.engine.behavior.ICacheElement;
23
24 import junit.framework.TestCase;
25
26 /***
27 * @author Aaron Smuts
28 *
29 */
30 public class JCSCacheElementRetrievalUnitTest
31 extends TestCase
32 {
33
34 /***
35 *
36 * @throws Exception
37 */
38 public void testSimpleElementRetrieval()
39 throws Exception
40 {
41 JCS jcs = JCS.getInstance( "testCache1" );
42
43 jcs.put( "test_key", "test_data" );
44
45 long now = System.currentTimeMillis();
46 ICacheElement 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 }