Search in sources :

Example 56 with MicroPlatform

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

the class SystemPathPluginProviderIT method testLoad_BadSolutionPath.

@SuppressWarnings("deprecation")
@Test(expected = PlatformPluginRegistrationException.class)
public void testLoad_BadSolutionPath() throws PlatformPluginRegistrationException {
    MicroPlatform mp = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/SystemPathPluginProviderTest/system");
    mp.define(ISolutionEngine.class, SolutionEngine.class);
    mp.init();
    provider.getPlugins(new StandaloneSession());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Test(org.junit.Test)

Example 57 with MicroPlatform

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

the class AxisWebServiceManagerIT method init0.

/*
   * Wire up an in-memory platform to register and expose plug-in web services.
   */
@SuppressWarnings("deprecation")
@Before
public void init0() throws ServiceInitializationException {
    // set solution path to a place that hosts an axis config file
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/AxisWebServiceManagerTest/", "http://test/");
    assertNotNull(PentahoSystem.getObjectFactory());
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    assertNotNull(PentahoSystem.getObjectFactory());
    microPlatform.define(IPluginManager.class, DefaultPluginManager.class, Scope.GLOBAL);
    microPlatform.define(IServiceManager.class, DefaultServiceManager.class, Scope.GLOBAL);
    microPlatform.define(IPluginProvider.class, TstPluginProvider.class);
    microPlatform.define(IThemeManager.class, DefaultThemeManager.class);
    IServiceTypeManager axisManager = new AxisWebServiceManager();
    DefaultServiceManager sm = (DefaultServiceManager) PentahoSystem.get(IServiceManager.class);
    sm.setServiceTypeManagers(Arrays.asList(axisManager));
    microPlatform.init();
    new StandaloneSession();
    PentahoSystem.get(IPluginManager.class).reload(PentahoSessionHolder.getSession());
}
Also used : DefaultServiceManager(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.DefaultServiceManager) IServiceTypeManager(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.IServiceTypeManager) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) AxisWebServiceManager(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.AxisWebServiceManager) IServiceManager(org.pentaho.platform.api.engine.IServiceManager) Before(org.junit.Before)

Example 58 with MicroPlatform

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

the class DefaultPluginManagerIT method test8b_getBeanFromPluginClassloader_altSolutionPath.

@Test
public void test8b_getBeanFromPluginClassloader_altSolutionPath() throws PluginBeanException, PlatformInitializationException {
    // This test is to validate a bug that had existed where a solution path ending in '/' was causing
    // the PluginClassLoader to not be able to open plugin jars, thus you would get ClassNotFound exceptions
    // when accessing plugin classes.
    MicroPlatform mp = new MicroPlatform(getSolutionPath() + "/");
    mp.define(ISolutionEngine.class, SolutionEngine.class);
    mp.define(IServiceManager.class, DefaultServiceManager.class);
    mp.define(IPluginProvider.class, Tst8PluginProvider.class).start();
    // reload should register the beans
    pluginManager.reload();
    try {
        Class.forName("org.pentaho.nowhere.PluginOnlyClass");
        fail("PluginOnlyClass needs to be available only through " + "the plugin lib dir in order for this test to be valid");
    } catch (ClassNotFoundException e) {
    // ignore
    }
    assertTrue("PluginOnlyClass should have been registered", pluginManager.isBeanRegistered("PluginOnlyClass"));
    assertNotNull("PluginOnlyClass bean should have been loaded from test-jar.jar in the plugin lib directory", pluginManager.getBean("PluginOnlyClass"));
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPluginProvider(org.pentaho.platform.api.engine.IPluginProvider) Test(org.junit.Test)

Example 59 with MicroPlatform

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

the class DefaultPluginManagerIT method test8c_loadClass.

@Test
public void test8c_loadClass() throws PlatformInitializationException, PluginBeanException {
    MicroPlatform mp = new MicroPlatform(getSolutionPath() + "/");
    mp.define(IPluginProvider.class, Tst8PluginProvider.class).start();
    pluginManager.reload();
    pluginManager.loadClass("PluginOnlyClass");
    pluginManager.loadClass("PluginOnlyClassSpringFile");
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPluginProvider(org.pentaho.platform.api.engine.IPluginProvider) Test(org.junit.Test)

Example 60 with MicroPlatform

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

the class UserRoleMapperIT method init0.

@Before
public void init0() {
    IAclNodeHelper aclHelper = mock(IAclNodeHelper.class);
    when(aclHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
    MondrianCatalogHelper catalogService = new MondrianCatalogHelper(aclHelper);
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
    microPlatform.defineInstance(IMondrianCatalogService.class, catalogService);
    microPlatform.define("connection-SQL", SQLConnection.class);
    microPlatform.define("connection-MDX", MDXConnection.class);
    microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
    microPlatform.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL);
    microPlatform.define(UserDetailsService.class, TestUserDetailsService.class, Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    try {
        microPlatform.start();
    } catch (PlatformInitializationException ex) {
        Assert.fail();
    }
    catalogService.setDataSourcesConfig("file:" + PentahoSystem.getApplicationContext().getSolutionPath("test/analysis/test-datasources.xml"));
    // JNDI
    System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
    System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
    System.setProperty("org.osjava.sj.delimiter", "/");
}
Also used : MondrianCatalogHelper(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) EnumSet(java.util.EnumSet) 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) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) 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