@Test public void testCreateConsoleLogger() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); ConsoleLogger consoleLogger = mock( ConsoleLogger.class ); ConsoleLogger decorator = (ConsoleLogger) CommonReflector.createConsoleLogger( consoleLogger, cl ); assertThat( decorator ) .isNotSameAs( consoleLogger ); assertThat( decorator.isDebugEnabled() ).isFalse(); when( consoleLogger.isDebugEnabled() ).thenReturn( true ); assertThat( decorator.isDebugEnabled() ).isTrue(); verify( consoleLogger, times( 2 ) ).isDebugEnabled(); decorator.info( "msg" ); ArgumentCaptor<String> argumentMsg = ArgumentCaptor.forClass( String.class ); verify( consoleLogger, times( 1 ) ).info( argumentMsg.capture() ); assertThat( argumentMsg.getAllValues() ).hasSize( 1 ); assertThat( argumentMsg.getAllValues().get( 0 ) ).isEqualTo( "msg" ); }
static Object createConsoleLogger( ConsoleLogger consoleLogger, ClassLoader cl ) { try { Class<?> decoratorClass = cl.loadClass( ConsoleLoggerDecorator.class.getName() ); return getConstructor( decoratorClass, Object.class ).newInstance( consoleLogger ); } catch ( Exception e ) { throw new SurefireReflectionException( e ); } }
CommonReflector { static Object createConsoleLogger( ConsoleLogger consoleLogger, ClassLoader cl ) { try { Class<?> decoratorClass = cl.loadClass( ConsoleLoggerDecorator.class.getName() ); return getConstructor( decoratorClass, Object.class ).newInstance( consoleLogger ); } catch ( Exception e ) { throw new SurefireReflectionException( e ); } } }
CommonReflector { static Object createConsoleLogger( ConsoleLogger consoleLogger, ClassLoader cl ) { try { Class<?> decoratorClass = cl.loadClass( ConsoleLoggerDecorator.class.getName() ); return getConstructor( decoratorClass, Object.class ).newInstance( consoleLogger ); } catch ( Exception e ) { throw new SurefireReflectionException( e ); } } CommonReflector( @Nonnull ClassLoader surefireClassLoader ); }
CommonReflector { static Object createConsoleLogger( ConsoleLogger consoleLogger, ClassLoader cl ) { try { Class<?> decoratorClass = cl.loadClass( ConsoleLoggerDecorator.class.getName() ); return getConstructor( decoratorClass, Object.class ).newInstance( consoleLogger ); } catch ( Exception e ) { throw new SurefireReflectionException( e ); } } CommonReflector( @Nonnull ClassLoader surefireClassLoader ); Object createReportingReporterFactory( @Nonnull StartupReportConfiguration startupReportConfiguration,
                                                  @Nonnull ConsoleLogger consoleLogger ); }
CommonReflector { static Object createConsoleLogger( ConsoleLogger consoleLogger, ClassLoader cl ) { try { Class<?> decoratorClass = cl.loadClass( ConsoleLoggerDecorator.class.getName() ); return getConstructor( decoratorClass, Object.class ).newInstance( consoleLogger ); } catch ( Exception e ) { throw new SurefireReflectionException( e ); } } CommonReflector( @Nonnull ClassLoader surefireClassLoader ); Object createReportingReporterFactory( @Nonnull StartupReportConfiguration startupReportConfiguration,
                                                  @Nonnull ConsoleLogger consoleLogger );  }