@@ -71,7 +71,7 @@ public class ReconfigureOnChangeTaskTest extends ReconfigureTaskTestSupport {
7171
7272 private static final String SCAN_PERIOD_DEFAULT_FILE_AS_STR = JORAN_INPUT_PREFIX + "roct/scan_period_default.xml" ;
7373
74- private static final String TOP_FILE_WITH_INCLUSION = "asResource /topWithFileInclusion.xml" ;
74+ private static final String TOP_FILE_WITH_INCLUSION = "misc /topWithFileInclusion.xml" ;
7575
7676 Logger logger = loggerContext .getLogger (this .getClass ());
7777 StatusChecker statusChecker = new StatusChecker (loggerContext );
@@ -160,22 +160,22 @@ public void propertiesConfigurationTest() throws IOException, JoranException, In
160160 String propertiesFileStr = CoreTestConstants .OUTPUT_DIR_PREFIX + "roct-" + diff + ".properties" ;
161161 File propertiesFile = new File (propertiesFileStr );
162162 String configurationStr = "<configuration debug=\" true\" scan=\" true\" scanPeriod=\" 10 millisecond\" ><propertiesConfigurator file=\" " + propertiesFileStr + "\" /></configuration>" ;
163- writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=INFO" );
163+ writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=INFO" );
164164 configure (asBAIS (configurationStr ));
165165 Logger abcLogger = loggerContext .getLogger (loggerName );
166166 assertEquals (Level .INFO , abcLogger .getLevel ());
167167
168168 CountDownLatch changeDetectedLatch0 = registerChangeDetectedListener ();
169169 CountDownLatch configurationDoneLatch0 = registerPartialConfigurationEndedSuccessfullyEventListener ();
170170
171- writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=WARN" );
171+ writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=WARN" );
172172 changeDetectedLatch0 .await ();
173173 configurationDoneLatch0 .await ();
174174 assertEquals (Level .WARN , abcLogger .getLevel ());
175175
176176 CountDownLatch changeDetectedLatch1 = registerChangeDetectedListener ();
177177 CountDownLatch configurationDoneLatch1 = registerPartialConfigurationEndedSuccessfullyEventListener ();
178- writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=ERROR" );
178+ writeToFile (propertiesFile , PropertiesConfigurator .LOGBACK_LOGGER_PREFIX + loggerName + "=ERROR" );
179179 changeDetectedLatch1 .await ();
180180 configurationDoneLatch1 .await ();
181181
@@ -268,7 +268,7 @@ public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranExcepti
268268
269269 private void addResetResistantOnConsoleStatusListener () {
270270 // enable when debugging
271- if ( 1 != 1 )
271+ if ( 1 == 1 )
272272 return ;
273273 OnConsoleStatusListener ocs = new OnConsoleStatusListener ();
274274 ocs .setContext (loggerContext );
@@ -279,38 +279,40 @@ private void addResetResistantOnConsoleStatusListener() {
279279
280280 @ Test
281281 @ Timeout (value = 2 , unit = TimeUnit .SECONDS )
282- public void XXXscanWithIncludedFileCreatedLater () throws IOException , JoranException , InterruptedException {
283- ReconfigurationTaskRegisteredConfigEventListener roctRegisteredListener = new ReconfigurationTaskRegisteredConfigEventListener ();
284- loggerContext .addConfigurationEventListener (roctRegisteredListener );
285- addResetResistantOnConsoleStatusListener ();
286- String innerFileAsStr = CoreTestConstants .OUTPUT_DIR_PREFIX + "scanWithIncludedFileCreatedLater-" + diff + ".xml" ;
287- System .setProperty ("fileCreatedLater" , innerFileAsStr );
288- configureAsResource (TOP_FILE_WITH_INCLUSION );
282+ public void scanWithIncludedFileCreatedLater () throws IOException , JoranException , InterruptedException {
289283
290- File innerFile = new File (innerFileAsStr );
284+ try {
285+ ReconfigurationTaskRegisteredConfigEventListener roctRegisteredListener = new ReconfigurationTaskRegisteredConfigEventListener ();
286+ loggerContext .addConfigurationEventListener (roctRegisteredListener );
287+ addResetResistantOnConsoleStatusListener ();
288+ String innerFileAsStr = CoreTestConstants .OUTPUT_DIR_PREFIX + "scanWithIncludedFileCreatedLater-" + diff + ".xml" ;
289+ System .setProperty ("fileCreatedLater" , innerFileAsStr );
290+ configureAsResource (TOP_FILE_WITH_INCLUSION );
291+
292+ if (isSurefire ()) {
293+ statusChecker .assertContainsMatch ("URL \\ [.*\\ ] is not of type file" );
294+ }
291295
292- List <File > fileList = getConfigurationWatchList (loggerContext );
293- assertThatListContainsFile (fileList , innerFile );
296+ File innerFile = new File (innerFileAsStr );
294297
295- // capture reference to ReconfigureOnChangeTask
296- //ReconfigureOnChangeTask roct = roctRegisteredListener.reconfigureOnChangeTask;
297- //assertNotNull(roct);
298+ List <File > fileList = getConfigurationWatchList (loggerContext );
299+ assertThatListContainsFile (fileList , innerFile );
298300
299- CountDownLatch changeDetectedLatch = registerChangeDetectedListener ();
300- CountDownLatch configurationDoneLatch = registerNewReconfigurationDoneSuccessfullyListener ();
301+ CountDownLatch changeDetectedLatch = registerChangeDetectedListener ();
302+ CountDownLatch configurationDoneLatch = registerNewReconfigurationDoneSuccessfullyListener ();
301303
304+ writeToFile (innerFile , "<included><root level=\" ERROR\" /></included> " );
305+ changeDetectedLatch .await ();
306+ configurationDoneLatch .await ();
302307
303- writeToFile (innerFile , "<included><root level=\" ERROR\" /></included> " );
304- changeDetectedLatch .await ();
305- configurationDoneLatch .await ();
306-
307- //Thread.sleep(1000);
308- //waitForReconfigureOnChangeTaskToRun();
309-
310- //statusPrinter2.print(loggerContext);
311- Logger root = loggerContext .getLogger (Logger .ROOT_LOGGER_NAME );
312- assertEquals (Level .ERROR , root .getLevel ());
308+ //statusPrinter2.print(loggerContext);
309+ Logger root = loggerContext .getLogger (Logger .ROOT_LOGGER_NAME );
310+ assertEquals (Level .ERROR , root .getLevel ());
313311
312+ //System.getProperties().forEach((k,v)->System.out.println(k+"="+v));
313+ } finally {
314+ System .getProperties ().remove ("fileCreatedLater" );
315+ }
314316 }
315317
316318
@@ -321,7 +323,7 @@ public void fallbackToSafeWithIncludedFile_FollowedByRecovery() throws IOExcepti
321323 String innerFileAsStr = CoreTestConstants .OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_inner-" + diff + ".xml" ;
322324 File topLevelFile = new File (topLevelFileAsStr );
323325 writeToFile (topLevelFile ,
324- "<configuration xdebug=\" true\" scan=\" true\" scanPeriod=\" 5 millisecond\" ><include file=\" " + innerFileAsStr + "\" /></configuration> " );
326+ "<configuration xdebug=\" true\" scan=\" true\" scanPeriod=\" 5 millisecond\" ><include file=\" " + innerFileAsStr + "\" /></configuration> " );
325327
326328 File innerFile = new File (innerFileAsStr );
327329 writeToFile (innerFile , "<included><root level=\" ERROR\" /></included> " );
@@ -330,6 +332,7 @@ public void fallbackToSafeWithIncludedFile_FollowedByRecovery() throws IOExcepti
330332 configure (topLevelFile );
331333
332334
335+
333336 CountDownLatch changeDetectedLatch = registerChangeDetectedListener ();
334337 CountDownLatch configurationDoneLatch = registerNewReconfigurationDoneSuccessfullyListener ();
335338
@@ -362,6 +365,16 @@ CountDownLatch registerNewReconfigurationDoneSuccessfullyListener() {
362365 return latch ;
363366 }
364367
368+ boolean isSurefire () {
369+ if (System .getProperty ("surefire.test.class.path" ) != null ) {
370+ return true ;
371+ }
372+ if (System .getProperty ("surefire.real.class.path" ) != null ) {
373+ return true ;
374+ }
375+ return false ;
376+ }
377+
365378 static class RunMethodInvokedListener implements ConfigurationEventListener {
366379 CountDownLatch countDownLatch ;
367380 ReconfigureOnChangeTask reconfigureOnChangeTask ;
0 commit comments