public boolean hasXMLParsingErrors(long threshold) { return containsMatch(threshold, Status.ERROR, CoreConstants.XML_PARSING); }
public boolean hasXMLParsingErrors(long threshold) { return containsMatch(threshold, Status.ERROR, CoreConstants.XML_PARSING); }
public boolean containsMatch(int level, String regex) { return containsMatch(0, level, regex); }
public boolean containsMatch(int level, String regex) { return containsMatch(0, level, regex); }
public void assertContainsMatch(int level, String regex) { assertTrue(containsMatch(level, regex)); }
public void assertNoMatch(String regex) { assertFalse(containsMatch(regex)); }
public void assertContainsMatch(String regex) { assertTrue(containsMatch(regex)); }
@Test(timeout = 4000L) public void reconfigurationIsNotPossibleInTheAbsenceOfATopFile() throws IOException, JoranException { 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); //assertNull(configurationWatchList.getMainURL()); statusChecker.containsMatch(Status.WARN, "Due to missing top level"); StatusPrinter.print(loggerContext); ReconfigureOnChangeTask roct = getRegisteredReconfigureTask(); assertNull(roct); assertEquals(0, loggerContext.getScheduledFutures().size()); }
/** * Test for http://jira.qos.ch/browse/LOGBACK-796 */ @Test public void testFileShouldNotMatchFileNamePattern() { rfa.setContext(context); rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX + "x-2013-04.log"); tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "x-%d{yyyy-MM}.log"); tbrp.start(); rfa.setRollingPolicy(tbrp); rfa.start(); StatusChecker statusChecker = new StatusChecker(context); final String msg = "File property collides with fileNamePattern. Aborting."; boolean containsMatch = statusChecker.containsMatch(Status.ERROR, msg); assertTrue("Missing error: " + msg, containsMatch); }
@Test(timeout = 3000L) public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranException, InterruptedException { String path = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_fallbackToSafe-" + diff + ".xml"; File topLevelFile = new File(path); writeToFile(topLevelFile, "<configuration debug=\"true\" scan=\"true\" scanPeriod=\"5 millisecond\"><root level=\"ERROR\"/></configuration> "); configure(topLevelFile); CountDownLatch changeDetectedLatch = waitForReconfigurationToBeDone(null); ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask(); assertNotNull(oldRoct); writeToFile(topLevelFile, "<configuration debug=\"true\" scan=\"true\" scanPeriod=\"5 millisecond\">\n" + " <root></configuration>"); changeDetectedLatch.await(); statusChecker.assertContainsMatch(Status.WARN, FALLING_BACK_TO_SAFE_CONFIGURATION); statusChecker.assertContainsMatch(Status.INFO, RE_REGISTERING_PREVIOUS_SAFE_CONFIGURATION); loggerContext.getStatusManager().clear(); CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct); writeToFile(topLevelFile, "<configuration debug=\"true\" scan=\"true\" scanPeriod=\"5 millisecond\"><root level=\"ERROR\"/></configuration> "); secondDoneLatch.await(); statusChecker.assertIsErrorFree(); statusChecker.containsMatch(DETECTED_CHANGE_IN_CONFIGURATION_FILES); }
@Test(timeout = 4000L) public void fallbackToSafeWithIncludedFile_FollowedByRecovery() 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 debug=\"true\" scan=\"true\" scanPeriod=\"5 millisecond\"><include file=\"" + innerFileAsStr + "\"/></configuration> "); File innerFile = new File(innerFileAsStr); writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> "); configure(topLevelFile); CountDownLatch doneLatch = waitForReconfigurationToBeDone(null); ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask(); assertNotNull(oldRoct); writeToFile(innerFile, "<included>\n<root>\n</included>"); doneLatch.await(); statusChecker.assertContainsMatch(Status.WARN, FALLING_BACK_TO_SAFE_CONFIGURATION); statusChecker.assertContainsMatch(Status.INFO, RE_REGISTERING_PREVIOUS_SAFE_CONFIGURATION); loggerContext.getStatusManager().clear(); CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct); writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> "); secondDoneLatch.await(); statusChecker.assertIsErrorFree(); statusChecker.containsMatch(DETECTED_CHANGE_IN_CONFIGURATION_FILES); }