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.Resource; 31 32 37 public class ReplicatedByteTest extends TestCase 38 { 39 Log log = LogFactory.getLog(ReplicatedByteTest.class); 40 PojoCache cache, cache1; 41 42 43 public ReplicatedByteTest(String name) 44 { 45 super(name); 46 } 47 48 protected void setUp() throws Exception 49 { 50 super.setUp(); 51 log.info("setUp() ...."); 52 String configFile = "META-INF/replSync-service.xml"; 53 boolean toStart = false; 54 cache = PojoCacheFactory.createCache(configFile, toStart); 55 cache.start(); 56 cache1 = PojoCacheFactory.createCache(configFile, toStart); 57 cache1.start(); 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 Resource res = new Resource(); 71 res.setName("mapping"); 72 res.setConnection("wire"); 73 String s = "This is a test"; 74 byte by = 1; 75 byte[] b = new byte[1]; 76 b[0] = by; 77 res.setByte(b); 78 79 cache.attach("resource", res); 80 81 Resource res1 = (Resource)cache1.find("resource"); 82 assertEquals("Name ", res.getName(), res1.getName()); 83 84 assertEquals("byte ", res.getByte()[0], res1.getByte()[0]); 85 86 by = 2; 88 b[0] = by; 89 res1.setByte(b); 90 assertEquals("Name ", res.getName(), res1.getName()); 91 92 assertEquals("byte ", res.getByte()[0], res1.getByte()[0]); 93 94 } 95 96 public static Test suite() throws Exception 97 { 98 return new TestSuite(ReplicatedByteTest.class); 99 } 100 101 102 public static void main(String [] args) throws Exception 103 { 104 junit.textui.TestRunner.run(suite()); 105 } 106 107 } 108 | Popular Tags |