Search in sources :

Example 1 with PentahoSystemBoot

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

the class SecurityHelperTest method init.

@Before
public void init() {
    setSystemSettingsService(null);
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("test-src/solution");
    emptySecurityHelper = spy(new SecurityHelper());
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) Before(org.junit.Before)

Example 2 with PentahoSystemBoot

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

the class BootTest method testBootSettings.

@Test
public void testBootSettings() throws Exception {
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("src/test/resources/solution");
    IPentahoObjectFactory factory = boot.getFactory();
    assertNotNull("object factory is null", factory);
    SystemSettings settings = new SystemSettings();
    boot.setSettingsProvider(settings);
    assertEquals(settings, boot.getSettingsProvider());
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) SystemSettings(org.pentaho.platform.engine.core.system.SystemSettings) Test(org.junit.Test)

Example 3 with PentahoSystemBoot

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

the class BootTest method testReadOnlyFactory.

@Test(expected = NoSuchMethodError.class)
public void testReadOnlyFactory() {
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("src/test/resources/solution");
    TestObjectFactory objectFactory = new TestObjectFactory();
    boot.setFactory(objectFactory);
    boot.define(ISolutionEngine.class.getSimpleName(), Object1.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) Test(org.junit.Test)

Example 4 with PentahoSystemBoot

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

the class BootTest method testBootListeners.

@Test
public void testBootListeners() throws Exception {
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("src/test/resources/solution");
    boot.define(ISolutionEngine.class.getSimpleName(), Object1.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
    TestLifecycleListener lifecycleListener1 = new TestLifecycleListener();
    TestLifecycleListener lifecycleListener2 = new TestLifecycleListener();
    boot.addLifecycleListener(lifecycleListener1);
    List<IPentahoSystemListener> lifecycleListeners1 = boot.getLifecycleListeners();
    assertEquals(1, lifecycleListeners1.size());
    assertEquals(lifecycleListener1, lifecycleListeners1.get(0));
    assertFalse(TestLifecycleListener.startupCalled);
    assertFalse(TestLifecycleListener.shutdownCalled);
    List<IPentahoSystemListener> lifecycleListeners2 = new ArrayList<IPentahoSystemListener>();
    lifecycleListeners2.add(lifecycleListener2);
    boot.setLifecycleListeners(lifecycleListeners2);
    List<IPentahoSystemListener> lifecycleListeners3 = boot.getLifecycleListeners();
    assertEquals(1, lifecycleListeners3.size());
    assertEquals(lifecycleListener2, lifecycleListeners3.get(0));
    assertEquals(lifecycleListeners2, lifecycleListeners3);
    IPentahoObjectFactory factory = boot.getFactory();
    assertNotNull("object factory is null", factory);
    assertTrue("object factory not definable", factory instanceof IPentahoDefinableObjectFactory);
    assertFalse(boot.isInitialized());
    boolean ok = boot.start();
    assertNull(boot.getSettingsProvider());
    assertTrue(boot.isInitialized());
    assertTrue(ok);
    assertTrue(TestLifecycleListener.startupCalled);
    assertFalse(TestLifecycleListener.shutdownCalled);
    boot.stop();
    assertFalse(boot.isInitialized());
    assertTrue(TestLifecycleListener.startupCalled);
    assertTrue(TestLifecycleListener.shutdownCalled);
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoSystemListener(org.pentaho.platform.api.engine.IPentahoSystemListener) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with PentahoSystemBoot

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

the class SecurityHelperTest method runAsSystemTest.

@Test
@SuppressWarnings("unchecked")
public void runAsSystemTest() throws Exception {
    // creating environment
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("test-src/solution");
    IPentahoObjectFactory pentahoObjectFactory = mock(IPentahoObjectFactory.class, PENTAHO_OBJECT_FACTORY_MOCK_NAME);
    when(pentahoObjectFactory.objectDefined(eq(SINGLE_TENANT_ADMIN_USER_NAME))).thenReturn(true);
    when(pentahoObjectFactory.get(eq(String.class), eq(SINGLE_TENANT_ADMIN_USER_NAME), Matchers.<IPentahoSession>any())).thenReturn(ADMIN_USER_NAME);
    when(pentahoObjectFactory.getName()).thenReturn(PENTAHO_OBJECT_FACTORY_MOCK_NAME);
    boot.setFactory(pentahoObjectFactory);
    IUserRoleListService mockUserRoleListService = getUserRoleListServiceMock(ADMIN_USER_NAME, ADMIN_ROLES_ARRAY);
    doReturn(mockUserRoleListService).when(emptySecurityHelper).getUserRoleListService();
    // test for call
    Callable<String> callable = (Callable<String>) mock(Callable.class);
    when(callable.call()).thenReturn(CALLABLE_RETURNED_VALUE_OK);
    String runningResult = emptySecurityHelper.runAsSystem(callable);
    assertEquals(CALLABLE_RETURNED_VALUE_OK, runningResult);
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Aggregations

PentahoSystemBoot (org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot)7 Test (org.junit.Test)6 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)5 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)4 IPentahoDefinableObjectFactory (org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)3 ArrayList (java.util.ArrayList)2 Callable (java.util.concurrent.Callable)1 Before (org.junit.Before)1 IPentahoSystemListener (org.pentaho.platform.api.engine.IPentahoSystemListener)1 ISessionStartupAction (org.pentaho.platform.api.engine.ISessionStartupAction)1 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)1 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)1