Search in sources :

Example 91 with IRuntimeContext

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

the class JavaScriptResultSetIT method testRSCompareNotOK5.

public void testRSCompareNotOK5() {
    startTest();
    IRuntimeContext context = run("/samples/rules/ResultSetCompareTest_error5.xaction");
    assertEquals(context.getStatus(), IRuntimeContext.RUNTIME_STATUS_FAILURE);
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 92 with IRuntimeContext

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

the class JavaScriptResultSetIT method testRSCompareOK.

public void testRSCompareOK() {
    startTest();
    IRuntimeContext context = run("/samples/rules/ResultSetTest.xaction");
    assertEquals(IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus());
    IActionParameter rtn = context.getOutputParameter("COMPARERESULT");
    assertNotNull(rtn);
    String compareResult = rtn.getStringValue();
    assertEquals(compareResult, "No Mismatches");
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 93 with IRuntimeContext

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

the class JavaScriptResultSetIT method testRSCompareNotOK3.

public void testRSCompareNotOK3() {
    startTest();
    IRuntimeContext context = run("/samples/rules/ResultSetCompareTest_error3.xaction");
    assertEquals(context.getStatus(), IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL);
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 94 with IRuntimeContext

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

the class GlobalOutputIT method testEmptyActionSequence.

public void testEmptyActionSequence() {
    startTest();
    List messages = new ArrayList();
    String instanceId = null;
    IPentahoSession session = new StandaloneSession("system");
    PentahoSessionHolder.setSession(session);
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class);
    solutionEngine.setLoggingLevel(ILogger.ERROR);
    solutionEngine.init(session);
    String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
    HashMap parameterProviderMap = new HashMap();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory(baseUrl);
    try {
        File file = new File(getSolutionPath() + "/samples/platform/SetGlobalOutputTest.xaction");
        StringBuilder str = new StringBuilder();
        Reader 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);
        IRuntimeContext runtimeContext = solutionEngine.execute(xactionStr, "SetGlobalOutputTest.xaction", "empty action sequence test", false, true, instanceId, false, parameterProviderMap, null, null, urlFactory, // $NON-NLS-1$ //$NON-NLS-2$
        messages);
        assertNotNull("RuntimeContext is null", runtimeContext);
        assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
        IParameterProvider provider = PentahoSystem.getGlobalParameters();
        // $NON-NLS-1$
        String parameter = provider.getStringParameter("GLOBAL_TEST", null);
        assertNotNull(parameter);
        // $NON-NLS-1$
        assertEquals("This is a test", parameter);
    } catch (Exception e) {
        // we should not get here
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
    }
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HashMap(java.util.HashMap) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ArrayList(java.util.ArrayList) Reader(java.io.Reader) FileReader(java.io.FileReader) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) File(java.io.File) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 95 with IRuntimeContext

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

the class VFSOutputIT method testFileOutput.

public void testFileOutput() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // create a user session
    IPentahoSession session = new StandaloneSession("test");
    PentahoSessionHolder.setSession(session);
    System.out.println("solution.root.dir = " + System.getProperty("solution.root.dir"));
    String xaction = "/test/platform/VFSOutputTest_file.xaction";
    if (System.getProperty("os.name").startsWith("Windows")) {
        xaction = "/test/platform/VFSOutputTestWindows_file.xaction";
    }
    IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    run(xaction, parameterProvider, "VFSOutputTest.testFileOutput", ".txt");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    finishTest();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)100 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)28 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)28 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)24 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)17 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)14 OutputStream (java.io.OutputStream)12 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)12 List (java.util.List)10 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)9 IOException (java.io.IOException)8 Map (java.util.Map)8 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)7 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)6 Document (org.dom4j.Document)5