@SuppressWarnings( { "all" } )
public class BootTest extends TestCase {
public void testBoot() throws PlatformInitializationException {
PentahoBoot boot = new PentahoBoot();
boot.setFilePath( "test-src/solution" );
boot.enableReporting();
// create a user session
IPentahoSession session = new StandaloneSession( "test" );
PentahoSessionHolder.setSession( session );
FileSystemBackedUnifiedRepository repo =
(FileSystemBackedUnifiedRepository) PentahoSystem.get( IUnifiedRepository.class );
repo.setRootDir( new File( "test-src/solution" ) );
boolean ok = boot.start();
assertTrue( ok );
String outputType = "pdf";
OutputStream outputStream = null;
try {
// create an output stream to write the report into
File outputFile = new File( "report." + outputType );
outputStream = new FileOutputStream( outputFile );
// pass the outputType parameter
Map parameters = new HashMap();
parameters.put( "output-type", outputType );
SolutionHelper.execute( "test report", session, "boot/report.xaction", parameters, outputStream );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
return;
} finally {
if ( outputStream != null ) {
try {
// close the output stream
outputStream.close();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
boot.stop();
}