Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 124   Methods: 7
NCLOC: 72   Classes: 3
 
 Source file Conditionals Statements Methods TOTAL
FailedStateTransferTest.java - 84% 57.1% 78.1%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    * Copyright 2005, JBoss Inc., and individual contributors as indicated
 4    * by the @authors tag. See the copyright.txt in the distribution for a
 5    * 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.statetransfer;
 24   
 25    import org.jboss.cache.CacheException;
 26    import org.jboss.cache.CacheImpl;
 27    import org.jboss.cache.Version;
 28    import org.jboss.cache.config.Configuration.CacheMode;
 29    import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 30    import org.jboss.cache.lock.TimeoutException;
 31   
 32    import java.io.InputStream;
 33   
 34    /**
 35    * A FailedStateTransferTest.
 36    *
 37    * @author Brian Stansberry
 38    * @version $Revision$
 39    */
 40    public class FailedStateTransferTest extends StateTransferTestBase
 41    {
 42   
 43  1 public void testFailedStateTransfer() throws Exception
 44    {
 45  1 CacheImpl cache = new SecretiveStateCache();
 46  1 cache.setConfiguration(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC));
 47  1 cache.getConfiguration().setClusterName("VersionedTestBase");
 48  1 cache.getConfiguration().setReplVersionString(getReplicationVersion());
 49    // Use a long timeout to facilitate setting debugger breakpoints
 50  1 cache.getConfiguration().setStateRetrievalTimeout(60000);
 51   
 52    // Put the cache in the map before starting, so if it fails in
 53    // start it can still be destroyed later
 54  1 caches.put("secretive", cache);
 55   
 56  1 cache.create();
 57  1 cache.start();
 58   
 59   
 60  1 CacheImpl recipient = new SecretiveStateCache();
 61  1 recipient.setConfiguration(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC));
 62  1 recipient.getConfiguration().setClusterName("VersionedTestBase");
 63  1 recipient.getConfiguration().setReplVersionString(getReplicationVersion());
 64    // Use a long timeout to facilitate setting debugger breakpoints
 65  1 recipient.getConfiguration().setStateRetrievalTimeout(60000);
 66   
 67    //Put the cache in the map before starting, so if it fails in
 68    // start it can still be destroyed later
 69  1 caches.put("secretive2", recipient);
 70   
 71  1 try
 72    {
 73  1 recipient.create();
 74  1 recipient.start();
 75  0 fail("start() should throw an exception");
 76    }
 77    catch (CacheException good)
 78    {
 79    // this is what we want
 80    }
 81    }
 82   
 83  2 protected String getReplicationVersion()
 84    {
 85  2 return Version.version;
 86    }
 87   
 88    private static class SecretiveStateCache extends CacheImpl
 89    {
 90  2 SecretiveStateCache() throws Exception
 91    {
 92  2 super();
 93  2 setMessageListener(new Adaptor());
 94    }
 95   
 96    class Adaptor extends MessageListenerAdaptor
 97    {
 98   
 99  0 @Override
 100    public void setState(byte[] new_state)
 101    {
 102  0 setStateException = new TimeoutException("Planned Timeout");
 103    }
 104   
 105  1 @Override
 106    public void setState(InputStream istream)
 107    {
 108  1 setStateException = new TimeoutException("Planned Timeout");
 109    }
 110   
 111  0 @Override
 112    public void setState(String state_id, byte[] state)
 113    {
 114  0 setStateException = new TimeoutException("Planned Timeout");
 115    }
 116   
 117  0 @Override
 118    public void setState(String state_id, InputStream istream)
 119    {
 120  0 setStateException = new TimeoutException("Planned Timeout");
 121    }
 122    }
 123    }
 124    }