Search in sources :

Example 16 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class BootIT method testBoot.

public void testBoot() throws PlatformInitializationException {
    PentahoBoot boot = new PentahoBoot();
    boot.setFilePath(TestResourceLocation.TEST_RESOURCES + "/solution");
    boot.enableReporting();
    // create a user session
    IPentahoSession session = new StandaloneSession("test");
    PentahoSessionHolder.setSession(session);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    boolean ok = boot.start();
    assertTrue(ok);
    String outputType = "pdf";
    OutputStream outputStream = null;
    try {
        // create an output stream to write the report into
        File outputFile = new File("report." + outputType);
        outputStream = new FileOutputStream(outputFile);
        // pass the outputType parameter
        Map parameters = new HashMap();
        parameters.put("output-type", outputType);
        SolutionHelper.execute("test report", session, "boot/report.xaction", parameters, outputStream);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return;
    } finally {
        if (outputStream != null) {
            try {
                // close the output stream
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    boot.stop();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HashMap(java.util.HashMap) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) PentahoBoot(org.pentaho.platform.plugin.boot.PentahoBoot) FileOutputStream(java.io.FileOutputStream) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 17 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class UserRoleMapperIT method init0.

@Before
public void init0() {
    IAclNodeHelper aclHelper = mock(IAclNodeHelper.class);
    when(aclHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
    MondrianCatalogHelper catalogService = new MondrianCatalogHelper(aclHelper);
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
    microPlatform.defineInstance(IMondrianCatalogService.class, catalogService);
    microPlatform.define("connection-SQL", SQLConnection.class);
    microPlatform.define("connection-MDX", MDXConnection.class);
    microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
    microPlatform.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL);
    microPlatform.define(UserDetailsService.class, TestUserDetailsService.class, Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    try {
        microPlatform.start();
    } catch (PlatformInitializationException ex) {
        Assert.fail();
    }
    catalogService.setDataSourcesConfig("file:" + PentahoSystem.getApplicationContext().getSolutionPath("test/analysis/test-datasources.xml"));
    // JNDI
    System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
    System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
    System.setProperty("org.osjava.sj.delimiter", "/");
}
Also used : MondrianCatalogHelper(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) EnumSet(java.util.EnumSet) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Example 18 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project data-access by pentaho.

the class DatasourceResourceIT method createMetadataDomainRepository.

private static PentahoMetadataDomainRepository createMetadataDomainRepository() throws Exception {
    IUnifiedRepository repository = new FileSystemBackedUnifiedRepository("target/test-classes/dsw");
    mp.defineInstance(IUnifiedRepository.class, repository);
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/mondrian", true, true, null));
    PentahoMetadataDomainRepository pentahoMetadataDomainRepository = new PentahoMetadataDomainRepository(repository);
    return pentahoMetadataDomainRepository;
}
Also used : RepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)

Example 19 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project data-access by pentaho.

the class DataAccessServiceTestBase method setUp.

@Before
public void setUp() throws Exception {
    platform = new MicroPlatform();
    metadataRepository = mock(IMetadataDomainRepository.class);
    platform.defineInstance(IMetadataDomainRepository.class, metadataRepository);
    importer = mock(IPlatformImporter.class);
    platform.defineInstance(IPlatformImporter.class, importer);
    policy = mock(IAuthorizationPolicy.class);
    platform.defineInstance(IAuthorizationPolicy.class, policy);
    catalogService = mock(IAclAwareMondrianCatalogService.class);
    platform.defineInstance(IMondrianCatalogService.class, catalogService);
    permissionHandler = mock(IDataAccessPermissionHandler.class);
    platform.defineInstance(IDataAccessPermissionHandler.class, permissionHandler);
    userRoleListService = mock(IUserRoleListService.class);
    platform.defineInstance(IUserRoleListService.class, userRoleListService);
    pluginResourceLoader = mock(IPluginResourceLoader.class);
    platform.defineInstance(IPluginResourceLoader.class, pluginResourceLoader);
    mondrianCatalogService = mock(IMondrianCatalogService.class);
    platform.defineInstance(IMondrianCatalogService.class, mondrianCatalogService);
    final IUnifiedRepository unifiedRepository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    platform.defineInstance(IUnifiedRepository.class, unifiedRepository);
    platform.defineInstance(String.class, "admin");
    config = new GeoContextPropertiesProvider(getGeoProps());
    GeoContext geo = GeoContextFactory.create(config);
    platform.start();
    acl.setOwner("owner");
    acl.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    modelerService = new ModelerService();
    datasourceService = mock(DSWDatasourceServiceImpl.class);
    when(datasourceService.getGeoContext()).thenReturn(geo);
    modelerService.setDatasourceService(datasourceService);
    domain = getDomain();
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) GeoContextPropertiesProvider(org.pentaho.agilebi.modeler.geo.GeoContextPropertiesProvider) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository) IMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) IAclAwareMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Aggregations

FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)19 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)12 File (java.io.File)11 Before (org.junit.Before)10 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)8 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)7 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 RepositoryUtils (org.pentaho.platform.repository2.unified.RepositoryUtils)4 InputStream (java.io.InputStream)3 Test (org.junit.Test)3 IMetadataDomainRepository (org.pentaho.metadata.repository.IMetadataDomainRepository)3 PentahoMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)2 IAclNodeHelper (org.pentaho.platform.api.repository2.unified.IAclNodeHelper)2