Search in sources :

Example 11 with ISystemConfig

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

Example 12 with ISystemConfig

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());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) 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 13 with ISystemConfig

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);
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig)

Example 14 with ISystemConfig

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 );
     */
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) SystemConfig(org.pentaho.platform.config.SystemConfig) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) FileSystemResource(org.springframework.core.io.FileSystemResource) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) Before(org.junit.Before)

Example 15 with ISystemConfig

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());
}
Also used : IPentahoObjectReference(org.pentaho.platform.api.engine.IPentahoObjectReference) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)17 IConfiguration (org.pentaho.platform.api.engine.IConfiguration)10 Properties (java.util.Properties)8 Test (org.junit.Test)7 IOException (java.io.IOException)3 Matchers.anyString (org.mockito.Matchers.anyString)3 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)3 Map (java.util.Map)2 Before (org.junit.Before)2 IPentahoObjectReference (org.pentaho.platform.api.engine.IPentahoObjectReference)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Locale (java.util.Locale)1 Node (org.dom4j.Node)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 IApplicationContext (org.pentaho.platform.api.engine.IApplicationContext)1 ISystemSettings (org.pentaho.platform.api.engine.ISystemSettings)1