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