use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class MetadataRepositoryLifecycleManagerIT method beforeTest.
@Before
public void beforeTest() throws PlatformInitializationException {
System.setProperty(SYSTEM_PROPERTY, "MODE_INHERITABLETHREADLOCAL");
mp = new MicroPlatform();
mp.defineInstance("tenantedUserNameUtils", tenantedUserNameUtils);
mp.define(IPluginManager.class, DefaultPluginManager.class, Scope.GLOBAL);
mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
mp.defineInstance(ITenantManager.class, tenantManager);
mp.define(ITenant.class, Tenant.class);
mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
mp.defineInstance(IRoleAuthorizationPolicyRoleBindingDao.class, roleBindingDaoTarget);
mp.defineInstance("tenantedUserNameUtils", tenantedUserNameUtils);
mp.defineInstance("tenantedRoleNameUtils", tenantedRoleNameUtils);
mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
mp.define(IConfiguration.class, SystemConfig.class);
mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(this.jcrTemplate, this.repositoryFileDao));
mp.defineInstance("useMultiByteEncoding", new Boolean(false));
UserRoleDaoUserDetailsService userDetailsService = new UserRoleDaoUserDetailsService();
userDetailsService.setUserRoleDao(userRoleDao);
List<String> systemRoles = new ArrayList<String>();
systemRoles.add("Administrator");
List<String> extraRoles = Arrays.asList(new String[] { "Authenticated", "Anonymous" });
String adminRole = "Admin";
userRoleListService = new UserRoleDaoUserRoleListService(userRoleDao, userDetailsService, tenantedUserNameUtils, systemRoles, extraRoles, adminRole);
((UserRoleDaoUserRoleListService) userRoleListService).setUserRoleDao(userRoleDao);
((UserRoleDaoUserRoleListService) userRoleListService).setUserDetailsService(userDetailsService);
mp.defineInstance(IUserRoleListService.class, userRoleListService);
mp.start();
loginAsRepositoryAdmin();
setAclManagement();
logout();
startupCalled = true;
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class PentahoSystemPluginManagerIT method init0.
public void init0() {
microPlatform = new MicroPlatform(solutionPath);
microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
microPlatform.define(ISystemConfig.class, SystemConfig.class);
microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
microPlatform.define(IPluginResourceLoader.class, PluginResourceLoader.class);
microPlatform.define(IServiceManager.class, DefaultServiceManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/PluginManagerTest"));
session = new StandaloneSession();
pluginManager = new PentahoSystemPluginManager();
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class MetadataQueryComponentIT method setUp.
@Before
public void setUp() throws Exception {
microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
microPlatform.define(IMetadataDomainRepository.class, InMemoryMetadataDomainRepository.class, Scope.GLOBAL);
microPlatform.define("connection-SQL", SQLConnection.class);
microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
FileSystemBackedUnifiedRepository repos = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
repos.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
KettleEnvironment.init(false);
IMetadataDomainRepository repo = PentahoSystem.get(IMetadataDomainRepository.class, null);
Domain domain = getBasicDomain();
Domain domain2 = getJdbcDomain();
Domain domain3 = getJdbcDomain();
domain3.setId("JDBCDOMAIN2");
domain3.getLogicalModels().get(0).setProperty("max_rows", new BigDecimal(10));
Domain domain4 = getBasicDomain();
((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setDialectType("MYSQL");
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("QUOTE_ALL_FIELDS", "Y");
((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setAttributes(attributes);
domain4.setId("MYSQL_DOMAIN");
repo.storeDomain(domain, true);
repo.storeDomain(domain2, true);
repo.storeDomain(domain3, true);
repo.storeDomain(domain4, true);
// JNDI
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.delimiter", "/");
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class SystemResourceIT method setUp.
@Before
public void setUp() throws Exception {
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
ISystemConfig systemConfig = new SystemConfig();
IConfiguration securityConfig = mock(IConfiguration.class);
Properties props = new Properties();
props.setProperty("provider", "jackrabbit");
when(securityConfig.getProperties()).thenReturn(props);
when(securityConfig.getId()).thenReturn("security");
systemConfig.registerConfiguration(securityConfig);
systemResource = new SystemResource(systemConfig);
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to populate PentahoSystem
boolean initOk = PentahoSystem.init(applicationContext);
/*
* StandaloneSession session = new StandaloneSession();
*
* StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
*
* File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
* FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
* XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
*
* factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
*/
}
use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.
the class PooledDatasourceHelperTest method testCreatePoolNoDialect.
@Test
public void testCreatePoolNoDialect() throws Exception {
DatabaseDialectService dialectService = new DatabaseDialectService(false);
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.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);
}
}
Aggregations