Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 121   Methods: 8
NCLOC: 75   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ReplicatedTest.java - 78.8% 75% 78%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source.
 3    * Copyright 2006, Red Hat Middleware LLC, and individual contributors
 4    * as indicated by the @author tags. See the copyright.txt file in the
 5    * distribution for a full listing of individual contributors.
 6    *
 7    * This is free software; you can redistribute it and/or modify it
 8    * under the terms of the GNU Lesser General Public License as
 9    * published by the Free Software Foundation; either version 2.1 of
 10    * the License, or (at your option) any later version.
 11    *
 12    * This software is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 15    * Lesser General Public License for more details.
 16    *
 17    * You should have received a copy of the GNU Lesser General Public
 18    * License along with this software; if not, write to the Free
 19    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 21    */
 22   
 23    package org.jboss.cache.pojo.statetransfer;
 24   
 25    import junit.framework.Test;
 26    import junit.framework.TestCase;
 27    import junit.framework.TestSuite;
 28    import org.apache.commons.logging.Log;
 29    import org.apache.commons.logging.LogFactory;
 30    import org.jboss.cache.CacheImpl;
 31    import org.jboss.cache.config.Configuration.CacheMode;
 32    import org.jboss.cache.factories.UnitTestCacheFactory;
 33    import org.jboss.cache.pojo.PojoCache;
 34    import org.jboss.cache.pojo.PojoCacheFactory;
 35    import org.jboss.cache.pojo.test.Person;
 36    import org.jboss.cache.pojo.test.Student;
 37   
 38    /**
 39    * Simple replicated test for state transfer
 40    *
 41    * @author Ben Wang
 42    */
 43    public class ReplicatedTest extends TestCase
 44    {
 45    Log log = LogFactory.getLog(ReplicatedTest.class);
 46    PojoCache cache, cache1;
 47   
 48   
 49  2 public ReplicatedTest(String name)
 50    {
 51  2 super(name);
 52    }
 53   
 54  2 protected void setUp() throws Exception
 55    {
 56  2 super.setUp();
 57  2 log.info("setUp() ....");
 58    }
 59   
 60  2 protected void tearDown() throws Exception
 61    {
 62  2 super.tearDown();
 63  2 cache.stop();
 64  2 cache1.stop();
 65    }
 66   
 67    // public void testDummy() {}
 68   
 69  2 private Person createPerson(String id, String name, int age)
 70    {
 71  2 Person p = new Person();
 72  2 p.setName(name);
 73  2 p.setAge(age);
 74  2 cache.attach(id, p);
 75  2 return p;
 76    }
 77   
 78  0 private Student createStudent(String id, String name, int age, String grade)
 79    {
 80  0 Student p = new Student();
 81  0 p.setName(name);
 82  0 p.setAge(age);
 83  0 p.setYear(grade);
 84  0 cache.attach(id, p);
 85  0 return p;
 86    }
 87   
 88  2 public void testSimple() throws Exception
 89    {
 90  2 boolean toStart = true;
 91  2 cache = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
 92  2 Person ben = createPerson("/person/test1", "Ben Wang", 40);
 93   
 94  2 System.out.println("\n*** I ***");
 95  2 System.out.println(((CacheImpl) cache.getCache()).printDetails());
 96  2 cache1 = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
 97  2 cache1.start();
 98   
 99  2 System.out.println("\n*** II ***");
 100  2 System.out.println(((CacheImpl) cache1.getCache()).printDetails());
 101   
 102  2 Person p = (Person) cache1.find("/person/test1");
 103   
 104  2 log.info("testSimple() ....");
 105  2 assertEquals("Ben Wang", ben.getName());
 106  2 assertEquals("Ben Wang", ((Person) cache1.find("/person/test1")).getName());
 107  2 cache.detach("/person/test1");
 108    }
 109   
 110  2 public static Test suite() throws Exception
 111    {
 112  2 return new TestSuite(ReplicatedTest.class);
 113    }
 114   
 115   
 116  0 public static void main(String[] args) throws Exception
 117    {
 118  0 junit.textui.TestRunner.run(suite());
 119    }
 120   
 121    }