Package org.pentaho.platform.engine.core.solution

Examples of org.pentaho.platform.engine.core.solution.SimpleParameterProvider


  }

  public void testStandAloneSession() {
    startTest();

    SimpleParameterProvider parameters = new SimpleParameterProvider();
    parameters.setParameter( "actionname", "ViewAction" ); //$NON-NLS-1$ //$NON-NLS-2$
    StandaloneSession session = new StandaloneSession( "BaseTest.DEBUG_JUNIT_SESSION" ); //$NON-NLS-1$
    Log log = session.getLogger();
    System.out.println( "Action Name for the Session is  " + session.getActionName() ); //$NON-NLS-1$
    session.setNotAuthenticated();
    log.info( "Session is active" ); //$NON-NLS-1$
View Full Code Here


    finishTest();
  }

  public void testUserSessionWithAuthentication() {
    startTest();
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    parameters.setParameter( "actionname", "ViewAction" ); //$NON-NLS-1$ //$NON-NLS-2$
    UserSession usession = new UserSession( "Admin", Locale.US, true, parameters ); //$NON-NLS-1$
    usession.setActionName( "ViewAction" );
    usession.doStartupActions( parameters );
    assertEquals( usession.getActionName(), "ViewAction" ); //$NON-NLS-1$
View Full Code Here

    finishTest();
  }

  public void testUserSessionWithOutAuthentication() {
    startTest();
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    parameters.setParameter( "actionname", "ViewAction" ); //$NON-NLS-1$ //$NON-NLS-2$
    UserSession usession = new UserSession( "Admin", Locale.US, parameters ); //$NON-NLS-1$
    Log log = usession.getLogger();
    usession.setActionName( "ViewAction" );
    usession.doStartupActions( parameters );
    log.info( "Session is active" ); //$NON-NLS-1$
View Full Code Here

      solutionEngine.setForcePrompt( false );

      ArrayList messages = new ArrayList();

      HashMap<String, Object> parameterProviders = new HashMap<String, Object>();
      parameterProviders.put( IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider( xActionInputParams ) );
      parameterProviders.put( IParameterProvider.SCOPE_SESSION, new PentahoSessionParameterProvider(
          PentahoSessionHolder.getSession() ) );
      String xactionPath = null;
      if ( xactionDefInputStream instanceof RepositoryFileInputStream ) {
        xactionPath = ( (RepositoryFileInputStream) xactionDefInputStream ).getFile().getPath();
View Full Code Here

  }

  public void testSuccessPaths() {
    startTest();
    String testName = CO_TEST_NAME + "string_" + System.currentTimeMillis(); //$NON-NLS-1$
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    IRuntimeContext context =
        run( "/test/platform/ContentOutputTest.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$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( "content" ); //$NON-NLS-1$
    assertNotNull( rtn );
    InputStream is = this.getInputStreamFromOutput( testName, CO_TEST_EXTN );
    assertNotNull( is ); // Did the test execute properly...
    String lookingFor = "This is sample output from the content-output component."; //$NON-NLS-1$
    String wasRead = FileHelper.getStringFromInputStream( is );
    assertTrue( wasRead.startsWith( lookingFor ) );

    // Test different path - Byte Array Output Stream
    lookingFor = "This is as sample bytearray output stream"; //$NON-NLS-1$
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      baos.write( lookingFor.getBytes() );
    } catch ( Exception ex ) {
      fail();
    }
    testName = CO_TEST_NAME + "ByteArrayOutputStream_" + System.currentTimeMillis(); //$NON-NLS-1$
    parameterProvider.setParameter( "CONTENTOUTPUT", baos ); //$NON-NLS-1$
    context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus() );
    is = this.getInputStreamFromOutput( testName, CO_TEST_EXTN );
    assertNotNull( is ); // Did the test execute properly...
    wasRead = FileHelper.getStringFromInputStream( is );
    FileHelper.getStringFromFile( new File( PentahoSystem.getApplicationContext().getSolutionPath(
        "test/datasource/books.xml" ) ) ); //$NON-NLS-1$
    try {
      FileHelper.getBytesFromFile( new File( PentahoSystem.getApplicationContext().getSolutionPath(
          "test/datasource/books.xml" ) ) ); //$NON-NLS-1$
    } catch ( IOException io ) {
      // do nothing
    }
    File f = null;
    FileHelper.getStringFromFile( f );
    assertTrue( wasRead.startsWith( lookingFor ) );

    // Test different path - InputStream
    testName = CO_TEST_NAME + "ByteArrayInputStream_" + System.currentTimeMillis(); //$NON-NLS-1$
    lookingFor = "This is as a simple bytearray input stream"; //$NON-NLS-1$
    ByteArrayInputStream bais = new ByteArrayInputStream( lookingFor.getBytes() );
    parameterProvider.setParameter( "CONTENTOUTPUT", bais ); //$NON-NLS-1$
    context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus() );
    is = this.getInputStreamFromOutput( testName, CO_TEST_EXTN );
    assertNotNull( is ); // Did the test execute properly...
    String newText = FileHelper.getStringFromInputStream( is );
View Full Code Here

    startTest();

    // Tests with bad output stream
    String neverWritten = "This data cannot be written"; //$NON-NLS-1$
    String testName = CO_TEST_NAME + "BAD_OUTPUTSTREAM_" + System.currentTimeMillis(); //$NON-NLS-1$
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter( "CONTENTOUTPUT", neverWritten );
    //$NON-NLS-1$
    IRuntimeContext context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus() ); //$NON-NLS-1$

    // Another test with a bad output stream...
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      baos.write( neverWritten.getBytes() );
    }
    catch (Exception ex) { fail(); }
    parameterProvider.setParameter( "CONTENTOUTPUT", baos ); //$NON-NLS-1$
    context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus() );

    // Final test with a bad output stream...
    parameterProvider.setParameter( "CONTENTOUTPUT", new ByteArrayInputStream( neverWritten.getBytes() ) ); //$NON-NLS-1$
    context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus() );

    // Tests with bad action sequences
    context = run( "/test/platform/ContentOutputTest_error1.xaction" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL, context.getStatus() );

    parameterProvider = new SimpleParameterProvider(); // Empty Parameter Provider
    context = run( "/test/platform/ContentOutputTest_error2.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL, context.getStatus() );

    // Test with an invalid input parameter
    parameterProvider.setParameter("CONTENTOUTPUT", neverWritten.getBytes()); //$NON-NLS-1$
    context = run( "/test/platform/ContentOutputTest_Bytearray.xaction", parameterProvider, testName, CO_TEST_EXTN ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals( IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus() );

    finishTest();
  }
View Full Code Here

  }

  public void testScriptRule() {
    startTest();

    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter( "customer", "Acme" ); //$NON-NLS-1$ //$NON-NLS-2$

    IRuntimeContext context = run( "/test/rules/script_rule1.xaction", parameterProvider ); //$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$
View Full Code Here

    widget.setUnits( "$" ); //$NON-NLS-1$

    OutputStream outputStream = getOutputStream( "DashboardWidgetTest.testWidget1", ".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( HttpRequestParameterProvider.SCOPE_REQUEST, requestParameters );
    parameterProviders.put( HttpSessionParameterProvider.SCOPE_SESSION, sessionParameters );
    StandaloneSession session = new StandaloneSession( "BaseTest.DEBUG_JUNIT_SESSION" ); //$NON-NLS-1$
View Full Code Here

    return SOLUTION_PATH;
  }

  public void testHelloWorld() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter( "type", "html" ); //$NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream( "RuntimeTest.testHelloWorld", ".html" ); //$NON-NLS-1$ //$NON-NLS-2$
    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, true );
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$
View Full Code Here

    finishTest();
  }

  public void testForcePrompt() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    OutputStream outputStream = getOutputStream( "RuntimeTest.testForcePrompt", ".html" ); //$NON-NLS-1$ //$NON-NLS-2$
    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, true );
    outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_PARAMETERS );
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.pentaho.platform.engine.core.solution.SimpleParameterProvider

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.