use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class SystemConfig method resolveValue.
private String resolveValue(String placeholder) {
Matcher matcher = pattern.matcher(placeholder);
matcher.find();
String pid = matcher.group(1);
String key = matcher.group(2);
IConfiguration con = getConfiguration(pid);
if (con == null) {
logger.info("Error resolving key replacement: " + placeholder);
return null;
}
try {
return con.getProperties().getProperty(key);
} catch (IOException e) {
logger.error("Error getting properties for configuration: " + key);
return null;
}
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class SqlMetadataQueryExecTest method testDriverClassesToForceMetaTwoEntries.
@Test
public void testDriverClassesToForceMetaTwoEntries() throws IOException {
ISystemConfig sysConfig = mock(ISystemConfig.class);
IConfiguration config = mock(IConfiguration.class);
String className = "test";
String className2 = "test2";
when(sysConfig.getConfiguration(SqlMetadataQueryExec.CONFIG_ID)).thenReturn(config);
Properties props = mock(Properties.class);
when(config.getProperties()).thenReturn(props);
when(props.getProperty(eq(SqlMetadataQueryExec.FORCE_DB_META_CLASSES_PROP), anyString())).thenReturn(" , " + className + " , " + className2 + " ,,, ");
SqlMetadataQueryExec sqlMetadataQueryExec = new SqlMetadataQueryExec(sysConfig);
assertEquals(2, sqlMetadataQueryExec.driverClassesToForceMeta.size());
assertTrue(sqlMetadataQueryExec.driverClassesToForceMeta.contains(className));
assertTrue(sqlMetadataQueryExec.driverClassesToForceMeta.contains(className2));
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class SqlMetadataQueryExecTest method testDriverClassesToForceMetaOneEntry.
@Test
public void testDriverClassesToForceMetaOneEntry() throws IOException {
ISystemConfig sysConfig = mock(ISystemConfig.class);
IConfiguration config = mock(IConfiguration.class);
String className = "test";
when(sysConfig.getConfiguration(SqlMetadataQueryExec.CONFIG_ID)).thenReturn(config);
Properties props = mock(Properties.class);
when(config.getProperties()).thenReturn(props);
when(props.getProperty(eq(SqlMetadataQueryExec.FORCE_DB_META_CLASSES_PROP), anyString())).thenReturn(" " + className + " ");
SqlMetadataQueryExec sqlMetadataQueryExec = new SqlMetadataQueryExec(sysConfig);
assertEquals(1, sqlMetadataQueryExec.driverClassesToForceMeta.size());
assertTrue(sqlMetadataQueryExec.driverClassesToForceMeta.contains(className));
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class RequestParameterAuthenticationFilterTest method beforeTest.
@Before
public void beforeTest() throws KettleException, IOException {
KettleClientEnvironment.init();
filter = new RequestParameterAuthenticationFilter();
authManagerMock = mock(AuthenticationManager.class);
filter.setAuthenticationManager(authManagerMock);
final Properties properties = new Properties();
properties.setProperty("requestParameterAuthenticationEnabled", "true");
IConfiguration config = mock(IConfiguration.class);
ISystemConfig mockISystemConfig = mock(ISystemConfig.class);
mockISystemConfig.registerConfiguration(config);
filter.setSystemConfig(mockISystemConfig);
doReturn(config).when(mockISystemConfig).getConfiguration("security");
doReturn(properties).when(config).getProperties();
}
use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.
the class SystemConfigIT method testGetConfiguration.
@Test
public void testGetConfiguration() throws Exception {
IConfiguration c = new PropertiesFileConfiguration("test", new File(TestResourceLocation.TEST_RESOURCES + "/SystemConfig/system/test.properties"));
systemConfig.registerConfiguration(c);
assertNotNull(systemConfig.getConfiguration("test"));
assertEquals("A dog's tale", systemConfig.getProperty("test.someProperty"));
assertEquals("A dog's tale", systemConfig.getConfiguration("test").getProperties().get("someProperty"));
}
Aggregations