@Test( expected = DriverNotInitializedException.class ) public void testDriverNotInitialized() throws DBDatasourceServiceException { when( dialectService.getDialect( connection ) ).thenReturn( driverLocatorDialect ); when( ( (IDriverLocator) driverLocatorDialect ).initialize( nativeDriverName ) ).thenReturn( false ); PooledDatasourceHelper.convert( connection, () -> dialectService ); }
@Before public void before() throws DatabaseDialectException { when( dialectService.getDialect( connection ) ).thenReturn( driverLocatorDialect ); when( connection.getDatabaseType() ).thenReturn( databaseType ); when( connection.getDatabaseType().getShortName() ).thenReturn( "SomeDBType" ); when( driverLocatorDialect.getNativeDriver() ).thenReturn( nativeDriverName ); when( driverLocatorDialect.getURLWithExtraOptions( connection ) ).thenReturn( jdbcUrl ); when( plainDialect.getNativeDriver() ).thenReturn( nativeDriverName ); when( plainDialect.getURLWithExtraOptions( connection ) ).thenReturn( jdbcUrl ); }
@Test public void testDialectWithoutLocatorAndDriverNotPresent() throws DBDatasourceServiceException { when( dialectService.getDialect( connection ) ).thenReturn( plainDialect ); try { PooledDatasourceHelper.convert( connection, () -> dialectService ); fail( "Expected exception, driver class should not be present." ); } catch ( Exception e ) { assertThat( e, instanceOf( DBDatasourceServiceException.class ) ); assertThat( e.getCause().getMessage(), containsString( nativeDriverName ) ); } }
@Test public void testDialectWithNoDriverSpecified() throws DBDatasourceServiceException { when( dialectService.getDialect( connection ) ).thenReturn( driverLocatorDialect ); when( driverLocatorDialect.getNativeDriver() ).thenReturn( "" ); try { PooledDatasourceHelper.convert( connection, () -> dialectService ); fail( "Expected exception, driver class not specified in dialect." ); } catch ( Exception e ) { assertThat( e, instanceOf( DBDatasourceServiceException.class ) ); } }
databaseConnection.getName() ) ); IDatabaseDialect dialect = databaseDialectService.getDialect( databaseConnection ); if ( dialect == null || dialect.getDatabaseType() == null ) { throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
Messages.getInstance().getErrorString( "PooledDatasourceHelper.ERROR_0001_DATASOURCE_CANNOT_LOAD_DIALECT_SVC" ) ) ).getDialect( databaseConnection ); if ( databaseConnection.getDatabaseType() == null && dialect == null ) {