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.UnitTestCacheFactory; |
30 |
| import org.jboss.cache.factories.XmlConfigurationParser; |
31 |
| import org.jboss.cache.lock.TimeoutException; |
32 |
| |
33 |
| import java.io.InputStream; |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
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 |
| |
51 |
1
| cache.getConfiguration().setInitialStateRetrievalTimeout(60000);
|
52 |
| |
53 |
| |
54 |
| |
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 |
| |
66 |
1
| recipient.getConfiguration().setInitialStateRetrievalTimeout(60000);
|
67 |
| |
68 |
| |
69 |
| |
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 |
| |
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 |
| } |