1 22 23 package org.jboss.cache.pojo; 24 25 import junit.framework.TestCase; 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.jboss.cache.pojo.test.ArrayObject; 31 import org.jboss.cache.pojo.test.Person; 32 import org.jboss.cache.pojo.test.EnumPlanet; 33 34 39 40 public class EnumTest extends TestCase 41 { 42 Log log = LogFactory.getLog(EnumTest.class); 43 PojoCache cache_, cache1_; 44 45 public EnumTest(String name) 46 { 47 super(name); 48 } 49 50 protected void setUp() throws Exception 51 { 52 super.setUp(); 53 log.info("setUp() ...."); 54 String configFile = "META-INF/replSync-service.xml"; 55 boolean toStart = true; 56 cache_ = PojoCacheFactory.createCache(configFile, toStart); 57 cache1_ = PojoCacheFactory.createCache(configFile, toStart); 58 } 59 60 protected void tearDown() throws Exception 61 { 62 super.tearDown(); 63 cache_.stop(); 64 cache1_.stop(); 65 } 66 67 public void testSimple() throws Exception 68 { 69 log.info("testSimple() ...."); 70 71 double earthWeight = 165; 72 double mass = earthWeight / EnumPlanet.EARTH.surfaceGravity(); 73 74 cache_.attach("enum", EnumPlanet.EARTH); 75 76 EnumPlanet ep = (EnumPlanet)cache1_.find("enum"); 77 78 EnumPlanet.EARTH.setMass(7.0e+24); 79 80 assertEquals("Earth mass ", EnumPlanet.EARTH.mass(), ep.mass()); 81 } 82 83 public static Test suite() throws Exception 84 { 85 return new TestSuite(EnumTest.class); 86 } 87 88 89 public static void main(String [] args) throws Exception 90 { 91 junit.textui.TestRunner.run(suite()); 92 } 93 94 } 95 | Popular Tags |