@Test public void testCachedPentahoConnectionServices( ){ try { // Now make sure that the JNDI service method gets called the first time, // but the second time it should retrieve from cache. spyService.getDataSource( dsName ); spyService.getDataSource( dsName ); verify(spyService, Mockito.times( 1 )).resolveDatabaseConnection( mockConnection ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testCachedJndiServices( ){ try { // Now make sure that the JNDI service method gets called the first time, // but the second time it should retrieve from cache. spyService.getDataSource( dsName ); spyService.getDataSource( dsName ); verify(spyService, Mockito.times( 1 )).getJndiDataSource( dsName ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testCacheClearinginDynamicConnectionServices( ) { try { when( mockConnection.isUsingConnectionPool() ).thenReturn( true ); spyService.getDataSource( dsName ); spyService.clearCache(); spyService.getDataSource( dsName ); verify( pooledSpyService, Mockito.times( 2 ) ).resolveDatabaseConnection( mockConnection ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testPentahoConnectionServices( ){ try { // Now make sure that the resolve.. service method gets called; if not, // fail the test spyService.getDataSource( dsName ); verify(spyService).resolveDatabaseConnection( mockConnection ); verify(spyService, Mockito.never()).getJndiDataSource( dsName ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testUsePoolingConnectionServices( ) { try { when( mockConnection.isUsingConnectionPool() ).thenReturn( true ); spyService.getDataSource( dsName ); verify( pooledSpyService ).resolveDatabaseConnection( mockConnection ); verify( nonPooledSpyService, Mockito.never() ).resolveDatabaseConnection( mockConnection ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testUseNonPoolingConnectionServices( ) { try { when( mockConnection.isUsingConnectionPool() ).thenReturn( false ); spyService.getDataSource( dsName ); verify( nonPooledSpyService ).resolveDatabaseConnection( mockConnection ); verify( pooledSpyService, Mockito.never() ).resolveDatabaseConnection( mockConnection ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }
@Test public void testJndiServices( ){ try { // Now make sure that the JNDI service method gets called; if not, // fail the test spyService.getDataSource( dsName ); verify(spyService).getJndiDataSource( dsName ); } catch ( DBDatasourceServiceException e ) { e.printStackTrace(); } }