1 |
| package org.jboss.cache.pojo; |
2 |
| |
3 |
| import junit.framework.Test; |
4 |
| import junit.framework.TestCase; |
5 |
| import junit.framework.TestSuite; |
6 |
| import org.apache.commons.logging.Log; |
7 |
| import org.apache.commons.logging.LogFactory; |
8 |
| import org.jboss.cache.pojo.test.SerializedAddress; |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| public class NonAspectizedTest extends TestCase |
18 |
| { |
19 |
| Log log_ = LogFactory.getLog(NonAspectizedTest.class); |
20 |
| PojoCache cache_; |
21 |
| |
22 |
4
| public NonAspectizedTest(String name)
|
23 |
| { |
24 |
4
| super(name);
|
25 |
| } |
26 |
| |
27 |
4
| protected void setUp() throws Exception
|
28 |
| { |
29 |
4
| super.setUp();
|
30 |
4
| log_.info("setUp() ....");
|
31 |
4
| String configFile = "META-INF/local-service.xml";
|
32 |
4
| boolean toStart = false;
|
33 |
4
| cache_ = PojoCacheFactory.createCache(configFile, toStart);
|
34 |
4
| cache_.start();
|
35 |
| } |
36 |
| |
37 |
4
| protected void tearDown() throws Exception
|
38 |
| { |
39 |
4
| super.tearDown();
|
40 |
4
| cache_.stop();
|
41 |
| } |
42 |
| |
43 |
| |
44 |
| |
45 |
2
| public void testPutPrimitive() throws Exception
|
46 |
| { |
47 |
2
| log_.info("testPutPrimitive() ....");
|
48 |
2
| String test = "test";
|
49 |
2
| cache_.attach("/a", test);
|
50 |
2
| String result = (String) cache_.find("/a");
|
51 |
2
| assertEquals("test string ", "test", result);
|
52 |
2
| cache_.detach("/a");
|
53 |
2
| assertNull("Object should be null ", cache_.find("/a"));
|
54 |
| } |
55 |
| |
56 |
2
| public void testPutSerializable() throws Exception
|
57 |
| { |
58 |
2
| log_.info("testPutSerializable() ....");
|
59 |
2
| SerializedAddress test = new SerializedAddress();
|
60 |
2
| test.setCity("Sunnyvale");
|
61 |
2
| test.setZip(94086);
|
62 |
2
| cache_.attach("/a", test);
|
63 |
2
| SerializedAddress result = (SerializedAddress) cache_.find("/a");
|
64 |
2
| assertEquals("test SerializedAddress ", test, result);
|
65 |
2
| cache_.detach("/a");
|
66 |
2
| assertNull("Object should be null ", cache_.find("/a"));
|
67 |
| } |
68 |
| |
69 |
2
| public static Test suite() throws Exception
|
70 |
| { |
71 |
2
| return new TestSuite(NonAspectizedTest.class);
|
72 |
| } |
73 |
| |
74 |
| |
75 |
0
| public static void main(String[] args) throws Exception
|
76 |
| { |
77 |
0
| junit.textui.TestRunner.run(suite());
|
78 |
| } |
79 |
| |
80 |
| } |
81 |
| |