Search in sources :

Example 1 with BaseRequestHandler

use of org.pentaho.platform.engine.services.BaseRequestHandler in project pentaho-platform by pentaho.

the class HTMLComponentIT method testComponent2.

public void testComponent2() {
    startTest();
    // $NON-NLS-1$
    info(Messages.getInstance().getString("HTMLComponentTest.USER_ERRORS_EXPECTED_CONTENT_TYPE_INVALID"));
    // this should fail because the requested content type is not supported
    // $NON-NLS-1$
    String url = "http://www.pentaho.org/demo/news.html";
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
    ArrayList messages = new ArrayList();
    // $NON-NLS-1$
    HtmlComponent component = new HtmlComponent(HtmlComponent.TYPE_URL, url, "", urlFactory, messages);
    component.setLoggingLevel(getLoggingLevel());
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent2", ".html");
    // $NON-NLS-1$
    String contentType = "text/xml";
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    HashMap parameterProviders = new HashMap();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
    parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
    try {
        component.validate(session, requestHandler);
        component.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) HtmlComponent(org.pentaho.platform.uifoundation.component.HtmlComponent) 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) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 2 with BaseRequestHandler

use of org.pentaho.platform.engine.services.BaseRequestHandler in project pentaho-platform by pentaho.

the class HTMLComponentIT method testComponent3.

public void testComponent3() {
    startTest();
    // $NON-NLS-1$
    info(Messages.getInstance().getString("HTMLComponentTest.USER_ERRORS_EXPECTED_URL_INVALID"));
    // this should fail because the url is bad
    // $NON-NLS-1$
    String url = "xttp://a";
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
    ArrayList messages = new ArrayList();
    HtmlComponent component = new HtmlComponent(HtmlComponent.TYPE_URL, url, Messages.getInstance().getString("HTML.ERROR_0001_NOT_AVAILABLE"), urlFactory, // $NON-NLS-1$
    messages);
    component.setLoggingLevel(getLoggingLevel());
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent3", ".html");
    // $NON-NLS-1$
    String contentType = "text/html";
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    HashMap parameterProviders = new HashMap();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
    parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
    try {
        component.validate(session, requestHandler);
        component.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) HtmlComponent(org.pentaho.platform.uifoundation.component.HtmlComponent) 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) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 3 with BaseRequestHandler

use of org.pentaho.platform.engine.services.BaseRequestHandler in project pentaho-platform by pentaho.

the class SolutionHelper method doActionInternal.

private static IRuntimeContext doActionInternal(final String actionPath, final String processId, final IParameterProvider parameterProvider, final OutputStream outputStream, final IPentahoSession userSession, final ArrayList messages, final ILogger logger) {
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(userSession, null, outputHandler, parameterProvider, null);
    requestHandler.setProcessId(processId);
    requestHandler.setActionPath(actionPath);
    return requestHandler.handleActionRequest(0, 0);
}
Also used : SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) BaseRequestHandler(org.pentaho.platform.engine.services.BaseRequestHandler)

Example 4 with BaseRequestHandler

use of org.pentaho.platform.engine.services.BaseRequestHandler in project pentaho-platform by pentaho.

the class ChartIT method runTimeSeriesChartTest.

/*
   * public void runPieChartTest(int chartType, String path, String testName) { SimpleUrlFactory urlFactory = new
   * SimpleUrlFactory("/testurl?"); //$NON-NLS-1$ ArrayList messages = new ArrayList();
   * 
   * int chartWidth = 400; int chartHeight = 400; PieDatasetChartComponent pieChartComponent = new
   * PieDatasetChartComponent(chartType, path, chartWidth, chartHeight, urlFactory, messages);
   * 
   * pieChartComponent.setLoggingLevel(ILogger.ERROR); pieChartComponent.setByRow(true);
   * 
   * pieChartComponent.setDataAction("/test-src/solutions/test/rules/department_stats.xaction", "rule-result");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
   * 
   * OutputStream outputStream = getOutputStream(SOLUTION_PATH, "ChartTest." + testName, ".html");
   * //$NON-NLS-1$//$NON-NLS-2$ String contentType = "text/html"; //$NON-NLS-1$
   * 
   * SimpleParameterProvider requestParameters = new SimpleParameterProvider(); SimpleParameterProvider
   * sessionParameters = new SimpleParameterProvider();
   * 
   * HashMap parameterProviders = new HashMap(); parameterProviders.put(IParameterProvider.SCOPE_REQUEST,
   * requestParameters); parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters); StandaloneSession
   * session = new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * 
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false); BaseRequestHandler requestHandler
   * = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
   * 
   * try { pieChartComponent.validate(session, requestHandler); pieChartComponent.handleRequest(outputStream,
   * requestHandler, contentType, parameterProviders); } catch (IOException e) { e.printStackTrace(); }
   * 
   * }
   */
public void runTimeSeriesChartTest(int chartType, String path, String testName) {
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
    ArrayList messages = new ArrayList();
    int chartWidth = 400;
    int chartHeight = 400;
    TimeSeriesCollectionChartComponent timeSeriesChartComponent = new TimeSeriesCollectionChartComponent(chartType, path, chartWidth, chartHeight, urlFactory, messages);
    timeSeriesChartComponent.setLoggingLevel(ILogger.ERROR);
    // $NON-NLS-1$ //$NON-NLS-2$
    timeSeriesChartComponent.setDataAction("/test/rules/department_stats.xaction", "rule-result");
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("ChartTest." + testName, ".html");
    // $NON-NLS-1$
    String contentType = "text/html";
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    HashMap parameterProviders = new HashMap();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
    parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
    try {
        timeSeriesChartComponent.validate(session, requestHandler);
        timeSeriesChartComponent.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
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) TimeSeriesCollectionChartComponent(org.pentaho.platform.uifoundation.chart.TimeSeriesCollectionChartComponent) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 5 with BaseRequestHandler

use of org.pentaho.platform.engine.services.BaseRequestHandler in project pentaho-platform by pentaho.

the class ChartIT method runCategoryChartTest.

/*
   * public void testChartComponent_AreaChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "area"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Area", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_BarChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "bar"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Bar", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_BubbleChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "bubble"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Bubble", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session =
   * new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_BarLineComboChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "barline"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_BarLineCombo", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession
   * session = new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_DialChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "dial"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Dial", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_LineChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "line"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Line", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_PieChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "pie"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_Pie", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_PieGridChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "piegrid"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_PieGrid", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session =
   * new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/samples/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testChartComponent_TimeSeriesChart() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "timeseries"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_TimeSeries", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session
   * = new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testTimeSeriesChartCollection() { SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream
   * outputStream = getOutputStream(SOLUTION_PATH, "Chart_TimeSeries", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 testXYZChart() { SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
   * parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream(SOLUTION_PATH, "Chart_XYZ", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("chart_type", "xy"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new
   * StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context = run(
   * SOLUTION_PATH + "/test/charts/", "ChartComponent_ChartTypes.xaction", parameterProvider, outputHandler);
   * //$NON-NLS-1$ 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 runCategoryChartTest(int chartType, String path, String testName) {
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("/testurl?");
    ArrayList messages = new ArrayList();
    int chartWidth = 400;
    int chartHeight = 400;
    CategoryDatasetChartComponent categoryChartComponent = new CategoryDatasetChartComponent(chartType, path, chartWidth, chartHeight, urlFactory, messages);
    categoryChartComponent.setLoggingLevel(ILogger.ERROR);
    categoryChartComponent.setByRow(true);
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    categoryChartComponent.setDataAction("/test-src/solution/test/rules/department_stats.xaction", "rule-result");
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("ChartTest." + testName, ".html");
    // $NON-NLS-1$
    String contentType = "text/html";
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    HashMap parameterProviders = new HashMap();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParameters);
    parameterProviders.put(IParameterProvider.SCOPE_SESSION, sessionParameters);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    // $NON-NLS-1$
    UserSession usession = new UserSession("Admin", Locale.US, true, requestParameters);
    usession.doStartupActions(requestParameters);
    // $NON-NLS-1$
    UserSession usessionNoAuth = new UserSession("Admin", Locale.US, requestParameters);
    usessionNoAuth.doStartupActions(requestParameters);
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(session, null, outputHandler, null, urlFactory);
    try {
        categoryChartComponent.validate(session, requestHandler);
        categoryChartComponent.handleRequest(outputStream, requestHandler, contentType, parameterProviders);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
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) IOException(java.io.IOException) BaseRequestHandler(org.pentaho.platform.engine.services.BaseRequestHandler) CategoryDatasetChartComponent(org.pentaho.platform.uifoundation.chart.CategoryDatasetChartComponent) UserSession(org.pentaho.platform.engine.core.system.UserSession) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)6 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)6 IOException (java.io.IOException)5 OutputStream (java.io.OutputStream)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)5 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)5 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)5 HtmlComponent (org.pentaho.platform.uifoundation.component.HtmlComponent)2 UserSession (org.pentaho.platform.engine.core.system.UserSession)1 CategoryDatasetChartComponent (org.pentaho.platform.uifoundation.chart.CategoryDatasetChartComponent)1 DashboardWidgetComponent (org.pentaho.platform.uifoundation.chart.DashboardWidgetComponent)1 TimeSeriesCollectionChartComponent (org.pentaho.platform.uifoundation.chart.TimeSeriesCollectionChartComponent)1