use of org.pentaho.platform.api.engine.ISolutionEngine 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);
}
}
use of org.pentaho.platform.api.engine.ISolutionEngine 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());
}
Aggregations