KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > NonAspectizedTest


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  * Test for Serializable POJOs
13  *
14  * @author Ben Wang
15  */

16
17 public class NonAspectizedTest extends TestCase
18 {
19    Log log_ = LogFactory.getLog(NonAspectizedTest.class);
20    PojoCache cache_;
21
22    public NonAspectizedTest(String JavaDoc name)
23    {
24       super(name);
25    }
26
27    protected void setUp() throws Exception JavaDoc
28    {
29       super.setUp();
30       log_.info("setUp() ....");
31       String JavaDoc configFile = "META-INF/local-service.xml";
32       boolean toStart = false;
33       cache_ = PojoCacheFactory.createCache(configFile, toStart);
34       cache_.start();
35    }
36
37    protected void tearDown() throws Exception JavaDoc
38    {
39       super.tearDown();
40       cache_.stop();
41    }
42
43 // public void testDummy() {}
44

45    public void testPutPrimitive() throws Exception JavaDoc
46    {
47       log_.info("testPutPrimitive() ....");
48       String JavaDoc test = "test";
49       cache_.attach("/a", test);
50       String JavaDoc result = (String JavaDoc) cache_.find("/a");
51       assertEquals("test string ", "test", result);
52       cache_.detach("/a");
53       assertNull("Object should be null ", cache_.find("/a"));
54    }
55
56    public void testPutSerializable() throws Exception JavaDoc
57    {
58       log_.info("testPutSerializable() ....");
59       SerializedAddress test = new SerializedAddress();
60       test.setCity("Sunnyvale");
61       test.setZip(94086);
62       cache_.attach("/a", test);
63       SerializedAddress result = (SerializedAddress) cache_.find("/a");
64       assertEquals("test SerializedAddress ", test, result);
65       cache_.detach("/a");
66       assertNull("Object should be null ", cache_.find("/a"));
67    }
68
69    public static Test suite() throws Exception JavaDoc
70    {
71       return new TestSuite(NonAspectizedTest.class);
72    }
73
74
75    public static void main(String JavaDoc[] args) throws Exception JavaDoc
76    {
77       junit.textui.TestRunner.run(suite());
78    }
79
80 }
81
82
Popular Tags