File tree 2 files changed +12
-11
lines changed
main/java/org/apache/ibatis/mapping
test/java/org/apache/ibatis/mapping
2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 21
21
22
22
import javax .sql .DataSource ;
23
23
24
- import org .apache .ibatis .logging .Log ;
25
- import org .apache .ibatis .logging .LogFactory ;
24
+ import org .apache .ibatis .builder .BuilderException ;
26
25
27
26
/**
28
27
* Vendor DatabaseId provider.
@@ -44,10 +43,9 @@ public String getDatabaseId(DataSource dataSource) {
44
43
}
45
44
try {
46
45
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 );
49
48
}
50
- return null ;
51
49
}
52
50
53
51
@ Override
@@ -70,8 +68,4 @@ private String getDatabaseProductName(DataSource dataSource) throws SQLException
70
68
}
71
69
}
72
70
73
- private static class LogHolder {
74
- private static final Log log = LogFactory .getLog (VendorDatabaseIdProvider .class );
75
- }
76
-
77
71
}
Original file line number Diff line number Diff line change 17
17
package org .apache .ibatis .mapping ;
18
18
19
19
import 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 ;
21
22
22
23
import java .sql .Connection ;
23
24
import java .sql .DatabaseMetaData ;
26
27
27
28
import javax .sql .DataSource ;
28
29
30
+ import org .apache .ibatis .builder .BuilderException ;
29
31
import org .junit .jupiter .api .Test ;
30
32
31
33
class VendorDatabaseIdProviderTest {
@@ -77,7 +79,12 @@ void shouldNullBeReturnedOnDbError() throws Exception {
77
79
VendorDatabaseIdProvider provider = new VendorDatabaseIdProvider ();
78
80
Properties properties = new Properties ();
79
81
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
+ }
81
88
}
82
89
83
90
private DataSource mockDataSource () throws SQLException {
You can’t perform that action at this time.
0 commit comments