1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
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 |
| |
36 |
| |
37 |
| |
38 |
| |
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 |
| |
50 |
1
| cache.getConfiguration().setStateRetrievalTimeout(60000);
|
51 |
| |
52 |
| |
53 |
| |
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 |
| |
65 |
1
| recipient.getConfiguration().setStateRetrievalTimeout(60000);
|
66 |
| |
67 |
| |
68 |
| |
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 |
| |
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 |
| } |