use of org.pentaho.platform.api.engine.IConfiguration 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.IConfiguration 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.IConfiguration in project pentaho-platform by pentaho.
the class SystemConfigIT method testListConfigurations.
@Test
public void testListConfigurations() throws Exception {
IConfiguration c = new PropertiesFileConfiguration("test", new File(TestResourceLocation.TEST_RESOURCES + "/SystemConfig/system/test.properties"));
systemConfig.registerConfiguration(c);
assertEquals(1, systemConfig.listConfigurations().length);
c = new PropertiesFileConfiguration("test", new File(TestResourceLocation.TEST_RESOURCES + "/SystemConfig/system/test.properties"));
systemConfig.registerConfiguration(c);
assertEquals(1, systemConfig.listConfigurations().length);
c = new PropertiesFileConfiguration("test2", new File(TestResourceLocation.TEST_RESOURCES + "/SystemConfig/system/test.properties"));
systemConfig.registerConfiguration(c);
assertEquals(2, systemConfig.listConfigurations().length);
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class SystemConfigIT method testSetConfiguration.
@Test
public void testSetConfiguration() throws Exception {
IConfiguration c = new PropertiesFileConfiguration("test", new File(TestResourceLocation.TEST_RESOURCES + "/SystemConfig/system/test.properties"));
systemConfig.registerConfiguration(c);
assertNotNull(systemConfig.getConfiguration("test"));
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class PentahoSystemTest method initXMLFactories.
private void initXMLFactories(boolean factoriesInPentahoXML) throws Exception {
// mock pentaho.xml
final ISystemSettings settingsService = mock(ISystemSettings.class);
if (factoriesInPentahoXML) {
final Node testNode = mock(Node.class);
final Node testNodeName = mock(Node.class);
when(testNodeName.getText()).thenReturn(testSystemPropertyName);
when(testNode.selectSingleNode(eq("@name"))).thenReturn(testNodeName);
final Node testNodeImplementation = mock(Node.class);
when(testNodeImplementation.getText()).thenReturn(testXMLValue);
when(testNode.selectSingleNode(eq("@implementation"))).thenReturn(testNodeImplementation);
when(settingsService.getSystemSettings(eq("xml-factories/factory-impl"))).thenReturn(new LinkedList() {
{
add(testNode);
}
});
} else {
when(settingsService.getSystemSettings(eq("xml-factories/factory-impl"))).thenReturn(new LinkedList());
}
when(settingsService.getSystemSetting(anyString(), anyString())).thenReturn("");
PentahoSystem.setSystemSettingsService(settingsService);
// mock java-system-properties.properties
final IPentahoObjectFactory objectFactory = mock(IPentahoObjectFactory.class);
final ISystemConfig systemConfig = mock(ISystemConfig.class);
final IConfiguration configuration = mock(IConfiguration.class);
when(configuration.getProperties()).thenReturn(new Properties() {
{
setProperty(testSystemPropertyName, testPropertyValue);
}
});
when(systemConfig.getConfiguration(eq(PentahoSystem.JAVA_SYSTEM_PROPERTIES))).thenReturn(configuration);
when(objectFactory.objectDefined(eq(ISystemConfig.class))).thenReturn(true);
final IPentahoObjectReference pentahoObjectReference = mock(IPentahoObjectReference.class);
when(pentahoObjectReference.getObject()).thenReturn(systemConfig);
when(objectFactory.getObjectReferences(eq(ISystemConfig.class), any(IPentahoSession.class), any(Map.class))).thenReturn(new LinkedList() {
{
add(pentahoObjectReference);
}
});
PentahoSystem.registerObjectFactory(objectFactory);
PentahoSystem.init();
}
Aggregations