Search in sources :

Example 46 with SimpleParameterProvider

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

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

Example 48 with SimpleParameterProvider

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

the class ContentOutputComponentIT method testErrorPaths.

public void testErrorPaths() {
    startTest();
    // Tests with bad output stream
    // $NON-NLS-1$
    String neverWritten = "This data cannot be written";
    // $NON-NLS-1$
    String testName = CO_TEST_NAME + "BAD_OUTPUTSTREAM_" + System.currentTimeMillis();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter("CONTENTOUTPUT", neverWritten);
    // $NON-NLS-1$
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN);
    // $NON-NLS-1$
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus());
    // Another test with a bad output stream...
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        baos.write(neverWritten.getBytes());
    } catch (Exception ex) {
        fail();
    }
    // $NON-NLS-1$
    parameterProvider.setParameter("CONTENTOUTPUT", baos);
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context = run("/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN);
    assertEquals(IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus());
    // Final test with a bad output stream...
    // $NON-NLS-1$
    parameterProvider.setParameter("CONTENTOUTPUT", new ByteArrayInputStream(neverWritten.getBytes()));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context = run("/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN);
    assertEquals(IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus());
    // Tests with bad action sequences
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context = run("/test/platform/ContentOutputTest_error1.xaction");
    assertEquals(IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL, context.getStatus());
    // Empty Parameter Provider
    parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context = run("/test/platform/ContentOutputTest_error2.xaction", parameterProvider, testName, CO_TEST_EXTN);
    assertEquals(IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL, context.getStatus());
    // Test with an invalid input parameter
    // $NON-NLS-1$
    parameterProvider.setParameter("CONTENTOUTPUT", neverWritten.getBytes());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context = run("/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN);
    assertEquals(IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus());
    finishTest();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IOException(java.io.IOException) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 49 with SimpleParameterProvider

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

the class HQLConnectionIT method testHQLConnection.

public void testHQLConnection() {
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream(SOLUTION_PATH, "Chart_Bubble", ".html");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    IRuntimeContext context = // $NON-NLS-1$
    run(getSolutionPath() + "/test/datasource/", "HQL_Datasource.xaction", parameters, outputHandler);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
}
Also used : OutputStream(java.io.OutputStream) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 50 with SimpleParameterProvider

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

the class ContentGeneratorUtil method getContentAsString.

/**
 * Convenience method for executing a content generator and getting back it's output as a string. Useful for
 * testing.
 *
 * @param cg
 *          the content generator to execute
 * @return the output of the content generator
 * @throws Exception
 *           if there was a problem creating the content
 */
public static String getContentAsString(IContentGenerator cg) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOutputHandler outputHandler = new SimpleOutputHandler(out, false);
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    SimpleParameterProvider requestParams = new SimpleParameterProvider();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParams);
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("?");
    List<String> messages = new ArrayList<String>();
    cg.setOutputHandler(outputHandler);
    IMimeTypeListener mimeTypeListener = new IMimeTypeListener() {

        @SuppressWarnings("unused")
        public String mimeType = null;

        @SuppressWarnings("unused")
        public String name = null;

        public void setMimeType(String mimeType) {
            this.mimeType = mimeType;
        }

        public void setName(String name) {
            this.name = name;
        }
    };
    outputHandler.setMimeTypeListener(mimeTypeListener);
    cg.setMessagesList(messages);
    cg.setParameterProviders(parameterProviders);
    cg.setSession(PentahoSessionHolder.getSession());
    cg.setUrlFactory(urlFactory);
    cg.createContent();
    String content = new String(out.toByteArray());
    return content;
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IOutputHandler(org.pentaho.platform.api.engine.IOutputHandler) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) 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