1 package org.apache.commons.jcs.auxiliary.disk;
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.engine.CacheElement;
24 import org.apache.commons.jcs.engine.ElementAttributes;
25 import org.apache.commons.jcs.engine.behavior.ICacheElement;
26 import org.apache.commons.jcs.engine.behavior.IElementAttributes;
27
28
29 public class PurgatoryElementUnitTest
30 extends TestCase
31 {
32
33 public void testSpoolable_normal()
34 {
35
36 String cacheName = "myCacheName";
37 String key = "myKey";
38 String value = "myValue";
39 IElementAttributes elementAttributes = new ElementAttributes();
40 ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
41 PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
42 purgatoryElement.setSpoolable( false );
43
44
45 boolean result = purgatoryElement.isSpoolable();
46
47
48 assertFalse( "Should not be spoolable.", result );
49 }
50
51
52 public void testElementAttributes_normal()
53 {
54
55 String cacheName = "myCacheName";
56 String key = "myKey";
57 String value = "myValue";
58 IElementAttributes elementAttributes = new ElementAttributes();
59
60 ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value );
61 PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
62 purgatoryElement.setElementAttributes( elementAttributes );
63
64
65 IElementAttributes result = cacheElement.getElementAttributes();
66
67
68 assertEquals( "Should have set the attributes on the element", elementAttributes, result );
69 }
70
71
72 public void testToString_normal()
73 {
74
75 String cacheName = "myCacheName";
76 String key = "myKey";
77 String value = "myValue";
78 IElementAttributes elementAttributes = new ElementAttributes();
79 ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
80 PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
81
82
83 String result = purgatoryElement.toString();
84
85
86 assertTrue( "Should have the cacheName.", result.indexOf( cacheName ) != -1 );
87 assertTrue( "Should have the key.", result.indexOf( key ) != -1 );
88 assertTrue( "Should have the value.", result.indexOf( value ) != -1 );
89 }
90 }