@Test public void shouldIncrementSpooledEventsCount() { final PrintWriter spoolWriter = mock(PrintWriter.class); spoolWriter.println("log event"); final File mockFile = setupInputFileExpectations(); LogSpoolerContext logSpoolerContext = new LogSpoolerContext(mockFile); logSpoolerContext.logEventSpooled(); expect(rolloverCondition.shouldRollover( cmp(logSpoolerContext, new LogSpoolerEventCountComparator(), LogicalOperator.EQUAL))). andReturn(false); replay(spoolWriter, rolloverCondition, mockFile); LogSpooler logSpooler = new LogSpooler(spoolDirectory, SOURCE_FILENAME_PREFIX, rolloverCondition, rolloverHandler) { @Override protected PrintWriter initializeSpoolWriter(File spoolFile) throws IOException { return spoolWriter; } @Override protected File initializeSpoolFile() { return mockFile; } }; logSpooler.add("log event"); verify(rolloverCondition); }
public synchronized void add(String logEvent) { currentSpoolBufferedWriter.println(logEvent); currentSpoolerContext.logEventSpooled(); if (rolloverCondition.shouldRollover(currentSpoolerContext)) { LOG.info("Trying to rollover based on rollover condition"); tryRollover(); } }
LogSpooler { public synchronized void add(String logEvent) { currentSpoolBufferedWriter.println(logEvent); currentSpoolerContext.logEventSpooled(); if (rolloverCondition.shouldRollover(currentSpoolerContext)) { LOG.info("Trying to rollover based on rollover condition"); tryRollover(); } } }
LogSpooler { public synchronized void add(String logEvent) { currentSpoolBufferedWriter.println(logEvent); currentSpoolerContext.logEventSpooled(); if (rolloverCondition.shouldRollover(currentSpoolerContext)) { LOG.info("Trying to rollover based on rollover condition"); tryRollover(); } } LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler);  LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler, long rolloverTimeThresholdSecs); }
LogSpooler { public synchronized void add(String logEvent) { currentSpoolBufferedWriter.println(logEvent); currentSpoolerContext.logEventSpooled(); if (rolloverCondition.shouldRollover(currentSpoolerContext)) { LOG.info("Trying to rollover based on rollover condition"); tryRollover(); } } LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler);  LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler, long rolloverTimeThresholdSecs); synchronized void add(String logEvent); void rollover(); void close(); }
LogSpooler { public synchronized void add(String logEvent) { currentSpoolBufferedWriter.println(logEvent); currentSpoolerContext.logEventSpooled(); if (rolloverCondition.shouldRollover(currentSpoolerContext)) { LOG.info("Trying to rollover based on rollover condition"); tryRollover(); } } LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler);  LogSpooler(String spoolDirectory, String sourceFileNamePrefix, RolloverCondition rolloverCondition,
                    RolloverHandler rolloverHandler, long rolloverTimeThresholdSecs); synchronized void add(String logEvent); void rollover(); void close(); static final long TIME_BASED_ROLLOVER_DISABLED_THRESHOLD; }