File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
main/java/org/apache/ibatis/mapping
test/java/org/apache/ibatis/mapping Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 2121
2222import javax .sql .DataSource ;
2323
24- import org .apache .ibatis .logging .Log ;
25- import org .apache .ibatis .logging .LogFactory ;
24+ import org .apache .ibatis .builder .BuilderException ;
2625
2726/**
2827 * Vendor DatabaseId provider.
@@ -44,10 +43,9 @@ public String getDatabaseId(DataSource dataSource) {
4443 }
4544 try {
4645 return getDatabaseName (dataSource );
47- } catch (Exception e ) {
48- LogHolder . log . error ( "Could not get a databaseId from dataSource " , e );
46+ } catch (SQLException e ) {
47+ throw new BuilderException ( "Error occurred when getting DB product name. " , e );
4948 }
50- return null ;
5149 }
5250
5351 @ Override
@@ -70,8 +68,4 @@ private String getDatabaseProductName(DataSource dataSource) throws SQLException
7068 }
7169 }
7270
73- private static class LogHolder {
74- private static final Log log = LogFactory .getLog (VendorDatabaseIdProvider .class );
75- }
76-
7771}
Original file line number Diff line number Diff line change 1717package org .apache .ibatis .mapping ;
1818
1919import static org .junit .jupiter .api .Assertions .*;
20- import static org .mockito .Mockito .*;
20+ import static org .mockito .Mockito .mock ;
21+ import static org .mockito .Mockito .when ;
2122
2223import java .sql .Connection ;
2324import java .sql .DatabaseMetaData ;
2627
2728import javax .sql .DataSource ;
2829
30+ import org .apache .ibatis .builder .BuilderException ;
2931import org .junit .jupiter .api .Test ;
3032
3133class VendorDatabaseIdProviderTest {
@@ -77,7 +79,12 @@ void shouldNullBeReturnedOnDbError() throws Exception {
7779 VendorDatabaseIdProvider provider = new VendorDatabaseIdProvider ();
7880 Properties properties = new Properties ();
7981 properties .put ("Ewok DB" , "ewok" );
80- assertNull (provider .getDatabaseId (dataSource ));
82+ try {
83+ provider .getDatabaseId (dataSource );
84+ fail ("Should BuilderException be thrown." );
85+ } catch (BuilderException e ) {
86+ // pass
87+ }
8188 }
8289
8390 private DataSource mockDataSource () throws SQLException {
You can’t perform that action at this time.
0 commit comments