Home / Function/ testFormatMessage() — netty Function Reference

testFormatMessage() — netty Function Reference

Architecture documentation for the testFormatMessage() function in Slf4JLoggerFactoryTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cfbd0e56_3dc5_613d_d403_72ccfd1c2d43["testFormatMessage()"]
  9f925406_7438_c14f_71a3_389088c21656["Slf4JLoggerFactoryTest"]
  cfbd0e56_3dc5_613d_d403_72ccfd1c2d43 -->|defined in| 9f925406_7438_c14f_71a3_389088c21656
  style cfbd0e56_3dc5_613d_d403_72ccfd1c2d43 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/internal/logging/Slf4JLoggerFactoryTest.java lines 59–124

    @Test
    public void testFormatMessage() {
        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
        LocationAwareLogger logger = mock(LocationAwareLogger.class);
        when(logger.isDebugEnabled()).thenReturn(true);
        when(logger.isErrorEnabled()).thenReturn(true);
        when(logger.isInfoEnabled()).thenReturn(true);
        when(logger.isTraceEnabled()).thenReturn(true);
        when(logger.isWarnEnabled()).thenReturn(true);
        when(logger.getName()).thenReturn("testlogger");

        InternalLogger internalLogger = Slf4JLoggerFactory.wrapLogger(logger);
        internalLogger.debug("{}", "debug");
        internalLogger.debug("{} {}", "debug1", "debug2");
        internalLogger.debug("{} {} {}", "debug1", "debug2", "debug3");

        internalLogger.error("{}", "error");
        internalLogger.error("{} {}", "error1", "error2");
        internalLogger.error("{} {} {}", "error1", "error2", "error3");

        internalLogger.info("{}", "info");
        internalLogger.info("{} {}", "info1", "info2");
        internalLogger.info("{} {} {}", "info1", "info2", "info3");

        internalLogger.trace("{}", "trace");
        internalLogger.trace("{} {}", "trace1", "trace2");
        internalLogger.trace("{} {} {}", "trace1", "trace2", "trace3");

        internalLogger.warn("{}", "warn");
        internalLogger.warn("{} {}", "warn1", "warn2");
        internalLogger.warn("{} {} {}", "warn1", "warn2", "warn3");

        verify(logger, times(3)).log(ArgumentMatchers.<Marker>isNull(), eq(LocationAwareSlf4JLogger.FQCN),
                eq(LocationAwareLogger.DEBUG_INT), captor.capture(), ArgumentMatchers.<Object[]>isNull(),
                ArgumentMatchers.<Throwable>isNull());
        verify(logger, times(3)).log(ArgumentMatchers.<Marker>isNull(), eq(LocationAwareSlf4JLogger.FQCN),
                eq(LocationAwareLogger.ERROR_INT), captor.capture(), ArgumentMatchers.<Object[]>isNull(),
                ArgumentMatchers.<Throwable>isNull());
        verify(logger, times(3)).log(ArgumentMatchers.<Marker>isNull(), eq(LocationAwareSlf4JLogger.FQCN),
                eq(LocationAwareLogger.INFO_INT), captor.capture(), ArgumentMatchers.<Object[]>isNull(),
                ArgumentMatchers.<Throwable>isNull());
        verify(logger, times(3)).log(ArgumentMatchers.<Marker>isNull(), eq(LocationAwareSlf4JLogger.FQCN),
                eq(LocationAwareLogger.TRACE_INT), captor.capture(), ArgumentMatchers.<Object[]>isNull(),
                ArgumentMatchers.<Throwable>isNull());
        verify(logger, times(3)).log(ArgumentMatchers.<Marker>isNull(), eq(LocationAwareSlf4JLogger.FQCN),
                eq(LocationAwareLogger.WARN_INT), captor.capture(), ArgumentMatchers.<Object[]>isNull(),
                ArgumentMatchers.<Throwable>isNull());

        Iterator<String> logMessages = captor.getAllValues().iterator();
        assertEquals("debug", logMessages.next());
        assertEquals("debug1 debug2", logMessages.next());
        assertEquals("debug1 debug2 debug3", logMessages.next());
        assertEquals("error", logMessages.next());
        assertEquals("error1 error2", logMessages.next());
        assertEquals("error1 error2 error3", logMessages.next());
        assertEquals("info", logMessages.next());
        assertEquals("info1 info2", logMessages.next());
        assertEquals("info1 info2 info3", logMessages.next());
        assertEquals("trace", logMessages.next());
        assertEquals("trace1 trace2", logMessages.next());
        assertEquals("trace1 trace2 trace3", logMessages.next());
        assertEquals("warn", logMessages.next());
        assertEquals("warn1 warn2", logMessages.next());
        assertEquals("warn1 warn2 warn3", logMessages.next());
        assertFalse(logMessages.hasNext());
    }

Domain

Subdomains

Frequently Asked Questions

What does testFormatMessage() do?
testFormatMessage() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/internal/logging/Slf4JLoggerFactoryTest.java.
Where is testFormatMessage() defined?
testFormatMessage() is defined in common/src/test/java/io/netty/util/internal/logging/Slf4JLoggerFactoryTest.java at line 59.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free