KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > cache > TreeCacheAdapterTest


1 /*
2  * Copyright (C) 2006 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.cache;
18
19 import java.io.Serializable JavaDoc;
20
21 import org.jboss.cache.DummyTransactionManagerLookup;
22 import org.jboss.cache.Fqn;
23 import org.jboss.cache.TreeCache;
24
25 import junit.framework.TestCase;
26
27 /**
28  * @see org.alfresco.repo.cache.TreeCacheAdapter
29  *
30  * @author Derek Hulley
31  */

32 public class TreeCacheAdapterTest extends TestCase
33 {
34     private static final String JavaDoc KEY_A = "A";
35     private static final String JavaDoc VALUE_A = "AAA";
36     private static final String JavaDoc KEY_B = "B";
37     private static final String JavaDoc VALUE_B = "BBB";
38     
39     private TreeCache treeCache;
40     private TreeCacheAdapter<Serializable JavaDoc, Serializable JavaDoc> cache;
41     
42     @Override JavaDoc
43     public void setUp() throws Exception JavaDoc
44     {
45         treeCache = new TreeCache();
46         treeCache.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
47         treeCache.start();
48         
49         cache = new TreeCacheAdapter<Serializable JavaDoc, Serializable JavaDoc>();
50         cache.setCache(treeCache);
51         cache.setRegionName(getName());
52     }
53     
54     public void testSimplePutGet() throws Exception JavaDoc
55     {
56         cache.put(KEY_A, VALUE_A);
57         cache.put(KEY_B, VALUE_B);
58         
59         // check that this is present in the underlying cache
60
Serializable JavaDoc checkValueA = (Serializable JavaDoc) treeCache.get(new Fqn(getName()), KEY_A);
61         assertNotNull("Value A is not present in underlying cache", checkValueA);
62         assertEquals("Value A is incorrect in underlying cache", VALUE_A, checkValueA);
63         
64         Serializable JavaDoc checkValueB = cache.get(KEY_B);
65         assertNotNull("Value B is not present in cache", checkValueB);
66         assertEquals("Value B is incorrect in cache", VALUE_B, checkValueB);
67     }
68 }
69
Popular Tags