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 NonAspectizedAopTest extends TestCase 19 { 20 Log log_=LogFactory.getLog(NonAspectizedAopTest.class); 21 TreeCacheAop cache_; 22 23 public NonAspectizedAopTest(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 testPutPrimitive() throws Exception 48 { 49 log_.info("testPutPrimitive() ...."); 50 String test = "test"; 51 cache_.putObject("/a", test); 52 String result = (String )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 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 72 { 73 return new TestSuite(NonAspectizedAopTest.class); 74 } 75 76 77 public static void main(String [] args) throws Exception 78 { 79 junit.textui.TestRunner.run(suite()); 80 } 81 82 } 83 84 | Popular Tags |