Java Code Examples for ch.qos.logback.core.read.ListAppender#setName()
The following examples show how to use
ch.qos.logback.core.read.ListAppender#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFileSystemRepository.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testMinimalArchiveCleanupIntervalHonoredAndLogged() throws Exception { // We are going to construct our own repository using different properties, so // we need to shutdown the existing one. shutdown(); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); ListAppender<ILoggingEvent> testAppender = new ListAppender<>(); testAppender.setName("Test"); testAppender.start(); root.addAppender(testAppender); final Map<String, String> addProps = new HashMap<>(); addProps.put(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY, "1 millis"); final NiFiProperties localProps = NiFiProperties.createBasicNiFiProperties(null, addProps); repository = new FileSystemRepository(localProps); repository.initialize(new StandardResourceClaimManager()); repository.purge(); boolean messageFound = false; String message = "The value of nifi.content.repository.archive.cleanup.frequency property " + "is set to '1 millis' which is below the allowed minimum of 1 second (1000 milliseconds). " + "Minimum value of 1 sec will be used as scheduling interval for archive cleanup task."; for (ILoggingEvent event : testAppender.list) { String actualMessage = event.getFormattedMessage(); if (actualMessage.equals(message)) { assertEquals(event.getLevel(), Level.WARN); messageFound = true; break; } } assertTrue(messageFound); }
Example 2
Source File: LoggerTestHelper.java From qpid-broker-j with Apache License 2.0 | 5 votes |
public static ListAppender createAndRegisterAppender(String appenderName) { ListAppender appender = new ListAppender(); appender.setName(appenderName); ROOT_LOGGER.addAppender(appender); appender.start(); return appender; }
Example 3
Source File: ExchangeRateServiceTest.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@BeforeAll static void setup() { // Get the logger object for logs in ExchangeRateService exchangeRateServiceLogger = (Logger) LoggerFactory.getLogger(ExchangeRateService.class); // Initiate and append a ListAppender, which allows us to programmatically inspect // log messages ListAppender<ILoggingEvent> listAppender = new ListAppender<>(); listAppender.setName(LIST_APPENDER_NAME); listAppender.start(); exchangeRateServiceLogger.addAppender(listAppender); }
Example 4
Source File: TestFileSystemRepository.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testMinimalArchiveCleanupIntervalHonoredAndLogged() throws Exception { // We are going to construct our own repository using different properties, so // we need to shutdown the existing one. shutdown(); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); ListAppender<ILoggingEvent> testAppender = new ListAppender<>(); testAppender.setName("Test"); testAppender.start(); root.addAppender(testAppender); final Map<String, String> addProps = new HashMap<>(); addProps.put(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY, "1 millis"); final NiFiProperties localProps = NiFiProperties.createBasicNiFiProperties(TestFileSystemRepository.class.getResource("/conf/nifi.properties").getFile(), addProps); repository = new FileSystemRepository(localProps); repository.initialize(new StandardResourceClaimManager()); repository.purge(); boolean messageFound = false; String message = "The value of nifi.content.repository.archive.cleanup.frequency property " + "is set to '1 millis' which is below the allowed minimum of 1 second (1000 milliseconds). " + "Minimum value of 1 sec will be used as scheduling interval for archive cleanup task."; // Must synchronize on testAppender, because the call to append() is synchronized and this synchronize // keyword guards testAppender.list. Since we are accessing testAppender.list, we must do so in a thread-safe manner. synchronized (testAppender) { for (ILoggingEvent event : testAppender.list) { String actualMessage = event.getFormattedMessage(); if (actualMessage.equals(message)) { assertEquals(event.getLevel(), Level.WARN); messageFound = true; break; } } } assertTrue(messageFound); }