Examples of XQConnection


Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    }
  }

  public void testExecuteQuery() throws Exception {

    XQConnection connection = new XQConnection();
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    assertTrue( "result set is wrong type", data instanceof XQResultSet );

    assertFalse( "Should not be scrollable", data.isScrollable() );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    data.closeConnection();
  }

  public void testExecuteWrongQuery() throws Exception {
    try {
      XQConnection connection = new XQConnection();
      StaticQueryContext mockContext = mock( StaticQueryContext.class );
      when( mockContext.compileQuery( TEST_QUERY ) ).thenThrow( new XPathException( "Test XPathException" ) );
      connection.sqc = mockContext;

      IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
      fail( "Should throw XPathException" );
    } catch ( XPathException e ) {
      // valid
    }
  }
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

      // valid
    }
  }

  public void testGetDataRow() throws Exception {
    XQConnection connection = new XQConnection();
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    Object[] row = data.getDataRow( 1 );
    assertEquals( "Harry Potter", row[0] );
    assertEquals( "J K. Rowling", row[1] );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    row = data.getDataRow( 99 );
    assertNull( row );
  }

  public void testGetDataColumn() throws Exception {
    XQConnection connection = new XQConnection();
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    Object[] col = data.getDataColumn( 2 );
    assertEquals( "row count is wrong", 4, col.length );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    assertNull( col );
  }

  public void testRowLimit() throws Exception {

    XQConnection connection = new XQConnection();
    connection.setMaxRows( 2 );
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    assertTrue( "result set is wrong type", data instanceof XQResultSet );

    assertEquals( "row count is wrong", 2, data.getRowCount() );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    assertNull( row );
  }

  public void testValueAt() throws Exception {

    XQConnection connection = new XQConnection();
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    assertEquals( "2005", data.getValueAt( 0, 2 ) );
    assertEquals( "Everyday Italian", data.getValueAt( 0, 0 ) );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    assertNull( data.getValueAt( 99, 0 ) );
    assertNull( data.getValueAt( 0, 99 ) );
  }

  public void testPeek() throws Exception {
    XQConnection connection = new XQConnection();
    IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
    assertNotNull( "result set is null", data );

    assertTrue( "result set is wrong type", data instanceof XQResultSet );

    assertEquals( "row count is wrong", 4, data.getRowCount() );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    assertEquals( 3, data.getValueAt( 2, 1 ) );
  }

  public void testXQConnectionExequtePreparedQuery() {
    try {
      XQConnection connection = new XQConnection();
      connection.prepareAndExecuteQuery( TEST_QUERY, ListUtils.EMPTY_LIST );
      fail( "Should throw UnsupportedOperationException" );
    } catch ( UnsupportedOperationException e ) {
      // valid
    } catch ( Exception e ) {
      fail( "Should throw UnsupportedOperationException" );
View Full Code Here

Examples of org.pentaho.platform.plugin.services.connections.xquery.XQConnection

    }
  }

  public void testXQConnectionConnect() {
    try {
      XQConnection connection = new XQConnection();
      ILogger mockLogger = mock( ILogger.class );
      connection.setLogger( mockLogger );

      Properties properties = null;
      boolean isConnected = connection.connect( properties );
      assertTrue( isConnected );

      properties = new Properties();
      isConnected = connection.connect( properties );
      assertTrue( isConnected );

      properties.setProperty( IPentahoConnection.QUERY_KEY, StringUtils.EMPTY );
      isConnected = connection.connect( properties );
      assertTrue( isConnected );

      properties.setProperty( IPentahoConnection.QUERY_KEY, TEST_QUERY );
      isConnected = connection.connect( properties );
      assertTrue( isConnected );

      StaticQueryContext mockContext = mock( StaticQueryContext.class );
      when( mockContext.compileQuery( TEST_QUERY ) ).thenThrow( new XPathException( "Test XPathException" ) );
      connection.sqc = mockContext;

      isConnected = connection.connect( properties );
      assertFalse( isConnected );
    } catch ( Exception e ) {
      e.printStackTrace();
      fail( "Should not throw Exception" );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.