private void checkResetCount(int expected) { StatusChecker checker = new StatusChecker(loggerContext); checker.assertIsErrorFree(); int effectiveResets = checker.matchCount(CoreConstants.RESET_MSG_PREFIX); assertEquals(expected, effectiveResets); // String failMsg = "effective=" + effectiveResets + ", expected=" + expected; // // there might be more effective resets than the expected amount // since the harness may be sleeping while a reset occurs //assertTrue(failMsg, expected <= effectiveResets && (expected + 2) >= effectiveResets); }
private void verify(int expected) { StatusChecker checker = new StatusChecker(loggerContext); //StatusPrinter.print(loggerContext); checker.assertIsErrorFree(); int effectiveResets = checker .matchCount(CoreConstants.RESET_MSG_PREFIX); String failMsg = "effective=" + effectiveResets + ", expected=" + expected; // there might be more effective resets than the expected amount // since the harness may be sleeping while a reset occurs assertTrue(failMsg, expected <= effectiveResets && (expected + 2) >= effectiveResets); }
@Test // LOGBACK-1054 public void renameLockedAbstractFile_LOGBACK_1054 () throws IOException, RolloverFailure { RenameUtil renameUtil = new RenameUtil(); renameUtil.setContext(context); String abstractFileName = "abstract_pathname-" + diff; String src = CoreTestConstants.OUTPUT_DIR_PREFIX + abstractFileName; String target = src + ".target"; makeFile(src); FileInputStream fisLock = new FileInputStream(src); renameUtil.rename(src, target); // release the lock fisLock.close(); StatusPrinter.print(context); assertEquals(0, statusChecker.matchCount("Parent of target file ." + target + ". is null")); }
@Test public void exceptionsShouldNotCauseHalting() throws InterruptedException { NPEAppender<Integer> npeAppender = new NPEAppender<Integer>(); npeAppender.setName("bad"); npeAppender.setContext(context); npeAppender.start(); asyncAppenderBase.addAppender(npeAppender); asyncAppenderBase.start(); assertTrue(asyncAppenderBase.isStarted()); for (int i = 0; i < 10; i++) asyncAppenderBase.append(i); asyncAppenderBase.stop(); assertFalse(asyncAppenderBase.isStarted()); assertEquals(AppenderBase.ALLOWED_REPEATS, statusChecker.matchCount("Appender \\[bad\\] failed to append.")); }