Search in sources :

Example 1 with IMessageFormatter

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

the class UIServletIT method setUp.

public void setUp() {
    // $NON-NLS-1$
    StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
    PentahoSystem.init(applicationContext, getRequiredListeners());
    IMessageFormatter msgFormatter = new MessageFormatter();
    PentahoSystem.registerObject(msgFormatter);
}
Also used : IMessageFormatter(org.pentaho.platform.api.engine.IMessageFormatter) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IMessageFormatter(org.pentaho.platform.api.engine.IMessageFormatter) MessageFormatter(org.pentaho.platform.engine.services.MessageFormatter)

Example 2 with IMessageFormatter

use of org.pentaho.platform.api.engine.IMessageFormatter 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)

Aggregations

IMessageFormatter (org.pentaho.platform.api.engine.IMessageFormatter)2 List (java.util.List)1 Map (java.util.Map)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 Test (org.junit.Test)1 IActionCompleteListener (org.pentaho.platform.api.engine.IActionCompleteListener)1 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)1 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)1 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)1 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)1 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)1 MessageFormatter (org.pentaho.platform.engine.services.MessageFormatter)1