KickJava   Java API By Example, From Geeks To Geeks.

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


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  * New LocalAopTest that doesn't use TreeCacheAopTester. There should have no need for it not.
14  *
15  * @author Ben Wang
16  */

17
18 public class NewLocalAopTest extends TestCase
19 {
20    Log log_=LogFactory.getLog(NewLocalAopTest.class);
21    TreeCacheAop cache_;
22
23    public NewLocalAopTest(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 testPutRemove() throws Exception JavaDoc
48    {
49       log_.info("testPutRemove() ....");
50       Person test = new Person();
51       test.setName("Ben");
52       test.setAge(10);
53       cache_.putObject("/a", test);
54       Person result = (Person)cache_.getObject("/a");
55       assertEquals(" ", test, result);
56       result.setAge(20);
57       cache_.removeObject("/a");
58       assertNull("Object should be null ", cache_.getObject("/a"));
59       assertEquals("Age should be updated as ", 20, test.getAge());
60    }
61
62    public static Test suite() throws Exception JavaDoc
63    {
64       return new TestSuite(NewLocalAopTest.class);
65    }
66
67
68    public static void main(String JavaDoc[] args) throws Exception JavaDoc
69    {
70       junit.textui.TestRunner.run(suite());
71    }
72
73 }
74
75
Popular Tags