Package org.pentaho.platform.api.repository.datasource

Examples of org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService


    // Set it up - this is a NATIVE connection
    when( mockConnection.getAccessType()).thenReturn( DatabaseAccessType.NATIVE );
    when( mockConnection.getDatabaseName()).thenReturn( dsName );

    DataSource mockDs = mock(DataSource.class);
    IDatasourceMgmtService mockMgmtService = mock(IDatasourceMgmtService.class);

    spyService = spy(service );

    try {
      when( mockMgmtService.getDatasourceByName( dsName ) ).thenReturn( mockConnection );
    } catch ( DatasourceMgmtServiceException e ) {
      e.printStackTrace();
    }

    try {
View Full Code Here


    // Set it up - this is a JNDI connection
    when( mockConnection.getAccessType()).thenReturn( DatabaseAccessType.JNDI );
    when( mockConnection.getDatabaseName()).thenReturn( dsName );

    DataSource mockDs = mock(DataSource.class);
    IDatasourceMgmtService mockMgmtService = mock(IDatasourceMgmtService.class);

    spyService = spy(service );

    try {
      when( mockMgmtService.getDatasourceByName( dsName ) ).thenReturn( mockConnection );
    } catch ( DatasourceMgmtServiceException e ) {
      e.printStackTrace();
    }

    try {
View Full Code Here

    // Set it up - this is a NATIVE connection
    when( mockConnection.getAccessType()).thenReturn( DatabaseAccessType.NATIVE );
    when( mockConnection.getDatabaseName()).thenReturn( dsName );

    DataSource mockDs = mock(DataSource.class);
    IDatasourceMgmtService mockMgmtService = mock(IDatasourceMgmtService.class);

    DynamicallyPooledOrJndiDatasourceService dynamic = new DynamicallyPooledOrJndiDatasourceService();
    dynamic.setNonPooledDatasourceService( nonPooledSpyService );
    dynamic.setPooledDatasourceService( pooledSpyService );
    spyService = spy(dynamic );

    try {
      when( mockMgmtService.getDatasourceByName( dsName ) ).thenReturn( mockConnection );
    } catch ( DatasourceMgmtServiceException e ) {
      e.printStackTrace();
    }

    try {
View Full Code Here

  }

  @VisibleForTesting
  protected List<IDatabaseConnection> getListOfDatabaseConnections( final IPentahoSession session )
      throws ObjectFactoryException, DatasourceMgmtServiceException {
    IDatasourceMgmtService datasourceMgmtSvc =
        (IDatasourceMgmtService) PentahoSystem.getObjectFactory().get( IDatasourceMgmtService.class, session );

    List<IDatabaseConnection> databaseConnections = datasourceMgmtSvc.getDatasources();
    return databaseConnections;
  }
View Full Code Here

  protected DataSource retrieve( String dsName ) throws DBDatasourceServiceException {
    DataSource ds = null;
    requestedDatasourceName = dsName;

    try {
      IDatasourceMgmtService datasourceMgmtSvc = getDatasourceMgmtService();
      IDatabaseConnection databaseConnection = datasourceMgmtSvc.getDatasourceByName( dsName );

      if ( databaseConnection != null && !databaseConnection.getAccessType().equals( DatabaseAccessType.JNDI ) ) {
        ds = resolveDatabaseConnection( databaseConnection );
        // Database does not have the datasource, look in jndi now
      } else if ( databaseConnection == null ) {
View Full Code Here

  @Override
  protected DataSource retrieve( String dsName ) throws DBDatasourceServiceException {
    DataSource ds = null;
    try {
      IDatasourceMgmtService datasourceMgmtSvc = getDatasourceMgmtService();
      IDatabaseConnection databaseConnection = datasourceMgmtSvc.getDatasourceByName( dsName );
      if ( databaseConnection != null ) {
        ds = resolveDatabaseConnection( databaseConnection );
        if ( ds != null ) {
          cacheManager.putInRegionCache( IDBDatasourceService.JDBC_DATASOURCE, dsName, ds );
        }
View Full Code Here

    // stub out get parent folder
    doReturn( new RepositoryFile.Builder( parentFolderId, "databases" ).folder( true ).build() ).when( repo ).getFile(
        "/etc/pdi/databases" );
    doReturn( reservedChars ).when( repo ).getReservedChars();

    IDatasourceMgmtService datasourceMgmtService =
        new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() );

    IDatabaseConnection databaseConnection = createDatabaseConnection( EXP_DBMETA_NAME );
    datasourceMgmtService.createDatasource( databaseConnection );

    verify( repo ).createFile( eq( parentFolderId ),
        argThat( isLikeFile( new RepositoryFile.Builder( EXP_DBMETA_NAME + ".kdb" ).build() ) ),
        argThat( hasData( pathPropertyPair( "/databaseMeta/HOST_NAME", EXP_DBMETA_HOSTNAME ) ) ), anyString() );
  }
View Full Code Here

        databasesFolderPath );
    doReturn( reservedChars ).when( repo ).getReservedChars();
    // stub out get file to delete
    doReturn( new RepositoryFile.Builder( fileId, EXP_DBMETA_NAME + dotKdb ).build() ).when( repo ).getFile(
        databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb );
    IDatasourceMgmtService datasourceMgmtService =
        new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() );

    datasourceMgmtService.deleteDatasourceByName( EXP_DBMETA_NAME );

    verify( repo ).deleteFile( eq( fileId ), eq( true ), anyString() );
  }
View Full Code Here

            databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb ).build();
    doReturn( f ).when( repo ).getFile( databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb );
    // stub out update file which requires a file to be returned
    doReturn( f ).when( repo )
        .updateFile( any( RepositoryFile.class ), any( NodeRepositoryFileData.class ), anyString() );
    IDatasourceMgmtService datasourceMgmtService =
        new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() );

    IDatabaseConnection databaseConnection = createDatabaseConnection( EXP_DBMETA_NAME );
    updateDatabaseConnection( databaseConnection );
    datasourceMgmtService.updateDatasourceByName( EXP_DBMETA_NAME, databaseConnection );

    verify( repo ).updateFile( argThat( isLikeFile( new RepositoryFile.Builder( EXP_DBMETA_NAME + ".kdb" ).build() ) ),
        argThat( hasData( pathPropertyPair( "/databaseMeta/HOST_NAME", EXP_UPDATED_DBMETA_HOSTNAME ) ) ), anyString() );
  }
View Full Code Here

    doReturn( new RepositoryFile.Builder( "123", "databases" ).folder( true ).build() ).when( repo ).getFile(
        databasesFolderPath );
    doReturn( reservedChars ).when( repo ).getReservedChars();
    // stub out get file not found
    doReturn( null ).when( repo ).getFile( databasesFolderPath + RepositoryFile.SEPARATOR + fileName );
    IDatasourceMgmtService datasourceMgmtService =
        new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() );

    Assert.assertNull( datasourceMgmtService.getDatasourceByName( datasourceName ) );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService

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.