Search in sources :

Example 16 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class BaseTestCase method init.

protected void init(String solnPath) {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    // $NON-NLS-1$
    applicationContext = new StandaloneApplicationContext(solnPath, "");
    applicationContext.setFullyQualifiedServerURL(getFullyQualifiedServerURL());
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    PentahoSystem.init(applicationContext);
    // $NON-NLS-1$
    session = new StandaloneSession("system");
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 17 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class MicroPlatform method setSpringConfig.

/**
 * Sets the StandaloneSpringPentahoObjectFactory for the Pentaho platform by xml path
 *
 * @return
 */
public void setSpringConfig(String cfgFile) {
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(cfgFile, null);
    setFactory(pentahoObjectFactory);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 18 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory 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)

Example 19 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class SystemSettingsTest method init.

public boolean init() {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    File file = new File(SOLUTION_PATH + PENTAHO_XML_PATH);
    StandaloneApplicationContext applicationContext = null;
    if (file.exists()) {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.SOLUTION_PATH, "");
    } else {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.ALT_SOLUTION_PATH, "");
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    return PentahoSystem.init(applicationContext);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) File(java.io.File) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 20 with IPentahoObjectFactory

use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.

the class BeanBuilderTest method testGetObjectWithoutDampeningTimeout.

@Test
public void testGetObjectWithoutDampeningTimeout() throws Exception {
    IPentahoObjectFactory pentahoObjectFactory = mock(IPentahoObjectFactory.class);
    ISystemConfig systemConfig = mock(ISystemConfig.class);
    doReturn(systemConfig).when(pentahoObjectFactory).get(eq(ISystemConfig.class), any(IPentahoSession.class));
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    final IPentahoObjectReference objectReference = mock(IPentahoObjectReference.class);
    when(pentahoObjectFactory.objectDefined(eq(BeanTestInterface.class))).thenReturn(true);
    when(pentahoObjectFactory.getObjectReferences(eq(BeanTestInterface.class), any(IPentahoSession.class), any(Map.class))).thenReturn(null, new ArrayList<IPentahoObjectReference>() {

        {
            add(objectReference);
        }
    });
    final int testValue = 5;
    doReturn(new BeanTestInterface() {

        @Override
        public int testMethod() {
            return testValue;
        }
    }).when(objectReference).getObject();
    BeanBuilder beanBuilder = new BeanBuilder();
    beanBuilder.setType(BeanTestInterface.class.getName());
    beanBuilder.setAttributes(new HashMap<String, String>());
    Object object = beanBuilder.getObject();
    assertNotNull(object);
    assertTrue(object instanceof BeanTestInterface);
    assertEquals(testValue, ((BeanTestInterface) object).testMethod());
}
Also used : IPentahoObjectReference(org.pentaho.platform.api.engine.IPentahoObjectReference) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)30 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)9 Test (org.junit.Test)7 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)7 IPentahoDefinableObjectFactory (org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)6 IPentahoObjectReference (org.pentaho.platform.api.engine.IPentahoObjectReference)6 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)6 ArrayList (java.util.ArrayList)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)5 PentahoSystemBoot (org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)5 HashSet (java.util.HashSet)3 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)3 ApplicationContext (org.springframework.context.ApplicationContext)3 File (java.io.File)2 Map (java.util.Map)2 Properties (java.util.Properties)2 IConfiguration (org.pentaho.platform.api.engine.IConfiguration)2 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)2