Search in sources :

Example 1 with PluginResourceLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader in project pentaho-platform by pentaho.

the class RepositoryResourceIT method beforeTest.

@Before
public void beforeTest() throws Exception {
    repositoryBase.setUp();
    repositoryBase.getMp().define(IPluginManager.class, DefaultPluginManager.class, Scope.GLOBAL);
    repositoryBase.getMp().defineInstance(IPluginResourceLoader.class, new PluginResourceLoader() {

        protected PluginClassLoader getOverrideClassloader() {
            return new PluginClassLoader(new File(TestResourceLocation.TEST_RESOURCES + "/PluginResourceTest/system/test-plugin"), this);
        }
    });
    repositoryBase.getMp().define(IPluginProvider.class, TestPlugin.class, Scope.GLOBAL);
    PentahoSystem.get(IPluginManager.class).reload();
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    repositoryBase.loginAsRepositoryAdmin();
    mainTenant_1 = repositoryBase.createTenant(repositoryBase.getSystemTenant(), MAIN_TENANT_1);
    repositoryBase.createUser(mainTenant_1, "admin", "password", new String[] { repositoryBase.getTenantAdminRoleName() });
    repositoryBase.login("admin", mainTenant_1, new String[] { repositoryBase.getTenantAdminRoleName() });
    publicFolderPath = ClientRepositoryPaths.getPublicFolderPath().replaceAll("/", ":");
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) Before(org.junit.Before)

Example 2 with PluginResourceLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader in project pentaho-platform by pentaho.

the class PluginResourceLoaderTest method init.

@Before
public void init() throws ClassNotFoundException {
    resLoader = new PluginResourceLoader();
    classLoader = new PluginClassLoader(new File("./" + TEST_RES + "PluginResourceLoaderTest"), getClass().getClassLoader());
    pluginClass = classLoader.loadClass("PluginResLoaderDummyClass");
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) File(java.io.File) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) Before(org.junit.Before)

Example 3 with PluginResourceLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader in project data-access by pentaho.

the class DataSourcePublishIT method setUp.

@Before
public void setUp() throws Exception {
    repositoryBase.setUp();
    repositoryBase.loginAsRepositoryAdmin();
    defaultTenant = repositoryBase.createTenant(repositoryBase.getSystemTenant(), TenantUtils.getDefaultTenant());
    singleTenantAdminUserName = (String) applicationContext.getBean("singleTenantAdminUserName");
    repositoryBase.createUser(defaultTenant, singleTenantAdminUserName, PASSWORD, new String[] { repositoryBase.getTenantAdminRoleName() });
    final String singleTenantAuthenticatedAuthorityName = (String) applicationContext.getBean("singleTenantAuthenticatedAuthorityName");
    repositoryBase.createUser(defaultTenant, USERNAME_SUZY, PASSWORD, new String[] { singleTenantAuthenticatedAuthorityName });
    repositoryBase.createUser(defaultTenant, USERNAME_TIFFANY, PASSWORD, new String[] { singleTenantAuthenticatedAuthorityName });
    repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName() });
    final IUnifiedRepository repo = PentahoSystem.get(IUnifiedRepository.class);
    String etcID = String.valueOf(repo.getFile(ClientRepositoryPaths.getEtcFolderPath()).getId());
    repo.createFolder(etcID, new RepositoryFile.Builder(MondrianCatalogHelper.MONDRIAN_DATASOURCE_FOLDER).folder(true).build(), "initialization");
    repo.createFolder(etcID, new RepositoryFile.Builder(PentahoMetadataDomainRepositoryInfo.getMetadataFolderName()).folder(true).build(), "initialization");
    final MicroPlatform mp = repositoryBase.getMp();
    mp.define(IMondrianCatalogService.class, MondrianCatalogHelper.class);
    mp.define(ISystemConfig.class, SystemConfig.class);
    mp.defineInstance(IPlatformMimeResolver.class, applicationContext.getBean("IPlatformImportMimeResolver"));
    mp.defineInstance(IPlatformImporter.class, applicationContext.getBean("IPlatformImporter"));
    mp.defineInstance(ICacheManager.class, applicationContext.getBean("ICacheManager"));
    mp.defineInstance(IMetadataDomainRepository.class, applicationContext.getBean("IMetadataDomainRepository"));
    final PluginResourceLoader pluginResourceLoader = (PluginResourceLoader) applicationContext.getBean("IPluginResourceLoader");
    pluginResourceLoader.setRootDir(new File("target/test-classes/solutionACL/system/data-access"));
    mp.defineInstance(IPluginResourceLoader.class, pluginResourceLoader);
    mp.define(IDataAccessPermissionHandler.class, SimpleDataAccessPermissionHandler.class);
    mp.define(IDataAccessViewPermissionHandler.class, SimpleDataAccessViewPermissionHandler.class);
    mp.defineInstance(IAclVoter.class, new PentahoAllowAllAclVoter());
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    super.setUp();
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) PentahoAllowAllAclVoter(org.pentaho.platform.engine.security.acls.voter.PentahoAllowAllAclVoter) 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) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Example 4 with PluginResourceLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader in project data-access by pentaho.

the class ConnectionServiceImplIT method setUpClass.

@BeforeClass
public static void setUpClass() throws PlatformInitializationException, DuplicateDatasourceException, DatasourceMgmtServiceException {
    MockDataSourceService dataSourceService = new MockDataSourceService(false);
    IAuthorizationPolicy mockAuthorizationPolicy = mock(IAuthorizationPolicy.class);
    when(mockAuthorizationPolicy.isAllowed(anyString())).thenReturn(true);
    booter = new MicroPlatform("target/test-classes/solution1");
    booter.define(IPentahoConnection.class, SQLConnection.class);
    booter.defineInstance(IDBDatasourceService.class, dataSourceService);
    booter.defineInstance(IAuthorizationPolicy.class, mockAuthorizationPolicy);
    booter.defineInstance(IPluginResourceLoader.class, new PluginResourceLoader() {

        protected PluginClassLoader getOverrideClassloader() {
            return new PluginClassLoader(new File(".", "target/test-classes/solution1/system/simple-jndi"), this);
        }
    });
    booter.defineInstance(IDatasourceMgmtService.class, mgmtService);
    booter.start();
    PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    connectionServiceImpl = new ConnectionServiceImpl();
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) MockDataSourceService(org.pentaho.platform.engine.services.MockDataSourceService) File(java.io.File) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) BeforeClass(org.junit.BeforeClass)

Example 5 with PluginResourceLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader in project data-access by pentaho.

the class DatasourceResourceIT method setUp.

@BeforeClass
public static void setUp() throws Exception {
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("org.osjava.sj.root", "target/test-classes/solution1/system/simple-jndi");
    mp = new MicroPlatform("target/test-classes/solution1");
    IAuthorizationPolicy mockAuthorizationPolicy = mock(IAuthorizationPolicy.class);
    when(mockAuthorizationPolicy.isAllowed(anyString())).thenReturn(true);
    IUserRoleListService mockUserRoleListService = mock(IUserRoleListService.class);
    IDataAccessPermissionHandler mockDataAccessPermHandler = mock(IDataAccessPermissionHandler.class);
    when(mockDataAccessPermHandler.hasDataAccessPermission(any(IPentahoSession.class))).thenReturn(true);
    mp.define(ISolutionEngine.class, SolutionEngine.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    mp.define(IUnifiedRepository.class, TestFileSystemBackedUnifiedRepository.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    mp.define(IMondrianCatalogService.class, MondrianCatalogHelper.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    mp.define("connection-SQL", SQLConnection.class);
    mp.define("connection-MDX", MDXConnection.class);
    mp.define("connection-MDXOlap4j", MDXOlap4jConnection.class);
    mp.define(IDBDatasourceService.class, JndiDatasourceService.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    mp.define(MDXConnection.MDX_CONNECTION_MAPPER_KEY, MondrianOneToOneUserRoleListMapper.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    mp.define(IDatasourceMgmtService.class, MockDatasourceMgmtService.class);
    mp.define(IClientRepositoryPathsStrategy.class, MockClientRepositoryPathsStrategy.class);
    mp.define(ISecurityHelper.class, MockSecurityHelper.class);
    mp.define(UserDetailsService.class, MockUserDetailService.class);
    mp.define("singleTenantAdminUserName", "admin");
    mp.defineInstance(IMetadataDomainRepository.class, createMetadataDomainRepository());
    mp.defineInstance(IAuthorizationPolicy.class, mockAuthorizationPolicy);
    mp.defineInstance(IPluginResourceLoader.class, new PluginResourceLoader() {

        protected PluginClassLoader getOverrideClassloader() {
            return new PluginClassLoader(new File(".", "target/test-classes/solution1/system/simple-jndi"), this);
        }
    });
    mp.defineInstance(IUserRoleListService.class, mockUserRoleListService);
    mp.defineInstance(IDataAccessPermissionHandler.class, mockDataAccessPermHandler);
    mp.setSettingsProvider(new SystemSettings());
    mp.start();
    PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) SystemSettings(org.pentaho.platform.engine.core.system.SystemSettings) ZipFile(java.util.zip.ZipFile) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) BeforeClass(org.junit.BeforeClass)

Aggregations

File (java.io.File)7 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)7 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)6 PluginClassLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader)6 Before (org.junit.Before)5 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)5 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)5 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)4 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)3 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)3 BeforeClass (org.junit.BeforeClass)2 Matchers.anyString (org.mockito.Matchers.anyString)2 MockSecurityHelper (org.pentaho.test.platform.engine.security.MockSecurityHelper)2 ZipFile (java.util.zip.ZipFile)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 PentahoAllowAllAclVoter (org.pentaho.platform.engine.security.acls.voter.PentahoAllowAllAclVoter)1 MockDataSourceService (org.pentaho.platform.engine.services.MockDataSourceService)1