1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| package org.jboss.cache.pojo; |
24 |
| |
25 |
| import junit.framework.Test; |
26 |
| import junit.framework.TestCase; |
27 |
| import junit.framework.TestSuite; |
28 |
| import org.apache.commons.logging.Log; |
29 |
| import org.apache.commons.logging.LogFactory; |
30 |
| import org.jboss.cache.config.Configuration.CacheMode; |
31 |
| import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; |
32 |
| import org.jboss.cache.pojo.test.EnumPlanet; |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| public class EnumTest extends TestCase |
41 |
| { |
42 |
| Log log = LogFactory.getLog(EnumTest.class); |
43 |
| PojoCache cache_, cache1_; |
44 |
| |
45 |
1
| public EnumTest(String name)
|
46 |
| { |
47 |
1
| super(name);
|
48 |
| } |
49 |
| |
50 |
1
| protected void setUp() throws Exception
|
51 |
| { |
52 |
1
| super.setUp();
|
53 |
1
| log.info("setUp() ....");
|
54 |
1
| boolean toStart = true;
|
55 |
1
| cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
56 |
1
| cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
57 |
| } |
58 |
| |
59 |
1
| protected void tearDown() throws Exception
|
60 |
| { |
61 |
1
| super.tearDown();
|
62 |
1
| cache_.stop();
|
63 |
1
| cache1_.stop();
|
64 |
| } |
65 |
| |
66 |
1
| public void testSimple() throws Exception
|
67 |
| { |
68 |
1
| log.info("testSimple() ....");
|
69 |
| |
70 |
1
| double earthWeight = 165;
|
71 |
1
| double mass = earthWeight / EnumPlanet.EARTH.surfaceGravity();
|
72 |
| |
73 |
1
| cache_.attach("enum", EnumPlanet.EARTH);
|
74 |
| |
75 |
1
| EnumPlanet ep = (EnumPlanet) cache1_.find("enum");
|
76 |
| |
77 |
1
| EnumPlanet.EARTH.setMass(7.0e+24);
|
78 |
| |
79 |
1
| assertEquals("Earth mass ", EnumPlanet.EARTH.mass(), ep.mass());
|
80 |
| } |
81 |
| |
82 |
1
| public static Test suite() throws Exception
|
83 |
| { |
84 |
1
| return new TestSuite(EnumTest.class);
|
85 |
| } |
86 |
| |
87 |
| |
88 |
0
| public static void main(String[] args) throws Exception
|
89 |
| { |
90 |
0
| junit.textui.TestRunner.run(suite());
|
91 |
| } |
92 |
| |
93 |
| } |