8
8
9
9
import java .util .Properties ;
10
10
import java .util .Set ;
11
+ import java .util .concurrent .Callable ;
12
+ import java .util .concurrent .TimeUnit ;
11
13
12
14
import org .hibernate .boot .registry .StandardServiceRegistry ;
13
15
import org .hibernate .boot .registry .StandardServiceRegistryBuilder ;
19
21
import org .infinispan .AdvancedCache ;
20
22
import org .infinispan .transaction .tm .BatchModeTransactionManager ;
21
23
import org .jboss .logging .Logger ;
22
- import org .junit .Ignore ;
23
24
import org .junit .Test ;
24
25
26
+ import static org .hibernate .test .cache .infinispan .util .CacheTestUtil .assertEqualsEventually ;
25
27
import static org .junit .Assert .assertEquals ;
26
28
import static org .junit .Assert .assertNull ;
27
29
@@ -59,7 +61,6 @@ protected void removeFromRegion(Region region, Object key) {
59
61
}
60
62
61
63
@ Test
62
- @ Ignore // currently ignored because of HHH-9800
63
64
public void testEvict () throws Exception {
64
65
evictOrRemoveTest ();
65
66
}
@@ -81,7 +82,7 @@ private void evictOrRemoveTest() throws Exception {
81
82
// Sleep a bit to avoid concurrent FLUSH problem
82
83
avoidConcurrentFlush ();
83
84
84
- GeneralDataRegion localRegion = (GeneralDataRegion ) createRegion (
85
+ final GeneralDataRegion localRegion = (GeneralDataRegion ) createRegion (
85
86
regionFactory ,
86
87
getStandardRegionName ( REGION_PREFIX ),
87
88
properties ,
@@ -93,7 +94,7 @@ private void evictOrRemoveTest() throws Exception {
93
94
getCacheTestSupport ()
94
95
);
95
96
96
- GeneralDataRegion remoteRegion = (GeneralDataRegion ) createRegion (
97
+ final GeneralDataRegion remoteRegion = (GeneralDataRegion ) createRegion (
97
98
regionFactory ,
98
99
getStandardRegionName ( REGION_PREFIX ),
99
100
properties ,
@@ -103,22 +104,29 @@ private void evictOrRemoveTest() throws Exception {
103
104
assertNull ( "remote is clean" , remoteRegion .get ( KEY ) );
104
105
105
106
regionPut ( localRegion );
106
- sleep ( 250 );
107
- assertEquals ( VALUE1 , localRegion .get ( KEY ) );
108
107
109
- // allow async propagation
110
- sleep ( 250 );
108
+ Callable <Object > getFromLocalRegion = new Callable <Object >() {
109
+ @ Override
110
+ public Object call () throws Exception {
111
+ return localRegion .get (KEY );
112
+ }
113
+ };
114
+ Callable <Object > getFromRemoteRegion = new Callable <Object >() {
115
+ @ Override
116
+ public Object call () throws Exception {
117
+ return remoteRegion .get (KEY );
118
+ }
119
+ };
120
+
121
+ assertEqualsEventually (VALUE1 , getFromLocalRegion , 10 , TimeUnit .SECONDS );
111
122
Object expected = invalidation ? null : VALUE1 ;
112
- assertEquals ( expected , remoteRegion . get ( KEY ) );
123
+ assertEqualsEventually ( expected , getFromRemoteRegion , 10 , TimeUnit . SECONDS );
113
124
114
- regionEvict ( localRegion );
125
+ regionEvict (localRegion );
115
126
116
- // allow async propagation
117
- sleep ( 250 );
118
- assertEquals ( null , localRegion .get ( KEY ) );
119
- assertEquals ( null , remoteRegion .get ( KEY ) );
120
- }
121
- finally {
127
+ assertEqualsEventually (null , getFromLocalRegion , 10 , TimeUnit .SECONDS );
128
+ assertEqualsEventually (null , getFromRemoteRegion , 10 , TimeUnit .SECONDS );
129
+ } finally {
122
130
StandardServiceRegistryBuilder .destroy ( registry1 );
123
131
StandardServiceRegistryBuilder .destroy ( registry2 );
124
132
}
0 commit comments