@Test public void testRecordsReturnsAnEmptyArrayWhenNoRecordHasBeenAdded() { final ShortTermMemoryHandler handler; handler = new ShortTermMemoryHandler(1, Level.FINEST, null); assertNotNull(handler.records()); assertEquals(0, handler.records().length); }
@Test public void testRecordsIsEmptyWhenAddedRecordIsLowerThanTheMinimumLevel() { final ShortTermMemoryHandler handler; final LogRecord theLogRecord; handler = new ShortTermMemoryHandler(1, Level.INFO, null); theLogRecord = new LogRecord(Level.FINE, ""); handler.publish(theLogRecord); assertNotNull(handler.records()); assertEquals(0, handler.records().length); }
@Test public void testRecordsReturnsTheAddedRecordWhenASingleOneIsPublished() { final ShortTermMemoryHandler handler; final LogRecord theLogRecord; handler = new ShortTermMemoryHandler(1, Level.FINEST, null); theLogRecord = new LogRecord(Level.INFO, ""); handler.publish(theLogRecord); assertNotNull(handler.records()); assertEquals(1, handler.records().length); assertEquals(theLogRecord, handler.records()[0]); }
@Test public void testAfterCloseAllRecordsAreCleared() { final ShortTermMemoryHandler handler; final LogRecord firstLogRecord; final LogRecord secondLogRecord; handler = new ShortTermMemoryHandler(2, Level.FINEST, null); firstLogRecord = new LogRecord(Level.INFO, ""); secondLogRecord = new LogRecord(Level.INFO, ""); handler.publish(firstLogRecord); handler.publish(secondLogRecord); handler.close(); assertNotNull(handler.records()); assertEquals(0, handler.records().length); }
@Test public void testRecordsOnlyReturnsTheLastRecordWhenATwoRecordsArePublishedAndCapacityIsExceeded() { final ShortTermMemoryHandler handler; final LogRecord firstLogRecord; final LogRecord secondLogRecord; handler = new ShortTermMemoryHandler(1, Level.FINEST, null); firstLogRecord = new LogRecord(Level.INFO, ""); secondLogRecord = new LogRecord(Level.INFO, ""); handler.publish(firstLogRecord); handler.publish(secondLogRecord); assertNotNull(handler.records()); assertEquals(1, handler.records().length); assertEquals(secondLogRecord, handler.records()[0]); }