Package org.pentaho.platform.api.engine

Examples of org.pentaho.platform.api.engine.IRuntimeContext


    startTest();
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo1b.xaction" );
      PojoComponentTest.doneCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "pojo1b.xaction", "empty action sequence test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertTrue( "done() was not called", PojoComponentTest.doneCalled );
      assertEquals( "setInt1 failed", 11, TestPojo1.int1 );
      assertEquals( "setInt2 failed", new Integer( 22 ), TestPojo1.int2 );
      assertEquals( "setBoolean1 failed", true, TestPojo1.bool1 );
      assertEquals( "setBoolean2 failed", new Boolean( true ), TestPojo1.bool2 );
      assertEquals( "setLong1 failed", 88, TestPojo1.long1 );
      assertEquals( "setLong2 failed", new Long( 99 ), TestPojo1.long2 );
      assertEquals( "setBigDecimal failed", new BigDecimal( "77.7" ), TestPojo1.bigDecimal );
      assertEquals( "setFloat1 failed", "33.3", Float.toString( TestPojo1.float1 ) );
      assertEquals( "setFloat2 failed", "44.4", TestPojo1.float2.toString() );
      assertEquals( "setDouble1 failed", "55.5", Double.toString( TestPojo1.double1 ) );
      assertEquals( "setDouble2 failed", "66.6", TestPojo1.double2.toString() );
      assertEquals( "Action sequence execution failed", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_STATUS_SUCCESS );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
View Full Code Here


    startTest();
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo4.xaction" );
      PojoComponentTest.doneCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "pojo4.xaction", "empty action sequence test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertNotNull( "param is null", param );
      assertEquals( "abcdeabcde", param.getValue().toString() );
      assertEquals( "done() was called", false, PojoComponentTest.doneCalled );
      assertEquals( "Action sequence execution failed", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_STATUS_SUCCESS );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
View Full Code Here

  public void testRuntimeInputsAndOutputs() {
    startTest();
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo5.xaction" );
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "pojo5.xaction", "empty action sequence test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "Action sequence execution failed", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_STATUS_SUCCESS );
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "param is null", param );
      assertEquals( "hello", param.getValue().toString() );
      param = runtimeContext.getOutputParameter( "output2" );
      assertNotNull( "param is null", param );
      assertEquals( "world", param.getValue().toString() );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
View Full Code Here

    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad1.xaction" );
      PojoComponentTest.doneCalled = false;
      PojoComponentTest.executeCalled = false;
      PojoComponentTest.validateCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test", "invalid class setting test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "execute was called", false, PojoComponentTest.executeCalled );
      assertEquals( "validate was called", false, PojoComponentTest.validateCalled );
      assertEquals( "Action sequence validation succeeded", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
View Full Code Here

    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad2.xaction" );
      PojoComponentTest.doneCalled = false;
      PojoComponentTest.executeCalled = false;
      PojoComponentTest.validateCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test", "invalid class setting test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "execute was called", false, PojoComponentTest.executeCalled );
      assertEquals( "validate was called", false, PojoComponentTest.validateCalled );
      assertEquals( "Action sequence validation succeeded", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
View Full Code Here

    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad3.xaction" );
      PojoComponentTest.doneCalled = false;
      PojoComponentTest.executeCalled = false;
      PojoComponentTest.validateCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test", "invalid class setting test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "execute was called", false, PojoComponentTest.executeCalled );
      assertEquals( "validate was not called", true, PojoComponentTest.validateCalled );
      assertEquals( "Action sequence execution succeeded", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_STATUS_FAILURE );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
View Full Code Here

    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad4.xaction" );
      PojoComponentTest.doneCalled = false;
      PojoComponentTest.executeCalled = false;
      PojoComponentTest.validateCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test", "invalid class setting test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "Action sequence succeeded", IRuntimeContext.RUNTIME_STATUS_SUCCESS, runtimeContext.getStatus() );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
    }
View Full Code Here

    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad5.xaction" );
      PojoComponentTest.doneCalled = false;
      PojoComponentTest.executeCalled = false;
      PojoComponentTest.validateCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test", "invalid class setting test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "Action sequence succeeded", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_FAILURE );
    } catch ( Exception e ) {
      // we should not get here
      e.printStackTrace();
      assertTrue( e.getMessage(), false );
    }
View Full Code Here

      outputHandler.setSession( session );
    }
    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo2.xaction" );
      PojoComponentTest.setActionSequenceResourceCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test1.xaction", "empty action sequence test", false, true, null, false, new HashMap(), outputHandler, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      IActionParameter param = runtimeContext.getOutputParameter( "outputstream" );
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "Action sequence execution failed", runtimeContext.getStatus(),
          IRuntimeContext.RUNTIME_STATUS_SUCCESS );
      assertTrue( "setResource was not called", PojoComponentTest.setResourceInputStreamCalled );
      assertTrue( "setResource was not called", PojoComponentTest.setActionSequenceResourceCalled );
    } catch ( Exception e ) {
      // we should not get here
View Full Code Here

  public static String executeHtml( RepositoryFile file, HttpServletRequest httpServletRequest,
                                    HttpServletResponse httpServletResponse, IPentahoSession userSession,
                                    IMimeTypeListener mimeTypeListener )
    throws Exception {
    IParameterProvider requestParams = new HttpRequestParameterProvider( httpServletRequest );
    IRuntimeContext runtime = null;
    try {

      HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider( userSession );
      HttpRequestParameterProvider requestParameters = new HttpRequestParameterProvider( httpServletRequest );

      boolean doMessages = "true".equalsIgnoreCase(
        requestParams.getStringParameter( "debug", "false" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      boolean doWrapper = "true".equalsIgnoreCase(
        requestParams.getStringParameter( "wrapper", "true" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

      IOutputHandler outputHandler =
        createOutputHandler( httpServletResponse, getOutputStream( httpServletResponse, doMessages ) );

      // configure output handler, this is necessary so that the right content
      // disposition is set on the response header
      if ( mimeTypeListener == null ) {
        mimeTypeListener = new HttpMimeTypeListener( httpServletRequest, httpServletResponse, null );
      }
      outputHandler.setMimeTypeListener( mimeTypeListener );
      outputHandler.setSession( userSession );

      Map parameterProviders = new HashMap();
      parameterProviders.put( "request", requestParameters ); //$NON-NLS-1$
      parameterProviders.put( "session", sessionParameters ); //$NON-NLS-1$
      createOutputFileName( file, outputHandler );
      int outputPreference = IOutputHandler.OUTPUT_TYPE_DEFAULT;
      outputHandler.setOutputPreference( outputPreference );
      boolean forcePrompt = "true".equalsIgnoreCase(
        requestParams.getStringParameter( "prompt", "false" ) ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$

      List messages = new ArrayList();
      runtime =
        executeInternal( file, requestParams, httpServletRequest, outputHandler, parameterProviders, userSession,
          forcePrompt, messages );
      String str =
        postExecute( runtime, doMessages, doWrapper, outputHandler, parameterProviders, httpServletRequest,
          httpServletResponse, messages );
      return str;
    } catch ( Exception e ) {
      logger.error(
        Messages.getInstance().getString( "XactionUtil.ERROR_EXECUTING_ACTION_SEQUENCE", file.getName() ),
        e ); //$NON-NLS-1$
      throw e;
    } finally {
      if ( runtime != null ) {
        runtime.dispose();
      }

    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.IRuntimeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.