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