SolutionContextListener implements ServletContextListener { public void showInitializationMessage( final boolean initOk, final String fullyQualifiedServerUrl ) { if ( PentahoSystem.getObjectFactory().objectDefined( IVersionHelper.class.getSimpleName() ) ) { IVersionHelper helper = PentahoSystem.get( IVersionHelper.class, null ); if ( initOk ) { System.out .println( Messages .getInstance() .getString( "SolutionContextListener.INFO_SYSTEM_READY", "(" + helper.getVersionInformation( PentahoSystem.class ) + ")", fullyQualifiedServerUrl, SolutionContextListener.solutionPath ) ); } else { System.err .println( Messages .getInstance() .getString( "SolutionContextListener.INFO_SYSTEM_NOT_READY", "(" + helper.getVersionInformation( PentahoSystem.class ) + ")", fullyQualifiedServerUrl, SolutionContextListener.solutionPath ) ); } } }  void contextInitialized( final ServletContextEvent event ); void showInitializationMessage( final boolean initOk, final String fullyQualifiedServerUrl ); void contextDestroyed( final ServletContextEvent event );  }
@Test public void testShowInitializationMessage() throws Exception { PentahoSystem.registerObjectFactory( objectFactory ); IVersionHelper versionHelper = mock( IVersionHelper.class ); PentahoSystem.registerObject( versionHelper ); when( versionHelper.getVersionInformation( PentahoSystem.class ) ).thenReturn( "version info" ); when( objectFactory.objectDefined( IVersionHelper.class.getSimpleName() ) ).thenReturn( true ); solutionContextListener.solutionPath = "solution-path"; ByteArrayOutputStream captureStdOut = new ByteArrayOutputStream(); ByteArrayOutputStream captureStdErr = new ByteArrayOutputStream(); System.setOut( new PrintStream( captureStdOut ) ); System.setErr( new PrintStream( captureStdErr ) ); solutionContextListener.showInitializationMessage( true, "http: assertTrue( captureStdOut.toString().contains( "Pentaho BI Platform server is ready. (version info) Fully Qualified Server Url = " + "http: solutionContextListener.showInitializationMessage( false, "http: assertTrue( captureStdErr.toString().contains( "Pentaho BI Platform server failed to properly initialize. The system will not be available for requests. " + "(version info) Fully Qualified Server Url = http: }