Examples of IUnifiedRepository


Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

  @Test
  public void testWriteToFile() throws IOException {
    final String fileName = "test-file2.txt";
    RepositoryFile file = createFile( fileName );
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate request for publicDir
    RepositoryFile publicDir =
        new RepositoryFile.Builder( "123", ClientRepositoryPaths.getPublicFolderName() ).folder( true ).build();
    doReturn( publicDir ).when( repo ).getFile( publicDirPath );
    mp.defineInstance( IUnifiedRepository.class, repo );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

  @Test( expected = FileNotFoundException.class )
  public void testWriteFileAtNewDir() throws IOException {
    final String fileName = "test.txt";
    final String intermediateDir = "newdir";
    final String filePath = publicDirPath + "/" + intermediateDir + "/" + fileName;
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate path does not exist
    doReturn( null ).when( repo ).getFile( publicDirPath + "/" + intermediateDir );
    mp.defineInstance( IUnifiedRepository.class, repo );

    RepositoryFileWriter writer = new RepositoryFileWriter( filePath, "UTF-8" );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

  @Test
  public void testWriteBinary() throws IOException {
    final String fileName = "test.bin";
    final String filePath = publicDirPath + "/" + fileName;
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate request for publicDir
    RepositoryFile publicDir =
        new RepositoryFile.Builder( "123", ClientRepositoryPaths.getPublicFolderName() ).folder( true ).build();
    doReturn( publicDir ).when( repo ).getFile( publicDirPath );
    mp.defineInstance( IUnifiedRepository.class, repo );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

  }

  @Test( expected = FileNotFoundException.class )
  public void testReadNonExistentPath() throws IOException {
    final String filePath = ClientRepositoryPaths.getPublicFolderPath() + "/doesnotexist";
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate path does not exist
    doReturn( null ).when( repo ).getFile( filePath );
    mp.defineInstance( IUnifiedRepository.class, repo );

    RepositoryFileReader reader = new RepositoryFileReader( filePath );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

  @Test( expected = FileNotFoundException.class )
  public void testReadNonExistentFile() throws IOException {
    final String fileName = "doesnotexist";
    final String filePath = publicDirPath + "/" + fileName;
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate file does not exist
    doReturn( null ).when( repo ).getFile( filePath );
    mp.defineInstance( IUnifiedRepository.class, repo );

    RepositoryFileReader reader = new RepositoryFileReader( createFile( fileName ) );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

    reader.close();
  }

  @Test( expected = FileNotFoundException.class )
  public void testReadDirectoryPath() throws IOException {
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate file exists but is a directory
    doReturn( new RepositoryFile.Builder( "123", ClientRepositoryPaths.getPublicFolderName() ).folder( true ).build() )
        .when( repo ).getFile( ClientRepositoryPaths.getPublicFolderPath() );
    mp.defineInstance( IUnifiedRepository.class, repo );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

    reader.close();
  }

  @Test( expected = FileNotFoundException.class )
  public void testWriteDirectory() throws IOException {
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // simulate file exists but is a directory
    doReturn( new RepositoryFile.Builder( "123", ClientRepositoryPaths.getPublicFolderName() ).folder( true ).build() )
        .when( repo ).getFile( ClientRepositoryPaths.getPublicFolderPath() );
    mp.defineInstance( IUnifiedRepository.class, repo );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

import java.io.UnsupportedEncodingException;

public class RepositoryFileReader extends InputStreamReader {

  protected static String getEncoding( RepositoryFile file ) throws FileNotFoundException {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    SimpleRepositoryFileData fileData = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    return fileData.getEncoding();
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

    SimpleRepositoryFileData fileData = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    return fileData.getEncoding();
  }

  protected static String getEncoding( String path ) throws FileNotFoundException {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile file = ( new RepositoryFileInputStream( path ) ).getFile();
    SimpleRepositoryFileData fileData = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    return fileData.getEncoding();
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.IUnifiedRepository

    SimpleRepositoryFileData fileData = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    return fileData.getEncoding();
  }

  protected static String getEncoding( Serializable id ) throws FileNotFoundException {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile file = ( new RepositoryFileInputStream( id ) ).getFile();
    SimpleRepositoryFileData fileData = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    return fileData.getEncoding();
  }
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.