16
16
*/
17
17
package com .optimizely .ab .config ;
18
18
19
+ import ch .qos .logback .classic .Level ;
20
+ import com .optimizely .ab .internal .LogbackVerifier ;
19
21
import com .optimizely .ab .internal .NotificationRegistry ;
20
22
import com .optimizely .ab .notification .NotificationCenter ;
21
23
import com .optimizely .ab .notification .UpdateConfigNotification ;
22
- import org . junit . After ;
23
- import org .junit .Before ;
24
- import org .junit .Ignore ;
25
- import org .junit .Test ;
24
+ import edu . umd . cs . findbugs . annotations . SuppressFBWarnings ;
25
+ import org .junit .* ;
26
+ import org .junit .rules . ExpectedException ;
27
+ import org .junit .rules . RuleChain ;
26
28
27
29
import java .util .concurrent .CompletableFuture ;
28
30
import java .util .concurrent .CountDownLatch ;
@@ -41,6 +43,13 @@ public class PollingProjectConfigManagerTest {
41
43
private static final TimeUnit POLLING_UNIT = TimeUnit .MILLISECONDS ;
42
44
private static final int PROJECT_CONFIG_DELAY = 100 ;
43
45
46
+ public ExpectedException thrown = ExpectedException .none ();
47
+ public LogbackVerifier logbackVerifier = new LogbackVerifier ();
48
+
49
+ @ Rule
50
+ @ SuppressFBWarnings ("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" )
51
+ public RuleChain ruleChain = RuleChain .outerRule (thrown )
52
+ .around (logbackVerifier );
44
53
private TestProjectConfigManager testProjectConfigManager ;
45
54
private ProjectConfig projectConfig ;
46
55
@@ -228,6 +237,13 @@ public void testUpdateConfigNotificationGetsTriggered() throws InterruptedExcept
228
237
assertTrue (countDownLatch .await (500 , TimeUnit .MILLISECONDS ));
229
238
}
230
239
240
+ @ Test
241
+ public void testSettingUpLowerPollingPeriodResultsInWarning () throws InterruptedException {
242
+ long pollingPeriod = 29 ;
243
+ new TestProjectConfigManager (projectConfig , pollingPeriod , TimeUnit .SECONDS , pollingPeriod / 2 , TimeUnit .SECONDS , new NotificationCenter ());
244
+ logbackVerifier .expectMessage (Level .WARN , "Polling intervals below 30 seconds are not recommended." );
245
+ }
246
+
231
247
@ Test
232
248
public void testUpdateConfigNotificationDoesNotResultInDeadlock () throws Exception {
233
249
NotificationCenter notificationCenter = new NotificationCenter ();
@@ -257,7 +273,11 @@ private TestProjectConfigManager(ProjectConfig projectConfig) {
257
273
}
258
274
259
275
private TestProjectConfigManager (ProjectConfig projectConfig , long blockPeriod , NotificationCenter notificationCenter ) {
260
- super (POLLING_PERIOD , POLLING_UNIT , blockPeriod , POLLING_UNIT , notificationCenter );
276
+ this (projectConfig , POLLING_PERIOD , POLLING_UNIT , blockPeriod , POLLING_UNIT , notificationCenter );
277
+ }
278
+
279
+ private TestProjectConfigManager (ProjectConfig projectConfig , long pollingPeriod , TimeUnit pollingUnit , long blockPeriod , TimeUnit blockingUnit , NotificationCenter notificationCenter ) {
280
+ super (pollingPeriod , pollingUnit , blockPeriod , blockingUnit , notificationCenter );
261
281
this .projectConfig = projectConfig ;
262
282
}
263
283
0 commit comments