1616 */
1717package com .optimizely .ab .config ;
1818
19+ import ch .qos .logback .classic .Level ;
20+ import com .optimizely .ab .internal .LogbackVerifier ;
1921import com .optimizely .ab .internal .NotificationRegistry ;
2022import com .optimizely .ab .notification .NotificationCenter ;
2123import 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 ;
2628
2729import java .util .concurrent .CompletableFuture ;
2830import java .util .concurrent .CountDownLatch ;
@@ -41,6 +43,13 @@ public class PollingProjectConfigManagerTest {
4143 private static final TimeUnit POLLING_UNIT = TimeUnit .MILLISECONDS ;
4244 private static final int PROJECT_CONFIG_DELAY = 100 ;
4345
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 );
4453 private TestProjectConfigManager testProjectConfigManager ;
4554 private ProjectConfig projectConfig ;
4655
@@ -228,6 +237,13 @@ public void testUpdateConfigNotificationGetsTriggered() throws InterruptedExcept
228237 assertTrue (countDownLatch .await (500 , TimeUnit .MILLISECONDS ));
229238 }
230239
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+
231247 @ Test
232248 public void testUpdateConfigNotificationDoesNotResultInDeadlock () throws Exception {
233249 NotificationCenter notificationCenter = new NotificationCenter ();
@@ -257,7 +273,11 @@ private TestProjectConfigManager(ProjectConfig projectConfig) {
257273 }
258274
259275 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 );
261281 this .projectConfig = projectConfig ;
262282 }
263283
0 commit comments