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);
}
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();
}
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);
}
}
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());
}
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));
}
});
}
Aggregations