Search in sources :

Example 1 with IConfiguration

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;
    }
}
Also used : Matcher(java.util.regex.Matcher) IOException(java.io.IOException) IConfiguration(org.pentaho.platform.api.engine.IConfiguration)

Example 2 with IConfiguration

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));
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) Matchers.anyString(org.mockito.Matchers.anyString) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with IConfiguration

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));
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) Matchers.anyString(org.mockito.Matchers.anyString) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with IConfiguration

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();
}
Also used : AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) Properties(java.util.Properties) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) RequestParameterAuthenticationFilter(org.pentaho.platform.web.http.security.RequestParameterAuthenticationFilter) Before(org.junit.Before)

Example 5 with IConfiguration

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"));
}
Also used : IConfiguration(org.pentaho.platform.api.engine.IConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

IConfiguration (org.pentaho.platform.api.engine.IConfiguration)17 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)10 Properties (java.util.Properties)9 Test (org.junit.Test)9 File (java.io.File)4 IOException (java.io.IOException)4 Matchers.anyString (org.mockito.Matchers.anyString)3 Before (org.junit.Before)2 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)2 LinkedList (java.util.LinkedList)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1