1 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.factories.XmlConfigurationParser; 29 import org.jboss.cache.lock.TimeoutException; 30 31 import java.io.InputStream ; 32 33 39 public class FailedStateTransferTest extends StateTransferTestBase 40 { 41 42 public void testFailedStateTransfer() throws Exception 43 { 44 CacheImpl cache = new SecretiveStateCache(); 45 cache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replAsync-service.xml")); 46 cache.getConfiguration().setClusterName("VersionedTestBase"); 47 cache.getConfiguration().setReplVersionString(getReplicationVersion()); 48 cache.getConfiguration().setInitialStateRetrievalTimeout(60000); 50 51 caches.put("secretive", cache); 54 55 cache.create(); 56 cache.start(); 57 58 59 CacheImpl recipient = new SecretiveStateCache(); 60 recipient.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replAsync-service.xml")); 61 recipient.getConfiguration().setClusterName("VersionedTestBase"); 62 recipient.getConfiguration().setReplVersionString(getReplicationVersion()); 63 recipient.getConfiguration().setInitialStateRetrievalTimeout(60000); 65 66 caches.put("secretive2", recipient); 69 70 try 71 { 72 recipient.create(); 73 recipient.start(); 74 fail("start() should throw an exception"); 75 } 76 catch (CacheException good) 77 { 78 } 80 } 81 82 protected String getReplicationVersion() 83 { 84 return Version.version; 85 } 86 87 private static class SecretiveStateCache extends CacheImpl 88 { 89 SecretiveStateCache() throws Exception 90 { 91 super(); 92 ml = new Adaptor(); 93 } 94 95 class Adaptor extends MessageListenerAdaptor 96 { 97 98 @Override 99 public void setState(byte[] new_state) 100 { 101 setStateException = new TimeoutException("Planned Timeout"); 102 } 103 104 @Override 105 public void setState(InputStream istream) 106 { 107 setStateException = new TimeoutException("Planned Timeout"); 108 } 109 110 @Override 111 public void setState(String state_id, byte[] state) 112 { 113 setStateException = new TimeoutException("Planned Timeout"); 114 } 115 116 @Override 117 public void setState(String state_id, InputStream istream) 118 { 119 setStateException = new TimeoutException("Planned Timeout"); 120 } 121 } 122 } 123 } 124 | Popular Tags |