Search in sources :

Example 1 with PentahoBoot

use of org.pentaho.platform.plugin.boot.PentahoBoot in project pentaho-platform by pentaho.

the class BootIT method testBoot.

public void testBoot() throws PlatformInitializationException {
    PentahoBoot boot = new PentahoBoot();
    boot.setFilePath(TestResourceLocation.TEST_RESOURCES + "/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(TestResourceLocation.TEST_RESOURCES + "/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();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HashMap(java.util.HashMap) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) PentahoBoot(org.pentaho.platform.plugin.boot.PentahoBoot) FileOutputStream(java.io.FileOutputStream) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)1 PentahoBoot (org.pentaho.platform.plugin.boot.PentahoBoot)1 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)1