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.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.config.Configuration.CacheMode; |
31 |
| import org.jboss.cache.factories.UnitTestCacheFactory; |
32 |
| import org.jboss.cache.pojo.test.Resource; |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| public class ReplicatedByteTest extends TestCase |
40 |
| { |
41 |
| Log log = LogFactory.getLog(ReplicatedByteTest.class); |
42 |
| PojoCache cache, cache1; |
43 |
| |
44 |
| |
45 |
2
| public ReplicatedByteTest(String name)
|
46 |
| { |
47 |
2
| super(name);
|
48 |
| } |
49 |
| |
50 |
2
| protected void setUp() throws Exception
|
51 |
| { |
52 |
2
| super.setUp();
|
53 |
2
| log.info("setUp() ....");
|
54 |
2
| boolean toStart = false;
|
55 |
2
| cache = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
56 |
2
| cache.start();
|
57 |
2
| cache1 = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
58 |
2
| cache1.start();
|
59 |
| } |
60 |
| |
61 |
2
| protected void tearDown() throws Exception
|
62 |
| { |
63 |
2
| super.tearDown();
|
64 |
2
| cache.stop();
|
65 |
2
| cache1.stop();
|
66 |
| } |
67 |
| |
68 |
2
| public void testSimple() throws Exception
|
69 |
| { |
70 |
2
| log.info("testSimple() ....");
|
71 |
2
| Resource res = new Resource();
|
72 |
2
| res.setName("mapping");
|
73 |
2
| res.setConnection("wire");
|
74 |
2
| String s = "This is a test";
|
75 |
2
| byte by = 1;
|
76 |
2
| byte[] b = new byte[1];
|
77 |
2
| b[0] = by;
|
78 |
2
| res.setByte(b);
|
79 |
| |
80 |
2
| cache.attach("resource", res);
|
81 |
| |
82 |
2
| Resource res1 = (Resource)cache1.find("resource");
|
83 |
2
| assertEquals("Name ", res.getName(), res1.getName());
|
84 |
| |
85 |
2
| assertEquals("byte ", res.getByte()[0], res1.getByte()[0]);
|
86 |
| |
87 |
| |
88 |
2
| by = 2;
|
89 |
2
| b[0] = by;
|
90 |
2
| res1.setByte(b);
|
91 |
2
| assertEquals("Name ", res.getName(), res1.getName());
|
92 |
| |
93 |
2
| assertEquals("byte ", res.getByte()[0], res1.getByte()[0]);
|
94 |
| |
95 |
| } |
96 |
| |
97 |
2
| public static Test suite() throws Exception
|
98 |
| { |
99 |
2
| return new TestSuite(ReplicatedByteTest.class);
|
100 |
| } |
101 |
| |
102 |
| |
103 |
0
| public static void main(String[] args) throws Exception
|
104 |
| { |
105 |
0
| junit.textui.TestRunner.run(suite());
|
106 |
| } |
107 |
| |
108 |
| } |