KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > collection > CachedMapImplTest


1 /*
2  * JBoss, Home of Professional Open Source.
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * as indicated by the @author tags. See the copyright.txt file in the
5  * distribution for a full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22
23 package org.jboss.cache.pojo.collection;
24
25 import junit.framework.TestCase;
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.jboss.cache.pojo.PojoCache;
31 import org.jboss.cache.pojo.PojoCacheFactory;
32 import org.jboss.cache.Fqn;
33
34 import java.util.List JavaDoc;
35 import java.util.ArrayList JavaDoc;
36 import java.util.Map JavaDoc;
37 import java.util.HashMap JavaDoc;
38
39 /**
40  * List implementation testing.
41  *
42  * @author Ben Wang
43  */

44
45 public class CachedMapImplTest extends TestCase
46 {
47    Log log = LogFactory.getLog(CachedMapImplTest.class);
48    PojoCache cache_, cache1_;
49
50    public CachedMapImplTest(String JavaDoc name)
51    {
52       super(name);
53    }
54
55
56    protected void setUp() throws Exception JavaDoc
57    {
58       super.setUp();
59       log.info("setUp() ....");
60       String JavaDoc configFile = "META-INF/replSync-service.xml";
61       boolean toStart = true;
62       cache_ = PojoCacheFactory.createCache(configFile, toStart);
63
64       cache1_ = PojoCacheFactory.createCache(configFile, toStart);
65    }
66
67    protected void tearDown() throws Exception JavaDoc
68    {
69       super.tearDown();
70       cache_.stop();
71       cache1_.stop();
72    }
73
74    public void testSimpleRepl()
75    {
76       Map JavaDoc map = new HashMap JavaDoc();
77       map.put("1", "1");
78       map.put("2", "2");
79
80       cache_.attach("map", map);
81
82       // proxy now
83
map = (Map JavaDoc)cache_.find("map");
84
85       // test repl
86
cache_.getCache().put(Fqn.fromString("test"), "1", map);
87
88       Map JavaDoc m1 = (Map JavaDoc)cache1_.getCache().get(Fqn.fromString("test"), "1");
89       System.out.println(" map : " +m1);
90    }
91
92    public static Test suite() throws Exception JavaDoc
93    {
94       return new TestSuite(CachedMapImplTest.class);
95    }
96
97    public static void main(String JavaDoc[] args) throws Exception JavaDoc
98    {
99       junit.textui.TestRunner.run(suite());
100    }
101
102 }
103
Popular Tags