KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > tests > aop > NonAspectizedAopTest


1 package org.jboss.cache.tests.aop;
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.PropertyConfigurator;
9 import org.jboss.cache.aop.TreeCacheAop;
10
11
12 /**
13  * ObjectTestCase.java that uses standalone aop package. Test simple get put Object
14  *
15  * @author Ben Wang
16  */

17
18 public class NonAspectizedAopTest extends TestCase
19 {
20    Log log_=LogFactory.getLog(NonAspectizedAopTest.class);
21    TreeCacheAop cache_;
22
23    public NonAspectizedAopTest(String JavaDoc name)
24    {
25       super(name);
26    }
27
28    protected void setUp() throws Exception JavaDoc
29    {
30       super.setUp();
31       log_.info("setUp() ....");
32       String JavaDoc configFile = "META-INF/local-service.xml";
33       cache_ = new TreeCacheAop();
34       PropertyConfigurator config = new PropertyConfigurator();
35       config.configure(cache_, configFile); // read in generic replSync xml
36
cache_.start();
37    }
38
39    protected void tearDown() throws Exception JavaDoc
40    {
41       super.tearDown();
42       cache_.stop();
43    }
44
45 // public void testDummy() {}
46

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