Search in sources :

Example 1 with DashboardWidgetComponent

use of org.pentaho.platform.uifoundation.chart.DashboardWidgetComponent in project pentaho-platform by pentaho.

the class DashboardWidgetIT method testWidget2.

public void testWidget2() {
    // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory("");
    ArrayList messages = new ArrayList();
    DashboardWidgetComponent widget = new DashboardWidgetComponent(DashboardWidgetComponent.TYPE_DIAL, getSolutionPath() + "/samples/charts/dashboardwidget1.dial.xml", 200, 200, urlFactory, // $NON-NLS-1$
    messages);
    widget.setValue(49);
    // $NON-NLS-1$
    widget.setTitle("test widget 1");
    // $NON-NLS-1$
    widget.setUnits("");
    // $NON-NLS-1$
    StandaloneSession session = new StandaloneSession("BaseTest.DEBUG_JUNIT_SESSION");
    widget.validate(session, null);
    SimpleParameterProvider requestParameters = new SimpleParameterProvider();
    SimpleParameterProvider sessionParameters = new SimpleParameterProvider();
    widget.setParameterProvider(HttpRequestParameterProvider.SCOPE_REQUEST, requestParameters);
    widget.setParameterProvider(HttpSessionParameterProvider.SCOPE_SESSION, sessionParameters);
    // $NON-NLS-1$
    String content = widget.getContent("text/html");
    // $NON-NLS-1$//$NON-NLS-2$
    OutputStream outputStream = getOutputStream("DashboardWidgetTest.testWidget1", ".html");
    try {
        outputStream.write(content.getBytes());
    } catch (Exception e) {
    // content check will test this
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) IOException(java.io.IOException) DashboardWidgetComponent(org.pentaho.platform.uifoundation.chart.DashboardWidgetComponent) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 2 with DashboardWidgetComponent

use of org.pentaho.platform.uifoundation.chart.DashboardWidgetComponent 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)

Aggregations

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