Search in sources :

Example 41 with SimpleUrlFactory

use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.

the class HTMLComponentIT method testComponent1.

public void testComponent1() {
    startTest();
    // This should succeed
    // $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);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    try {
        // $NON-NLS-1$//$NON-NLS-2$
        OutputStream outputStream = getOutputStream("HTMLComponentTest.testComponent1", ".html");
        component.validate(session, null);
        // $NON-NLS-1$
        String content = component.getContent("text/html");
        outputStream.write(content.getBytes());
    } catch (IOException e) {
        e.printStackTrace();
    }
    finishTest();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HtmlComponent(org.pentaho.platform.uifoundation.component.HtmlComponent) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) IOException(java.io.IOException)

Example 42 with SimpleUrlFactory

use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.

the class ReportingIT method testActionComponent.

/*
   * public void testBIRTReport1() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream
   * outputStream = getOutputStream("ReportingTest.testBIRTReport1-a", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
   * "test", "reporting", "quadrant-budget-hsql.xaction", null, false, parameterProvider, outputHandler, session);
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ outputStream = getOutputStream("ReportingTest.testBIRTReport1-b", ".pdf");
   * //$NON-NLS-1$ //$NON-NLS-2$ outputHandler = new SimpleOutputHandler(outputStream, true);
   * parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ context = run( "test", "reporting",
   * "quadrant-budget-hsql.xaction", null, false, parameterProvider, outputHandler, session); //$NON-NLS-1$
   * //$NON-NLS-2$ //$NON-NLS-3$ assertEquals( Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
   * IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); //$NON-NLS-1$ finishTest(); }
   * 
   * public void testBIRTReport4() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("DEPARTMENT", "Finance"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream("ReportingTest.testBIRTReport4", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
   * outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
   * "test", "reporting", "quadrant-budget-for-region-and-dept-to-repository.xaction", null, false, parameterProvider,
   * outputHandler, session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
   * 
   * public void testBIRTIntparm() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("intparm", "300000"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream("ReportingTest.testIntParm", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
   * outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
   * "test", "reporting", "BIRT-quadrant-budget-hsql-intparm.xaction", null, false, parameterProvider, outputHandler,
   * session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
   */
/*
   * public void testJasperReports1() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
   * OutputStream outputStream = getOutputStream("ReportingTest.testJasperReports1", ".html"); //$NON-NLS-1$
   * //$NON-NLS-2$ SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession
   * session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext
   * context = run( "test", "reporting", "jasper-reports-test-1.xaction", null, false, parameterProvider, outputHandler,
   * session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
   * 
   * public void testJasperReports2() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("REGION", "Eastern"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream outputStream =
   * getOutputStream("ReportingTest.testJasperReports2", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler
   * outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
   * "test", "reporting", "jasper-reports-test-2.xaction", null, false, parameterProvider, outputHandler, session);
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success finishTest(); }
   */
/*
   * public void testBIRTReport3() { startTest(); SimpleParameterProvider parameterProvider = new
   * SimpleParameterProvider(); parameterProvider.setParameter("type", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream
   * outputStream = getOutputStream("ReportingTest.testBIRTReport3", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$
   * SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ IRuntimeContext context = run(
   * "test", "reporting", "quadrant-budget-for-region-hsql.xaction", null, false, parameterProvider, outputHandler,
   * session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ finishTest(); }
   */
public void testActionComponent() {
    startTest();
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath());
    ArrayList messages = new ArrayList();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("solution", "test");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("path", "reporting");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("action", "custom-parameter-page-example.xaction");
    ActionComponent component = new ActionComponent("test/reporting/custom-parameter-page-example.xaction", null, IOutputHandler.OUTPUT_TYPE_DEFAULT, urlFactory, // $NON-NLS-1$
    messages);
    component.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    component.validate(session, null);
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("ReportingTest.testActionComponent", ".html");
    // $NON-NLS-1$
    String content = component.getContent("text/html");
    try {
        outputStream.write(content.getBytes());
    } catch (Exception e) {
    // ignore
    }
    finishTest();
}
Also used : IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) ActionComponent(org.pentaho.platform.uifoundation.component.ActionComponent) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 43 with SimpleUrlFactory

use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.

the class MetadataIT method __testLoadView.

public void __testLoadView() {
    startTest();
    // $NON-NLS-1$
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
    PMDUIComponent component = new PMDUIComponent(urlFactory, new ArrayList());
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    component.validate(session, null);
    component.setAction(PMDUIComponent.ACTION_LOAD_MODEL);
    // $NON-NLS-1$
    component.setDomainName("test");
    // $NON-NLS-1$
    component.setModelId("Orders");
    Document doc = component.getXmlContent();
    System.out.println(doc.asXML());
    try {
        // $NON-NLS-1$//$NON-NLS-2$
        OutputStream outputStream = getOutputStream("MetadataTest.testLoadView", ".xml");
        outputStream.write(doc.asXML().getBytes());
    } catch (IOException e) {
    // ignore
    }
    finishTest();
}
Also used : IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) PMDUIComponent(org.pentaho.platform.uifoundation.component.xml.PMDUIComponent) IOException(java.io.IOException) Document(org.dom4j.Document)

Example 44 with SimpleUrlFactory

use of org.pentaho.platform.util.web.SimpleUrlFactory 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 45 with SimpleUrlFactory

use of org.pentaho.platform.util.web.SimpleUrlFactory in project pentaho-platform by pentaho.

the class GlobalOutputIT method testEmptyActionSequence.

public void testEmptyActionSequence() {
    startTest();
    List messages = new ArrayList();
    String instanceId = null;
    IPentahoSession session = new StandaloneSession("system");
    PentahoSessionHolder.setSession(session);
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class);
    solutionEngine.setLoggingLevel(ILogger.ERROR);
    solutionEngine.init(session);
    String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
    HashMap parameterProviderMap = new HashMap();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory(baseUrl);
    try {
        File file = new File(getSolutionPath() + "/samples/platform/SetGlobalOutputTest.xaction");
        StringBuilder str = new StringBuilder();
        Reader reader = new FileReader(file);
        char[] buffer = new char[4096];
        int n = reader.read(buffer);
        while (n != -1) {
            str.append(buffer, 0, n);
            n = reader.read(buffer);
        }
        String xactionStr = str.toString();
        solutionEngine.setSession(session);
        IRuntimeContext runtimeContext = solutionEngine.execute(xactionStr, "SetGlobalOutputTest.xaction", "empty action sequence test", false, true, instanceId, false, parameterProviderMap, null, null, urlFactory, // $NON-NLS-1$ //$NON-NLS-2$
        messages);
        assertNotNull("RuntimeContext is null", runtimeContext);
        assertEquals("Action sequence execution failed", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_SUCCESS);
        IParameterProvider provider = PentahoSystem.getGlobalParameters();
        // $NON-NLS-1$
        String parameter = provider.getStringParameter("GLOBAL_TEST", null);
        assertNotNull(parameter);
        // $NON-NLS-1$
        assertEquals("This is a test", parameter);
    } catch (Exception e) {
        // we should not get here
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
    }
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HashMap(java.util.HashMap) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ArrayList(java.util.ArrayList) Reader(java.io.Reader) FileReader(java.io.FileReader) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) File(java.io.File) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Aggregations

SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)51 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)31 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)23 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)20 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)20 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)17 OutputStream (java.io.OutputStream)16 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)16 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)15 IOException (java.io.IOException)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)11 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)11 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)9 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)8 List (java.util.List)6 Document (org.dom4j.Document)6 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)6 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)5