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 16 17 public class NonAspectizedTest extends TestCase 18 { 19 Log log_ = LogFactory.getLog(NonAspectizedTest.class); 20 PojoCache cache_; 21 22 public NonAspectizedTest(String name) 23 { 24 super(name); 25 } 26 27 protected void setUp() throws Exception 28 { 29 super.setUp(); 30 log_.info("setUp() ...."); 31 String 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 38 { 39 super.tearDown(); 40 cache_.stop(); 41 } 42 43 45 public void testPutPrimitive() throws Exception 46 { 47 log_.info("testPutPrimitive() ...."); 48 String test = "test"; 49 cache_.attach("/a", test); 50 String result = (String ) 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 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 70 { 71 return new TestSuite(NonAspectizedTest.class); 72 } 73 74 75 public static void main(String [] args) throws Exception 76 { 77 junit.textui.TestRunner.run(suite()); 78 } 79 80 } 81 82 | Popular Tags |