9
9
import org .junit .jupiter .api .Test ;
10
10
import org .junit .jupiter .api .Timeout ;
11
11
12
- class EventsLockTest {
12
+ class FlagdProviderSyncResourcesTest {
13
13
private static final long PERMISSIBLE_EPSILON = 20 ;
14
14
15
- private FlagdProviderSyncResources eventsLock ;
15
+ private FlagdProviderSyncResources flagdProviderSyncResources ;
16
16
17
17
@ BeforeEach
18
18
void setUp () {
19
- eventsLock = new FlagdProviderSyncResources ();
19
+ flagdProviderSyncResources = new FlagdProviderSyncResources ();
20
20
}
21
21
22
22
@ Timeout (2 )
23
23
@ Test
24
24
void waitForInitialization_failsWhenDeadlineElapses () {
25
- Assertions .assertThrows (GeneralError .class , () -> eventsLock .waitForInitialization (2 ));
25
+ Assertions .assertThrows (GeneralError .class , () -> flagdProviderSyncResources .waitForInitialization (2 ));
26
26
}
27
27
28
28
@ Timeout (2 )
@@ -34,7 +34,7 @@ void waitForInitialization_waitsApproxForDeadline() {
34
34
Assertions .assertThrows (GeneralError .class , () -> {
35
35
start .set (System .currentTimeMillis ());
36
36
try {
37
- eventsLock .waitForInitialization (deadline );
37
+ flagdProviderSyncResources .waitForInitialization (deadline );
38
38
} catch (Exception e ) {
39
39
end .set (System .currentTimeMillis ());
40
40
throw e ;
@@ -55,7 +55,7 @@ void interruptingWaitingThread_isIgnored() throws InterruptedException {
55
55
Thread waitingThread = new Thread (() -> {
56
56
long start = System .currentTimeMillis ();
57
57
isWaiting .set (true );
58
- eventsLock .waitForInitialization (deadline );
58
+ flagdProviderSyncResources .waitForInitialization (deadline );
59
59
long end = System .currentTimeMillis ();
60
60
long duration = end - start ;
61
61
// even though thread was interrupted, it still waited for the deadline
@@ -85,7 +85,7 @@ void callingInitialize_wakesUpWaitingThread() throws InterruptedException {
85
85
Thread waitingThread = new Thread (() -> {
86
86
long start = System .currentTimeMillis ();
87
87
isWaiting .set (true );
88
- eventsLock .waitForInitialization (10000 );
88
+ flagdProviderSyncResources .waitForInitialization (10000 );
89
89
long end = System .currentTimeMillis ();
90
90
long duration = end - start ;
91
91
Assertions .assertTrue (duration < PERMISSIBLE_EPSILON );
@@ -98,7 +98,7 @@ void callingInitialize_wakesUpWaitingThread() throws InterruptedException {
98
98
99
99
Thread .sleep (PERMISSIBLE_EPSILON ); // waitingThread should have started waiting in the meantime
100
100
101
- eventsLock .initialize ();
101
+ flagdProviderSyncResources .initialize ();
102
102
103
103
waitingThread .join ();
104
104
}
@@ -110,7 +110,7 @@ void callingShutdown_wakesUpWaitingThreadWithException() throws InterruptedExcep
110
110
Thread waitingThread = new Thread (() -> {
111
111
long start = System .currentTimeMillis ();
112
112
isWaiting .set (true );
113
- Assertions .assertThrows (IllegalArgumentException .class , () -> eventsLock .waitForInitialization (10000 ));
113
+ Assertions .assertThrows (IllegalArgumentException .class , () -> flagdProviderSyncResources .waitForInitialization (10000 ));
114
114
115
115
long end = System .currentTimeMillis ();
116
116
long duration = end - start ;
@@ -124,17 +124,17 @@ void callingShutdown_wakesUpWaitingThreadWithException() throws InterruptedExcep
124
124
125
125
Thread .sleep (PERMISSIBLE_EPSILON ); // waitingThread should have started waiting in the meantime
126
126
127
- eventsLock .shutdown ();
127
+ flagdProviderSyncResources .shutdown ();
128
128
129
129
waitingThread .join ();
130
130
}
131
131
132
132
@ Timeout (2 )
133
133
@ Test
134
134
void waitForInitializationAfterCallingInitialize_returnsInstantly () {
135
- eventsLock .initialize ();
135
+ flagdProviderSyncResources .initialize ();
136
136
long start = System .currentTimeMillis ();
137
- eventsLock .waitForInitialization (10000 );
137
+ flagdProviderSyncResources .waitForInitialization (10000 );
138
138
long end = System .currentTimeMillis ();
139
139
// do not use PERMISSIBLE_EPSILON here, this should happen faster than that
140
140
Assertions .assertTrue (start + 1 >= end );
0 commit comments