Search in sources :

Example 26 with IRuntimeContext

use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.

the class SubActionComponentIT method testChildConnectionNotSharing.

/**
 * parent action creates a connection, used by sub-action parent then re-uses connection
 */
/*
   * public void testParentConnectionSharing() {
   * 
   * startTest(); info("Expected: Successful execution with object available"); //$NON-NLS-1$ IRuntimeContext context =
   * run("test", "platform", "SubActionConnectionTest4.xaction"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   * assertEquals( Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
   * IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); //$NON-NLS-1$
   * 
   * IActionParameter rtn = context.getOutputParameter("query-results"); //$NON-NLS-1$ assertNotNull(rtn);
   * IPentahoResultSet resultSet = (IPentahoResultSet) rtn.getValue(); assertNotNull(resultSet);
   * 
   * try { assertEquals(5, resultSet.getRowCount()); } catch (Exception e) { e.printStackTrace(); fail(); }
   * 
   * finishTest(); }
   */
/**
 * sub-action creates connection, passes result set on to parent action
 */
/*
   * public void testChildResultSetSharing() {
   * 
   * startTest(); info("Expected: Successful execution with object available"); //$NON-NLS-1$ IRuntimeContext context =
   * run("test", "platform", "SubActionConnectionTest3.xaction"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   * assertEquals( Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
   * IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); //$NON-NLS-1$
   * 
   * IActionParameter rtn = context.getOutputParameter("query-results"); //$NON-NLS-1$ assertNotNull(rtn);
   * IPentahoResultSet resultSet = (IPentahoResultSet) rtn.getValue(); assertNotNull(resultSet);
   * 
   * try { // if row count is zero, that means the native connection has been closed. assertEquals(5,
   * resultSet.getRowCount()); } catch (Exception e) { e.printStackTrace(); fail(); }
   * 
   * finishTest(); }
   */
/**
 * sub-action creates result set, uses, and passes nothing to parent action
 */
public void testChildConnectionNotSharing() {
    startTest();
    // $NON-NLS-1$
    info("Expected: Failed execution with object not available");
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/platform/SubActionConnectionTest2.xaction");
    // xaction should fail, because connection isn't available
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
    context.getStatus());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 27 with IRuntimeContext

use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.

the class TemplateIT method testTemplate1.

public void testTemplate1() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("customer", "Acme");
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/template/template1.xaction", parameterProvider);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertNotNull("", context.getOutputParameter("output"));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals("", "Customer 'Acme' is in region West", context.getOutputParameter("output").getStringValue());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 28 with IRuntimeContext

use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.

the class TemplateIT method testTemplate3.

public void testTemplate3() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("type", "html");
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("TemplateTest.testTemplate3", ".svg");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    run("/test/template/europemap.xaction", null, false, parameterProvider, outputHandler, session);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertNotNull("", context.getOutputParameter("svg"));
    finishTest();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) 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 29 with IRuntimeContext

use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.

the class TemplateIT method testTemplate2.

public void testTemplate2() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/template/template2.xaction", parameterProvider);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertNotNull("", context.getOutputParameter("output"));
    assertEquals("", "Eastern is 120000 with a color of #00ff00, Western is 90000 with a color of #ffff00, Southern is 75000 with a color of #ff0000", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context.getOutputParameter("output").getStringValue());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 30 with IRuntimeContext

use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.

the class ResultSetCompareComponentTest method createResultSetCompareComponent.

private static ResultSetCompareComponent createResultSetCompareComponent() {
    ResultSetCompareComponent rscc = new ResultSetCompareComponent();
    IRuntimeContext context = mock(IRuntimeContext.class);
    rscc.setRuntimeContext(context);
    rscc.setSession(mock(IPentahoSession.class));
    rscc.setComponentDefinition(mock(Node.class));
    rscc.setInstanceId("TEST_ID");
    rscc.setProcessId("TEST_PROCESS_ID");
    rscc.setActionName("TEST_ACTION_NAME");
    return rscc;
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Node(org.dom4j.Node) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Aggregations

IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)100 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)28 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)28 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)24 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)17 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)14 OutputStream (java.io.OutputStream)12 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)12 List (java.util.List)10 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)9 IOException (java.io.IOException)8 Map (java.util.Map)8 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)7 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)6 Document (org.dom4j.Document)5