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 17 18 public class NewLocalAopTest extends TestCase 19 { 20 Log log_=LogFactory.getLog(NewLocalAopTest.class); 21 TreeCacheAop cache_; 22 23 public NewLocalAopTest(String name) 24 { 25 super(name); 26 } 27 28 protected void setUp() throws Exception 29 { 30 super.setUp(); 31 log_.info("setUp() ...."); 32 String configFile = "META-INF/local-service.xml"; 33 cache_ = new TreeCacheAop(); 34 PropertyConfigurator config = new PropertyConfigurator(); 35 config.configure(cache_, configFile); cache_.start(); 37 } 38 39 protected void tearDown() throws Exception 40 { 41 super.tearDown(); 42 cache_.stop(); 43 } 44 45 47 public void testPutRemove() throws Exception 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 63 { 64 return new TestSuite(NewLocalAopTest.class); 65 } 66 67 68 public static void main(String [] args) throws Exception 69 { 70 junit.textui.TestRunner.run(suite()); 71 } 72 73 } 74 75 | Popular Tags |