Search in sources :

Example 21 with ISolutionEngine

use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.

the class RuntimeIT method testForcePrompt.

public void testForcePrompt() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("RuntimeTest.testForcePrompt", ".html");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_PARAMETERS);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setLoggingLevel(getLoggingLevel());
    solutionEngine.init(session);
    solutionEngine.setForcePrompt(true);
    IRuntimeContext context = run(solutionEngine, "/test/reporting/jfreereport-reports-test-param.xaction", null, false, parameterProvider, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    outputHandler);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    finishTest();
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 22 with ISolutionEngine

use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.

the class BaseTest method run.

public IRuntimeContext run(String actionPath, String instanceId, boolean persisted, IParameterProvider parameterProvider, IOutputHandler outputHandler, IPentahoSession session) {
    assertTrue(initOk);
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setLoggingLevel(getLoggingLevel());
    solutionEngine.init(session);
    return run(solutionEngine, actionPath, instanceId, persisted, parameterProvider, outputHandler);
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine)

Example 23 with ISolutionEngine

use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.

the class BaseTestCase method run.

public IRuntimeContext run(String actionSequencePath, String actionSequence, IParameterProvider parameterProvider, IOutputHandler outputHandler) {
    List messages = new ArrayList();
    String instanceId = null;
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setLoggingLevel(ILogger.ERROR);
    solutionEngine.init(session);
    HashMap parameterProviderMap = new HashMap();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
    IRuntimeContext runtimeContext = null;
    Reader reader = null;
    try {
        File file = new File(actionSequencePath + actionSequence);
        StringBuilder str = new StringBuilder();
        reader = new FileReader(file);
        char[] buffer = new char[4096];
        int n = reader.read(buffer);
        while (n != -1) {
            str.append(buffer, 0, n);
            n = reader.read(buffer);
        }
        String xactionStr = str.toString();
        solutionEngine.setSession(session);
        runtimeContext = // $NON-NLS-1$
        solutionEngine.execute(// $NON-NLS-1$
        xactionStr, // $NON-NLS-1$
        actionSequence, // $NON-NLS-1$
        "action sequence test", // $NON-NLS-1$
        false, // $NON-NLS-1$
        true, // $NON-NLS-1$
        instanceId, // $NON-NLS-1$
        false, parameterProviderMap, null, null, urlFactory, messages);
    } catch (Exception e) {
        // we should not get here
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Exception ex) {
                ex.printStackTrace();
                assertTrue(ex.getMessage(), false);
            }
        }
    }
    return runtimeContext;
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Reader(java.io.Reader) FileReader(java.io.FileReader) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) File(java.io.File)

Example 24 with ISolutionEngine

use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.

the class GenericPentahoTest method getSolutionEngine.

public ISolutionEngine getSolutionEngine(String path) {
    // $NON-NLS-1$
    StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(path, "");
    if (!PentahoSystem.getInitializedOK()) {
        PentahoSystem.init(applicationContext);
        // $NON-NLS-1$
        assertTrue("PentahoSystem did not initialize", PentahoSystem.getInitializedOK());
    }
    // $NON-NLS-1$
    IPentahoSession session = new StandaloneSession("system");
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    // $NON-NLS-1$
    assertNotNull("SolutionEngine is null", solutionEngine);
    solutionEngine.setLoggingLevel(ILogger.ERROR);
    solutionEngine.init(session);
    try {
        solutionEngine.setSession(session);
        return solutionEngine;
    } catch (Exception e) {
        // we should not get here
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
    }
    return null;
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 25 with ISolutionEngine

use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.

the class MultiOutputTest method testMultiOutput.

public void testMultiOutput() {
    startTest();
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    String xactionStr = ServiceTestHelper.getXAction(SOLUTION_PATH, "services/MultiOutputTest.xaction");
    IRuntimeContext runtimeContext = // $NON-NLS-1$ //$NON-NLS-2$
    solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
    xactionStr, // $NON-NLS-1$ //$NON-NLS-2$
    "test1a.xaction", // $NON-NLS-1$ //$NON-NLS-2$
    "empty action sequence test", // $NON-NLS-1$ //$NON-NLS-2$
    false, // $NON-NLS-1$ //$NON-NLS-2$
    true, // $NON-NLS-1$ //$NON-NLS-2$
    null, // $NON-NLS-1$ //$NON-NLS-2$
    false, new HashMap(), null, null, new SimpleUrlFactory(""), new ArrayList());
    finishTest();
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Aggregations

ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)37 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)27 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)25 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)22 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)13 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)11 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)9 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)9 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)5 OutputStream (java.io.OutputStream)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 File (java.io.File)3 FileReader (java.io.FileReader)3 IOException (java.io.IOException)3 Reader (java.io.Reader)3 BigDecimal (java.math.BigDecimal)3