Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 135   Methods: 8
NCLOC: 94   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ReplicatedSerializableTest.java - 63.5% 75% 65%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7   
 8    package org.jboss.cache.pojo;
 9   
 10    import junit.framework.Test;
 11    import junit.framework.TestCase;
 12    import junit.framework.TestSuite;
 13    import org.apache.commons.logging.Log;
 14    import org.apache.commons.logging.LogFactory;
 15    import org.jboss.cache.config.Configuration.CacheMode;
 16    import org.jboss.cache.factories.UnitTestCacheFactory;
 17    import org.jboss.cache.pojo.test.CacheObject;
 18    import org.jboss.cache.pojo.test.Student;
 19   
 20    import javax.naming.Context;
 21    import java.util.Properties;
 22   
 23    /**
 24    * New NewReplicatedAopTest that doesn't use TreeCacheAopTester.
 25    *
 26    * @author Ben Wang
 27    */
 28   
 29    public class ReplicatedSerializableTest extends TestCase
 30    {
 31    Log log_ = LogFactory.getLog(ReplicatedSerializableTest.class);
 32    PojoCache cache_;
 33    PojoCache cache1_;
 34   
 35  4 public ReplicatedSerializableTest(String name)
 36    {
 37  4 super(name);
 38    }
 39   
 40  4 protected void setUp() throws Exception
 41    {
 42  4 super.setUp();
 43  4 Properties prop = new Properties();
 44  4 prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
 45  4 boolean toStart = false;
 46  4 cache_ = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
 47  4 cache1_ = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
 48  4 cache_.start();
 49  4 cache1_.start();
 50    }
 51   
 52  4 protected void tearDown() throws Exception
 53    {
 54  4 super.tearDown();
 55  4 cache_.stop();
 56  4 cache1_.stop();
 57    }
 58   
 59  2 public void testSeriazableSubObject() throws Exception
 60    {
 61  2 log_.info("testSerializableSubObject() ....");
 62   
 63  2 Student ben = new Student();
 64  2 ben.setName("Ben");
 65  2 ben.setYear("9th grade");
 66  2 CacheObject co1 = new CacheObject("1");
 67  2 ben.setCO1(co1);
 68  2 CacheObject co2 = new CacheObject("2");
 69  2 ben.setCO2(co2);
 70   
 71  2 cache_.attach("/test", ben);
 72   
 73  2 Student be = (Student) cache1_.find("/test");
 74  2 assertNotNull("CacheObject should not be null", be.getCO1());
 75  2 assertNotNull("CacheObject should not be null", be.getCO2());
 76  2 assertEquals("1", be.getCO1().getId());
 77  2 assertEquals("2", be.getCO2().getId());
 78    }
 79   
 80    /**
 81    * We don;t currently support Serializable with relationship now.
 82    *
 83    * @throws Exception
 84    */
 85  0 public void XtestSeriazableSubObjectRelation() throws Exception
 86    {
 87  0 log_.info("testSerializableSubObjectRelation() ....");
 88   
 89  0 Student ben = new Student();
 90  0 ben.setName("Ben");
 91  0 ben.setYear("9th grade");
 92  0 CacheObject co1 = new CacheObject("1");
 93  0 ben.setCO1(co1);
 94   
 95  0 Student elynne = new Student();
 96  0 elynne.setName("Elynne");
 97  0 elynne.setYear("9th grade");
 98    // Same co object
 99  0 elynne.setCO1(co1);
 100   
 101  0 cache_.attach("/ben", ben);
 102  0 cache_.attach("/elynne", elynne);
 103   
 104  0 Student be = (Student) cache1_.find("/ben");
 105  0 Student el = (Student) cache1_.find("/elynne");
 106  0 assertNotNull("CacheObject should not be null", be.getCO1());
 107  0 assertNotNull("CacheObject should not be null", el.getCO1());
 108  0 assertEquals("Both co object should be the same", be.getCO1().getId(), el.getCO1().getId());
 109  0 assertTrue("Both co should be the same reference", be.getCO1() == el.getCO1());
 110    }
 111   
 112  2 public void testPlainSeriazable() throws Exception
 113    {
 114  2 log_.info("testPlainSerializable() ....");
 115    // First the flag is set to false
 116  2 CacheObject co = new CacheObject("1");
 117  2 cache_.attach("/test", co);
 118  2 CacheObject co1 = (CacheObject) cache1_.find("/test");
 119  2 assertNotNull("co on remote cache should not be null", co1);
 120  2 assertEquals("co should be the same", co.getId(), co1.getId());
 121   
 122    }
 123   
 124  2 public static Test suite() throws Exception
 125    {
 126  2 return new TestSuite(ReplicatedSerializableTest.class);
 127    }
 128   
 129   
 130  0 public static void main(String[] args) throws Exception
 131    {
 132  0 junit.textui.TestRunner.run(ReplicatedSerializableTest.suite());
 133    }
 134   
 135    }