Search in sources :

Example 1 with MockDataSourceService

use of org.pentaho.platform.engine.services.MockDataSourceService in project pentaho-platform by pentaho.

the class DynamicallyPooledDatasourceSystemListenerTest method testGetDataSource.

@Test
public void testGetDataSource() {
    when(listener.getDatasourceService()).thenReturn(new MockDataSourceService(false));
    DataSource ds = listener.getDataSource(connection);
    assertNotNull(ds);
}
Also used : MockDataSourceService(org.pentaho.platform.engine.services.MockDataSourceService) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 2 with MockDataSourceService

use of org.pentaho.platform.engine.services.MockDataSourceService in project data-access by pentaho.

the class ConnectionServiceImplIT method setUpClass.

@BeforeClass
public static void setUpClass() throws PlatformInitializationException, DuplicateDatasourceException, DatasourceMgmtServiceException {
    MockDataSourceService dataSourceService = new MockDataSourceService(false);
    IAuthorizationPolicy mockAuthorizationPolicy = mock(IAuthorizationPolicy.class);
    when(mockAuthorizationPolicy.isAllowed(anyString())).thenReturn(true);
    booter = new MicroPlatform("target/test-classes/solution1");
    booter.define(IPentahoConnection.class, SQLConnection.class);
    booter.defineInstance(IDBDatasourceService.class, dataSourceService);
    booter.defineInstance(IAuthorizationPolicy.class, mockAuthorizationPolicy);
    booter.defineInstance(IPluginResourceLoader.class, new PluginResourceLoader() {

        protected PluginClassLoader getOverrideClassloader() {
            return new PluginClassLoader(new File(".", "target/test-classes/solution1/system/simple-jndi"), this);
        }
    });
    booter.defineInstance(IDatasourceMgmtService.class, mgmtService);
    booter.start();
    PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    connectionServiceImpl = new ConnectionServiceImpl();
}
Also used : PluginResourceLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) MockDataSourceService(org.pentaho.platform.engine.services.MockDataSourceService) File(java.io.File) PluginClassLoader(org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader) BeforeClass(org.junit.BeforeClass)

Aggregations

MockDataSourceService (org.pentaho.platform.engine.services.MockDataSourceService)2 File (java.io.File)1 DataSource (javax.sql.DataSource)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)1 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)1 PluginClassLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader)1 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)1 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)1