Search in sources :

Example 1 with PluginClassLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader 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 PluginClassLoader

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

the class DefaultSpringWadlResourceDocumentTest method setUp.

@Before
public void setUp() throws Exception {
    File plugin = mock(File.class);
    doReturn(pluginName).when(plugin).getName();
    pluginClassLoader = mock(PluginClassLoader.class);
    doReturn(plugin).when(pluginClassLoader).getPluginDir();
    classPathResourcePlugin = new ClassPathResource(pluginName, pluginClassLoader);
    wadlResourceDocumentPlugin = new DefaultSpringWadlResourceDocument(classPathResourcePlugin);
    wadlResourceDocumentPluginSpy = spy(wadlResourceDocumentPlugin);
    webAppClassLoader = mock(WebAppClassLoader.class);
    classPathResourceWebapp = new ClassPathResource(pluginName, webAppClassLoader);
    wadlResourceDocumentWebapp = new DefaultSpringWadlResourceDocument(classPathResourceWebapp);
    wadlResourceDocumentWebappSpy = spy(wadlResourceDocumentWebapp);
}
Also used : File(java.io.File) WebAppClassLoader(org.eclipse.jetty.webapp.WebAppClassLoader) ClassPathResource(org.springframework.core.io.ClassPathResource) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) Before(org.junit.Before)

Example 3 with PluginClassLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader 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 4 with PluginClassLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader 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 PluginClassLoader

use of org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader 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 PluginClassLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader)7 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)6 Before (org.junit.Before)5 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)5 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)4 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)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 WebAppClassLoader (org.eclipse.jetty.webapp.WebAppClassLoader)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)1 MockDataSourceService (org.pentaho.platform.engine.services.MockDataSourceService)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1