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());
}
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());
}
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();
}
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
}
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();
}
Aggregations