Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 94   Methods: 3
NCLOC: 63   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeInterceptorTransactionTest.java - 97.2% 100% 97.4%
coverage coverage
 1    /*
 2    * Created on 17-Feb-2005
 3    *
 4    *
 5    *
 6    */
 7    package org.jboss.cache.optimistic;
 8   
 9    import org.jboss.cache.CacheImpl;
 10    import org.jboss.cache.interceptors.Interceptor;
 11    import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
 12    import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
 13   
 14    /**
 15    * @author xenephon
 16    */
 17    public class NodeInterceptorTransactionTest extends AbstractOptimisticTestCase
 18    {
 19   
 20    /**
 21    * @param name
 22    */
 23  2 public NodeInterceptorTransactionTest(String name)
 24    {
 25  2 super(name);
 26   
 27    }
 28   
 29  1 public void testNoTransactionCRUDMethod() throws Exception
 30    {
 31   
 32  1 TestListener listener = new TestListener();
 33  1 final CacheImpl cache = createCacheWithListener(listener);
 34   
 35  1 Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
 36  1 interceptor.setCache(cache);
 37  1 Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
 38  1 nodeInterceptor.setCache(cache);
 39  1 MockInterceptor dummy = new MockInterceptor();
 40  1 dummy.setCache(cache);
 41   
 42  1 interceptor.setNext(nodeInterceptor);
 43  1 nodeInterceptor.setNext(dummy);
 44   
 45  1 cache.setInterceptorChain(interceptor);
 46   
 47  1 try
 48    {
 49  1 cache.put("/one/two", "key1", new Object());
 50  0 fail();
 51    }
 52    catch (Throwable t)
 53    {
 54   
 55  1 assertTrue(true);
 56    }
 57  1 assertEquals(null, dummy.getCalled());
 58  1 cache.stop();
 59    }
 60   
 61  1 public void testNoTransactionGetMethod() throws Exception
 62    {
 63   
 64  1 TestListener listener = new TestListener();
 65  1 final CacheImpl cache = createCacheWithListener(listener);
 66   
 67  1 Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
 68  1 interceptor.setCache(cache);
 69  1 Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
 70  1 nodeInterceptor.setCache(cache);
 71  1 MockInterceptor dummy = new MockInterceptor();
 72  1 dummy.setCache(cache);
 73   
 74  1 interceptor.setNext(nodeInterceptor);
 75  1 nodeInterceptor.setNext(dummy);
 76   
 77  1 cache.setInterceptorChain(interceptor);
 78   
 79  1 boolean fail = false;
 80  1 try
 81    {
 82  1 assertEquals(null, cache.get("/one/two", "key1"));
 83    }
 84    catch (Exception e)
 85    {
 86  1 fail = true;
 87    }
 88  1 assertTrue(fail);
 89  1 assertEquals(null, dummy.getCalled());
 90  1 cache.stop();
 91    }
 92   
 93   
 94    }