Search in sources :

Example 96 with IRuntimeContext

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

the class ViewActionServletIT method testBackgroundExecutionNoExecutor.

/**
 * This test covers execution without background parameter. In that case <code>servlet.error()</code>
 * wouldn't be executed.
 *
 * @throws ServletException
 * @throws IOException
 */
@Test
public void testBackgroundExecutionNoExecutor() throws ServletException, IOException {
    when(request.getParameter(eq("background"))).thenReturn(Boolean.TRUE.toString());
    final String actionPath = "test-path";
    when(request.getParameter(eq("path"))).thenReturn(actionPath);
    final String instanceID = "instance-id";
    when(request.getParameter(eq("instance-id"))).thenReturn(instanceID);
    final ServletOutputStream outputStream = mock(ServletOutputStream.class);
    when(response.getOutputStream()).thenReturn(outputStream);
    final ISolutionEngine solutionEngine = mock(ISolutionEngine.class);
    final IRuntimeContext runtime = mock(IRuntimeContext.class);
    when(runtime.getStatus()).thenReturn(IRuntimeContext.RUNTIME_STATUS_SUCCESS);
    when(solutionEngine.execute(eq(actionPath), eq(servlet.getClass().getName()), eq(false), eq(true), eq(instanceID), eq(true), any(Map.class), any(IOutputHandler.class), any(IActionCompleteListener.class), any(IPentahoUrlFactory.class), any(List.class))).thenReturn(runtime);
    mp.defineInstance(ISolutionEngine.class, solutionEngine);
    final IMessageFormatter messageFormatter = mock(IMessageFormatter.class);
    mp.defineInstance(IMessageFormatter.class, messageFormatter);
    servlet.service(request, response);
    verify(servlet).error(matches(".*ERROR_0001.*"));
    verify(outputStream).write(any(byte[].class));
    verify(messageFormatter).formatSuccessMessage(eq("text/html"), eq(runtime), any(StringBuffer.class), anyBoolean(), anyBoolean());
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IOutputHandler(org.pentaho.platform.api.engine.IOutputHandler) IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) IMessageFormatter(org.pentaho.platform.api.engine.IMessageFormatter) ServletOutputStream(javax.servlet.ServletOutputStream) List(java.util.List) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) Map(java.util.Map) IActionCompleteListener(org.pentaho.platform.api.engine.IActionCompleteListener) Test(org.junit.Test)

Example 97 with IRuntimeContext

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

the class SQLExecuteComponentIT method testSQLExecuteErrorDropTableSingleStatement.

public void testSQLExecuteErrorDropTableSingleStatement() {
    startTest();
    // $NON-NLS-1$
    info("Expected: Failed execution - should error out at the drop table statement");
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/rules/sqlexecute_error3.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
    context.getStatus());
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 98 with IRuntimeContext

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

the class SubActionComponentIT method testSuccessPaths.

public void testSuccessPaths() {
    startTest();
    // $NON-NLS-1$
    String testName = CO_TEST_NAME + "string_" + System.currentTimeMillis();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter(SOLUTION_NAME_PARAM, SOLUTION_NAME);
    parameterProvider.setParameter(SOLUTION_PATH_PARAM, "platform");
    parameterProvider.setParameter(SUBACTION_PARAM, SUBACTION);
    parameterProvider.setParameter(TEST_INPUT_PARAM, TEST_STRING);
    IRuntimeContext context = run("/" + SOLUTION_NAME + "/platform/" + TEST_XACTION, parameterProvider, testName, CO_TEST_EXTN);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    IActionParameter rtn = context.getOutputParameter(TEST_OUTPUT_PARAM);
    Object value = rtn.getValue();
    assertEquals(TEST_STRING, value);
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 99 with IRuntimeContext

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

the class XQConnectionIT method testXQConnection.

public void testXQConnection() {
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("DatasourceTest.XQ_Datasource", ".html");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    run("/test/datasource/XQ_Datasource.xaction", null, false, parameterProvider, outputHandler, session);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
// TODO need some validation of success
}
Also used : 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 100 with IRuntimeContext

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

the class XQConnectionIT method testJFreeReportParameterPage2.

/*
   * public void testXQConnection_JFreeXQuery() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ OutputStream
   * outputStream = getOutputStream("DatasourceTest.XQ_Datasource", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context =
   * run("test", "reporting", "JFree_XQuery_report.xaction", null, false, parameterProvider, outputHandler, session);
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success }
   */
public void testJFreeReportParameterPage2() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("type", "html");
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("ReportingTest.testJFreeReportParameterPage2", ".html");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    IRuntimeContext context = run("/test/reporting/jfreereport-reports-test-param2.xaction", null, false, parameterProvider, outputHandler, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    session);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // TODO need some validation of success
    finishTest();
}
Also used : 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)

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