use of org.pentaho.platform.api.engine.ISystemConfig in project pentaho-platform by pentaho.
the class SqlMetadataQueryExecTest method testDriverClassesToForceMetaNullProps.
@Test
public void testDriverClassesToForceMetaNullProps() throws IOException {
ISystemConfig sysConfig = mock(ISystemConfig.class);
IConfiguration config = mock(IConfiguration.class);
when(sysConfig.getConfiguration(SqlMetadataQueryExec.CONFIG_ID)).thenReturn(config);
SqlMetadataQueryExec sqlMetadataQueryExec = new SqlMetadataQueryExec(sysConfig);
assertEquals(0, sqlMetadataQueryExec.driverClassesToForceMeta.size());
}
use of org.pentaho.platform.api.engine.ISystemConfig in project pentaho-platform by pentaho.
the class SqlMetadataQueryExecTest method testDriverClassesToForceMetaNoEntries.
@Test
public void testDriverClassesToForceMetaNoEntries() throws IOException {
ISystemConfig sysConfig = mock(ISystemConfig.class);
IConfiguration config = mock(IConfiguration.class);
when(sysConfig.getConfiguration(SqlMetadataQueryExec.CONFIG_ID)).thenReturn(config);
Properties props = mock(Properties.class);
when(config.getProperties()).thenReturn(props);
final ArgumentCaptor<String> defaultValue = ArgumentCaptor.forClass(String.class);
when(props.getProperty(eq(SqlMetadataQueryExec.FORCE_DB_META_CLASSES_PROP), defaultValue.capture())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return defaultValue.getValue();
}
});
SqlMetadataQueryExec sqlMetadataQueryExec = new SqlMetadataQueryExec(sysConfig);
assertEquals(0, sqlMetadataQueryExec.driverClassesToForceMeta.size());
}
use of org.pentaho.platform.api.engine.ISystemConfig in project pentaho-platform by pentaho.
the class PentahoACLProvider method init.
/**
* Overridden to:
* <ul>
* <li>Store {@code configuration} for later passing to {@link PentahoEntryCollector}.</li>
* <li>Add JCR_READ_ACCESS_CONTROL to root ACL. This is harmless and avoids more customization.</li>
* </ul>
*/
@Override
@SuppressWarnings("rawtypes")
public void init(final Session systemSession, final Map conf) throws RepositoryException {
this.configuration = conf;
ISystemConfig settings = PentahoSystem.get(ISystemConfig.class);
if (settings != null) {
useCachingEntryCollector = "true".equals(settings.getProperty("system.cachingEntryCollector"));
}
super.init(systemSession, conf);
// original initRootACL should run during super.init call above
updateRootAcl((SessionImpl) systemSession, new ACLEditor(session, this, false));
this.initialized = true;
registerEntryCollectorWithObservationManager(systemSession);
}
use of org.pentaho.platform.api.engine.ISystemConfig in project pentaho-platform by pentaho.
the class SystemResourceIT method setUp.
@Before
public void setUp() throws Exception {
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
ISystemConfig systemConfig = new SystemConfig();
IConfiguration securityConfig = mock(IConfiguration.class);
Properties props = new Properties();
props.setProperty("provider", "jackrabbit");
when(securityConfig.getProperties()).thenReturn(props);
when(securityConfig.getId()).thenReturn("security");
systemConfig.registerConfiguration(securityConfig);
systemResource = new SystemResource(systemConfig);
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to populate PentahoSystem
boolean initOk = PentahoSystem.init(applicationContext);
/*
* StandaloneSession session = new StandaloneSession();
*
* StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
*
* File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
* FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
* XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
*
* factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
*/
}
use of org.pentaho.platform.api.engine.ISystemConfig 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