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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations