Search in sources :

Example 21 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class MondrianCatalogHelperIT method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(olapService.getConnection(any(String.class), any(IPentahoSession.class))).thenReturn(olapConn);
    when(rolapConn.getSchema()).thenReturn(mondrianSchema);
    when(rolapConn.getCacheControl(any(PrintWriter.class))).thenReturn(mondrianCacheControl);
    when(olapConn.unwrap(Connection.class)).thenReturn(rolapConn);
    booter = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    booter.define(IPasswordService.class, KettlePasswordService.class, Scope.GLOBAL);
    booter.define(IDatabaseConnection.class, DatabaseConnection.class, Scope.GLOBAL);
    booter.define(IDatabaseDialectService.class, DatabaseDialectService.class, Scope.GLOBAL);
    booter.define(IAclAwareMondrianCatalogService.class, MondrianCatalogHelper.class, Scope.GLOBAL);
    booter.define(ICacheManager.class, CacheManager.class, Scope.GLOBAL);
    booter.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL);
    booter.defineInstance(IUnifiedRepository.class, repo);
    booter.defineInstance(IOlapService.class, olapService);
    booter.defineInstance("inlineModeling", new MondrianSchemaAnnotator() {

        @Override
        public InputStream getInputStream(final InputStream schemaInputStream, final InputStream annotationsInputStream) {
            return schemaInputStream;
        }
    });
    booter.setSettingsProvider(new SystemSettings());
    booter.start();
    cacheMgr = PentahoSystem.getCacheManager(null);
    helper = (MondrianCatalogHelper) PentahoSystem.get(IAclAwareMondrianCatalogService.class);
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Matchers.anyString(org.mockito.Matchers.anyString) SystemSettings(org.pentaho.platform.engine.core.system.SystemSettings) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Example 22 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class ChartbeansIT method init0.

@Before
public void init0() {
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution/");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IChartBeansGenerator.class, DefaultChartBeansGenerator.class);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    session = new StandaloneSession();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) 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 23 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class PooledDatasourceHelperTest method testCreatePoolNoClassName.

@Test
public void testCreatePoolNoClassName() throws Exception {
    DatabaseDialectService dialectService = new DatabaseDialectService(false);
    final DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(dialectService.getDatabaseTypes());
    mp = new MicroPlatform(SOLUTION_PATH);
    mp.defineInstance(IDatabaseDialectService.class, dialectService);
    mp.start();
    final DatabaseConnection con = new DatabaseConnection();
    con.setId("Postgres");
    con.setName("Postgres");
    con.setAccessType(DatabaseAccessType.NATIVE);
    con.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName("GENERIC"));
    con.setUsername("pentaho_user");
    con.setPassword("password");
    final HashMap<String, String> attrs = new HashMap<>();
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_DRIVER_CLASS, "");
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_URL, "jdbc:postgresql://localhost:5432/hibernate");
    con.setAttributes(attrs);
    try {
        PooledDatasourceHelper.setupPooledDataSource(con);
        fail("Expecting the exception to be thrown");
    } catch (DBDatasourceServiceException ex) {
        assertNotNull(ex);
    }
}
Also used : DBDatasourceServiceException(org.pentaho.platform.api.data.DBDatasourceServiceException) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) HashMap(java.util.HashMap) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) DatabaseDialectService(org.pentaho.database.service.DatabaseDialectService) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 24 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project data-access by pentaho.

the class AnalysisServiceTest method initPlatform.

@BeforeClass
public static void initPlatform() throws Exception {
    MicroPlatform 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);
    final IUnifiedRepository unifiedRepository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    platform.defineInstance(IUnifiedRepository.class, unifiedRepository);
    platform.start();
    acl.setOwner("owner");
    acl.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IDataAccessPermissionHandler(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.IDataAccessPermissionHandler) IAclAwareMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) BeforeClass(org.junit.BeforeClass)

Example 25 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project data-access by pentaho.

the class MetadataDatasourceServiceTest method setUp.

@Before
public void setUp() throws Exception {
    Mockery context = new JUnit4Mockery();
    manager = new MockBackingRepositoryLifecycleManager(new MockSecurityHelper());
    booter = new MicroPlatform("test-res");
    // Clear up the cache
    final ICacheManager cacheMgr = PentahoSystem.getCacheManager(null);
    cacheMgr.clearRegionCache(MondrianCatalogHelper.MONDRIAN_CATALOG_CACHE_REGION);
    // Define a repository for testing
    repository = new MockUnifiedRepository(new MockUserProvider());
    repository.createFolder(repository.getFile("/etc").getId(), new RepositoryFile.Builder("metadata").folder(true).build(), "initialization");
    final IAuthorizationPolicy policy = context.mock(IAuthorizationPolicy.class);
    booter.defineInstance(IAuthorizationPolicy.class, policy);
    booter.defineInstance(IUnifiedRepository.class, repository);
    booter.start();
    logout();
    manager.startup();
    context.checking(new Expectations() {

        {
            oneOf(policy);
            will(returnValue(true));
            oneOf(policy);
            will(returnValue(true));
            oneOf(policy);
            will(returnValue(true));
        }
    });
}
Also used : MockSecurityHelper(org.pentaho.test.platform.engine.security.MockSecurityHelper) Expectations(org.jmock.Expectations) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) ICacheManager(org.pentaho.platform.api.engine.ICacheManager) MockUnifiedRepository(org.pentaho.test.platform.repository2.unified.MockUnifiedRepository) Mockery(org.jmock.Mockery) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Before(org.junit.Before)

Aggregations

MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)64 Before (org.junit.Before)40 File (java.io.File)15 Test (org.junit.Test)12 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)10 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)10 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)10 RepositoryFileProxyFactory (org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)9 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)8 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)8 BeforeClass (org.junit.BeforeClass)7 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)6 ArrayList (java.util.ArrayList)5 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)5 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)5 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ITenant (org.pentaho.platform.api.mt.ITenant)4