Search in sources :

Example 61 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class DashboardWidgetIT method testWidget1.

public void testWidget1() {
    startTest();
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
    ArrayList messages = new ArrayList();
    DashboardWidgetComponent widget = new DashboardWidgetComponent(DashboardWidgetComponent.TYPE_DIAL, getSolutionPath() + "/samples/charts/dashboardwidget1.dial.xml", 300, 300, urlFactory, // $NON-NLS-1$
    messages);
    widget.setLoggingLevel(getLoggingLevel());
    widget.setValue(72.5);
    // $NON-NLS-1$
    widget.setTitle("test widget 1");
    // $NON-NLS-1$
    widget.setUnits("$");
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("DashboardWidgetTest.testWidget1", ".html");
    // $NON-NLS-1$
    String contentType = "text/html";
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    HashMap parameterProviders = new HashMap();
    parameterProviders.put(HttpRequestParameterProvider.SCOPE_REQUEST, requestParameters);
    parameterProviders.put(HttpSessionParameterProvider.SCOPE_SESSION, sessionParameters);
    // $NON-NLS-1$
    StandaloneSession session = new StandaloneSession("BaseTest.DEBUG_JUNIT_SESSION");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
    try {
        widget.validate(session, requestHandler);
        widget.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
    } catch (IOException e) {
        e.printStackTrace();
    }
    finishTest();
}
Also used : HashMap(java.util.HashMap) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) IOException(java.io.IOException) BaseRequestHandler(org.pentaho.platform.engine.services.BaseRequestHandler) DashboardWidgetComponent(org.pentaho.platform.uifoundation.chart.DashboardWidgetComponent) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 62 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider 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)

Example 63 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class SessionIT method testUserSessionWithOutAuthentication.

public void testUserSessionWithOutAuthentication() {
    startTest();
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("actionname", "ViewAction");
    // $NON-NLS-1$
    UserSession usession = new UserSession("Admin", Locale.US, parameters);
    Log log = usession.getLogger();
    usession.setActionName("ViewAction");
    usession.doStartupActions(parameters);
    // $NON-NLS-1$
    log.info("Session is active");
    // $NON-NLS-1$
    assertEquals(usession.getActionName(), "ViewAction");
    finishTest();
}
Also used : Log(org.apache.commons.logging.Log) UserSession(org.pentaho.platform.engine.core.system.UserSession) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 64 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class SessionIT method testStandAloneSession.

public void testStandAloneSession() {
    startTest();
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("actionname", "ViewAction");
    // $NON-NLS-1$
    StandaloneSession session = new StandaloneSession("BaseTest.DEBUG_JUNIT_SESSION");
    Log log = session.getLogger();
    // $NON-NLS-1$
    System.out.println("Action Name for the Session is  " + session.getActionName());
    session.setNotAuthenticated();
    // $NON-NLS-1$
    log.info("Session is active");
    session.destroy();
    assertTrue(true);
    finishTest();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) Log(org.apache.commons.logging.Log) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 65 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider 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)

Aggregations

SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)72 HashMap (java.util.HashMap)32 ArrayList (java.util.ArrayList)23 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)23 OutputStream (java.io.OutputStream)21 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)21 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)21 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)16 Test (org.junit.Test)13 IOException (java.io.IOException)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 Map (java.util.Map)5 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)5 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)5 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)5 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)5 Iterator (java.util.Iterator)4