KettleSystemListener implements IPentahoSystemListener { public boolean startup( final IPentahoSession session ) { if ( StringUtils.isEmpty( System.getProperty( "DI_HOME" ) ) ) { String defaultKettleHomePath = PentahoSystem.getApplicationContext().getSolutionPath( "system" + File.separator + "kettle" ); logger.error( "DI_HOME System Property not properly set. The default location of " + defaultKettleHomePath + " will be used." ); System.setProperty( "DI_HOME", defaultKettleHomePath ); } if ( usePlatformLogFile ) { KettleLogStore.init( false, false ); initLogging(); } hookInDataSourceProvider(); try { KettleSystemListener.environmentInit( session ); } catch ( Throwable t ) { t.printStackTrace(); Logger.error( KettleSystemListener.class.getName(), Messages.getInstance().getErrorString( "KettleSystemListener.ERROR_0001_PLUGIN_LOAD_FAILED" ) ); } try { String slaveServerConfigFilename = "system" + File.separator + "kettle" + File.separator + "slave-server-config.xml"; File slaveServerConfigFile = new File( PentahoSystem.getApplicationContext().getSolutionPath( slaveServerConfigFilename ) ); if ( slaveServerConfigFile.exists() ) { try ( InputStream is = new FileInputStream( slaveServerConfigFile ) ) { Node configNode = getSlaveServerConfigNode( is ); SlaveServerConfig config = new DIServerConfig( new LogChannel( "Slave server config" ), configNode ); config.setFilename( slaveServerConfigFile.getAbsolutePath() ); SlaveServer slaveServer = new SlaveServer(); config.setSlaveServer( slaveServer ); CarteSingleton.setSlaveServerConfig( config ); } } } catch ( Throwable t ) { t.printStackTrace(); Logger.error( KettleSystemListener.class.getName(), t.getMessage() ); } return true; }  boolean startup( final IPentahoSession session ); static Map readProperties( final IPentahoSession session ); static void environmentInit( final IPentahoSession session ); void shutdown(); void setUsePlatformLogFile( final boolean usePlatformLogFile );  }
@Test public void testStartup() { KettleSystemListener ksl = new KettleSystemListener(); assertTrue( ksl.startup( null ) ); }
@Test public void testDefaultDIHome() throws Exception { System.setProperty( "DI_HOME", "" ); when( mockApplicationContext.getSolutionPath( anyString() ) ).thenReturn( "/kettle" ); KettleSystemListener ksl = new KettleSystemListener(); ksl.startup( null ); assertThat( "Empty DI_HOME should be defaulted", System.getProperty( "DI_HOME" ), equalTo( "/kettle" ) ); System.setProperty( "DI_HOME", "custom" ); ksl = new KettleSystemListener(); ksl.startup( null ); assertThat( "Validly set DI_HOME not preserved", System.getProperty( "DI_HOME" ), equalTo( "custom" ) ); }