Search in sources :

Example 36 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class PluginAdapterIT method init0.

@SuppressWarnings("deprecation")
@Before
public void init0() {
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/PluginManagerTest/");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IPluginManager.class, DefaultPluginManager.class);
    microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
    microPlatform.define(IServiceManager.class, DefaultServiceManager.class);
    session = new StandaloneSession();
    pluginAdapter = new PluginAdapter();
    microPlatform.addAdminAction(pluginAdapter);
    microPlatform.init();
}
Also used : PluginAdapter(org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Before(org.junit.Before)

Example 37 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class PluginManagerNotConfiguredIT method testPluginAdapterViaSystemListenerAPI.

@SuppressWarnings("cast")
public void testPluginAdapterViaSystemListenerAPI() throws Exception {
    startTest();
    // $NON-NLS-1$
    IPentahoSession session = new StandaloneSession("test user");
    PluginAdapter mgr = new PluginAdapter();
    assertTrue(mgr instanceof IPentahoSystemListener);
    IPentahoSystemListener listener = (IPentahoSystemListener) mgr;
    assertFalse(listener.startup(session));
    // this does not do anything but it shouldn't error
    listener.shutdown();
    finishTest();
}
Also used : PluginAdapter(org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter) IPentahoSystemListener(org.pentaho.platform.api.engine.IPentahoSystemListener) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Example 38 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method tesLoadtLifecycleListener.

@SuppressWarnings("deprecation")
@Test
public void tesLoadtLifecycleListener() throws PlatformPluginRegistrationException {
    microPlatform.init();
    PluginMessageLogger.clear();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    // first make sure Plugin 1 was loaded, otherwise our check for lifcycle class will never happen
    assertTrue("plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1")));
    for (IPlatformPlugin plugin : plugins) {
        if (plugin.getId().equals("Plugin 1")) {
            assertEquals("org.pentaho.test.platform.plugin.pluginmgr.FooInitializer", plugin.getLifecycleListenerClassname());
        }
        if (plugin.getId().equals("Plugin 2")) {
            // no listener defined to for Plugin 2
            assertNull(plugin.getLifecycleListenerClassname());
        }
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Test(org.junit.Test)

Example 39 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoadLifeCycleListener.

@SuppressWarnings("deprecation")
@Test
public void testLoadLifeCycleListener() throws PlatformPluginRegistrationException {
    microPlatform.init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);
    assertEquals("org.pentaho.test.platform.plugin.pluginmgr.FooInitializer", plugin.getLifecycleListenerClassname());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Test(org.junit.Test)

Example 40 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoadWebservices.

@SuppressWarnings("deprecation")
@Test
public void testLoadWebservices() throws PlatformPluginRegistrationException {
    microPlatform.init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    System.out.println(PluginMessageLogger.getAll());
    IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);
    Collection<PluginServiceDefinition> webservices = plugin.getServices();
    Object wsobj = CollectionUtils.find(webservices, new Predicate() {

        public boolean evaluate(Object object) {
            PluginServiceDefinition ws = (PluginServiceDefinition) object;
            boolean ret = ws.getTitle().equals("%TestWS1.TITLE%");
            return ret;
        }
    });
    assertNotNull("Webservice \"%TestWS1.TITLE%\" should have been loaded", wsobj);
    PluginServiceDefinition wsDfn = (PluginServiceDefinition) wsobj;
    assertEquals("org.pentaho.test.platform.engine.core.EchoServiceBean", wsDfn.getServiceClass());
    assertEquals("xml", wsDfn.getTypes()[0]);
    assertEquals("gwt", wsDfn.getTypes()[1]);
    assertEquals("A test webservice", wsDfn.getDescription());
    assertEquals(1, wsDfn.getExtraClasses().size());
    assertEquals("java.lang.String", wsDfn.getExtraClasses().iterator().next());
}
Also used : PluginServiceDefinition(org.pentaho.platform.api.engine.PluginServiceDefinition) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Aggregations

StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)218 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)74 ArrayList (java.util.ArrayList)46 Authentication (org.springframework.security.core.Authentication)39 Test (org.junit.Test)38 OutputStream (java.io.OutputStream)34 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)30 GrantedAuthority (org.springframework.security.core.GrantedAuthority)30 User (org.springframework.security.core.userdetails.User)30 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)29 UserDetails (org.springframework.security.core.userdetails.UserDetails)29 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)24 File (java.io.File)21 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)21 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)21 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)20 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 HashMap (java.util.HashMap)16 Before (org.junit.Before)16