@Test(timeout = 4000L) public void fallbackToSafeWithIncludedFile() throws IOException, JoranException, InterruptedException { String topLevelFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_top-" + diff + ".xml"; String innerFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_inner-" + diff + ".xml"; File topLevelFile = new File(topLevelFileAsStr); writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><include file=\"" + innerFileAsStr + "\"/></configuration> "); File innerFile = new File(innerFileAsStr); writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> "); configure(topLevelFile); writeToFile(innerFile, "<included>\n<root>\n</included>"); rocfDetachReconfigurationToNewThreadAndAwaitTermination(); checker.assertContainsMatch(Status.WARN, "Falling back to previously registered safe configuration."); checker.assertContainsMatch(Status.INFO, "Re-registering previous fallback configuration once more"); assertThatFirstFilterIsROCF(); }
@Test public void installFilter() throws JoranException, IOException, InterruptedException { File file = new File(SCAN1_FILE_AS_STR); configure(file); List<File> fileList = getConfigurationFileList(loggerContext); assertThatListContainsFile(fileList, file); assertThatFirstFilterIsROCF(); StatusPrinter.print(loggerContext); }
@Test(timeout = 4000L) public void scanWithFileInclusion() throws JoranException, IOException, InterruptedException { File topLevelFile = new File(INCLUSION_SCAN_TOPLEVEL0_AS_STR); File innerFile = new File(INCLUSION_SCAN_INNER0_AS_STR); configure(topLevelFile); List<File> fileList = getConfigurationFileList(loggerContext); assertThatListContainsFile(fileList, topLevelFile); assertThatListContainsFile(fileList, innerFile); }
@Test(timeout = 4000L) public void scan_LOGBACK_474() throws JoranException, IOException, InterruptedException { File file = new File(SCAN_LOGBACK_474_FILE_AS_STR); configure(file); RunnableWithCounterAndDone[] runnableArray = buildRunnableArray(file, UpdateType.TOUCH); harness.execute(runnableArray); loggerContext.getStatusManager().add( new InfoStatus("end of execution ", this)); verify(expectedResets); }
@Test public void includeScanViaInputStreamSuppliedConfigFile() throws IOException, JoranException, InterruptedException { String configurationStr = "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><include resource=\"asResource/inner1.xml\"/></configuration>"; configure(new ByteArrayInputStream(configurationStr.getBytes("UTF-8"))); ConfigurationWatchList configurationWatchList = ConfigurationWatchListUtil.getConfigurationWatchList(loggerContext); assertNull(configurationWatchList.getMainURL()); ReconfigureOnChangeFilter reconfigureOnChangeFilter = (ReconfigureOnChangeFilter) getFirstTurboFilter(); // without a top level file, reconfigureOnChangeFilter should not start assertFalse(reconfigureOnChangeFilter.isStarted()); }
private void malformedUpdate() throws IOException { writeToFile(configFile, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\">\n" + " <root level=\"ERROR\">\n" + "</configuration>"); }
private void rocfDetachReconfigurationToNewThreadAndAwaitTermination() throws InterruptedException { ReconfigureOnChangeFilter reconfigureOnChangeFilter = (ReconfigureOnChangeFilter) getFirstTurboFilter(); reconfigureOnChangeFilter.detachReconfigurationToNewThread(); executorService.shutdown(); executorService.awaitTermination(1000, TimeUnit.MILLISECONDS); }
ReconfigureOnChangeTest.this.addInfo("***settting last modified", this); switch (updateType) { case TOUCH:
@Test(timeout = 4000L) public void scanWithResourceInclusion() throws JoranException, IOException, InterruptedException { File topLevelFile = new File(INCLUSION_SCAN_TOP_BY_RESOURCE_AS_STR); File innerFile = new File(getClass().getResource(INCLUSION_SCAN_INNER1_AS_STR).getFile()); configure(topLevelFile); List<File> fileList = getConfigurationFileList(loggerContext); assertThatListContainsFile(fileList, topLevelFile); assertThatListContainsFile(fileList, innerFile); }
private void malformedInnerUpdate() throws IOException { writeToFile(configFile, "<included>\n" + " <root>\n" + "</included>"); }
private void assertThatFirstFilterIsROCF() { assertTrue(getFirstTurboFilter() instanceof ReconfigureOnChangeFilter); }
@Test(timeout = 4000L) public void fallbackToSafe() throws IOException, JoranException, InterruptedException { String path = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_fallbackToSafe-" + diff + ".xml"; File topLevelFile = new File(path); writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><root level=\"ERROR\"/></configuration> "); configure(topLevelFile); writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\">\n" + " <root></configuration>"); rocfDetachReconfigurationToNewThreadAndAwaitTermination(); checker.assertContainsMatch(Status.WARN, "Falling back to previously registered safe configuration."); checker.assertContainsMatch(Status.INFO, "Re-registering previous fallback configuration once more"); assertThatFirstFilterIsROCF(); }